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.
TinyMurky
README
mcp-api-tester 工具 & 接口
本文档总结了潜在的工具或接口,这些工具或接口使 LLM(大型语言模型)能够执行自动化 API 测试。 通过利用这些工具,LLM 可以读取 API 文档,使用 net/http
选择和测试特定的端点,并帮助开发人员快速识别潜在问题。
核心工具(最小可行工具)
以下三个工具是最基本和必不可少的接口,允许 LLM 进行最小可行的自动化测试:
-
listAllAPIFromDocument
- 目的:从文档中列出所有可用的 API(名称、URL、HTTP 方法等)。
- 示例:一个示例返回值可能如下所示:
[ { "name": "getUser", "method": "GET", "url": "/users/{id}" }, { "name": "createUser", "method": "POST", "url": "/users" } ... ]
- LLM 何时使用它:浏览可用的 API 并选择要测试的 API。
-
getSingleAPIDetail
- 目的:按名称或路径检索特定 API 的详细文档,例如:
- 请求参数(查询、路径、正文等)
- 响应结构(模式)
- 可能的状态代码和错误定义
- 示例:一个示例返回值可能如下所示:
{ "name": "getUser", "method": "GET", "url": "/users/{id}", "parameters": [ { "in": "path", "name": "id", "type": "string", "required": true } ], "responses": { "200": { "description": "成功时返回用户数据", "schema": { ... } }, "404": { "description": "未找到用户" } } }
- LLM 何时使用它:为特定端点生成测试参数和预期响应。
- 目的:按名称或路径检索特定 API 的详细文档,例如:
-
callNetHTTP
- 目的:允许 LLM 发送真实的 HTTP 请求并接收结果(状态代码、标头、正文)。
- 示例:
{ "request": { "method": "POST", "url": "/users", "headers": { "Content-Type": "application/json" }, "body": { "name": "NewUser", "age": 30 } }, "response": { "status": 201, "headers": { ... }, "body": { "id": "123", "name": "NewUser", "age": 30 } } }
- LLM 何时使用它:执行测试调用并将实际结果与预期结果进行比较。
高级建议工具(增强工具)
这些工具不是强制性的,但它们可以显着改善自动化测试、报告、环境设置等。
1. 响应验证/解析工具
-
模式验证
validateResponseWithSchema(responseBody, schemaInfo) -> (isValid, errorList)
- 将返回的 JSON 正文与记录的模式进行比较,以检查字段一致性、数据类型和任何必需字段。
-
JSON 解析
parseJSON(responseBody) -> (parsedObject)
- 使 LLM 能够方便地读取和检查响应中的特定字段(例如,确认某些字段不为空)。
2. 用于测试执行的上下文/日志记录工具
-
测试结果日志记录/存储
storeTestResult(testCase, response, passOrFail, errorMessage)
- 让 LLM 记录每个测试用例的执行详细信息、错误和结果,从而更容易编译报告。
-
历史测试结果
getTestHistory(apiName or endpoint) -> (historyData)
- 允许 LLM(或其他系统)查询同一端点的过去测试结果,并了解一段时间内的回归或更改。
3. 环境设置/管理工具
-
身份验证/凭据设置
getAuthToken(username, password) -> token
- 某些 API 需要令牌或 cookie 进行身份验证。 LLM 可能需要首先调用此工具以获取正确的凭据。
-
重置/初始化测试数据
resetTestData()
或seedTestData()
- 确保数据库或系统状态在测试开始之前处于已知的默认状态。
4. Fuzz/边缘情况测试工具
- generateFuzzyInput(fieldType, constraints)
- 返回极端或不寻常的输入(例如,负值、极大的值、随机字符、特殊符号),用于压力测试和安全检查。
推荐的开发流程
-
集成最小可行工具
- 在您的系统中实现
listAllAPIFromDocument
、getSingleAPIDetail
和callNetHTTP
,以便 LLM 可以:- 获取可用端点的列表
- 获取给定 API 的详细规范
- 发出真实的 HTTP 请求
- 在您的系统中实现
-
连接 LLM
- 使 LLM 能够使用上述三个工具。 它可以列出潜在的端点,检索每个端点的详细信息,生成测试场景,并最终通过
callNetHTTP
运行它们。
- 使 LLM 能够使用上述三个工具。 它可以列出潜在的端点,检索每个端点的详细信息,生成测试场景,并最终通过
-
添加验证工具(响应/模式)
- 提供实用程序,让 LLM 验证返回的数据是否与记录的模式和预期相符。
-
扩展测试日志记录和环境管理
- 提供用于存储测试结果、查询历史测试、重置环境和检索身份验证令牌的接口。
- LLM 可以调用这些工具来维护一致的状态和测试过程的文档。
-
Fuzz/边缘情况测试
- 集成一个工具来生成恶意或极端值,或者让 LLM 自动生成它们以进行深入的压力或安全测试。
重要提示
-
安全和权限
- 当 LLM 发出 API 调用时,请确保这些测试在安全的环境(开发或沙箱)中运行,并且不会泄露敏感数据。
-
LLM 生成内容的准确性
- LLM 可能会生成无效或不正确的参数。 您的接口中可能需要额外的验证或错误处理。
-
无法完全取代传统测试
- 虽然 LLM 可以快速生成边界和异常测试用例,但传统的单元测试对于彻底的覆盖仍然至关重要。
测试
ReadOpenAPIDocument
curl -X POST --data '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "ReadOpenAPIDocument",
"arguments": {
"openAPIPath": "/absolute/path/to/your/openAPI/file"
}
}
}' http://localhost:8000/message?sessionId=9fa4fc8c-1799-4955-a0bb-4881258f13f9
ListAllAPIFromDocument
curl -X POST --data '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "ListAllAPIFromDocument"
}
}' http://localhost:8000/message?sessionId=9fa4fc8c-1799-4955-a0bb-4881258f13f9
推荐服务器
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
MCP Package Docs Server
促进大型语言模型高效访问和获取 Go、Python 和 NPM 包的结构化文档,通过多语言支持和性能优化来增强软件开发。
Claude Code MCP
一个实现了 Claude Code 作为模型上下文协议(Model Context Protocol, MCP)服务器的方案,它可以通过标准化的 MCP 接口来使用 Claude 的软件工程能力(代码生成、编辑、审查和文件操作)。
@kazuph/mcp-taskmanager
用于任务管理的模型上下文协议服务器。它允许 Claude Desktop(或任何 MCP 客户端)在基于队列的系统中管理和执行任务。
mermaid-mcp-server
一个模型上下文协议 (MCP) 服务器,用于将 Mermaid 图表转换为 PNG 图像。
Jira-Context-MCP
MCP 服务器向 AI 编码助手(如 Cursor)提供 Jira 工单信息。

Linear MCP Server
一个模型上下文协议(Model Context Protocol)服务器,它与 Linear 的问题跟踪系统集成,允许大型语言模型(LLM)通过自然语言交互来创建、更新、搜索和评论 Linear 问题。

Sequential Thinking MCP Server
这个服务器通过将复杂问题分解为顺序步骤来促进结构化的问题解决,支持修订,并通过完整的 MCP 集成来实现多条解决方案路径。
Curri MCP Server
通过管理文本笔记、提供笔记创建工具以及使用结构化提示生成摘要,从而实现与 Curri API 的交互。