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

# Custom MCP Server

## Overview

If none of the built-in connectors meet your needs, connect to any MCP Server directly using Google ADK's `MCPToolset`. Once registered, the agent automatically loads the tools exposed by the MCP Server and calls them as needed during reasoning.

## Usage

```python lines theme={null}
from veadk import Agent
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset
from google.adk.tools.mcp_tool.mcp_session_manager import (
    StreamableHTTPConnectionParams,
)

toolset = MCPToolset(
    connection_params=StreamableHTTPConnectionParams(
        url="https://your-mcp-endpoint",
        headers={"Authorization": "Bearer your-api-key-here"},
    ),
)

agent = Agent(tools=[toolset])
```

## Automatic reconnection after a dropped session

If an MCP Server restarts, scales down, or expires its session, VeADK discards
the stale cached session, reconnects, and retries the current tool discovery or
tool call once. If that retry also fails, the error is returned to the caller.
An explicitly cancelled task is not retried.
