Mcp Postman

Mcp Postman

🚀 Postman MCP 服务器

Postman MCP 服务器是一个基于 Model Context Protocol (MCP) 的服务器,借助 Newman 运行 Postman 集合。它允许大语言模型 (LLMs) 执行 API 测试,并通过统一接口获取详细测试结果,为 API 测试工作提供了高效且便捷的解决方案。

smithery 徽章 Postman MCP 服务器演示

✨ 主要特性

  • 利用 Newman 运行 Postman 集合。
  • 支持环境文件,方便在不同环境下进行测试。
  • 支持全局变量,灵活配置测试参数。
  • 提供详细的测试结果,具体包括:
    • 整体成功/失败状态,快速了解测试总体情况。
    • 测试摘要(总数,通过数,失败数),清晰掌握测试结果分布。
    • 详细的失败信息,便于定位问题。
    • 执行时间,评估测试效率。

📦 安装指南

通过 Smithery 安装

要通过 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"]
}
}
}

可用工具

run-collection

运行 Postman 集合并返回测试结果。

参数:

  • collection(必填):Postman 集合的路径或 URL
  • environment(可选):环境文件的路径或 URL
  • globals(可选):全局变量文件的路径或 URL
  • iterationCount(可选):迭代次数

示例响应:

{
"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 将会:

  1. 使用 MCP 协议调用 run-collection 工具。
  2. 收到详细的测试结果。
  3. 生成自然语言的测试报告。

🔧 技术细节

项目结构

- src/
- CollectionRunner.ts # 处理 Postman 集合运行的主类
- NewmanAdapter.ts     # Newman 的适配器接口
- types.ts            # 定义 MCP 协议类型

运行测试

npm test

# 或者具体测试文件
npm test src/CollectionRunner.spec.ts

构建项目

pnpm build

🤝 贡献指南

  1. Fork 本仓库。
  2. 新建功能分支 git checkout -b feature/NewmanAdapter
  3. 提交你的修改 git commit -m 'feat: 添加 Newman 支持'
  4. 推送到远端 git push origin feature/NewmanAdapter
  5. 创建 Pull Request。

📄 许可证

MIT

  • 0 关注
  • 0 收藏,26 浏览
  • system 提出于 2025-10-06 18:00

相似服务问题

相关AI产品