Skip to main content
The Model Context Protocol (MCP) enables agents to interact with external systems through a standardized interface. Connect your agents to any MCP server using Laddr’s MCP integration.

Quick Start

Connect an agent to an MCP server:

Basic Usage

Single MCP Server

The simplest way to use MCP is with a single server:

Multiple MCP Servers

Use MultiMCPToolProvider to connect to multiple servers:

Transport Methods

Laddr supports three MCP transport methods:

1. Stdio Transport

For local command-based MCP servers:
Use when:
  • Running local MCP servers
  • Server is launched via command line
  • Examples: filesystem, git, database servers

2. HTTP Transport (Streamable HTTP)

For remote HTTP-based MCP servers:
Use when:
  • Connecting to remote MCP servers
  • Server exposes HTTP endpoint
  • Examples: hosted MCP services, cloud-based tools

3. SSE Transport (Server-Sent Events)

For real-time streaming MCP servers:
Use when:
  • Server uses Server-Sent Events
  • Real-time event streaming needed
  • Examples: live data feeds, streaming APIs

Connection Lifecycle

Automatic Connection Management

When you pass MCPToolProvider to an Agent, connections are managed automatically:

Manual Connection Management

For more control, use connect() and disconnect():

Async Context Manager

You can also use MCP providers as async context managers:

Auto Refresh

Enable auto_refresh to reconnect and refresh tools on each agent run:
Use when:
  • MCP server tools change frequently
  • Server may restart between runs
  • Tool schema updates are common

Tool Name Collision Handling

When multiple MCP servers provide tools with the same name, Laddr automatically prefixes tool names with the server identifier:
If server_name is not provided, the transport type is used as prefix (e.g., stdio_read_file).

Example: Filesystem Agent

Complete example of a filesystem exploration agent:

Example: Multiple MCP Servers

Combining filesystem and git MCP servers:

Best Practices

1. Resource Cleanup

Always disconnect MCP connections when done:

2. Error Handling

Handle connection failures gracefully:

3. Server Names

Always provide server_name when using multiple servers:

4. Auto Refresh

Use auto_refresh=True for hosted servers that may restart:

5. Tool Discovery

Tools are automatically discovered and registered - no need to explicitly list them.

Troubleshooting

Connection Failures

If MCP connection fails:
  • Check that the MCP server command is correct
  • Verify network connectivity for HTTP/SSE transports
  • Check API keys for authenticated servers
  • Review logs for detailed error messages

Tool Not Found

If an MCP tool is not available:
  • Ensure MCP provider is connected: mcp.is_connected()
  • Check tool name (may be prefixed with server name)
  • Verify MCP server provides the expected tools
  • Use await mcp.discover_tools() to list available tools

Import Errors

If you see import errors:
  • Install required dependencies: pip install aiohttp
  • For stdio transport, ensure Node.js/npx is available
  • Check that MCP server packages are installed

Advanced Usage

Custom Tool Prefixing

Control how tool names are prefixed:

Connection State Checking

Check if MCP provider is connected:

Manual Tool Registration

Register MCP tools manually into a ToolRegistry:

Finding MCP Servers

Check out the MCP Servers repository for a collection of available MCP servers:
  • Filesystem - File and directory operations
  • Git - Git repository operations
  • PostgreSQL - Database queries
  • Brave Search - Web search
  • And many more…

Next Steps