> ## Documentation Index
> Fetch the complete documentation index at: https://docs.upsonic.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Integrate external tools using the Model Context Protocol

## What is Model Context Protocol (MCP)?

The Model Context Protocol (MCP) is an open protocol that enables seamless integration between LLM applications and external data sources and tools. It provides a standardized way for AI agents to communicate with external servers and access their capabilities.

## How MCP Works

MCP creates a bridge between your AI agents and external tool servers:

1. **Server Registration**: You configure an MCP server by specifying its connection details
2. **Tool Discovery**: The framework automatically discovers available tools from the server
3. **Tool Execution**: When your agent needs a tool, the framework handles communication with the MCP server
4. **Result Handling**: Results are returned to your agent in a standardized format

## Key Benefits

* **Extensive Ecosystem**: Access thousands of community-developed and official tools
* **No Custom Development**: Use pre-built tools without writing integration code
* **Standardized Protocol**: Consistent interface across different tool providers
* **Live Updates**: Servers can update tools without changing your code

<Warning>
  **MCP Security:** Only connect to MCP servers you trust. Stdio servers run arbitrary processes on your machine; do not use commands or config from untrusted sources.
</Warning>

## Two Ways to Use MCP

### 1. MCPHandler (Single Server)

```python theme={null}
from upsonic import Agent, Task
from upsonic.tools.mcp import MCPHandler

mcp_handler = MCPHandler(
    command="uvx mcp-server-sqlite --db-path /tmp/db.db",
    timeout_seconds=60
)

agent = Agent(model="anthropic/claude-sonnet-4-5")
task = Task(
    description="Query the database to list all tables and their schema information to understand the database structure.",
    tools=[mcp_handler]
)
result = agent.print_do(task)
print("Result:", result)
```

### 2. MultiMCPHandler (Multiple Servers)

```python theme={null}
from upsonic import Agent, Task
from upsonic.tools.mcp import MultiMCPHandler

multi_handler = MultiMCPHandler(
    commands=[
        "uvx mcp-server-sqlite --db-path /tmp/db1.db",
        "uvx mcp-server-sqlite --db-path /tmp/db2.db",
    ],
    tool_name_prefixes=["users_db", "products_db"],  # Prevent tool name collisions
    timeout_seconds=60
)

agent = Agent(model="anthropic/claude-sonnet-4-5")
task = Task(
    description="""
    Connect to both databases using prefixed tools:
    - Use 'users_db_*' tools to query the users database
    - Use 'products_db_*' tools to query the products database
    Cross-reference the data between both databases.
    """,
    tools=[multi_handler]
)
result = agent.print_do(task)
print("Result:", result)
```

<Tip>
  Use `tool_name_prefix` or `tool_name_prefixes` when connecting to multiple servers that expose tools with the same names. This prevents collisions and makes it clear which server's tools to use.
</Tip>

## MCP Server Resources

Discover available MCP servers:

* [Glama MCP Servers](https://glama.ai/mcp/servers)
* [MCP Run](https://www.mcp.run/)
* [Smithery](https://smithery.ai/)

## Navigation

* [MCPHandler](/concepts/tools/mcp-tools/mcp-handler) - Use MCPHandler for single server
* [MultiMCPHandler](/concepts/tools/mcp-tools/multi-mcp-handler) - Use MultiMCPHandler for multiple servers
* [Authentication](/concepts/tools/mcp-tools/authentication) - Configure authentication for MCP servers
