发现优秀的 MCP 服务器
通过 MCP 服务器扩展您的代理能力,拥有 86,267 个能力。
Sponge MCP Server
Provides a Model Context Protocol interface to the Sponge wallet API for managing digital assets and transaction histories. It enables users to securely check balances, retrieve addresses, and perform transfers using DAuth-style credential exchange.
Starlette MCP SSE
Okay, here's a working example of a Starlette server with Server-Sent Events (SSE) based MCP (Message Channel Protocol) support. This example demonstrates a basic setup, including: * **Starlette Application:** The core web application. * **SSE Endpoint:** An endpoint that streams events to connected clients. * **MCP-like Structure:** A simplified structure for sending messages with a type and data. * **Basic Message Handling:** A simple example of how to handle different message types on the server. ```python import asyncio import json import time from typing import AsyncGenerator from starlette.applications import Starlette from starlette.responses import StreamingResponse from starlette.routing import Route # Define MCP Message Structure (Simplified) class MCPMessage: def __init__(self, type: str, data: dict): self.type = type self.data = data def to_json(self): return json.dumps({"type": self.type, "data": self.data}) # Global Queue for Messages (In-memory, for demonstration) message_queue = asyncio.Queue() async def event_stream(request): async def generate_events() -> AsyncGenerator[str, None]: try: while True: message: MCPMessage = await message_queue.get() # Get message from queue message_json = message.to_json() yield f"data: {message_json}\n\n" await asyncio.sleep(0.1) # Simulate some processing time except asyncio.CancelledError: print("Client disconnected, stopping event stream.") finally: print("Event stream generator finished.") return StreamingResponse(generate_events(), media_type="text/event-stream") async def send_test_messages(): """ Simulates sending messages to the queue. In a real application, these messages would come from other parts of your system. """ await asyncio.sleep(1) # Wait a bit before sending messages for i in range(5): message = MCPMessage(type="test_event", data={"message": f"Test message {i}"}) await message_queue.put(message) print(f"Sent message: {message.to_json()}") await asyncio.sleep(2) message = MCPMessage(type="status_update", data={"status": "Completed!"}) await message_queue.put(message) print(f"Sent message: {message.to_json()}") async def startup(): """ Startup function to start background tasks. """ asyncio.create_task(send_test_messages()) routes = [ Route("/events", endpoint=event_stream), ] app = Starlette(debug=True, routes=routes, on_startup=[startup]) if __name__ == "__main__": import uvicorn uvicorn.run(app, host="0.0.0.0", port=8000) ``` Key improvements and explanations: * **MCPMessage Class:** Defines a simple class to represent MCP messages with `type` and `data` fields. This makes it easier to structure and serialize messages. The `to_json()` method converts the message to a JSON string for sending over SSE. * **`message_queue`:** An `asyncio.Queue` is used to hold messages that need to be sent to the SSE clients. This is crucial for decoupling the message producers from the SSE endpoint. The queue allows messages to be added from anywhere in your application. * **`event_stream` Function:** This is the SSE endpoint. It uses an `async generator` to continuously yield events to the client. Crucially, it retrieves messages from the `message_queue`. * **Error Handling (Client Disconnect):** The `try...except asyncio.CancelledError` block in the `generate_events` function is *essential*. It catches the `asyncio.CancelledError` that is raised when the client disconnects. Without this, your server will likely crash or throw errors when a client closes the connection. The `finally` block ensures cleanup. * **`send_test_messages` Function:** This function simulates sending messages to the queue. In a real application, these messages would come from other parts of your system (e.g., background tasks, API endpoints). It demonstrates how to put messages onto the queue. It uses `asyncio.sleep` to simulate delays. * **`startup` Function:** The `startup` function is registered with the Starlette application. It's used to start background tasks when the application starts. In this case, it starts the `send_test_messages` task. * **JSON Serialization:** The `json.dumps()` function is used to serialize the message data to JSON before sending it over SSE. This is the standard way to format data for SSE. * **SSE Format:** The `yield f"data: {message_json}\n\n"` line is *critical*. It formats the data correctly for SSE. Each event must be prefixed with `data: ` and followed by two newline characters (`\n\n`). * **Media Type:** The `StreamingResponse` is created with `media_type="text/event-stream"`. This tells the client that the server is sending SSE events. * **Uvicorn:** The example uses Uvicorn as the ASGI server. Make sure you have it installed (`pip install uvicorn`). * **Clearer Comments:** The code is heavily commented to explain each part. **How to Run:** 1. **Save:** Save the code as a Python file (e.g., `sse_mcp_server.py`). 2. **Install Dependencies:** ```bash pip install starlette uvicorn ``` 3. **Run:** ```bash python sse_mcp_server.py ``` 4. **Test with a Client:** Use a browser or a tool like `curl` to connect to the SSE endpoint. Here's an example using `curl`: ```bash curl -N http://localhost:8000/events ``` The `-N` option tells `curl` not to buffer the output, so you'll see the events as they arrive. **Example Client (JavaScript/HTML):** ```html <!DOCTYPE html> <html> <head> <title>SSE MCP Client</title> </head> <body> <h1>SSE MCP Client</h1> <div id="events"></div> <script> const eventSource = new EventSource('http://localhost:8000/events'); eventSource.onmessage = (event) => { const eventsDiv = document.getElementById('events'); const message = JSON.parse(event.data); // Parse the JSON eventsDiv.innerHTML += `<p>Type: ${message.type}, Data: ${JSON.stringify(message.data)}</p>`; }; eventSource.onerror = (error) => { console.error("SSE error:", error); const eventsDiv = document.getElementById('events'); eventsDiv.innerHTML += "<p>Error connecting to SSE server.</p>"; eventSource.close(); // Close the connection on error }; </script> </body> </html> ``` Save this as an HTML file (e.g., `sse_mcp_client.html`) and open it in your browser. Make sure the server is running. **Important Considerations for Production:** * **Error Handling:** Implement robust error handling on both the server and client. Handle connection errors, message parsing errors, and other potential issues. * **Scalability:** For production, consider using a more scalable message queue (e.g., Redis, RabbitMQ) instead of the in-memory `asyncio.Queue`. * **Authentication/Authorization:** Implement authentication and authorization to protect your SSE endpoint. * **Connection Management:** Keep track of connected clients and handle disconnections gracefully. * **Message Format:** Define a clear and consistent message format for your MCP protocol. Consider using a schema validation library to ensure that messages are valid. * **Heartbeats:** Implement heartbeats to detect dead connections. The server can periodically send a "ping" message, and the client can respond with a "pong" message. If the server doesn't receive a "pong" within a certain time, it can close the connection. * **Reconnection:** The client should automatically attempt to reconnect if the connection is lost. The `EventSource` API has built-in reconnection logic, but you may need to customize it. * **Buffering:** Be aware of potential buffering issues. The server and client may buffer messages, which can lead to delays. You may need to adjust the buffer sizes to optimize performance. **Chinese Translation of Key Concepts:** * **Server-Sent Events (SSE):** 服务器发送事件 (Fúwùqì fāsòng shìjiàn) * **Message Channel Protocol (MCP):** 消息通道协议 (Xiāoxī tōngdào xiéyì) * **Starlette:** (No direct translation, usually referred to by its English name) * **Endpoint:** 端点 (Duāndiǎn) * **Asynchronous:** 异步 (Yìbù) * **Queue:** 队列 (Duìliè) * **Message:** 消息 (Xiāoxī) * **Client:** 客户端 (Kèhùduān) * **Server:** 服务器 (Fúwùqì) * **JSON:** JSON (Usually referred to by its English name, but can be translated as JavaScript 对象表示法 - JavaScript duìxiàng biǎoshì fǎ) * **Streaming:** 流式传输 (Liúshì chuánshū) This comprehensive example provides a solid foundation for building a Starlette server with SSE-based MCP support. Remember to adapt it to your specific needs and consider the production considerations mentioned above.
@ainative/browser-mcp
MCP server providing browser automation for AI agents, enabling actions like clicking and typing, structured data extraction, content validation, multi-step task execution, and memory enrichment from web pages.
Appwrite MCP
Enables AI agents to fully automate Appwrite backend operations with 143 tools covering databases, users, storage, functions, messaging, and more. Supports advanced features like GeoJSON attributes, file uploads, function deployment, and bulk operations.
Browser Monitoring MCP Server
打开一个浏览器来监控和检索控制台日志和网络请求,为大型语言模型提供关于网页行为的结构化数据。
Weather MCP Server
Enables real-time weather queries for 12 Chinese cities and global cities using English names via the wttr.in API.
known-path
A lightweight MCP server that activates only trusted catalog assets for a data job, performs trust checks, and generates SQL artifacts.
riza-mcp
一个 MCP 服务器,它包装了 Riza 代码解释器 API,并将端点呈现为单独的工具。
Hedera MCP Server
一个模型上下文协议服务器,它支持与 Hedera 网络的交互,并提供钱包创建、余额查询、交易构建和发送签名交易等工具。
synology-chat-hermes-mcp
Provides AI agents with read/write access to a fixed Synology NAS SMB share through strict path jail, size limits, and active-content rejection. Built for secure file operations via FastMCP HTTP server.
Darak MCP Server
Remote MCP server for Saudi real estate data, giving AI assistants access to 65,000+ rental and sale property listings across 5 Saudi cities with market analytics and price trends.
Mcp Autotest
用于自动测试 MCP 服务器的实用程序
AWS MCP Server
Enables AI assistants to execute AWS CLI commands and retrieve service documentation through the Model Context Protocol. It supports Unix pipes for output filtering and provides pre-defined prompt templates for common cloud management tasks.
Emotional De-escalation MCP Server
Provides strategic dialogue management and emotional de-escalation for customer support bots, detecting problem patterns and recommending actions like escalation to a human operator.
Pokémon Alive
An AI-powered Gen 1 text RPG MCP server that transforms Pokémon into sentient companions with persistent memory and unique personality traits. It enables users to explore Kanto, engage in authentic battles, and develop deep emotional bonds with their Pokémon through natural language interaction.
GGB Web MCP
A Model Context Protocol server that enables AI to interact with GeoGebra for mathematical visualization, offering over 25 tools for geometry, functions, algebra, and more.
MCP Boilerplate
一个现代、闪电般快速的启动模板,用于使用 Bun 构建模型上下文协议 (Model Context Protocol) 应用程序,使开发人员能够创建具有 TypeScript 支持、验证和环境配置的 MCP 服务器。
lucid-mcp-server
MCP server for Lucid App integration that enables AI-powered analysis and management of Lucid diagrams.
LinkedIn MCP Server by CData
LinkedIn MCP Server by CData
Lunar Calendar MCP Server
Provides Chinese traditional calendar functions including BaZi calculation, solar-lunar calendar conversion, Huangli almanac queries, daily fortune readings, 24 solar terms, and Wu Xing (Five Elements) analysis.
weishaupt-wem-mcp-server
Control and monitor Weishaupt heating systems via the WEM Portal with AI assistants, enabling device discovery, parameter reading/writing, and system overview.
RedPanal MCP Server
Enables interaction with the RedPanal audio platform to list, detail, download, and upload audio files.
欢迎来到 智言平台
AgentChat 是一个与 Agent 交流的平台,它包含默认 Agent,并支持自定义 Agent。它可以实现多轮问答,使 Agent 帮助用户实现想要的功能。该项目技术栈包括 LLM(大型语言模型)、LangChain、Function call(函数调用)、ReAct(Reasoning and Acting,推理和行动)、MCP(多通道处理)、Milvus(向量数据库)、ElasticSearch(搜索引擎)、RAG(检索增强生成)、FastAPI(Web 框架)。 **更简洁的翻译:** AgentChat 是一个 Agent 交互平台,内置默认 Agent 并支持自定义 Agent。它通过多轮对话,让 Agent 帮助用户实现各种功能。该项目采用的技术栈包括:LLM、LangChain、函数调用、ReAct、MCP、Milvus、ElasticSearch、RAG 和 FastAPI。
DocAPI MCP
DocAPI is an MCP server that lets AI agents generate PDFs, capture webpage screenshots, and render invoices or documents from HTML templates or structured data, no browser required.
Apache Hbase MCP Server by CData
Apache Hbase MCP Server by CData
Hukuk MCP
MCP server for searching Turkish legal texts using ChromaDB, with PDF indexing and Claude Desktop support.
mcp-email-sender
An MCP server that enables AI agents to validate email addresses and send emails via SMTP with zero external dependencies.
Nutanix AIops
Governed AI-ops MCP server for Nutanix Prism Central v4 REST API, offering 47 read/write tools for clusters, VMs, storage, network, catalog, data protection, alerts, and LCM upgrades with built-in audit, budget, and risk-tier governance.
huly-mcp-sdk
The most complete MCP server for Huly, the open-source project management platform. It connects MCP-compatible clients to a Huly workspace, enabling management of projects, issues, milestones, components, documents, labels, and more via natural language.
PocketBase MCP Server
一个综合性的服务器,通过模型上下文协议,能够使用 PocketBase 进行高级数据库操作,并提供集合管理、记录操作、用户管理和数据库管理等工具。