REST到邮递员MCP
](https://smithery.ai/server/@runninghare/rest-to-postman-mcp)
模型上下文协议(MCP)服务器,用于将REST API代码(例如,NestJS控制器、FastAPI/Flask端点)转换为Postman集合和环境。该工具帮助开发人员自动将他们的REST API端点和环境配置与Postman同步。
特性
- 将REST API端点转换为Postman集合
- 将环境变量与Postman环境同步
- 支持各种身份验证方法(例如,承载令牌)
- 新端点与现有集合的智能合并
- 敏感环境变量的自动处理
- 支持stdio和SSE传输模式
先决条件
- 包子 v1.2.2或更高版本
- 邮差API密钥
- 邮递员工作区ID
安装与使用
这是一个模型上下文协议(MCP)stdio服务器,需要访问Postman工作区来创建/更新集合和环境。
通过Smithery安装
通过以下方式自动将REST安装到克劳德桌面版的Postman MCP 史密瑟里:
npx -y @smithery/cli install @runninghare/rest-to-postman-mcp --client claude使用以下命令运行MCP服务器 npx
使用MCP服务器 npx:
npx -y rest-to-postman@latest --postman-api-key your_api_key --postman-workspace-id your_workspace_id或者使用环境变量:
export POSTMAN_API_KEY=your_api_key
export POSTMAN_ACTIVE_WORKSPACE_ID=your_workspace_id
npx -y rest-to-postman@latest 您可以将此命令与支持MCP的各种AI代码编辑器集成:
- 克劳德桌面
- 光标
- 帆板运动
- Roo Cline编辑
重要提示:服务器需要Postman API凭据才能运行。在启动服务器之前,请确保已准备好API密钥和工作区ID。
工具说明
服务器提供两个主要工具:
1.REST到Postman环境(rest_to_postman_env)
使用应用程序的环境变量创建或更新Postman环境。
输入参数:
envName(string):Postman环境的名称envVars(object):环境变量的键值对
输入示例:
{
"envName": "REST Environment",
"envVars": {
"API_URL": "https://api.example.com",
"API_TOKEN": "secret-token-1"
}
}2.休息至邮差收藏(rest_to_postman_collection)
使用REST API终结点创建或更新Postman集合。
输入参数:
collectionRequest(对象):邮差集合配置,包含:
- info:集合元数据 - auth:身份验证设置 - item:API终结点数组
输入示例:
{
"info": {
"name": "REST Collection",
"description": "REST Collection",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"auth": {
"type": "bearer",
"bearer": [
{
"key": "Authorization",
"value": "Bearer {{API_TOKEN}}",
"type": "string"
}
]
},
"item": [
{
"name": "Get Users",
"request": {
"method": "GET",
"url": {
"raw": "{{API_URL}}/users",
"protocol": "https",
"host": ["api", "example", "com"],
"path": ["users"]
}
}
}
]
}响应格式
这两个工具都会返回一条成功消息,确认Postman资源的创建/更新:
{
"content": [{
"type": "text",
"text": "Successfully created/updated Postman environment: REST Environment"
}]
}在游标中使用此MCP
您可以在Cursor中使用此MCP服务器。下面是一个基于Nest.js Typescript控制器生成Postman Collection的示例。
__提示__:
Create a postman collection named "Campaign Endpoints" based on this next.js controller. The baseUrl is `http://localhost:7022`. The collection should have a Bear token which applies to all the endpoints以下是自动生成的邮差收藏:
注意来自的所有端点 Campaign 控制器与熊令牌设置一起生成。
发展
本地设置
- 克隆存储库:
git clone https://github.com/runninghare/rest-to-postman.git
cd rest-to-postman- 安装依赖项:
bun install- 创建一个
.env文件:
POSTMAN_API_KEY=your_api_key_here
POSTMAN_ACTIVE_WORKSPACE_ID=your_workspace_id_here以开发模式运行
对于开发,您可以直接使用Bun运行服务器:
# Start in stdio mode (default)
bun run src/mcp.ts
# Start in SSE mode
bun run src/mcp.ts --sse建筑
要构建项目,请执行以下操作:
bun run build这将在 dist 目录。
脚本
bun run build-构建项目bun run dev-在开发模式下运行服务器bun run startSSE-以SSE模式启动服务器
贡献
欢迎投稿!请随时提交拉取请求。
许可证
此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件。
