Skip to main content

A custom MCP SSE HTTP Server with parameter support

Project description

MCP SSE 服务器

这是一个基于Python Flask实现的MCP(Message Communication Protocol)服务器,支持SSE(Server-Sent Events)和自定义HTTP参数。

功能特点

  • 基于SSE的实时消息推送
  • 支持自定义客户端ID和消息类型
  • 跨域支持(CORS)
  • 内置测试页面

依赖要求

  • Python 3.7+
  • Flask 2.3.3
  • Flask-CORS 4.0.0
  • Gunicorn 21.2.0
  • python-dotenv 1.0.0

安装说明

从PyPI安装(推荐)

pip install mcp-test-server

从源码安装

  1. 克隆仓库:
git clone https://github.com/mcp-demo/my-sse-http-custom-param-server.git
cd my-sse-http-custom-param-server
  1. 安装依赖:
pip install -r requirements.txt

运行服务器

mcp-test-server

服务器将在 http://localhost:5000 启动

发布说明

  1. 构建包:
python -m build
  1. 发布到PyPI:
python -m twine upload dist/*

使用方法

测试页面

访问 http://localhost:5000 可以看到内置的测试页面。

SSE 接口

接口地址:/events

支持的URL参数:

  • client_id: 客户端标识符
  • type: 消息类型

示例:

const eventSource = new EventSource('/events?client_id=client1&type=notification');

eventSource.onmessage = function(event) {
    const data = JSON.parse(event.data);
    console.log('收到消息:', data);
};

生产环境部署

使用Gunicorn启动服务:

gunicorn -w 4 -b 0.0.0.0:5000 main:app

注意事项

  • 开发模式下默认启用了调试功能
  • 生产环境部署时建议使用Gunicorn作为WSGI服务器
  • 确保防火墙允许5000端口的访问

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_test_server-0.1.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_test_server-0.1.1-py2.py3-none-any.whl (3.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file mcp_test_server-0.1.1.tar.gz.

File metadata

  • Download URL: mcp_test_server-0.1.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for mcp_test_server-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8c576081a24ed64c0c3d51cb9eee265861d20a4909c9734924b4f668cb3765ea
MD5 2760efedc8b8033d6d4b1a1855156896
BLAKE2b-256 9268a48fdb6aa73993fabfd3f5cc3be442835068f63f47e7465277fc69fb607a

See more details on using hashes here.

File details

Details for the file mcp_test_server-0.1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_test_server-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ba1992b189963c706d90f2c0596d74b8aeceaae921a5e983af7fea517353632a
MD5 6d896a7fc6e5a2f045c1052520c51b32
BLAKE2b-256 ccf03a6823da7ede1501de6714ebe39687bfe64215d9b31b4d0450072865f7e6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page