P

Postman API Testing MCP Server

Connect Claude Code to your Postman workspace for API testing and exploration. Browse collections, run requests, inspect responses, and generate API client code directly from your Postman definitions.

MCPCommunityapiv1.0.0MIT
0 views0 copies

MCP Server Configuration

Add to .claude/settings.json:

{ "mcpServers": { "postman": { "command": "npx", "args": ["-y", "@postman/mcp-server"], "env": { "POSTMAN_API_KEY": "${POSTMAN_API_KEY}" } } } }

Available Tools

ToolDescription
list-collectionsList all Postman collections in your workspace
get-collectionGet full details of a collection (requests, folders, variables)
list-environmentsList available environments (dev, staging, prod)
get-environmentGet environment variables for a specific environment
send-requestExecute a request from a collection and return the response
list-apisList API definitions in your workspace
get-api-schemaGet the OpenAPI/Swagger schema for an API

Common Workflows

API Exploration

1. list-collections β†’ browse available API collections
2. get-collection β†’ see all endpoints with request/response examples
3. get-api-schema β†’ get the full OpenAPI spec for code generation

Testing & Debugging

1. list-environments β†’ switch to the right environment (dev/staging)
2. send-request β†’ execute an API call and inspect the response
3. Compare response with schema β†’ validate correctness
4. Generate integration tests from the collection

Code Generation from Collection

1. Get collection with all request examples
2. Generate TypeScript API client with proper types
3. Include error handling for each endpoint's error responses
4. Add request/response interceptors for auth

Collection Structure Example

{ "info": { "name": "User Service API", "description": "REST API for user management" }, "item": [ { "name": "Authentication", "item": [ { "name": "Login", "request": { "method": "POST", "url": "{{baseUrl}}/auth/login", "header": [{"key": "Content-Type", "value": "application/json"}], "body": { "mode": "raw", "raw": "{\"email\": \"[email protected]\", \"password\": \"secret\"}" } }, "response": [ { "name": "Success", "status": "OK", "code": 200, "body": "{\"token\": \"eyJ...\", \"expiresIn\": 3600}" }, { "name": "Invalid Credentials", "status": "Unauthorized", "code": 401, "body": "{\"error\": \"Invalid email or password\"}" } ] } ] }, { "name": "Users", "item": [ { "name": "Get User", "request": { "method": "GET", "url": "{{baseUrl}}/users/{{userId}}", "header": [{"key": "Authorization", "value": "Bearer {{token}}"}] } } ] } ] }

Generated TypeScript Client (Example)

// Auto-generated from Postman collection: User Service API interface LoginRequest { email: string; password: string; } interface LoginResponse { token: string; expiresIn: number; } class UserServiceClient { constructor(private baseUrl: string, private token?: string) {} async login(data: LoginRequest): Promise<LoginResponse> { const res = await fetch(`${this.baseUrl}/auth/login`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data), }); if (!res.ok) throw new ApiError(res.status, await res.json()); const result = await res.json(); this.token = result.token; return result; } async getUser(userId: string): Promise<User> { const res = await fetch(`${this.baseUrl}/users/${userId}`, { headers: { Authorization: `Bearer ${this.token}` }, }); if (!res.ok) throw new ApiError(res.status, await res.json()); return res.json(); } }

Setup

  1. Get a Postman API key at https://web.postman.co/settings/me/api-keys
  2. Set the environment variable:
    export POSTMAN_API_KEY="PMAK-your-key-here"
  3. Add the MCP configuration to .claude/settings.json

Security Notes

  • The Postman API key grants access to all collections and environments in your workspace
  • Environment variables in Postman may contain API keys, passwords, and tokens -- review before sharing
  • Use workspace-scoped tokens with minimal permissions when possible
  • The send-request tool executes actual HTTP requests -- be careful with destructive operations (DELETE, PUT)
  • Never store the Postman API key in version control
Community

Reviews

Write a review

No reviews yet. Be the first to review this template!

Similar Templates