***

title: enable_mcp_server
slug: /reference/python/agents/agent-base/enable-mcp-server
description: Expose the agent's tools as an MCP server endpoint.
max-toc-depth: 3
---------------------

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

[add-mcp-server]: /docs/server-sdks/reference/python/agents/agent-base/add-mcp-server

[ref-agentbase]: /docs/server-sdks/reference/python/agents/agent-base

Expose this agent's `@tool` functions as a Model Context Protocol (MCP) server
endpoint. Adds a `/mcp` route that speaks JSON-RPC 2.0, allowing external MCP clients
(Claude Desktop, other agents, etc.) to discover and invoke the same tools.

<Note>
  This method only registers the `/mcp` HTTP route. It does **not** automatically
  add the endpoint to the agent's SWML output. To include the MCP server in your
  SWML document for native tool discovery, also call
  [`add_mcp_server()`][add-mcp-server] pointing at the agent's own `/mcp` URL.
</Note>

<Note>
  This method exposes your agent's tools **as** an MCP server. To connect your agent
  **to** an external MCP server as a client, use
  [`add_mcp_server()`][add-mcp-server].
</Note>

## **Parameters**

None.

## **Returns**

[`AgentBase`][ref-agentbase] -- Returns self for method chaining.

## **Example**

```python {12}
from signalwire import AgentBase
from signalwire.core.function_result import FunctionResult

agent = AgentBase(name="assistant", route="/assistant")
agent.set_prompt_text("You are a helpful assistant.")

@agent.tool(name="get_weather", description="Get weather for a city")
def get_weather(args, raw_data):
    city = args.get("city", "Unknown")
    return FunctionResult(f"The weather in {city} is sunny.")

agent.enable_mcp_server()
agent.serve()
```