Skip to content

manavghosh/api2mcp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

60 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

API2MCP

Universal API to MCP Server Converter with LangGraph Orchestration

CI PyPI version Python versions License: MIT Coverage

Convert any REST/GraphQL API into a fully functional MCP (Model Context Protocol) server, and orchestrate intelligent multi-API workflows using LangGraph.

API2MCP v0.1.0 is a complete framework, not a preview. Here's what's available today:

Core Pipeline

  • OpenAPI 3.0/3.1, Swagger 2.0, GraphQL SDL, and Postman Collection parsers
  • MCP Tool Generator with full JSON Schema type mapping
  • Streamable HTTP and stdio transports (MCP spec 2025-03-26 compliant)

Security & Infrastructure

  • Authentication: API key, Bearer, Basic, OAuth 2.0 (client credentials + PKCE)
  • Secret management: environment variables, OS keychain, HashiCorp Vault, AWS Secrets Manager, encrypted file store
  • Input validation: SQL injection and command injection protection
  • Rate limiting (token bucket, per-tool configurable), circuit breaker, connection pooling, response caching (memory and Redis)

LangGraph Orchestration

  • ReactiveGraph, PlannerGraph, ConversationalGraph
  • MCP Tool Adapter (MCP β†’ LangChain StructuredTool) with colon namespacing
  • Checkpointing: MemorySaver, SqliteSaver, PostgresSaver
  • End-to-end streaming via LangGraph astream_events v2
  • Multi-model support: Anthropic, OpenAI, Google Gemini

Developer Experience

  • Interactive setup wizard (api2mcp wizard)
  • Hot reload dev server (api2mcp dev)
  • In-process testing framework (MCPTestClient, CoverageReporter)
  • VS Code integration (launch configs, tasks, schema validation)
  • Plugin system with lifecycle hooks, template registry, CLI export and diff commands

Features

  • πŸ”„ Automatic Conversion: OpenAPI, GraphQL, Postman β†’ MCP Server
  • πŸ” Enterprise Security: OAuth 2.0, API keys, secret management
  • 🧠 Intelligent Orchestration: LangGraph-powered multi-API workflows
  • πŸ’Ύ State Persistence: Checkpoint-based workflow recovery
  • πŸ”Œ Extensible: Plugin architecture for custom integrations

Quick Start

# Install
pip install api2mcp

# Generate MCP server from OpenAPI spec
api2mcp generate --spec openapi.yaml --output ./server

# Run the server
api2mcp serve ./server

LangGraph 1.0 Orchestration

from api2mcp import MCPToolRegistry, PlannerGraph
from langchain_anthropic import ChatAnthropic
from langgraph.checkpoint.sqlite import SqliteSaver

# Register MCP servers
registry = MCPToolRegistry()
await registry.connect_server("github", github_config)
await registry.connect_server("jira", jira_config)

# Create orchestrator with official checkpointer
orchestrator = PlannerGraph(
    model=ChatAnthropic(model="claude-sonnet-4-5-20250929"),
    tool_registry=registry,
    api_names=["github", "jira"],
    checkpointer=SqliteSaver.from_conn_string("workflows.db"),
    execution_mode="mixed"  # parallel for independent steps
)

# Run complex workflow
result = await orchestrator.run(
    "Sync all GitHub bugs to Jira project SUPPORT"
)

Documentation

Development

Prerequisites

  • Python 3.11+
  • pip or any PEP 517-compatible build tool

Setup

# Clone and install in editable mode with dev dependencies
git clone https://github.com/manavghosh/api2mcp.git
cd api2mcp
pip install -e ".[dev]"

Optional extras

pip install -e ".[dev,graphql]"    # add GraphQL parser support
pip install -e ".[dev,postgres]"   # add PostgreSQL checkpointer
pip install -e ".[dev,docs]"       # add MkDocs documentation tooling

Running tests

pytest                        # run full test suite
pytest tests/unit/            # unit tests only
pytest -m "not e2e"           # skip end-to-end tests
pytest --no-cov               # skip coverage (faster)

Linting and type-checking

ruff check .                  # lint
ruff format .                 # format
mypy src/                     # type-check

Building the package

pip install build
python -m build               # produces dist/*.whl and dist/*.tar.gz

Building the documentation site

pip install -e ".[docs]"
mkdocs serve                  # live-reload preview at http://127.0.0.1:8000
mkdocs build --strict         # static build into site/

Project Structure

api2mcp/
β”œβ”€β”€ src/api2mcp/         # Source code
β”‚   β”œβ”€β”€ orchestration/   # LangGraph integration
β”‚   β”‚   β”œβ”€β”€ adapters/    # MCP-to-LangChain adapters
β”‚   β”‚   β”œβ”€β”€ graphs/      # Workflow patterns
β”‚   β”‚   └── state/       # State management
β”‚   └── ...
β”œβ”€β”€ tests/               # Test suite
β”œβ”€β”€ docs/                # Documentation source (MkDocs)
β”œβ”€β”€ examples/            # Usage examples
└── demo/                # Runnable demos

Acknowledgements

API2MCP was built with the assistance of Claude (Anthropic). The product vision, architecture decisions, specifications, and every design trade-off were directed by the project author. Claude served as the implementation tool β€” the same way a framework or a compiler is a tool.

Key open source projects that power API2MCP:

Project Role
LangGraph Orchestration graph engine
MCP SDK Model Context Protocol runtime
Pydantic Data validation
httpx Async HTTP client
Click CLI framework
Rich Terminal output
MkDocs Material Documentation site

Contributing

Contributions are welcome! Please read CONTRIBUTING.md and our Code of Conduct before submitting a pull request.

License

MIT License - see LICENSE for details.


Disclaimer

API2MCP is an independent personal project created and maintained solely by Manav Ghosh in a personal capacity. It is not affiliated with, sponsored by, endorsed by, or in any way associated with any current or former employer, client, or organisation. All design decisions, source code, documentation, and expressed opinions are those of the author alone and do not represent the views or intellectual property of any third party.

About

Universal API to MCP Server Converter with LangGraph Orchestration

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors