MCP-Postman API测试工具
启用通过Newman运行Postman集合,以进行API测试并通过对标准化接口获取详细的结果分析。
可用工具 (1 个)
该服务在 MCP 协议中暴露的工具,AI 可按需调用
run-collection 4 个参数 需填 1 项
Run a Postman Collection using Newman
必填参数:collection
服务介绍
Postman MCP 服务器
这是一个 MCP(Model Context Protocol)服务器,它通过 Newman 运行 Postman 集合。此服务器允许 LLMs 通过标准化接口执行 API 测试并获取详细结果。
功能
- 使用 Newman 运行 Postman 集合
- 支持环境文件
- 支持全局变量
- 详细的测试结果包括:
- 总体成功/失败状态
- 测试摘要(总数、通过数、失败数)
- 详细的失败信息
- 执行时间
安装
通过 Smithery 安装
要通过 Smithery 自动安装 Claude 桌面版的 Postman Runner:
npx -y @smithery/cli install mcp-postman --client claude
手动安装
# Clone the repository
git clone <repository-url>
cd mcp-postman
# Install dependencies
pnpm install
# Build the project
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"]
}
}
}
可用工具
run-collection
运行一个 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 中使用示例
你可以通过让 Claude 运行一个 Postman 集合来使用该服务器:
"运行位于 /path/to/collection.json 的 Postman 集合并告诉我所有测试是否通过"
Claude 将会:
- 使用 run-collection 工具
- 分析测试结果
- 提供易于理解的执行摘要
开发
项目结构
src/
├── index.ts # Entry point
├── server/
│ ├── server.ts # MCP Server implementation
│ └── types.ts # Type definitions
└── newman/
└── runner.ts # Newman runner implementation
test/
├── server.test.ts # Server tests
├── newman-runner.test.ts # Runner tests
└── fixtures/ # Test fixtures
└── sample-collection.json
运行测试
# Run tests
pnpm test
# Run tests with coverage
pnpm test:coverage
构建
# Build the project
pnpm build
# Clean build artifacts
pnpm clean
贡献
- 分叉仓库
- 创建你的功能分支 (
git checkout -b feature/amazing-feature) - 提交你的更改 (
git commit -m 'Add some amazing feature') - 推送到分支 (
git push origin feature/amazing-feature) - 打开一个 Pull Request
许可证
ISC
