Cover image
Try Now
2025-03-23

MCP服务器のSSE実装のサンプル

3 years

Works with Finder

1

Github Watches

1

Github Forks

1

Github Stars

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
  2. add

    • Adds two numbers together
    • Inputs:
      • a (number): First number
      • b (number): Second number
    • Returns: Text result of the addition
  3. 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
  4. 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
  5. getTinyImage

    • Returns a small test image
    • No inputs required
    • Returns: Base64 encoded PNG image data
  6. printEnv

    • Prints all environment variables
    • Useful for debugging MCP server configuration
    • No inputs required
    • Returns: JSON string of all environment variables
  7. 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"
      ]
    }
  }
}

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Bora Yalcin
  • Evaluator for marketplace product descriptions, checks for relevancy and keyword stuffing.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Lists Tailwind CSS classes in monospaced font

  • Beniyam Berhanu
  • Therapist adept at identifying core issues and offering practical advice with images.

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • huahuayu
  • 统一的API网关,用于将多个Etherscan样区块链Explorer API与对AI助手的模型上下文协议(MCP)支持。

  • deemkeen
  • 用电源组合控制您的MBOT2:MQTT+MCP+LLM

  • jae-jae
  • MCP服务器使用剧作《无头浏览器》获取网页内容。

    Reviews

    3 (1)
    Avatar
    user_ph6xvV5m
    2025-04-16

    Crypto_mcp by telegramtool is an outstanding tool for managing and enhancing your cryptocurrency projects and communities. Its user-friendly interface and robust features make handling crypto tasks seamless. I highly recommend it to anyone in need of efficient cryptocurrency management. Check it out at https://mcp.so/server/crypto_mcp/telegramtool.