Skip to main content

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

安装说明

  1. 安装依赖:
pip install -r requirements.txt
  1. 运行服务器:
python main.py

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

使用方法

测试页面

访问 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端口的访问

Metadata

Release files for my-sse-http-custom-param-server 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for my-sse-http-custom-param-server 0.1.1
File Size Uploaded Provenance
my-sse-http-custom-param-server-0.1.1.tar.gz 2.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for my-sse-http-custom-param-server 0.1.1
File Interpreter ABI Platform
my_sse_http_custom_param_server-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 6.0 kB

Release files / my-sse-http-custom-param-server-0.1.1.tar.gz

Download URL my-sse-http-custom-param-server-0.1.1.tar.gz
Size 2.7 kB
Tags Source
SHA-256 checksum
How to use checksums
838f3ed6e7224a7d1f592bd5ad9e62942ee7d513484e18140768b5350ef1189f
BLAKE2b-256 checksum
How to use checksums
1063ac8a381056055784603442f0920e10cf2f1b269549e9db7b12bb26dcb3b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.11

Release files / my_sse_http_custom_param_server-0.1.1-py3-none-any.whl

Download URL my_sse_http_custom_param_server-0.1.1-py3-none-any.whl
Size 3.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
078d17ed9bef7e785a41a2a53abf32ffd49b1ba7e35205fb3c3ca1c1705524db
BLAKE2b-256 checksum
How to use checksums
7ede759776c3cc3bf022825a3ce73d6637840b5befc8ff050f1d2f59d0b30f81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.11

Security for my-sse-http-custom-param-server 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page