> ## 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.

# MCP Router

## Overview

`mcp_router` (`from veadk.tools.builtin_tools.mcp_router import mcp_router`) aggregates and forwards the tools of multiple MCP Servers through the Volcengine MCP Router, which is ideal when you need a single entry point for several MCP services. It works over a streamable HTTP connection (`StreamableHTTPConnectionParams`).

## Environment & prerequisites

Environment variables:

* `TOOL_MCP_ROUTER_URL`: the MCP Router service address
* `TOOL_MCP_ROUTER_API_KEY`: the API key for authentication, sent as the `Authorization: Bearer <key>` request header

Set these environment variables before importing `mcp_router`; restart the process after changing them:

```bash lines theme={null}
export TOOL_MCP_ROUTER_URL="https://your-mcp-router-endpoint"
export TOOL_MCP_ROUTER_API_KEY="your-router-api-key"
```

## Usage

```python lines theme={null}
from veadk import Agent
from veadk.tools.builtin_tools.mcp_router import mcp_router

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

## Verify the connection and release resources

Use an active Streamable HTTP MCP URL and a Router-issued API key. An empty key omits the `Authorization` header; it does not imply anonymous access is allowed. This prebuilt toolset reads environment variables at import time. For `config.yaml`, import `Agent` to load configuration before importing `mcp_router`; the standalone check below uses environment variables set before startup. The endpoint is not switched to BytePlus automatically.

This example lists the tools currently exposed by the service without performing a business operation. For an empty list, check the mounted MCP servers and credential permissions.

```python lines theme={null}
import asyncio

from veadk.tools.builtin_tools.mcp_router import mcp_router


async def main():
    try:
        tools = await mcp_router.get_tools()
        print([tool.name for tool in tools])
    finally:
        await mcp_router.close()


if __name__ == "__main__":
    asyncio.run(main())
```
