发现优秀的 MCP 服务器
通过 MCP 服务器扩展您的代理能力,拥有 14,264 个能力。
MultiversX MCP Server
MultiversX 的 MCP 服务器
MCP Development Server
镜子 (jìng zi)
Gridly MCP Server
Gridly MCP 服务器 (Gridly MCP fúwùqì)
Stereotype This MCP Server
Simple MCP Client
一个测试模型上下文协议 (MCP) 服务器和客户端交互的示例项目。
Mcp Server Form Testing
peer-mcp
MCP 代理,用于暴露本地 MCP 服务器
Awesome Mcp Servers
The code samples here are not for production use
安全的可执行代理工具仓库环境
mcp
MCP 服务器 (MCP fúwùqì)
Spotify MCP Server
MCP 服务器,用于与 Splunk 交互
Jupiter MCP Server
为 Claude AI 提供访问 Solana 上 Jupiter 交换 API 的模型上下文协议服务器
FindRepo MCP Server
Remote MCP Server on Cloudflare
GitLab MR Reviewer
MCPServer
一个简单的 MCP 服务器,用于启用代理工作流。 (Yī gè jiǎndān de MCP fúwùqì, yòng yú qǐyòng dàilǐ gōngzuò liú.) Alternatively, depending on the context, you might also use: 一个简单的 MCP 服务器,以实现基于代理的工作流程。(Yī gè jiǎndān de MCP fúwùqì, yǐ shíxiàn jīyú dàilǐ de gōngzuò liúchéng.) The first translation is more literal, while the second emphasizes the "agent-based" nature of the workflow. Choose the one that best fits the specific context.
Unity AI MCP Server
一个 MCP 服务器,为 Unity 游戏开发提供 AI 驱动的工具和助手,并与 Cursor IDE 集成。 (Alternatively, a slightly more literal translation could be:) 一个提供 AI 驱动的工具和助手给 Unity 游戏开发的 MCP 服务器,它与 Cursor IDE 集成。
Runbook MCP server
mcp-server-demo
Todo Assistant with AI and Google Calendar Integration
基于人工智能的待办事项助手,集成了 Google 日历,并使用 OpenAI 的 API 和模型上下文协议 (MCP) 来支持自然语言任务管理。
🌐 Starknet MCP Server
Starknet MCP 服务器。
Advanced PocketBase MCP Server
镜子 (jìng zi)
MCP Servers - OpenAI and Flux Integration
镜子 (jìng zi)
Pocketbase Mcp
MCP 兼容的 PocketBase 服务器实现
Remote MCP Server on Cloudflare
Remote MCP Server on Cloudflare
goose-with-mcp-servers
代号“鹅”的包含 MCP 服务器的 Docker 镜像
supOS MCP Server
镜子 (jìng zi)
aiohttp-mcp
构建在 aiohttp 之上的模型上下文协议 (MCP) 服务器的工具: Here are some tools and libraries that can help you build Model Context Protocol (MCP) servers on top of aiohttp: * **aiohttp:** This is the fundamental asynchronous HTTP server and client library for Python. You'll use it to handle incoming MCP requests and send responses. You'll need to understand how to define routes, handle requests, and serialize/deserialize data. * **asyncio:** Since aiohttp is built on asyncio, you'll need a good understanding of asynchronous programming concepts like event loops, coroutines, and tasks. This is crucial for handling concurrent requests efficiently. * **Marshmallow (or similar serialization library):** MCP often involves structured data. Marshmallow is a popular library for serializing and deserializing Python objects to and from formats like JSON. This helps you validate incoming requests and format outgoing responses according to the MCP specification. Alternatives include `attrs` with `cattrs`, or `pydantic`. * **JSON Schema (and a validator):** MCP implementations often use JSON Schema to define the structure and validation rules for the request and response payloads. Libraries like `jsonschema` can be used to validate incoming requests against a schema, ensuring that they conform to the MCP specification. * **gRPC (optional, but relevant for comparison):** While you're building on aiohttp, it's worth understanding gRPC. gRPC is a high-performance RPC framework that's often used for similar purposes as MCP. Understanding gRPC can help you make informed design decisions about your MCP implementation. If performance is critical, consider whether gRPC might be a better fit than a custom aiohttp-based solution. * **Logging:** Use Python's built-in `logging` module to log requests, errors, and other relevant information. This is essential for debugging and monitoring your MCP server. * **Testing Framework (pytest, unittest):** Write unit tests and integration tests to ensure that your MCP server is working correctly. `pytest` is a popular and flexible testing framework. * **OpenAPI/Swagger (optional):** If you want to document your MCP API, you can use OpenAPI (formerly Swagger). Tools like `aiohttp-apispec` can help you generate OpenAPI specifications from your aiohttp routes. This makes it easier for clients to understand and use your MCP server. **Example (Conceptual):** ```python import asyncio import json from aiohttp import web import marshmallow import jsonschema # Define your data models using Marshmallow class MyRequestSchema(marshmallow.Schema): input_data = marshmallow.fields.String(required=True) class MyResponseSchema(marshmallow.Schema): output_data = marshmallow.fields.String(required=True) # Define your JSON Schema (alternative to Marshmallow for validation) request_schema = { "type": "object", "properties": { "input_data": {"type": "string"} }, "required": ["input_data"] } async def handle_mcp_request(request): try: data = await request.json() # Option 1: Validate with JSON Schema try: jsonschema.validate(instance=data, schema=request_schema) except jsonschema.exceptions.ValidationError as e: return web.json_response({"error": str(e)}, status=400) # Option 2: Validate and deserialize with Marshmallow # try: # validated_data = MyRequestSchema().load(data) # except marshmallow.exceptions.ValidationError as err: # return web.json_response({"errors": err.messages}, status=400) # Process the request (replace with your actual logic) input_data = data['input_data'] # or validated_data['input_data'] output_data = f"Processed: {input_data}" # Serialize the response with Marshmallow response_data = MyResponseSchema().dump({"output_data": output_data}) return web.json_response(response_data) except Exception as e: print(f"Error: {e}") return web.json_response({"error": "Internal Server Error"}, status=500) async def main(): app = web.Application() app.add_routes([web.post('/mcp', handle_mcp_request)]) runner = web.AppRunner(app) await runner.setup() site = web.TCPSite(runner, 'localhost', 8080) await site.start() print("Server started on http://localhost:8080") await asyncio.Future() # Run forever if __name__ == '__main__': asyncio.run(main()) ``` **Key Considerations for MCP:** * **Specification Adherence:** Carefully review the MCP specification you're implementing. Pay close attention to the required data formats, error codes, and communication protocols. * **Error Handling:** Implement robust error handling to gracefully handle invalid requests, unexpected errors, and other issues. Return informative error messages to the client. * **Security:** Consider security implications, especially if your MCP server is exposed to the internet. Implement authentication, authorization, and input validation to protect against malicious attacks. * **Performance:** Optimize your code for performance, especially if you expect a high volume of requests. Use asynchronous programming effectively, and consider caching frequently accessed data. * **Scalability:** Design your MCP server to be scalable, so that it can handle increasing traffic. Consider using a load balancer and multiple instances of your server. * **Monitoring:** Implement monitoring to track the performance and health of your MCP server. Use metrics like request latency, error rates, and resource utilization to identify and resolve issues. This comprehensive list should give you a good starting point for building your MCP server on top of aiohttp. Remember to adapt the tools and techniques to the specific requirements of your MCP implementation.
Typescript Mcp Server Usage
Okay, I will provide you with a basic example of how to create an MCP (Minecraft Protocol) server using TypeScript. Keep in mind that building a full-fledged Minecraft server from scratch is a complex undertaking. This example will focus on the core networking and handshake aspects. You'll need to install some dependencies first. **1. Project Setup and Dependencies:** First, create a new TypeScript project: ```bash mkdir mcp-server cd mcp-server npm init -y npm install typescript ts-node ws --save npm install @types/node @types/ws --save-dev ``` * `ws`: A popular WebSocket library for Node.js. Minecraft uses a custom protocol over TCP, but WebSocket provides a convenient way to handle the underlying socket communication for this example. In a real Minecraft server, you'd implement the protocol directly over TCP. * `typescript`: The TypeScript compiler. * `ts-node`: Allows you to execute TypeScript files directly. * `@types/node`, `@types/ws`: TypeScript type definitions for Node.js and WebSocket, respectively. Create a `tsconfig.json` file: ```json { "compilerOptions": { "target": "es2017", "module": "commonjs", "outDir": "./dist", "rootDir": "./src", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true, "resolveJsonModule": true }, "include": ["src/**/*"], "exclude": ["node_modules"] } ``` **2. `src/index.ts` (Main Server Code):** ```typescript import * as WebSocket from 'ws'; const PORT = 25565; // Or any port you prefer const wss = new WebSocket.Server({ port: PORT }, () => { console.log(`Server started on port ${PORT}`); }); wss.on('connection', ws => { console.log('Client connected'); ws.on('message', message => { // In a real Minecraft server, you'd parse the Minecraft protocol packets here. // This is a simplified example, so we're just echoing the message. console.log(`Received: ${message}`); // Example: Echo the message back to the client ws.send(`Server received: ${message}`); }); ws.on('close', () => { console.log('Client disconnected'); }); ws.on('error', error => { console.error('WebSocket error:', error); }); }); wss.on('error', error => { console.error('Server error:', error); }); console.log('MCP Server is starting...'); ``` **Explanation:** * **Import `ws`:** Imports the WebSocket library. * **`PORT`:** Defines the port the server will listen on. Minecraft's default port is 25565. * **`WebSocket.Server`:** Creates a new WebSocket server instance. * **`wss.on('connection', ...)`:** This is the core of the server. It's called whenever a new client connects. * `ws`: Represents the WebSocket connection to the client. * `ws.on('message', ...)`: Handles incoming messages from the client. **This is where you would implement the Minecraft protocol parsing and handling.** In this example, it simply logs the message and echoes it back. * `ws.on('close', ...)`: Handles client disconnections. * `ws.on('error', ...)`: Handles errors on the WebSocket connection. * **`wss.on('error', ...)`:** Handles errors on the server itself. **3. Building and Running:** 1. **Compile:** Run `npm run tsc` (or just `tsc` if you have it globally installed) to compile the TypeScript code into JavaScript. This will create a `dist` directory with the compiled `index.js` file. You might need to add `"build": "tsc"` to your `package.json` scripts section. 2. **Run:** Execute the server using `node dist/index.js` or `ts-node src/index.ts`. **Important Considerations and Next Steps (for a *real* Minecraft server):** * **Minecraft Protocol:** The code above uses WebSockets for simplicity. A *real* Minecraft server communicates using a custom binary protocol over TCP. You'll need to: * **Understand the Protocol:** Study the Minecraft protocol documentation (see links below). It involves packets with specific IDs, data types, and structures. * **Implement Packet Parsing/Serialization:** Write code to read incoming TCP data, parse it into Minecraft packets, and serialize packets to send back to the client. Libraries exist that can help with this, but you'll still need to understand the protocol. * **Handshake:** The initial connection involves a handshake where the client and server exchange protocol versions. You need to implement this handshake correctly. * **Authentication:** Minecraft servers typically require authentication. You'll need to handle login requests and verify user credentials. * **Game Logic:** This example has *no* game logic. You'll need to implement the core game mechanics: world generation, player movement, entity management, block updates, etc. * **Threading/Asynchronous Operations:** Minecraft servers are highly concurrent. You'll need to use threading or asynchronous programming (e.g., `async/await` in TypeScript) to handle multiple clients efficiently. * **World Storage:** You'll need a way to store the game world data (blocks, entities, etc.). This could involve files, databases, or other storage mechanisms. **Example of a very basic handshake (to illustrate the concept):** ```typescript // Inside the 'connection' handler: ws.on('message', message => { const buffer = Buffer.from(message); // Convert to Buffer for binary data // Example: Very basic handshake (replace with actual protocol parsing) if (buffer[0] === 0x00) { // Assuming 0x00 is a handshake packet ID const protocolVersion = buffer.readInt32BE(1); // Read protocol version const serverAddressLength = buffer.readInt8(5); const serverAddress = buffer.toString('utf8', 6, 6 + serverAddressLength); const serverPort = buffer.readUInt32BE(6 + serverAddressLength); const nextState = buffer.readInt8(10 + serverAddressLength); console.log(`Handshake: Protocol ${protocolVersion}, Address ${serverAddress}:${serverPort}, Next State ${nextState}`); // Send a response (e.g., a status response) const response = JSON.stringify({ version: { name: "My TypeScript Server", protocol: protocolVersion }, players: { max: 10, online: 0, sample: [] }, description: { text: "A simple TypeScript Minecraft server" } }); const responseBuffer = Buffer.from(response); const length = responseBuffer.length; const lengthBuffer = Buffer.alloc(1); lengthBuffer.writeInt8(length); ws.send(Buffer.concat([lengthBuffer, responseBuffer])); } else { console.log(`Received other message: ${message}`); } }); ``` **Important Resources:** * **Minecraft Protocol Documentation:** This is essential. Search for "Minecraft Protocol" or "wiki.vg Minecraft Protocol". `wiki.vg` is a good starting point. * **Existing Minecraft Server Implementations:** Look at open-source Minecraft server projects (e.g., in Java or other languages) to see how they handle the protocol and game logic. This can be a great learning resource. However, be aware that the protocol changes over time, so make sure the implementation you're looking at is relatively up-to-date. **Chinese Translation of Key Terms:** * **Minecraft Protocol:** 我的世界协议 (Wǒ de shìjiè xiéyì) * **Server:** 服务器 (Fúwùqì) * **Client:** 客户端 (Kèhùduān) * **Packet:** 数据包 (Shùjù bāo) * **Handshake:** 握手 (Wòshǒu) * **Authentication:** 身份验证 (Shēnfèn yànzhèng) * **WebSocket:** WebSocket (Websocket, no direct translation is commonly used) * **TCP:** TCP (TCP, no direct translation is commonly used) * **Port:** 端口 (Duānkǒu) * **Connection:** 连接 (Liánjiē) * **Message:** 消息 (Xiāoxī) * **Error:** 错误 (Cuòwù) * **Protocol Version:** 协议版本 (Xiéyì bǎnběn) This is a very basic starting point. Building a real Minecraft server is a significant project. Good luck!