Postman MCP 服务器是一个基于 Model Context Protocol (MCP) 的服务器,借助 Newman 运行 Postman 集合。它允许大语言模型 (LLMs) 执行 API 测试,并通过统一接口获取详细测试结果,为 API 测试工作提供了高效且便捷的解决方案。
要通过 Smithery 自动安装 Postman 运行器,可执行以下命令:
npx -y @smithery/cli install mcp-postman --client claude
# 克隆仓库
git clone
cd mcp-postman
# 安装依赖
pnpm install
# 构建项目
pnpm build
在你的 Claude 桌面配置文件 ~/Library/Application Support/Claude/claude_desktop_config.json 中添加此服务器:
{
"mcpServers": {
"postman-runner": {
"command": "node",
"args": ["/absolute/path/to/mcp-postman/build/index.js"]
}
}
}
运行 Postman 集合并返回测试结果。
参数:
collection(必填):Postman 集合的路径或 URLenvironment(可选):环境文件的路径或 URLglobals(可选):全局变量文件的路径或 URLiterationCount(可选):迭代次数示例响应:
{
"success": true,
"summary": {
"total": 5,
"failed": 0,
"passed": 5
},
"failures": [],
"timings": {
"started": "2024-03-14T10:00:00.000Z",
"completed": "2024-03-14T10:00:01.000Z",
"duration": 1000
}
}
你可以在 Claude 中通过让其运行一个 Postman 集合来实现: "运行位于 /path/to/collection.json 的 Postman 集合,并告诉我所有测试是否通过"
Claude 将会:
run-collection 工具。- src/
- CollectionRunner.ts # 处理 Postman 集合运行的主类
- NewmanAdapter.ts # Newman 的适配器接口
- types.ts # 定义 MCP 协议类型
npm test
# 或者具体测试文件
npm test src/CollectionRunner.spec.ts
pnpm build
git checkout -b feature/NewmanAdapter。git commit -m 'feat: 添加 Newman 支持'。git push origin feature/NewmanAdapter。MIT