发现优秀的 MCP 服务器
通过 MCP 服务器扩展您的代理能力,拥有 13,631 个能力。
MCP TTS Server
用于TTS引擎的MCP服务器封装器 (Kokoro TTS 和 OpenAI TTS)
aptos-wallet-mcp
Aptos钱包的MCP服务器
Mcp Server Tester
Local Scanner MCP Server
Okay, here are a few possible translations of "MCP server for scanning local code and localhost URLs," depending on the specific nuance you want to convey. I'll also include some context about what "MCP" might mean, as it's ambiguous. **Understanding "MCP"** "MCP" is an acronym that could stand for several things. Without more context, it's difficult to know the *exact* meaning. Here are a few possibilities, and I'll tailor the translations accordingly: * **Most Likely: Malware/Code Protection (or similar):** This is the most likely interpretation given the context of scanning code and URLs. It suggests a server designed to detect malicious code or vulnerabilities. * **Less Likely: Minecraft Coder Pack (MCP):** This is a tool for decompiling and re-compiling Minecraft code. It's *unlikely* to be the meaning here, but I'll include a translation just in case. * **Least Likely: Other meanings:** MCP could stand for many other things (e.g., Master Control Program, Microsoft Certified Professional). These are highly unlikely in this context. **Translations (Assuming MCP = Malware/Code Protection)** Here are a few options, ranked by how common and natural they sound: **Option 1 (Most Common & General):** * **Chinese:** 用于扫描本地代码和 localhost URL 的 MCP 服务器 (Yòng yú sǎo miáo běndì dàimǎ hé localhost URL de MCP fúwùqì) * **Pinyin:** Yòng yú sǎo miáo běndì dàimǎ hé localhost URL de MCP fúwùqì * **Explanation:** This is a direct translation. It uses "MCP" as is, assuming the target audience understands the acronym (or you will define it elsewhere). "用于 (yòng yú)" means "used for" or "for the purpose of." "扫描 (sǎo miáo)" means "scan." "本地代码 (běndì dàimǎ)" means "local code." "服务器 (fúwùqì)" means "server." **Option 2 (More Explicit - Malware/Code Protection):** * **Chinese:** 用于扫描本地代码和 localhost URL 的恶意代码/代码保护服务器 (Yòng yú sǎo miáo běndì dàimǎ hé localhost URL de èyì dàimǎ/dàimǎ bǎohù fúwùqì) * **Pinyin:** Yòng yú sǎo miáo běndì dàimǎ hé localhost URL de èyì dàimǎ/dàimǎ bǎohù fúwùqì * **Explanation:** This replaces "MCP" with a more descriptive phrase: "恶意代码/代码保护 (èyì dàimǎ/dàimǎ bǎohù)," which means "malicious code/code protection." The "/" indicates "or." This is useful if you want to be very clear about the server's purpose. **Option 3 (Focus on Vulnerability Scanning):** * **Chinese:** 用于扫描本地代码和 localhost URL 的漏洞扫描服务器 (Yòng yú sǎo miáo běndì dàimǎ hé localhost URL de lòudòng sǎo miáo fúwùqì) * **Pinyin:** Yòng yú sǎo miáo běndì dàimǎ hé localhost URL de lòudòng sǎo miáo fúwùqì * **Explanation:** This focuses on *vulnerability* scanning. "漏洞扫描 (lòudòng sǎo miáo)" means "vulnerability scanning." This is appropriate if the server's primary function is to find security weaknesses. **Option 4 (More Natural Phrasing - Implies Purpose):** * **Chinese:** 一款用于扫描本地代码和 localhost URL 的 MCP 服务器 (Yī kuǎn yòng yú sǎo miáo běndì dàimǎ hé localhost URL de MCP fúwùqì) * **Pinyin:** Yī kuǎn yòng yú sǎo miáo běndì dàimǎ hé localhost URL de MCP fúwùqì * **Explanation:** Adding "一款 (yī kuǎn)" which means "a" or "one type of" makes the sentence flow a little more naturally. **Translation (Assuming MCP = Minecraft Coder Pack - Highly Unlikely):** * **Chinese:** 用于扫描本地代码和 localhost URL 的 Minecraft Coder Pack (MCP) 服务器 (Yòng yú sǎo miáo běndì dàimǎ hé localhost URL de Minecraft Coder Pack (MCP) fúwùqì) * **Pinyin:** Yòng yú sǎo miáo běndì dàimǎ hé localhost URL de Minecraft Coder Pack (MCP) fúwùqì * **Explanation:** This is a direct translation, keeping the English name "Minecraft Coder Pack" and the acronym "MCP." It's unlikely this is the correct meaning, but included for completeness. **Recommendation:** I recommend **Option 1** or **Option 2** (if you want to be very explicit). If the server is specifically for finding vulnerabilities, **Option 3** is a good choice. **Option 4** is a slight improvement in naturalness. **Important Considerations:** * **Target Audience:** Who are you writing for? If they are familiar with the acronym "MCP" in the context of code security, then using it directly is fine. If not, use a more descriptive phrase like in Option 2 or 3. * **Context:** Where will this translation be used? If it's in documentation, you can define "MCP" the first time you use it. * **Specificity:** What *specifically* does the server do? Does it focus on malware detection, vulnerability scanning, or something else? Tailor the translation to reflect the server's primary function. To give you the *best* translation, please provide more context about what "MCP" means in your specific case.
mcp-server-etcd
Custom MCP Servers
我自建的 MCP 服务器合集 🧠⚡️。
On Running MCP
用于与 On Running API 交互的 MCP 服务器
🤖 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)) { // 处理 WebSocket 关闭事件 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 (_ignore) { // 忽略关闭错误,因为连接可能已经关闭 } } } // 模拟模型请求处理函数 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", data: { input: requestData, output: "This is a simulated model output.", }, }; } // 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 事件。 - **处理文本消息 (`typeof event === "string"`):** - 使用 `JSON.parse(event)` 将文本消息解析为 `MCPMessage` 对象。 - 使用 `switch` 语句根据 `message.type` 进行不同的处理: - `ping`: 响应 `pong` 消息。 - `model_request`: 调用 `processModelRequest` 函数处理模型请求,并将响应发送回客户端。 - `default`: 处理未知消息类型,并发送错误消息。 - 使用 `try...catch` 块捕获 JSON 解析错误。 - **处理 WebSocket 关闭事件 (`isWebSocketCloseEvent(event)`):** - 记录关闭代码和原因。 - 使用 `try...catch` 块捕获 WebSocket 处理过程中的错误,并尝试关闭连接。 4. **`processModelRequest(requestData: any): Promise<any>` 函数:** - **模拟** 模型请求处理逻辑。 - 接受 `requestData` 作为输入。 - 使用 `await new Promise((resolve) => setTimeout(resolve, 500))` 模拟延迟。 - 返回一个包含 `result` 和 `data` 的模拟响应。 - **你需要根据你的实际模型处理逻辑替换此函数的内容。** 5. **`handleHttpRequest(request: Request): Promise<Response>` 函数:** - 处理 HTTP 请求的逻辑。 - **WebSocket 升级:** - 检查请求头中是否包含 `upgrade: websocket`。 - 如果是,则使用 `Deno.upgradeWebSocket(request)` 将 HTTP 连接升级为 WebSocket 连接。 - 调用 `handleWebSocket(socket)` 处理 WebSocket 连接。 - 返回 `response` 对象。 - **HTTP 请求处理:** - 如果不是 WebSocket 升级请求,则返回一个简单的 "Hello, Deno!" 响应。 6. **启动服务器:** - 定义服务器监听的端口号 `port = 8080`。 - 使用 `console.log` 打印服务器启动信息。 - 使用 `await serve(handleHttpRequest, { port })` 启动服务器,并传入 HTTP 请求处理函数和端口号。 **如何运行:** 1. **保存代码:** 将代码保存为 `mcp_server.ts` 文件。 2. **运行命令:** 在终端中运行以下命令: ```bash deno run --allow-net mcp_server.ts ``` - `--allow-net` 标志允许 Deno 程序访问网络。 **如何测试:** 你可以使用 WebSocket 客户端(例如 wscat 或 Postman)连接到服务器,并发送 MCP 消息进行测试。 **示例 WebSocket 客户端交互:** 1. **连接:** 连接到 `ws://localhost:8080`。 2. **发送 ping 消息:** ```json {"type": "ping"} ``` 3. **接收 pong 消息:** ```json {"type": "pong"} ``` 4. **发送模型请求消息:** ```json {"type": "model_request", "data": {"input_data": "example input"}} ``` 5. **接收模型响应消息:** ```json {"type": "model_response", "data": {"result": "Model processing successful", "data": {"input": {"input_data": "example input"}, "output": "This is a simulated model output."}}} ``` **重要提示:** - **替换 `processModelRequest` 函数:** 你需要根据你的实际模型处理逻辑替换 `processModelRequest` 函数的内容。 - **错误处理:** 在实际应用中,你需要添加更完善的错误处理机制。 - **安全性:** 在生产环境中,你需要考虑安全性问题,例如身份验证和授权。 - **依赖管理:** Deno 使用 URL 作为依赖项,因此你需要确保你的依赖项 URL 是正确的。 **中文翻译:** 好的,这是一个用 Deno 实现的模板模型上下文协议 (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)) { // 处理 WebSocket 关闭事件 const { code, reason } = event; console.log("WebSocket 已关闭:", code, reason); } } } catch (error) { console.error("处理 WebSocket 时出错:", error); try { ws.close(1011, "Internal Server Error"); // 1011 表示服务器遇到了意外情况,阻止其完成请求。 } catch (_ignore) { // 忽略关闭错误,因为连接可能已经关闭 } } } // 模拟模型请求处理函数 async function processModelRequest(requestData: any): Promise<any> { // 在这里实现你的模型处理逻辑 console.log("正在处理模型请求:", requestData); // 模拟延迟 await new Promise((resolve) => setTimeout(resolve, 500)); // 模拟模型响应 return { result: "模型处理成功", data: { input: requestData, output: "这是一个模拟的模型输出。", }, }; } // 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!这是一个模型上下文协议服务器。", { 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 事件。 - **处理文本消息 (`typeof event === "string"`):** - 使用 `JSON.parse(event)` 将文本消息解析为 `MCPMessage` 对象。 - 使用 `switch` 语句根据 `message.type` 进行不同的处理: - `ping`: 响应 `pong` 消息。 - `model_request`: 调用 `processModelRequest` 函数处理模型请求,并将响应发送回客户端。 - `default`: 处理未知消息类型,并发送错误消息。 - 使用 `try...catch` 块捕获 JSON 解析错误。 - **处理 WebSocket 关闭事件 (`isWebSocketCloseEvent(event)`):** - 记录关闭代码和原因。 - 使用 `try...catch` 块捕获 WebSocket 处理过程中的错误,并尝试关闭连接。 4. **`processModelRequest(requestData: any): Promise<any>` 函数:** - **模拟** 模型请求处理逻辑。 - 接受 `requestData` 作为输入。 - 使用 `await new Promise((resolve) => setTimeout(resolve, 500))` 模拟延迟。 - 返回一个包含 `result` 和 `data` 的模拟响应。 - **你需要根据你的实际模型处理逻辑替换此函数的内容。** 5. **`handleHttpRequest(request: Request): Promise<Response>` 函数:** - 处理 HTTP 请求的逻辑。 - **WebSocket 升级:** - 检查请求头中是否包含 `upgrade: websocket`。 - 如果是,则使用 `Deno.upgradeWebSocket(request)` 将 HTTP 连接升级为 WebSocket 连接。 - 调用 `handleWebSocket(socket)` 处理 WebSocket 连接。 - 返回 `response` 对象。 - **HTTP 请求处理:** - 如果不是 WebSocket 升级请求,则返回一个简单的 "你好,Deno!" 响应。 6. **启动服务器:** - 定义服务器监听的端口号 `port = 8080`。 - 使用 `console.log` 打印服务器启动信息。 - 使用 `await serve(handleHttpRequest, { port })` 启动服务器,并传入 HTTP 请求处理函数和端口号。 **如何运行:** 1. **保存代码:** 将代码保存为 `mcp_server.ts` 文件。 2. **运行命令:** 在终端中运行以下命令: ```bash deno run --allow-net mcp_server.ts ``` - `--allow-net` 标志允许 Deno 程序访问网络。 **如何测试:** 你可以使用 WebSocket 客户端(例如 wscat 或 Postman)连接到服务器,并发送 MCP 消息进行测试。 **示例 WebSocket 客户端交互:** 1. **连接:** 连接到 `ws://localhost:8080`。 2. **发送 ping 消息:** ```json {"type": "ping"} ``` 3. **接收 pong 消息:** ```json {"type": "pong"} ``` 4. **发送模型请求消息:** ```json {"type": "model_request", "data": {"input_data": "example input"}} ``` 5. **接收模型响应消息:** ```json {"type": "model_response", "data": {"result": "模型处理成功", "data": {"input": {"input_data": "example input"}, "output": "这是一个模拟的模型输出。"}}} ``` **重要提示:** - **替换 `processModelRequest` 函数:** 你需要根据你的实际模型处理逻辑替换 `processModelRequest` 函数的内容。 - **错误处理:** 在实际应用中,你需要添加更完善的错误处理机制。 - **安全性:** 在生产环境中,你需要考虑安全性问题,例如身份验证和授权。 - **依赖管理:** Deno 使用 URL 作为依赖项,因此你需要确保你的依赖项 URL 是正确的。 This provides a basic template. Remember to replace the placeholder `processModelRequest` function with your actual model processing logic. Also, consider adding more robust error handling and security measures for production use.
mcp-servers
Boilerplate MCP Server
TypeScript 模型上下文协议 (MCP) 服务器样板,提供 IP 查询工具/资源。包含 CLI 支持和可扩展的结构,用于将 AI 系统 (LLM) 连接到外部数据源,例如 ip-api.com。是通过 Node.js 创建新的 MCP 集成的理想模板。
Databricks Permissions MCP Server
用于管理 Databricks 权限和凭据的 MCP 服务器
Bazel MCP Server
镜子 (jìng zi)
Untappd MCP Server using Azure Functions
Okay, here's an example of a minimal, complete, and practical (MCP) Azure Function written in F# that demonstrates a simple HTTP trigger. I'll break it down with explanations. ```fsharp namespace MyAzureFunction open Microsoft.AspNetCore.Mvc open Microsoft.Azure.WebJobs open Microsoft.Azure.WebJobs.Extensions.Http open Microsoft.AspNetCore.Http open Microsoft.Extensions.Logging module HelloFunction = [<FunctionName("Hello")>] let Run ( [<HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)>] req: HttpRequest, log: ILogger ) = log.LogInformation "C# HTTP trigger function processed a request." let name = match req.Query.["name"] with | ValueSome n -> n | ValueNone -> match System.IO.StreamReader(req.Body).ReadToEndAsync().Result with | body when not (String.IsNullOrEmpty body) -> body | _ -> "Azure Function" let responseMessage = sprintf "Hello, %s. This HTTP triggered function executed successfully." name ActionResult(OkObjectResult responseMessage) ``` **Explanation:** 1. **Namespace:** `namespace MyAzureFunction` This organizes your code. Choose a meaningful name. 2. **`open` Statements:** These bring in the necessary libraries. Crucially: * `Microsoft.AspNetCore.Mvc`: For `IActionResult` (the return type) and `OkObjectResult`. * `Microsoft.Azure.WebJobs`: The core Azure Functions library. * `Microsoft.Azure.WebJobs.Extensions.Http`: For HTTP trigger functionality. * `Microsoft.AspNetCore.Http`: For the `HttpRequest` object. * `Microsoft.Extensions.Logging`: For logging. 3. **Module:** `module HelloFunction` F# code is typically organized into modules. 4. **`[<FunctionName("Hello")>]`:** This *attribute* is **essential**. It tells Azure Functions the name of your function. This is the name you'll use in the Azure portal or when deploying. Change `"Hello"` to whatever you want to call your function. 5. **`let Run (...) = ...`:** This defines the function itself. `Run` is the standard name for the entry point. 6. **Function Parameters:** * `[<HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)>] req: HttpRequest`: This is the HTTP trigger. * `[<HttpTrigger(...)]`: This attribute configures the trigger. * `AuthorizationLevel.Anonymous`: Means anyone can call the function without authentication. Other options are `Function` (requires a function key) and `Admin` (requires an admin key). * `"get", "post"`: Specifies that the function will respond to both GET and POST requests. You can add other HTTP methods like `"put"`, `"delete"`, etc. * `Route = null`: This means the function is triggered directly by the function name. If you set `Route = "myroute/{id}"`, the function would be triggered by a URL like `/api/myroute/123`. `null` is the simplest option for a basic example. * `req: HttpRequest`: This is the HTTP request object. It contains information about the request, such as headers, query parameters, and the request body. * `log: ILogger`: This is the logger. Use it to write information to the Azure Functions logs. Very helpful for debugging. 7. **Function Body:** * `log.LogInformation "C# HTTP trigger function processed a request."`: Logs a message to the console. This will appear in the Azure Functions logs. * **Name Extraction:** This part tries to get the `name` parameter from either the query string or the request body. * `req.Query.["name"]`: Tries to get the `name` parameter from the query string (e.g., `?name=John`). `req.Query` is a dictionary-like structure. * `ValueSome n -> n`: If the `name` parameter is found in the query string, its value is assigned to `n`. * `ValueNone -> ...`: If the `name` parameter is *not* found in the query string, the code proceeds to read the request body. * `System.IO.StreamReader(req.Body).ReadToEndAsync().Result`: Reads the entire request body as a string. **Important:** Using `.Result` is generally discouraged in asynchronous code because it can lead to deadlocks. However, in the context of an Azure Function, it's often acceptable for simplicity, *especially* in F#. For more complex scenarios, you'd want to use `async` and `await` properly. * `body when not (String.IsNullOrEmpty body) -> body`: If the request body is not empty, its content is used as the `name`. * `_ -> "Azure Function"`: If neither the query string nor the request body contains a `name`, the default value "Azure Function" is used. * `let responseMessage = sprintf "Hello, %s. This HTTP triggered function executed successfully." name`: Creates the response message using `sprintf` (string formatting). * `ActionResult(OkObjectResult responseMessage)`: Creates an `OkObjectResult` (an HTTP 200 OK response) with the response message as the body. The `ActionResult` type is used to wrap the result. This is how you return a response from an Azure Function. **How to Use It:** 1. **Create an Azure Functions Project:** In Visual Studio or VS Code with the Azure Functions extension, create a new F# Azure Functions project. Choose the "HTTP trigger" template. 2. **Replace the Code:** Replace the contents of the generated `.fs` file with the code above. 3. **Run Locally:** Run the function locally. The Azure Functions runtime will start and tell you the URL to access your function. 4. **Test:** * **GET Request (with query parameter):** Open a browser and go to `http://localhost:7071/api/Hello?name=YourName` (replace `7071` with the port your function is running on). You should see "Hello, YourName. This HTTP triggered function executed successfully." * **GET Request (without query parameter):** Go to `http://localhost:7071/api/Hello`. You should see "Hello, Azure Function. This HTTP triggered function executed successfully." * **POST Request (with body):** Use a tool like `curl` or Postman to send a POST request to `http://localhost:7071/api/Hello` with a request body containing the name (e.g., `"MyName"`). The response should be "Hello, MyName. This HTTP triggered function executed successfully." 5. **Deploy to Azure:** Deploy your function to Azure using Visual Studio, VS Code, or the Azure CLI. **Key Improvements and Considerations:** * **Error Handling:** This example lacks proper error handling. In a real-world function, you should handle exceptions and return appropriate error responses (e.g., `BadRequestObjectResult`, `InternalServerErrorResult`). * **Asynchronous Operations:** For more complex operations (especially I/O), use `async` and `await` to avoid blocking the thread. This is crucial for scalability. The `.Result` call is a shortcut for this example, but should be avoided in production code where possible. * **Dependency Injection:** For larger functions, use dependency injection to manage dependencies (e.g., configuration, database connections). Azure Functions supports dependency injection. * **Configuration:** Use the Azure Functions configuration system to store settings (e.g., connection strings, API keys). * **Logging:** Use the `ILogger` interface extensively to log information, warnings, and errors. This is essential for debugging and monitoring. * **Idempotency:** If your function performs operations that should only be executed once (e.g., processing payments), ensure that it's idempotent. * **Testing:** Write unit tests to verify the logic of your function. **Chinese Translation of the Explanation:** **F# 中的一个最小、完整、实用的 (MCP) Azure 函数示例** 这是一个用 F# 编写的最小、完整、实用的 (MCP) Azure 函数示例,它演示了一个简单的 HTTP 触发器。 我将分解并解释它。 ```fsharp namespace MyAzureFunction open Microsoft.AspNetCore.Mvc open Microsoft.Azure.WebJobs open Microsoft.Azure.WebJobs.Extensions.Http open Microsoft.AspNetCore.Http open Microsoft.Extensions.Logging module HelloFunction = [<FunctionName("Hello")>] let Run ( [<HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)>] req: HttpRequest, log: ILogger ) = log.LogInformation "C# HTTP 触发器函数处理了一个请求。" let name = match req.Query.["name"] with | ValueSome n -> n | ValueNone -> match System.IO.StreamReader(req.Body).ReadToEndAsync().Result with | body when not (String.IsNullOrEmpty body) -> body | _ -> "Azure Function" let responseMessage = sprintf "你好,%s。 此 HTTP 触发函数已成功执行。" name ActionResult(OkObjectResult responseMessage) ``` **解释:** 1. **命名空间:** `namespace MyAzureFunction` 这组织你的代码。 选择一个有意义的名称。 2. **`open` 语句:** 这些引入了必要的库。 至关重要的是: * `Microsoft.AspNetCore.Mvc`:用于 `IActionResult`(返回类型)和 `OkObjectResult`。 * `Microsoft.Azure.WebJobs`:核心 Azure Functions 库。 * `Microsoft.Azure.WebJobs.Extensions.Http`:用于 HTTP 触发器功能。 * `Microsoft.AspNetCore.Http`:用于 `HttpRequest` 对象。 * `Microsoft.Extensions.Logging`:用于日志记录。 3. **模块:** `module HelloFunction` F# 代码通常组织成模块。 4. **`[<FunctionName("Hello")>]`:** 这个*属性*是**必不可少的**。 它告诉 Azure Functions 你的函数的名称。 这是你将在 Azure 门户中使用或部署时使用的名称。 将 `"Hello"` 更改为你想要调用的任何名称。 5. **`let Run (...) = ...`:** 这定义了函数本身。 `Run` 是入口点的标准名称。 6. **函数参数:** * `[<HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)>] req: HttpRequest`:这是 HTTP 触发器。 * `[<HttpTrigger(...)]`:此属性配置触发器。 * `AuthorizationLevel.Anonymous`:表示任何人都可以调用该函数而无需身份验证。 其他选项是 `Function`(需要函数密钥)和 `Admin`(需要管理员密钥)。 * `“get”, “post”`:指定该函数将响应 GET 和 POST 请求。 你可以添加其他 HTTP 方法,例如 `"put"`、`"delete"` 等。 * `Route = null`:这意味着该函数由函数名称直接触发。 如果你设置 `Route = "myroute/{id}"`,则该函数将由类似 `/api/myroute/123` 的 URL 触发。 `null` 是基本示例的最简单选项。 * `req: HttpRequest`:这是 HTTP 请求对象。 它包含有关请求的信息,例如标头、查询参数和请求正文。 * `log: ILogger`:这是记录器。 使用它将信息写入 Azure Functions 日志。 对调试非常有帮助。 7. **函数体:** * `log.LogInformation "C# HTTP 触发器函数处理了一个请求。"`:将消息记录到控制台。 这将出现在 Azure Functions 日志中。 * **名称提取:** 这部分尝试从查询字符串或请求正文中获取 `name` 参数。 * `req.Query.["name"]`:尝试从查询字符串中获取 `name` 参数(例如,`?name=John`)。 `req.Query` 是一个类似字典的结构。 * `ValueSome n -> n`:如果在查询字符串中找到 `name` 参数,则将其值分配给 `n`。 * `ValueNone -> ...`:如果在查询字符串中*未*找到 `name` 参数,则代码继续读取请求正文。 * `System.IO.StreamReader(req.Body).ReadToEndAsync().Result`:将整个请求正文读取为字符串。 **重要提示:** 通常不鼓励在异步代码中使用 `.Result`,因为它可能导致死锁。 但是,在 Azure Function 的上下文中,为了简单起见,通常是可以接受的,*尤其是在 F# 中*。 对于更复杂的场景,你将需要正确使用 `async` 和 `await`。 * `body when not (String.IsNullOrEmpty body) -> body`:如果请求正文不为空,则其内容将用作 `name`。 * `_ -> "Azure Function"`:如果查询字符串和请求正文都不包含 `name`,则使用默认值 "Azure Function"。 * `let responseMessage = sprintf "你好,%s。 此 HTTP 触发函数已成功执行。" name`:使用 `sprintf`(字符串格式化)创建响应消息。 * `ActionResult(OkObjectResult responseMessage)`:创建一个 `OkObjectResult`(HTTP 200 OK 响应),并将响应消息作为正文。 `ActionResult` 类型用于包装结果。 这是你从 Azure Function 返回响应的方式。 **如何使用它:** 1. **创建 Azure Functions 项目:** 在 Visual Studio 或带有 Azure Functions 扩展的 VS Code 中,创建一个新的 F# Azure Functions 项目。 选择“HTTP 触发器”模板。 2. **替换代码:** 将生成的 `.fs` 文件的内容替换为上面的代码。 3. **在本地运行:** 在本地运行该函数。 Azure Functions 运行时将启动并告诉你访问你的函数的 URL。 4. **测试:** * **GET 请求(带查询参数):** 打开浏览器并转到 `http://localhost:7071/api/Hello?name=YourName`(将 `7071` 替换为你的函数正在运行的端口)。 你应该看到“你好,YourName。 此 HTTP 触发函数已成功执行。” * **GET 请求(不带查询参数):** 转到 `http://localhost:7071/api/Hello`。 你应该看到“你好,Azure Function。 此 HTTP 触发函数已成功执行。” * **POST 请求(带正文):** 使用 `curl` 或 Postman 等工具向 `http://localhost:7071/api/Hello` 发送 POST 请求,请求正文包含名称(例如,`"MyName"`)。 响应应为“你好,MyName。 此 HTTP 触发函数已成功执行。” 5. **部署到 Azure:** 使用 Visual Studio、VS Code 或 Azure CLI 将你的函数部署到 Azure。 **关键改进和注意事项:** * **错误处理:** 此示例缺少适当的错误处理。 在实际函数中,你应该处理异常并返回适当的错误响应(例如,`BadRequestObjectResult`、`InternalServerErrorResult`)。 * **异步操作:** 对于更复杂的操作(尤其是 I/O),请使用 `async` 和 `await` 以避免阻塞线程。 这对于可伸缩性至关重要。 `.Result` 调用是此示例的快捷方式,但在可能的情况下应避免在生产代码中使用。 * **依赖注入:** 对于更大的函数,请使用依赖注入来管理依赖项(例如,配置、数据库连接)。 Azure Functions 支持依赖注入。 * **配置:** 使用 Azure Functions 配置系统来存储设置(例如,连接字符串、API 密钥)。 * **日志记录:** 广泛使用 `ILogger` 接口来记录信息、警告和错误。 这对于调试和监控至关重要。 * **幂等性:** 如果你的函数执行应仅执行一次的操作(例如,处理付款),请确保它是幂等的。 * **测试:** 编写单元测试以验证你的函数的逻辑。 This should give you a solid starting point for building Azure Functions in F#. Let me know if you have any more questions.
mcp-api-tester Tools & Interfaces
For testing LLM APIs, an "MCP server" isn't a standard term. It's likely you're looking for a way to **mock**, **simulate**, or **proxy** an LLM API endpoint. Here are a few ways to approach this, along with their Chinese translations: **1. Mock Server (模拟服务器 - mó nǐ fú wù qì):** * **Concept:** A mock server simulates the behavior of a real LLM API. You define the expected requests and the corresponding responses. This is ideal for testing your application's logic without actually calling the LLM. * **Tools:** * **Mockoon:** A popular and easy-to-use mock server application. * **WireMock:** A more powerful and flexible tool, often used in Java environments. * **JSON Server:** A simple way to create a REST API from a JSON file. * **How it works:** You configure the mock server to listen on a specific port and define routes that match the API endpoints you want to test. When your application makes a request to the mock server, it returns the pre-defined response. **2. Proxy Server (代理服务器 - dài lǐ fú wù qì):** * **Concept:** A proxy server sits between your application and the real LLM API. It can intercept requests and responses, allowing you to: * **Inspect traffic:** See exactly what data is being sent and received. * **Modify requests/responses:** Change the data being sent to the LLM or the data being returned to your application. * **Simulate errors:** Force the API to return error codes to test your application's error handling. * **Rate limiting:** Simulate rate limits to test your application's behavior under load. * **Tools:** * **Charles Proxy:** A popular commercial proxy tool. * **Fiddler:** A free proxy tool from Telerik. * **mitmproxy:** A free and open-source interactive HTTPS proxy. * **How it works:** You configure your application to use the proxy server as its HTTP/HTTPS proxy. The proxy server then intercepts all traffic and allows you to inspect and modify it. **3. Local LLM (本地LLM - běn dì LLM):** * **Concept:** Run a smaller, open-source LLM locally on your machine. This allows you to test your application against a real LLM without relying on an external API. * **Tools:** * **llama.cpp:** A library for running LLaMA models on CPUs. * **Ollama:** A tool for running and managing LLMs locally. * **GPT4All:** A project that provides a GUI and API for running LLMs locally. * **How it works:** You download and install the local LLM and then configure your application to connect to it. This gives you full control over the LLM and allows you to test your application in a completely isolated environment. **4. API Simulation Library (API 模拟库 - API mó nǐ kù):** * **Concept:** Libraries that allow you to create mock API responses directly within your code. * **Examples:** * **Python:** `unittest.mock` (built-in), `responses` * **JavaScript:** `nock`, `jest.fn()` * **How it works:** You use the library to replace the actual API call with a mock function that returns a pre-defined response. This is useful for unit testing individual components of your application. **Which approach is best for you depends on your specific needs:** * **Simple testing with static responses:** Mock server (Mockoon, JSON Server) * **Inspecting and modifying API traffic:** Proxy server (Charles, Fiddler, mitmproxy) * **Testing against a real LLM without external dependencies:** Local LLM (llama.cpp, Ollama, GPT4All) * **Unit testing individual components:** API simulation library (unittest.mock, responses, nock) **Example Scenario (使用 Mockoon 的例子 - shǐ yòng Mockoon de lì zi):** Let's say you want to test your application's interaction with an LLM API that generates text completions. The API endpoint is `https://api.example.com/completions` and it expects a JSON payload like this: ```json { "prompt": "The quick brown fox", "max_tokens": 50 } ``` You can use Mockoon to create a mock server that listens on port 3000 and defines a route for `/completions`. The mock server would return a JSON response like this: ```json { "completion": "The quick brown fox jumps over the lazy dog." } ``` Your application would then be configured to send requests to `http://localhost:3000/completions` instead of `https://api.example.com/completions`. This allows you to test your application's logic without actually calling the real LLM API. **In summary (总结 - zǒng jié):** Instead of a specific "MCP server," you're likely looking for a way to simulate or mock an LLM API. Consider using a mock server, proxy server, local LLM, or API simulation library, depending on your testing requirements. Each approach offers different levels of control and complexity. Choose the one that best suits your needs.
Claude Custom Prompts Server
Claude Custom Prompts MCP Server - 使用 Claude AI 创建和使用自定义提示模板
Cursor Azure DevOps MCP Server
Azure DevOps Cursor IDE MCP 服务器插件
Peeper MCP Server
Peeper 应用程序的模型控制面板服务器
Framelink Figma MCP Server
MCP Server Template (
这个模板可以帮助你基于推荐实践快速启动一个新的模型上下文协议(MCP)服务器项目。
OMNI-Sales
销售 MCP 服务器 (Xiāoshòu MCP fúwùqì)
MCP Helm Chart
Here are a few possible translations, depending on the context and what you want to emphasize: **General/Neutral:** * **MCP 服务器的 Helm Chart** (MCP fúwùqì de Helm Chart) - This is the most straightforward and common translation. It literally means "Helm Chart for MCP Server." **More Emphasizing the Purpose (Deployment):** * **用于部署 MCP 服务器的 Helm Chart** (Yòng yú bùshǔ MCP fúwùqì de Helm Chart) - This translates to "Helm Chart for deploying MCP Server." It highlights the chart's purpose. **More Emphasizing the Package/Template:** * **MCP 服务器的 Helm 图表** (MCP fúwùqì de Helm túbiǎo) - This translates to "Helm Chart of MCP Server." While "图表" (túbiǎo) literally means "chart," in this context, it can also refer to the Helm chart as a package or template. **Recommendation:** The best translation is likely the **general/neutral** one: * **MCP 服务器的 Helm Chart** (MCP fúwùqì de Helm Chart) This is clear, concise, and easily understood. Unless you have a specific reason to emphasize deployment or the package nature of the chart, stick with the simplest option.
MCP Server (mcp-tools)
MCP Server Setup Guide
GitHub API 集成的 MCP 服务器
MCP Server for MySQL based on NodeJS
镜子 (jìng zi)
MCP Server template for better AI Coding
这个模板为在 Python 中构建模型上下文协议 (MCP) 服务器提供了一个简化的基础。它的设计旨在使 AI 辅助的 MCP 工具的开发更容易、更高效。
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` 等工具来测试服务器。 请记住,这只是一个简单的示例,你需要根据你的实际需求进行修改和扩展。
Shopify MCP Server
镜子 (jìng zi)
MCP Server for FTP Access
镜子 (jìng zi)
GitHub MCP Server
GitHub 官方 MCP 服务器
Mcp Server Wrapper Bitbucket
这是一个 MCP 桥接器,用于现有的 TypeScript Bitbucket MCP 服务器,在 Python UV 基础上构建 API 层,本质上是让 UV 充当代理/桥梁。