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

# MCP Integration

> Connect to Model Context Protocol servers and use their tools

<Info>
  Source: [`09_mcp_stdio.py`](https://github.com/opper-ai/opper-sdks/blob/main/python/examples/agents/09_mcp_stdio.py) · [`09-mcp-stdio.ts`](https://github.com/opper-ai/opper-sdks/blob/main/typescript/examples/agents/09-mcp-stdio.ts) · Applied: [`daily_digest_agent.py`](https://github.com/opper-ai/opper-sdks/blob/main/python/examples/agents/applied_agents/daily_digest_agent.py)
</Info>

[MCP](https://modelcontextprotocol.io/) servers expose tools (filesystem, databases, APIs, etc.) over a standard protocol. The agent SDK can connect to any MCP server and turn its tools into native agent tools.

## Stdio (local process)

<CodeGroup>
  ```python Python theme={null}
  from opperai.agent import Agent
  from opperai.agent.mcp import MCPStdioConfig, mcp

  agent = Agent(
      name="fs-assistant",
      instructions="You have filesystem access via MCP. Be concise.",
      tools=[
          mcp(MCPStdioConfig(
              name="filesystem",
              command="npx",
              args=["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
          )),
      ],
  )

  result = await agent.run("List the files in /tmp.")
  ```

  ```typescript TypeScript theme={null}
  import { Agent, mcp } from "opperai";

  const agent = new Agent({
    name: "fs-assistant",
    instructions: "You have filesystem access via MCP. Be concise.",
    tools: [
      mcp({
        name: "filesystem",
        transport: "stdio",
        command: "npx",
        args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
      }),
    ],
  });

  const result = await agent.run("List the files in /tmp.");
  ```
</CodeGroup>

The SDK starts the server, discovers its tools, and makes them available to the agent. When the run ends, it shuts the server down.

## Streamable HTTP / SSE (remote)

Both SDKs also accept `MCPStreamableHTTPConfig` (`MCPSSEConfig` for legacy SSE) for remote servers. Useful for hosted MCPs like [Composio](https://composio.dev/) or [Smithery](https://smithery.ai/):

```python Python theme={null}
from opperai.agent.mcp import MCPStreamableHTTPConfig, mcp

mcp(MCPStreamableHTTPConfig(
    name="gmail",
    url=os.environ["COMPOSIO_GMAIL_MCP_URL"],
))
```

The applied [`daily_digest_agent`](https://github.com/opper-ai/opper-sdks/blob/main/python/examples/agents/applied_agents/daily_digest_agent.py) example wires four remote MCP servers (Gmail, Hacker News, Notion, Search) into a single agent.

## Multiple servers

Pass multiple `mcp(...)` providers in the same `tools=[...]` list, and the agent merges all of their tools. If two tool names collide, the agent prefixes them with the server name.
