Discover Awesome MCP Servers

Extend your agent with 26,794 capabilities via MCP servers.

All26,794
Boilerplate MCP Server

Boilerplate MCP Server

一个基于 TypeScript 的模型上下文协议 (MCP) 服务器样板,用于构建 AI 连接的工具。它具有 IP 查询工具、CLI 支持、MCP Inspector 集成以及可扩展的架构,用于将 Claude/Anthropic AI 系统连接到外部数据源。

Peeper MCP Server

Peeper MCP Server

Peeper 应用程序的模型控制面板服务器

Model Context Protocal (MCP) Implementation

Model Context Protocal (MCP) Implementation

这是一个简单的 MCP 服务器框架,它能够通过结构化的消息协议传递数据,从而实现客户端和服务器之间的无缝通信。它支持高效的数据交换、实时处理以及针对各种应用的可定制扩展,从而确保在各种环境中的可扩展性和可靠性。

Databricks Permissions MCP Server

Databricks Permissions MCP Server

用于管理 Databricks 权限和凭据的 MCP 服务器

mcp-servers

mcp-servers

Workflows MCP Server

Workflows MCP Server

一个服务器,它通过直接的 REST 端点和模型上下文协议 (MCP) 集成,为工作流引擎提供集成。

Cursor Azure DevOps MCP Server

Cursor Azure DevOps MCP Server

Azure DevOps Cursor IDE MCP 服务器插件

Weather MCP Server

Weather MCP Server

MCP 服务器获取美国城市天气 Or, more literally: MCP 服务器获取美国城市的天气

🤖 Deno Model Context Protocol (MCP) Agent Template Repository

🤖 Deno Model Context Protocol (MCP) Agent Template Repository

好的,这是用 Deno 实现的模板 Model Context Protocol (MCP) 服务器: ```typescript import { serve } from "https://deno.land/std@0.177.1/http/server.ts"; import { acceptWebSocket, isWebSocketCloseEvent, WebSocket, } from "https://deno.land/std@0.177.1/ws/mod.ts"; // 定义 MCP 消息类型 interface MCPMessage { type: string; data: any; } // 处理 WebSocket 连接 async function handleWebSocket(ws: WebSocket) { console.log("WebSocket connected"); try { for await (const event of ws) { if (typeof event === "string") { // 处理文本消息 try { const message: MCPMessage = JSON.parse(event); console.log("Received message:", message); // 根据消息类型进行处理 switch (message.type) { case "ping": // 响应 ping 消息 ws.send(JSON.stringify({ type: "pong" })); break; case "model_request": // 处理模型请求 const modelResponse = await processModelRequest(message.data); ws.send(JSON.stringify({ type: "model_response", data: modelResponse })); break; default: console.warn("Unknown message type:", message.type); ws.send(JSON.stringify({ type: "error", data: "Unknown message type" })); } } catch (error) { console.error("Error parsing message:", error); ws.send(JSON.stringify({ type: "error", data: "Invalid message format" })); } } else if (isWebSocketCloseEvent(event)) { // 处理连接关闭事件 const { code, reason } = event; console.log("WebSocket closed:", code, reason); } } } catch (error) { console.error("Error handling WebSocket:", error); try { ws.close(1011, "Internal Server Error"); // 1011 表示服务器遇到了意外情况 } catch (_error) { // 忽略关闭错误 } } } // 模拟模型请求处理函数 (需要根据实际情况实现) async function processModelRequest(requestData: any): Promise<any> { console.log("Processing model request:", requestData); // 模拟模型处理延迟 await new Promise((resolve) => setTimeout(resolve, 500)); // 模拟模型响应 return { result: "Model processing successful!", requestData: requestData, timestamp: Date.now(), }; } // HTTP 请求处理函数 async function handleHttpRequest(request: Request): Promise<Response> { if (request.headers.get("upgrade") === "websocket") { // 处理 WebSocket 连接 const { socket, response } = Deno.upgradeWebSocket(request); handleWebSocket(socket); return response; } else { // 处理 HTTP 请求 return new Response("Hello, Deno! This is a Model Context Protocol server.", { headers: { "content-type": "text/plain" }, }); } } // 启动服务器 const port = 8080; console.log(`Server listening on port ${port}`); await serve(handleHttpRequest, { port }); ``` **代码解释:** 1. **导入必要的模块:** - `serve` 来自 `https://deno.land/std@0.177.1/http/server.ts` 用于启动 HTTP 服务器。 - `acceptWebSocket`, `isWebSocketCloseEvent`, `WebSocket` 来自 `https://deno.land/std@0.177.1/ws/mod.ts` 用于处理 WebSocket 连接。 2. **定义 `MCPMessage` 接口:** - 定义了 MCP 消息的结构,包含 `type` (消息类型) 和 `data` (消息数据) 两个字段。 3. **`handleWebSocket(ws: WebSocket)` 函数:** - 处理 WebSocket 连接的逻辑。 - 使用 `for await (const event of ws)` 循环监听 WebSocket 事件。 - 如果事件是字符串,则尝试解析为 `MCPMessage` 对象。 - 根据 `message.type` 进行不同的处理: - `ping`: 响应 `pong` 消息。 - `model_request`: 调用 `processModelRequest` 函数处理模型请求,并将结果作为 `model_response` 发送回去。 - `default`: 处理未知消息类型,并发送错误消息。 - 如果事件是 `isWebSocketCloseEvent`,则处理连接关闭事件。 - 使用 `try...catch` 块捕获和处理错误,并在发生错误时关闭 WebSocket 连接。 4. **`processModelRequest(requestData: any): Promise<any>` 函数:** - **重要:** 这是一个**模拟**的模型请求处理函数,你需要根据你的实际模型处理逻辑来实现它。 - 模拟了模型处理的延迟 (500ms)。 - 返回一个包含处理结果、请求数据和时间戳的模拟响应。 5. **`handleHttpRequest(request: Request): Promise<Response>` 函数:** - 处理 HTTP 请求的逻辑。 - 如果请求头包含 `upgrade: websocket`,则使用 `Deno.upgradeWebSocket` 将 HTTP 连接升级为 WebSocket 连接,并调用 `handleWebSocket` 函数处理 WebSocket 连接。 - 否则,返回一个简单的 HTTP 响应。 6. **启动服务器:** - 定义服务器监听的端口 (8080)。 - 使用 `serve` 函数启动服务器,并将 `handleHttpRequest` 函数作为请求处理函数。 **如何运行:** 1. **保存代码:** 将代码保存为 `mcp_server.ts` 文件。 2. **运行命令:** 在终端中运行以下命令: ```bash deno run --allow-net --allow-read mcp_server.ts ``` - `--allow-net`: 允许程序监听网络端口。 - `--allow-read`: 如果你的模型需要读取文件,则需要添加此权限。 **如何测试:** 你可以使用 WebSocket 客户端工具 (例如 `wscat` 或在线 WebSocket 测试工具) 连接到服务器,并发送 MCP 消息进行测试。 **示例测试消息:** ```json { "type": "ping" } ``` ```json { "type": "model_request", "data": { "input": "This is a test input." } } ``` **重要注意事项:** * **替换 `processModelRequest` 函数:** 这是代码中最关键的部分。 你需要根据你的实际模型处理逻辑来实现它。 这可能涉及到加载模型、预处理输入数据、运行模型推理、后处理输出数据等步骤。 * **错误处理:** 代码中包含基本的错误处理,但你需要根据你的实际需求进行更完善的错误处理。 * **安全性:** 在生产环境中,你需要考虑安全性问题,例如身份验证、授权、数据加密等。 * **依赖管理:** Deno 使用 URL 来管理依赖,因此你需要确保你的依赖 URL 是正确的。 * **性能:** 如果你的模型处理需要高性能,你需要考虑优化你的代码和模型。 **中文翻译:** 好的,这是一个用 Deno 实现的模板 Model Context Protocol (MCP) 服务器: ```typescript import { serve } from "https://deno.land/std@0.177.1/http/server.ts"; import { acceptWebSocket, isWebSocketCloseEvent, WebSocket, } from "https://deno.land/std@0.177.1/ws/mod.ts"; // 定义 MCP 消息类型 interface MCPMessage { type: string; data: any; } // 处理 WebSocket 连接 async function handleWebSocket(ws: WebSocket) { console.log("WebSocket 已连接"); try { for await (const event of ws) { if (typeof event === "string") { // 处理文本消息 try { const message: MCPMessage = JSON.parse(event); console.log("收到消息:", message); // 根据消息类型进行处理 switch (message.type) { case "ping": // 响应 ping 消息 ws.send(JSON.stringify({ type: "pong" })); break; case "model_request": // 处理模型请求 const modelResponse = await processModelRequest(message.data); ws.send(JSON.stringify({ type: "model_response", data: modelResponse })); break; default: console.warn("未知消息类型:", message.type); ws.send(JSON.stringify({ type: "error", data: "未知消息类型" })); } } catch (error) { console.error("解析消息时出错:", error); ws.send(JSON.stringify({ type: "error", data: "无效的消息格式" })); } } else if (isWebSocketCloseEvent(event)) { // 处理连接关闭事件 const { code, reason } = event; console.log("WebSocket 已关闭:", code, reason); } } } catch (error) { console.error("处理 WebSocket 时出错:", error); try { ws.close(1011, "Internal Server Error"); // 1011 表示服务器遇到了意外情况 } catch (_error) { // 忽略关闭错误 } } } // 模拟模型请求处理函数 (需要根据实际情况实现) async function processModelRequest(requestData: any): Promise<any> { console.log("处理模型请求:", requestData); // 模拟模型处理延迟 await new Promise((resolve) => setTimeout(resolve, 500)); // 模拟模型响应 return { result: "模型处理成功!", requestData: requestData, timestamp: Date.now(), }; } // HTTP 请求处理函数 async function handleHttpRequest(request: Request): Promise<Response> { if (request.headers.get("upgrade") === "websocket") { // 处理 WebSocket 连接 const { socket, response } = Deno.upgradeWebSocket(request); handleWebSocket(socket); return response; } else { // 处理 HTTP 请求 return new Response("你好,Deno!这是一个 Model Context Protocol 服务器。", { headers: { "content-type": "text/plain" }, }); } } // 启动服务器 const port = 8080; console.log(`服务器监听端口 ${port}`); await serve(handleHttpRequest, { port }); ``` **代码解释:** (与英文版本相同,只是翻译成了中文) 1. **导入必要的模块:** - `serve` 来自 `https://deno.land/std@0.177.1/http/server.ts` 用于启动 HTTP 服务器。 - `acceptWebSocket`, `isWebSocketCloseEvent`, `WebSocket` 来自 `https://deno.land/std@0.177.1/ws/mod.ts` 用于处理 WebSocket 连接。 2. **定义 `MCPMessage` 接口:** - 定义了 MCP 消息的结构,包含 `type` (消息类型) 和 `data` (消息数据) 两个字段。 3. **`handleWebSocket(ws: WebSocket)` 函数:** - 处理 WebSocket 连接的逻辑。 - 使用 `for await (const event of ws)` 循环监听 WebSocket 事件。 - 如果事件是字符串,则尝试解析为 `MCPMessage` 对象。 - 根据 `message.type` 进行不同的处理: - `ping`: 响应 `pong` 消息。 - `model_request`: 调用 `processModelRequest` 函数处理模型请求,并将结果作为 `model_response` 发送回去。 - `default`: 处理未知消息类型,并发送错误消息。 - 如果事件是 `isWebSocketCloseEvent`,则处理连接关闭事件。 - 使用 `try...catch` 块捕获和处理错误,并在发生错误时关闭 WebSocket 连接。 4. **`processModelRequest(requestData: any): Promise<any>` 函数:** - **重要:** 这是一个**模拟**的模型请求处理函数,你需要根据你的实际模型处理逻辑来实现它。 - 模拟了模型处理的延迟 (500ms)。 - 返回一个包含处理结果、请求数据和时间戳的模拟响应。 5. **`handleHttpRequest(request: Request): Promise<Response>` 函数:** - 处理 HTTP 请求的逻辑。 - 如果请求头包含 `upgrade: websocket`,则使用 `Deno.upgradeWebSocket` 将 HTTP 连接升级为 WebSocket 连接,并调用 `handleWebSocket` 函数处理 WebSocket 连接。 - 否则,返回一个简单的 HTTP 响应。 6. **启动服务器:** - 定义服务器监听的端口 (8080)。 - 使用 `serve` 函数启动服务器,并将 `handleHttpRequest` 函数作为请求处理函数。 **如何运行:** (与英文版本相同) 1. **保存代码:** 将代码保存为 `mcp_server.ts` 文件。 2. **运行命令:** 在终端中运行以下命令: ```bash deno run --allow-net --allow-read mcp_server.ts ``` - `--allow-net`: 允许程序监听网络端口。 - `--allow-read`: 如果你的模型需要读取文件,则需要添加此权限。 **如何测试:** (与英文版本相同) 你可以使用 WebSocket 客户端工具 (例如 `wscat` 或在线 WebSocket 测试工具) 连接到服务器,并发送 MCP 消息进行测试。 **示例测试消息:** (与英文版本相同) ```json { "type": "ping" } ``` ```json { "type": "model_request", "data": { "input": "This is a test input." } } ``` **重要注意事项:** (与英文版本相同) * **替换 `processModelRequest` 函数:** 这是代码中最关键的部分。 你需要根据你的实际模型处理逻辑来实现它。 这可能涉及到加载模型、预处理输入数据、运行模型推理、后处理输出数据等步骤。 * **错误处理:** 代码中包含基本的错误处理,但你需要根据你的实际需求进行更完善的错误处理。 * **安全性:** 在生产环境中,你需要考虑安全性问题,例如身份验证、授权、数据加密等。 * **依赖管理:** Deno 使用 URL 来管理依赖,因此你需要确保你的依赖 URL 是正确的。 * **性能:** 如果你的模型处理需要高性能,你需要考虑优化你的代码和模型。 希望这个模板能帮助你构建你的 MCP 服务器!

Simple_dart_mcp_server

Simple_dart_mcp_server

以下是一个用 Dart 编写的非常简单的模型上下文协议服务器实现: ```dart import 'dart:io'; import 'dart:convert'; void main() async { final server = await ServerSocket.bind('localhost', 4040); print('服务器已启动,监听端口 ${server.port}'); server.listen((client) { handleClient(client); }); } void handleClient(Socket client) { print('客户端连接:${client.remoteAddress.address}:${client.remotePort}'); client.listen( (List<int> data) { final message = utf8.decode(data); print('收到消息:$message'); try { // 尝试解析 JSON final request = jsonDecode(message); // 模拟处理请求并生成响应 final response = processRequest(request); // 将响应编码为 JSON 并发送回客户端 final responseJson = jsonEncode(response); client.write(responseJson); print('发送响应:$responseJson'); } catch (e) { print('错误:无法解析 JSON 或处理请求:$e'); client.write('{"error": "Invalid request"}'); } }, onError: (error) { print('客户端错误:$error'); client.close(); }, onDone: () { print('客户端断开连接'); client.close(); }, ); } // 模拟处理请求的函数 Map<String, dynamic> processRequest(dynamic request) { // 在这里实现你的模型上下文逻辑 // 例如,根据请求中的参数执行某些操作并返回结果 // 示例:如果请求包含 "query" 字段,则返回一个包含 "response" 字段的响应 if (request is Map && request.containsKey('query')) { final query = request['query']; return {'response': '您查询的是:$query'}; } else { return {'error': '无效的请求格式'}; } } ``` **代码解释:** 1. **`import 'dart:io';` 和 `import 'dart:convert';`**: 导入必要的库,`dart:io` 用于网络操作,`dart:convert` 用于 JSON 编码和解码。 2. **`main()` 函数**: - 使用 `ServerSocket.bind()` 绑定服务器到 `localhost` 的 `4040` 端口。你可以根据需要更改端口。 - 使用 `server.listen()` 监听客户端连接。 - 对于每个连接的客户端,调用 `handleClient()` 函数来处理。 3. **`handleClient()` 函数**: - 打印客户端的连接信息。 - 使用 `client.listen()` 监听客户端发送的数据。 - **数据处理**: - 使用 `utf8.decode()` 将接收到的字节数据解码为字符串。 - 使用 `jsonDecode()` 尝试将字符串解析为 JSON 对象。 - 调用 `processRequest()` 函数来模拟处理请求并生成响应。 - 使用 `jsonEncode()` 将响应编码为 JSON 字符串。 - 使用 `client.write()` 将 JSON 字符串发送回客户端。 - **错误处理**: - 使用 `onError` 回调函数处理客户端错误。 - 使用 `onDone` 回调函数处理客户端断开连接。 4. **`processRequest()` 函数**: - 这是一个模拟函数,用于处理客户端的请求。 - 你需要根据你的模型上下文协议的实际需求来实现这个函数。 - 示例代码检查请求是否包含 "query" 字段,如果包含,则返回一个包含 "response" 字段的响应。 - 如果请求格式无效,则返回一个包含 "error" 字段的响应。 **如何运行:** 1. 将代码保存为 `server.dart` 文件。 2. 在终端中运行 `dart server.dart`。 **如何测试:** 你可以使用 `telnet` 或 `curl` 等工具来测试服务器。 **使用 `telnet`:** 1. 打开终端并运行 `telnet localhost 4040`。 2. 输入以下 JSON 字符串并按 Enter 键: ```json {"query": "你好"} ``` 3. 你应该会收到服务器的响应: ```json {"response": "您查询的是:你好"} ``` **使用 `curl`:** 1. 打开终端并运行以下命令: ```bash curl -X POST -H "Content-Type: application/json" -d '{"query": "你好"}' http://localhost:4040 ``` 2. 你应该会收到服务器的响应: ```json {"response": "您查询的是:你好"} ``` **重要说明:** * 这是一个非常简单的示例,仅用于演示模型上下文协议服务器的基本概念。 * 你需要根据你的实际需求来实现 `processRequest()` 函数,并添加必要的错误处理和安全性措施。 * 实际的模型上下文协议可能需要更复杂的协议和数据格式。 * 考虑使用更健壮的库,例如 `shelf` 或 `aqueduct`,来构建更复杂的服务器应用程序。 **中文总结:** 这段代码创建了一个简单的 Dart 服务器,监听 4040 端口。当客户端连接时,服务器接收客户端发送的 JSON 消息,然后调用 `processRequest()` 函数来处理请求并生成响应。最后,服务器将响应编码为 JSON 字符串并发送回客户端。 `processRequest()` 函数是一个占位符,你需要根据你的模型上下文协议的实际需求来实现它。 你可以使用 `telnet` 或 `curl` 等工具来测试服务器。 请记住,这只是一个简单的示例,你需要根据你的实际需求进行修改和扩展。

MCP Server template for better AI Coding

MCP Server template for better AI Coding

这个模板为在 Python 中构建模型上下文协议 (MCP) 服务器提供了一个简化的基础。它的设计旨在使 AI 辅助的 MCP 工具的开发更容易、更高效。

hackernew-mcp

hackernew-mcp

为 Hacker News 准备的对 AI 友好的 MCP 服务器

Shopify MCP Server

Shopify MCP Server

镜子 (jìng zi)

Todoist MCP Server

Todoist MCP Server

镜子 (jìng zi)

Compound Interest CalculatorCompound Interest Calculator

Compound Interest CalculatorCompound Interest Calculator

用于测试 MCP 服务器功能的存储库

MCP Server Setup Guide

MCP Server Setup Guide

GitHub API 集成的 MCP 服务器

mcp-server-opensearch MCP server

mcp-server-opensearch MCP server

MCP Server for MySQL based on NodeJS

MCP Server for MySQL based on NodeJS

镜子 (jìng zi)

Test

Test

测试 (cè shì)

OpenAI Web Search MCP Server

OpenAI Web Search MCP Server

使用 MCP (多配置协议) 处理 OpenAI 网络搜索的服务器

HDW MCP Server

HDW MCP Server

镜子 (jìng zi)

Polygon MCP Server

Polygon MCP Server

用于与 Polygon 网络交互的 Polygon 区块链 MCP 服务器

File Operations MCP Server

File Operations MCP Server

镜子 (jìng zi)

Dev Log MCP Component

Dev Log MCP Component

一个开发者日志 MCP 服务器,用于 Cline、Roo Code 或其他代理式 AI 工具。

Teamwork MCP

Teamwork MCP

连接到 Teamwork API 的 MCP 服务器

Tugboat MCP Server

Tugboat MCP Server

一个用于与 Tugboat API 交互的模型上下文协议 (MCP) 服务器。

MCP Magic UI

MCP Magic UI

一个模型上下文协议(Model Context Protocol,MCP)服务器,提供对 Magic UI 组件的访问,允许 AI 助手和其他 MCP 客户端发现和使用来自 Magic UI 设计系统的 UI 组件。

Google Search MCP Server

Google Search MCP Server

专为 VS Code / Cline / Anthropic 构建的 MCP 服务器 - 启用 Google 搜索并具备跟踪链接和研究网站的能力

Comfy MCP Server

Comfy MCP Server

镜子 (jìng zi)

GitHub PR MCP Server

GitHub PR MCP Server

用于 Github 的 Claude MCP 服务器,集成 Linear