Skip to content

Quickstart

Installation

Install mcpadapt for your agentic framework of choice with:

pip install mcpadapt[agentic-framework]

where agentic-framework can be:

  • smolagents
  • crewai
  • langchain
  • google-genai
  • llamaindex

Usage

Standard IO (stdio)

In the most simple case, MCP adapt takes the following form:

from mcp import StdioServerParameters
from mcpadapt.core import MCPAdapt
from mcpadapt.<agentic-framework>_adapter import <AgenticFramework>Adapter

with MCPAdapt(
    StdioServerParameters(command="uv", args=["run", "src/echo.py"]),
    <AgenticFramework>Adapter(),
) as tools:
    # tools is a list of tools 100% compatible with your agentic framework.
    ...

In this setup:

  1. You define your MCP server parameters using the official Python SDK
  2. You import the MCPAdapt core and the appropriate adapter for your agentic framework
  3. You wrap your agent's code within the MCPAdapt context manager

Behind the scenes, MCPAdapt launches your MCP server in a subprocess and handles all communication between your agentic framework and the MCP server. When your agent uses a tool, MCPAdapt transparently routes the call to the corresponding MCP server tool and returns the results in your framework's expected format.

If your agentic framework support async then you can also use MCPAdapt with async:

from mcp import StdioServerParameters
from mcpadapt.core import MCPAdapt
from mcpadapt.<agentic-framework>_adapter import <AgenticFramework>Adapter

async with MCPAdapt(
    StdioServerParameters(command="uv", args=["run", "src/echo.py"]),
    <AgenticFramework>Adapter(),
) as tools:
    # tools is a list of tools 100% compatible with your agentic framework.
    ...

SSE (Server-Sent Events) Support

MCPAdapt supports SSE for both synchronous and asynchronous operations. Here's how to use it:

from mcpadapt.core import MCPAdapt
from mcpadapt.<framework>_adapter import <Framework>Adapter

async with MCPAdapt(
    {
        "url": "http://127.0.0.1:8000/sse",
        # Optional parameters:
        # "headers": {"Authorization": "Bearer token"},
        # "timeout": 5,  # Connection timeout in seconds
        # "sse_read_timeout": 300  # SSE read timeout in seconds (default: 5 minutes)
    },
    <Framework>Adapter()
) as tools:
    # 'tools' contains framework-compatible tools
    ...

To use SSE, simply provide a configuration dictionary instead of StdioServerParameters. The configuration accepts the following parameters:

Parameter Type Required Default Description
url str Yes - The SSE endpoint URL
headers dict[str, Any] No None Custom HTTP headers
timeout float No 5 Connection timeout in seconds
sse_read_timeout float No 300 SSE read timeout in seconds

These parameters are passed directly to the MCP Python SDK's SSE client. For more details, see the official MCP Python SDK documentation.

Examples

We provide guided examples of usage for each framework in their respective guides: