***

title: mcp_gateway
slug: /reference/python/agents/skills/mcp-gateway
description: Connect to MCP (Model Context Protocol) servers via the MCP Gateway service.
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

Connect to MCP (Model Context Protocol) servers via the MCP Gateway service. Each MCP
tool is dynamically registered as a SWAIG function, enabling your agent to use any
MCP-compatible tool.

**Tools:** Dynamically created from connected MCP services

**Requirements:** Running MCP Gateway service

**Multi-instance:** Yes

<ParamField path="gateway_url" type="str" required={true} toc={true}>
  MCP Gateway service URL.
</ParamField>

<ParamField path="auth_user" type="str" toc={true}>
  Basic auth username for the gateway.
</ParamField>

<ParamField path="auth_password" type="str" toc={true}>
  Basic auth password for the gateway.
</ParamField>

<ParamField path="auth_token" type="str" toc={true}>
  Bearer token (alternative to basic auth).
</ParamField>

<ParamField path="services" type="list[dict]" toc={true}>
  Specific services and tools to enable. Each dict has `name` (str) and `tools` (str `"*"`
  or list of tool names). If omitted, all available services are enabled.
</ParamField>

<ParamField path="session_timeout" type="int" default="300" toc={true}>
  Session timeout in seconds.
</ParamField>

<ParamField path="tool_prefix" type="str" default="mcp_" toc={true}>
  Prefix for generated function names (e.g., `mcp_todo_add_todo`).
</ParamField>

<ParamField path="retry_attempts" type="int" default="3" toc={true}>
  Number of connection retry attempts.
</ParamField>

<ParamField path="request_timeout" type="int" default="30" toc={true}>
  Individual request timeout in seconds.
</ParamField>

<ParamField path="verify_ssl" type="bool" default="True" toc={true}>
  Whether to verify SSL certificates.
</ParamField>

```python
from signalwire import AgentBase

class MyAgent(AgentBase):
    def __init__(self):
        super().__init__(name="assistant", route="/assistant")
        self.set_prompt_text("You are a helpful assistant.")
        self.add_skill("mcp_gateway", {
            "gateway_url": "http://localhost:8080",
            "auth_user": "admin",
            "auth_password": "secure-password",
            "services": [
                {"name": "todo", "tools": "*"},
                {"name": "calculator", "tools": ["add", "multiply"]}
            ]
        })

agent = MyAgent()
agent.serve()
```