Code2Postman MCP
Generates Postman collections from source code, including endpoints, folders, variables, authentication, and scripts.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Code2Postman MCP Generate a Postman collection from my Flask app in /projects/api"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Code2Postman MCP
Code2Postman MCP - A Model Context Protocol (MCP) server implementation that automatically converts code directories into Postman collections.
Overview
Code2Postman MCP is an open-source tool that leverages the Model Context Protocol to help developers quickly generate Postman collections from their codebase. This tool analyzes your code files, identifies API endpoints, and creates structured Postman collections that you can use for testing, documentation, and sharing. It is an MCP that generate postman's collection from code and local repositories.
Related MCP server: Postman MCP Generator
Features
Code Analysis: Automatically scan your codebase to identify API endpoints and their parameters
Collection Generation: Create complete Postman collections with proper structure
Folder Organization: Organize endpoints logically in folders based on code structure
Variables Support: Add and manage collection variables for greater flexibility
Authentication Configuration: Set up authentication methods automatically based on code patterns
Event Scripts: Generate pre-request and test scripts when applicable
Supported Tools
create_postman_collection- Create a new Postman collectionadd_postman_collection_item- Add a request item to a collectionread_postman_collection- Read an existing Postman collectionadd_postman_collection_info- Add metadata to a collectionadd_postman_collection_event- Add pre-request or test scriptsadd_postman_collection_variable- Add variables to a collectionadd_postman_collection_auth- Configure authentication for a collectionadd_postman_collection_protocol_behavior- Configure protocol behaviorsdelete_postman_collection_item- Remove items from a collectionupdate_postman_collection_variable- Update existing variablesadd_postman_collection_folder- Create folders for organizing requestsadd_item_to_folder- Add items to specific foldersget_tree_directory_from_path- Get a file tree structure from a directoryread_file- Read the contents of a specific file
Installation
pip install code2postman-mcpUsage with Claude Desktop
Add Code2Postman MCP to your
claude_desktop_config.jsonfile:
"code2postman-mcp": {
"command": "uvx",
"args": ["code2postman-mcp"]
}Launch Claude Desktop and start using the MCP tools to analyze your code and generate Postman collections.
Command Line Usage
You can also use Code2Postman MCP directly from the command line:
uvx code2postman-mcpExamples
Creating a Postman Collection from Source Code
First, analyze your codebase to identify API endpoints.
Create a new Postman collection.
Add identified endpoints as items to the collection.
Configure authentication if needed.
Add collection variables for flexibility.
Export the collection as a JSON file that can be imported into Postman.
Adding to an Existing Collection
You can also extend existing Postman collections by:
Reading an existing collection.
Adding new items or folders.
Updating variables or authentication methods.
Saving the updated collection.
Development
To contribute to Code2Postman MCP:
Clone the repository:
git clone https://github.com/yourusername/code2postman-mcp.gitInstall development dependencies:
cd code2postman-mcp uv pip install -e .Run tests:
uv run pytest tests/
License
This project is licensed under the MIT License - see the LICENSE file for details.
Available Tools
14 toolsadd_item_to_folderC
Add an item to a specific folder in the Postman collection
Args:
file_path: The path to the Postman collection file (string)
folder_name: The name of the folder to add the item to (string)
item: The item dictionary to add (dict)
Returns:
The updated Postman collection data (dict)
Inputs: file_path (required), folder_name (required), item (required).
add_postman_collection_authB
Add or update authentication information for the Postman collection
Args:
file_path: The path to the Postman collection file (string)
auth: The auth dictionary with type and necessary auth parameters (dict)
Example: {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{token_variable}}",
"type": "string"
}
]
}
Returns:
The updated Postman collection data (dict)
Inputs: file_path (required), auth (required).
add_postman_collection_eventB
Add an event to the Postman collection
Args:
file_path: The path to the Postman collection file (string)
event: The event dictionary with keys like listen, script, etc. (dict)
Example: {
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": ["console.log('This runs before each request');"]
}
}
Returns:
The updated Postman collection data (dict)
Inputs: file_path (required), event (required).
add_postman_collection_folderB
Add a folder to the Postman collection
Args:
file_path: The path to the Postman collection file (string)
folder_name: The name of the folder (string)
items: Optional list of item dictionaries to add to the folder (list of dicts)
Returns:
The updated Postman collection data (dict)
Inputs: file_path (required), folder_name (required), items.
add_postman_collection_infoA
Update or add the info section of a Postman collection
Args:
file_path: The path to the Postman collection file (string)
info: The info dictionary to update/add (dict)
Example: {
"name": "Updated Collection",
"description": "Updated description",
"version": "1.0.0",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
}
Returns:
The updated Postman collection data (dict)
Inputs: file_path (required), info (required).
add_postman_collection_itemB
Add an item to the Postman collection
Args:
file_path: The path to the Postman collection file (string)
item: The item dictionary to add (dict containing at least 'name' and 'request' keys)
Example: {
"name": "Get User",
"request": {
"method": "GET",
"url": "https://api.example.com/users/1"
}
}
Returns:
The updated Postman collection data (dict)
Inputs: file_path (required), item (required).
add_postman_collection_protocol_behaviorA
Add or update protocol profile behavior settings for the Postman collection
Args:
file_path: The path to the Postman collection file (string)
behavior: The protocolProfileBehavior dictionary (dict)
Example: {
"disableBodyPruning": true,
"followRedirects": false
}
Returns:
The updated Postman collection data (dict)
Inputs: file_path (required), behavior (required).
add_postman_collection_variableB
Add a variable to the Postman collection
Args:
file_path: The path to the Postman collection file (string)
variable: The variable dictionary with keys like key, value, type, etc. (dict)
Example: {
"key": "base_url",
"value": "https://api.example.com",
"type": "string"
}
Returns:
The updated Postman collection data (dict)
Inputs: file_path (required), variable (required).
create_postman_collectionB
Create a Postman collection from a directory structure. Extension of the file must be .json
Args:
file_path: The path to the file to create the Postman collection from (string)
name: The name of the project (string)
description: The description of the project (string)
Returns:
The initial Postman collection in JSON format (string)
Inputs: file_path (required), name (required), description (required).
delete_postman_collection_itemA
Delete an item from the Postman collection by name
Args:
file_path: The path to the Postman collection file (string)
item_name: The name of the item to delete (string)
Returns:
The updated Postman collection data (dict)
Inputs: file_path (required), item_name (required).
get_tree_directory_from_pathA
Generate a tree directory structure as a string, excluding files and directories
based on the specified programming language using regex patterns.
Args:
path: The root path to start generating the tree from
language: The programming language to filter files. Possible values: ["python", "javascript", "java", "go", "ruby", "rust", "csharp", "generic"]
Returns:
A formatted string representing the directory tree with line counts for each file
Inputs: path (required), language (required).
read_fileA
Read content from a file with line numbers, validating the file path first.
Args:
file_path: Path to the file to read
start_line: Line number to start reading from (0-indexed, default: 0)
end_line: Line number to end reading at (0-indexed, inclusive, default: None for all lines)
Returns:
A string with numbered lines from the file
Raises:
FileNotFoundError: If the file does not exist
ValueError: If the line parameters are invalid
Inputs: file_path (required), start_line, end_line.
read_postman_collectionC
Read the Postman collection
Args:
file_path: The path to the Postman collection file (string)
Returns:
The Postman collection data (dict)
Inputs: file_path (required).
update_postman_collection_variableA
Update a specific variable in the Postman collection by key
Args:
file_path: The path to the Postman collection file (string)
key: The key of the variable to update (string)
new_value: The new value for the variable (string)
Returns:
The updated Postman collection data (dict)
Inputs: file_path (required), key (required), new_value (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 14 tools
Most tools have distinct purposes, e.g., adding items to root vs folder, managing variables vs events. The generic file tools (read_file, get_tree_directory) are clearly separate from Postman-specific tools, so agents can distinguish between them.
Naming is inconsistent: some tools use 'postman_collection' (e.g., add_postman_collection_item) while others omit it (e.g., add_item_to_folder). Verbs vary (add, create, read, delete, update, get) without a consistent pattern, mixing snake_case and multi-word names.
14 tools cover the core workflows of creating and managing Postman collections from code. The count is well within the 3-15 range and each tool serves a specific purpose without redundancy.
The set covers creation, reading, and deletion of items, variables, and folders, but lacks update operations for items and variables, and does not support deleting folders or variables. Some lifecycle steps are missing.
Maintenance
Related MCP Connectors
Generate wiki docs from source code. Supports PowerShell, Python, Go, C#, Java, COBOL.
AI-callable tools for API mocking, testing, monitoring, security, and automation.
End-to-end API testing — generate and run tests from OpenAPI, curl, Postman, or real user traffic.
Give your AI agents trusted access to the full Postman platform.
Related MCP Servers
- AlicenseAqualityDmaintenanceConverts REST API code (like NestJS controllers or FastAPI endpoints) to Postman collections and environments, helping developers automatically sync their API endpoints with Postman.210 npmMIT
- AlicenseNot gradedqualityDmaintenanceAutomatically converts Postman API collections into MCP-compatible tools for AI assistants. Enables users to interact with any API through natural language by generating JavaScript tools from Postman requests.MIT
- AlicenseNot gradedqualityCmaintenanceAnalyzes API codebases from GitHub and Bitbucket repositories to generate Postman collections, business reports, and detailed code insights. Supports multiple frameworks including FastAPI, Spring Boot, Flask, Express, and OpenAPI/Swagger specifications.MIT
- FlicenseBqualityDmaintenanceGenerates API documentation in Confluence from Swagger/OpenAPI specs or NestJS controller files, including automatic Postman collection generation.9-