发现优秀的 MCP 服务器
通过 MCP 服务器扩展您的代理能力,拥有 14,364 个能力。
Sample code for Model Context Protocl (MCP) with Server Sent Event (SSE)
mermaid-preview-mcp
用于预览 Mermaid 图表并处理语法错误的 MCP 服务器。支持 GitHub 仓库可视化。
Okta MCP Server
Remote MCP Server on Cloudflare
Linear MCP Server
镜子 (jìng zi)
note.com MCP Server
使用 note.com API 的 Model Context Protocol (MCP) 服务器
Mcp Server Demo
Demo MCP Server
一个简单的 MCP 服务器小组件
create-mcp-server-app
Debug MCP Server in VSCode
Okay, here's a basic example of a Minecraft Protocol (MCP) server in Python, along with instructions on how to set it up for debugging in VS Code. This is a *very* simplified example and doesn't implement the full Minecraft protocol. It's designed to be a starting point for learning and debugging. **1. Install Necessary Libraries:** ```bash pip install twisted ``` **2. Create the Python Server File (e.g., `mcp_server.py`):** ```python from twisted.internet import reactor, protocol from twisted.internet.endpoints import TCP4ServerEndpoint from twisted.protocols.basic import LineReceiver class MinecraftServerProtocol(LineReceiver): delimiter = b'\n' # Use newline as the delimiter def connectionMade(self): print(f"Client connected: {self.transport.getHost()}") self.sendLine(b"Hello from the MCP server!") # Send a greeting def lineReceived(self, line): try: decoded_line = line.decode('utf-8') print(f"Received: {decoded_line}") # Simple command handling (example) if decoded_line.lower() == "ping": self.sendLine(b"pong") elif decoded_line.lower() == "time": import time self.sendLine(str(time.time()).encode('utf-8')) # Send current time else: self.sendLine(b"Unknown command") except UnicodeDecodeError: print("Received invalid UTF-8 data") self.sendLine(b"Error: Invalid input") def connectionLost(self, reason): print(f"Client disconnected: {reason}") class MinecraftServerFactory(protocol.Factory): protocol = MinecraftServerProtocol if __name__ == '__main__': endpoint = TCP4ServerEndpoint(25565, reactor) # Listen on port 25565 endpoint.listen(MinecraftServerFactory()) print("MCP server started on port 25565") reactor.run() ``` **Explanation:** * **`twisted`:** This is an asynchronous networking library. It's well-suited for handling network connections efficiently. * **`MinecraftServerProtocol`:** This class handles the communication with each client. * `connectionMade()`: Called when a client connects. Sends a greeting. * `lineReceived()`: Called when a line of data is received from the client. Decodes the line, prints it, and handles simple commands (ping, time). Includes error handling for invalid UTF-8. * `connectionLost()`: Called when a client disconnects. * **`MinecraftServerFactory`:** Creates instances of the `MinecraftServerProtocol` when a new connection is made. * **`if __name__ == '__main__':`:** This block starts the server when the script is run directly. * `TCP4ServerEndpoint`: Creates a TCP server endpoint that listens on port 25565. * `reactor.run()`: Starts the Twisted event loop, which handles all the network events. **3. Configure VS Code for Debugging:** 1. **Open the project folder in VS Code.** 2. **Create a `.vscode` folder** in the root of your project (if it doesn't exist). 3. **Create a `launch.json` file** inside the `.vscode` folder. This file tells VS Code how to run and debug your Python script. ```json { "version": "0.2.0", "configurations": [ { "name": "Python: MCP Server", "type": "python", "request": "launch", "program": "${workspaceFolder}/mcp_server.py", "console": "integratedTerminal", "justMyCode": false // Important for debugging Twisted code } ] } ``` **Explanation of `launch.json`:** * `"name"`: A descriptive name for your debug configuration. * `"type"`: Specifies that you're debugging Python code. * `"request"`: `"launch"` means you're starting the program from VS Code. * `"program"`: The path to your Python script. `${workspaceFolder}` is a VS Code variable that represents the root of your project. * `"console"`: `"integratedTerminal"` means the output will be displayed in VS Code's integrated terminal. * `"justMyCode": false`: **Crucially important for Twisted!** Twisted uses a lot of internal code. Setting this to `false` allows you to step into Twisted's code while debugging, which is often necessary to understand what's going on. **4. Run and Debug:** 1. **Set a breakpoint:** Click in the left margin of the `mcp_server.py` file next to a line of code where you want the debugger to pause (e.g., inside the `lineReceived` function). 2. **Start debugging:** Go to the "Run and Debug" view in VS Code (the icon looks like a play button with a bug). Select "Python: MCP Server" from the dropdown and click the green "Start Debugging" button (or press F5). 3. **The server will start.** You should see the "MCP server started on port 25565" message in the terminal. **5. Test with a Simple Client (netcat or similar):** Open a terminal and use `netcat` (or `nc`) to connect to the server: ```bash nc localhost 25565 ``` Type some text and press Enter. You should see the output in the VS Code terminal where the server is running, and the debugger should pause at your breakpoint. Try sending "ping" or "time". **Important Considerations and Improvements:** * **Error Handling:** The example has basic error handling, but you'll need to add more robust error handling for production code. Consider logging errors to a file. * **Protocol Implementation:** This is a *very* basic example. The real Minecraft protocol is much more complex and uses binary data. You'll need to study the Minecraft protocol documentation to implement it correctly. Libraries like `struct` in Python are essential for packing and unpacking binary data. * **Asynchronous Programming:** Twisted is an asynchronous framework. Make sure you understand how asynchronous programming works to avoid blocking the event loop. Use `defer.inlineCallbacks` and `yield` for asynchronous operations. * **Security:** If you're building a real server, security is paramount. Implement proper authentication, authorization, and input validation to prevent attacks. * **Threading/Multiprocessing:** For a high-performance server, you might need to use threads or processes to handle multiple clients concurrently. Twisted can be integrated with threads, but be careful to avoid race conditions and deadlocks. * **Logging:** Implement proper logging to track server activity and diagnose problems. **Simplified Chinese Translation of Key Phrases:** * "Client connected": 客户端已连接 (Kèhùduān yǐ liánjiē) * "Received": 收到 (Shōudào) * "Unknown command": 未知命令 (Wèi zhī mìnglìng) * "Client disconnected": 客户端已断开连接 (Kèhùduān yǐ duàn kāi liánjiē) * "MCP server started on port 25565": MCP 服务器已在端口 25565 上启动 (MCP fúwùqì yǐ zài duānkǒu 25565 shàng qǐdòng) * "Error: Invalid input": 错误:无效输入 (Cuòwù: Wúxiào shūrù) * "MCP Server": MCP 服务器 (MCP fúwùqì) * "Start Debugging": 开始调试 (Kāishǐ tiáoshì) * "Breakpoint": 断点 (Duàndiǎn) This example provides a foundation for building a more complete MCP server. Remember to consult the Minecraft protocol documentation and use appropriate libraries for handling binary data and asynchronous operations. Good luck!
Toolhouse MCP Server
镜子 (jìng zi)
mcp-server
bongo-mcp-server
GitHub Explorer MCP
一个 TypeScript 实现的 MCP 服务器,为 MCP 客户端提供 GitHub 仓库信息,包括文件内容、目录结构和其他元数据。
Twitter MCP Server for Claude Desktop
SurrealDB MCP Server
镜子 (jìng zi)
Mcp Servers
MySQLReader
这是一个关于从 MySQL 数据库读取数据的 MCP 服务器。
McpDoc
一个 MCP 服务器,用于从代码生成 C4 架构图。
MyMcpServer MCP Server
MCP-server Discord Webhook
用于通过 Discord Webhook 发送消息的 Model Context Protocol 服务器
CoCube MCP Server
为 Cocube 准备的 MCP 服务器 (Wèi Cocube zhǔnbèi de MCP fúwùqì)
PowerPoint Creator MCP Server
一个 MCP 服务器,支持你使用 LLM 和自然语言自动生成 PowerPoint。
ComfyUI MCP Server
MCP System Backend
Pinner MCP 📍
将模型上下文协议 (MCP) 服务器用于将组件固定到其不可变版本
fish-speech-mcp
一个用于大型语言模型 (LLM) 的文本转语音 (TTS) 合成 MCP 服务器。
MCP Server Tester
EnterpriseMCP
用于连接企业功能的 MCP 服务器,例如 SAP 或 Salesforce 集成。 (Yòng yú liánjiē qǐyè gōngnéng de MCP fúwùqì, lìrú SAP huò Salesforce jíchéng.)
onepay-mcp-server
一个用于调用 onepay.la API 服务的 MCP 服务器。