mcpField
R
REST-to-Postman MCP

REST-to-Postman MCP

本地服务
github.com/runninghare开发工具081 周前更新

关于 REST-to-Postman MCP

REST-to-Postman MCP 是面向 API 开发者的 MCP 服务,可将 REST API 端点和环境变量同步为 Postman 集合与环境。它支持多种认证方式、与现有集合合并端点,并可通过 stdio 或 SSE 传输。

主要功能

  1. 01将 REST 端点转换为 Postman 集合
  2. 02创建或更新 Postman 环境
  3. 03支持多种认证方式
  4. 04合并新端点与现有集合
  5. 05处理敏感环境变量
  6. 06支持 stdio 和 SSE 传输

适用场景

  1. 01根据应用 REST API 生成 Postman 集合
  2. 02将应用环境变量同步到 Postman
  3. 03更新已有集合并保留现有端点

MCP 相关

该 MCP 服务向客户端提供创建或更新 Postman 环境及集合的工具,需要 Postman API 密钥和工作区 ID。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"rest-to-postman": {
"command": "npx",
"args": [
"-y",
"@smithery/cli"
]
}
}
}
启动命令npx -y @smithery/cli

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npm@smithery/cli

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

REST-to-Postman MCP

smithery badge

一个 Model Context Protocol(MCP)服务,可将 REST API 代码(例如 NestJS 控制器、FastAPI/Flask 端点)转换为 Postman 集合和环境。此工具可帮助开发者自动将 REST API 端点和环境配置同步到 Postman。

功能

  • 将 REST API 端点转换为 Postman 集合
  • 将环境变量同步到 Postman 环境
  • 支持多种身份验证方式(例如 Bearer 令牌)
  • 智能地将新端点合并到现有集合中
  • 自动处理敏感环境变量
  • 支持 stdio 和 SSE 两种传输模式

前提条件

  • Bun v1.2.2 或更高版本
  • Postman API 密钥
  • Postman 工作区 ID

安装与使用

这是一个 Model Context Protocol(MCP)stdio 服务,需要访问你的 Postman 工作区才能创建或更新集合和环境。

通过 Smithery 安装

通过 Smithery 自动为 Claude Desktop 安装 REST-to-Postman MCP:

npx -y @smithery/cli install @runninghare/rest-to-postman-mcp --client claude
使用 npx 运行 MCP 服务

使用 npx 运行 MCP 服务:

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 代码编辑器中:

  • Claude Desktop
  • Cursor
  • Windsurf
  • Roo Cline Editor

重要提示:此服务需要 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 转 Postman 集合(rest_to_postman_collection)

使用 REST API 端点创建或更新 Postman 集合。

输入参数:

  • collectionRequest(object):Postman 集合配置,包含:
    • 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"
    }]
}
在 Cursor 中使用此 MCP

你可以在 Cursor 中使用此 MCP 服务。以下示例展示了如何根据 Nest.js Typescript 控制器生成 Postman 集合。

提示词:

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
2025-04-13_18-10-50

以下是自动生成的 Postman 集合:

2025-04-13_18-17-34

请注意,Campaign 控制器中的所有端点均已生成,同时也配置了 Bearer 令牌。

开发

本地设置
  1. 克隆仓库:
git clone https://github.com/runninghare/rest-to-postman.git
cd rest-to-postman
  1. 安装依赖:
bun install
  1. 创建 .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 模式启动服务

贡献

欢迎贡献!欢迎提交 Pull Request。

许可证

本项目采用 MIT 许可证,详情请参阅 LICENSE 文件。

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。