iuill_mcp_sse_sample

iuill_mcp_sse_sample

by iuill
A sample implementation of an MCP server using Server-Sent Events (SSE) for real-time communication.

SSE Implementation for MCP Server

Overview

This project provides a sample implementation of Server-Sent Events (SSE) for the MCP Server. It demonstrates how to use SSE with the MCP protocol, offering a practical example for developers. The project includes various tools and components to showcase the capabilities of SSE in real-time communication.

Components

Tools

  1. Echo
  2. Description: Simple tool to echo back input messages.
  3. Input: message (string): Message to echo back.
  4. Returns: Text content with echoed message.

  5. Add

  6. Description: Adds two numbers together.
  7. Inputs: a (number): First number, b (number): Second number.
  8. Returns: Text result of the addition.

  9. Long Running Operation

  10. Description: Demonstrates progress notifications for long operations.
  11. Inputs: duration (number, default: 10): Duration in seconds, steps (number, default: 5): Number of progress steps.
  12. Returns: Completion message with duration and steps.
  13. Sends: Progress notifications during execution.

  14. Sample LLM

  15. Description: Demonstrates LLM sampling capability using MCP sampling feature.
  16. Inputs: prompt (string): The prompt to send to the LLM, maxTokens (number, default: 100): Maximum tokens to generate.
  17. Returns: Generated LLM response.

  18. Get Tiny Image

  19. Description: Returns a small test image.
  20. No inputs required.
  21. Returns: Base64 encoded PNG image data.

  22. Print Env

  23. Description: Prints all environment variables.
  24. Useful for debugging MCP server configuration.
  25. No inputs required.
  26. Returns: JSON string of all environment variables.

  27. Annotated Message

  28. Description: Demonstrates how annotations can be used to provide metadata about content.
  29. Inputs: messageType (enum: "error" | "success" | "debug"): Type of message to demonstrate different annotation patterns, includeImage (boolean, default: false): Whether to include an example image.
  30. Returns: Content with varying annotations.

Logging

The server sends random-leveled log messages every 15 seconds, e.g.:

{
  "method": "notifications/message",
  "params": {
    "level": "info",
    "data": "Info-level message"
  }
}

Usage

Local Execution

# Install dependencies
npm install

# Build the project
npm run build

# Run in STDIO mode
npm run start

# Run in SSE mode
npm run start:sse

Using with Claude Desktop

Add the following to claude_desktop_config.json:

{
  "mcpServers": {
    "sse-sample": {
      "command": "npx",
      "args": [
        "-y",
        "mcp_sse_sample"
      ]
    }
  }
}

About

This project is a sample implementation of SSE for the MCP Server, designed to help developers understand and utilize SSE in their MCP-based applications.

Resources

License

MIT license

Languages

  • TypeScript 97.6%
  • Dockerfile 2.4%

Features & Capabilities

Categories
mcp_server model_context_protocol sse typescript docker api_integration real-time_communication claude

Implementation Details

Stats

0 Views
1 GitHub Stars

Repository Info

iuill Organization

Similar MCP Servers

continuedev_continue by continuedev
25049
21423
9300