Navigation
MCP SSE Sample: Real-Time Streaming & Effortless SSE Implementation - MCP Implementation

MCP SSE Sample: Real-Time Streaming & Effortless SSE Implementation

MCP SSE Sample delivers seamless, real-time data streams with effortless Server-Sent Events implementation—developers’ go-to for reliable, low-latency solutions.

Developer Tools
4.4(32 reviews)
48 saves
22 comments

Users create an average of 26 projects per month with this tool

About MCP SSE Sample

What is MCP SSE Sample: Real-Time Streaming & Effortless SSE Implementation?

Imagine a Swiss Army knife for real-time communication—this sample project showcases how to effortlessly integrate Server-Sent Events (SSE) with the Model Context Protocol (MCP). It’s not just code; it’s a playground for developers to explore real-time streaming, progress updates, and LLM (Large Language Model) interactions—all wrapped in a package that’s easier to deploy than your average gym routine.

How to Use MCP SSE Sample: Real-Time Streaming & Effortless SSE Implementation?

Ready to dive in? Let’s get this party started:

  • Local Setup: Install dependencies with npm install, build with npm run build, then run in either STDIO mode (npm run start) or SSE mode (npm run start:sse). Simple as brewing coffee!
  • Claude Desktop Integration: Add this config to claude_desktop_config.json:
    {
            "mcpServers": {
              "sse-sample": {
                "command": "npx",
                "args": ["-y", "mcp_sse_sample"]
              }
            }
          }
    Now you’re connected like Wi-Fi in a tech conference.

MCP SSE Sample Features

Key Features of MCP SSE Sample: Real-Time Streaming & Effortless SSE Implementation

Why this sample? Let’s break it down:

  • Zero-Copy Tools: From the humble echo to the heavy-lifting longRunningOperation (with progress updates!), each tool is a Swiss cheese wheel—full of holes… but in a good way.
  • LLM Sampling: The sampleLLM tool turns prompts into poetry (or prose, depending on your LLM’s mood).
  • Progress Notifications: Watch long tasks tick away like a digital hourglass—perfect for keeping users from checking the clock.
  • Debugging Delight: printEnv spills all your environment variables like a gossip at a tech meetup.
  • Annotations Galore: The annotatedMessage tool teaches machines to speak in emojis… well, metadata emojis.

Use Cases of MCP SSE Sample: Real-Time Streaming & Effortless SSE Implementation

Where does this shine? Let’s dream big:

  • Real-time chat apps with instant feedback (because “later” isn’t a response).
  • Progress dashboards for background tasks (think “Your PDF is 73% less boring!”).
  • LLM-driven apps needing quick sampling without the hassle of reinventing the wheel.
  • Debugging sessions so smooth, you’ll forget you’re troubleshooting.
  • Teaching bots to annotate their thoughts for those “Why did it do that?” moments.

MCP SSE Sample FAQ

FAQ from MCP SSE Sample: Real-Time Streaming & Effortless SSE Implementation

  • “Does this work with my favorite browser?” Yep—SSE is supported in modern browsers, but check your user’s device before they rage-quit.
  • “Can I add my own tools?” Absolutely! This is open-source—hack, tweak, and share like it’s a communal notebook.
  • “What if my operation takes hours?” The longRunningOperation handles it with grace, but consider user patience limits. Coffee breaks are optional but encouraged.
  • “Why use SSE instead of WebSockets?”
  • Because SSE is simpler for one-way data flows. Think of it as the “drive-thru” of real-time communication—fast, focused, and less fancy.

  • “Can I trust the random logs?” They’re not random—just randomized levels (info, warning, debug) every 15 seconds. Like a digital haiku generator.

Content

MCP SSE Sample

SSEを使用したMCPサーバーのサンプルです。 MCPプロトコルのSSE実装を示すサンプルプロジェクトです。

オリジナルは以下コードです。

Components

Tools

  1. echo
* Simple tool to echo back input messages
* Input: 
  * `message` (string): Message to echo back
* Returns: Text content with echoed message
  1. add
* Adds two numbers together
* Inputs: 
  * `a` (number): First number
  * `b` (number): Second number
* Returns: Text result of the addition
  1. longRunningOperation
* Demonstrates progress notifications for long operations
* Inputs: 
  * `duration` (number, default: 10): Duration in seconds
  * `steps` (number, default: 5): Number of progress steps
* Returns: Completion message with duration and steps
* Sends progress notifications during execution
  1. sampleLLM
* Demonstrates LLM sampling capability using MCP sampling feature
* Inputs: 
  * `prompt` (string): The prompt to send to the LLM
  * `maxTokens` (number, default: 100): Maximum tokens to generate
* Returns: Generated LLM response
  1. getTinyImage
* Returns a small test image
* No inputs required
* Returns: Base64 encoded PNG image data
  1. printEnv
* Prints all environment variables
* Useful for debugging MCP server configuration
* No inputs required
* Returns: JSON string of all environment variables
  1. annotatedMessage
* Demonstrates how annotations can be used to provide metadata about content
* Inputs: 
  * `messageType` (enum: "error" | "success" | "debug"): Type of message to demonstrate different annotation patterns
  * `includeImage` (boolean, default: false): Whether to include an example image
* Returns: Content with varying annotations: 
  * Error messages: High priority (1.0), visible to both user and assistant
  * Success messages: Medium priority (0.7), user-focused
  * Debug messages: Low priority (0.3), assistant-focused
  * Optional image: Medium priority (0.5), user-focused
* Example annotations:
    
            {
      "priority": 1.0,
      "audience": ["user", "assistant"]
    }
    

Logging

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

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

使用方法

ローカルでの実行

# インストール
npm install

# ビルド
npm run build

# 実行(STDIOモード)
npm run start

# 実行(SSEモード)
npm run start:sse

Claude Desktopでの使用

claude_desktop_config.jsonに以下を追加してください:

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

Related MCP Servers & Clients