***

title: enableMcpServer
slug: /reference/typescript/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/typescript/agents/agent-base/add-mcp-server

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

Expose this agent's tools 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 agent's tools.

<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
  [`addMcpServer()`][add-mcp-server].
</Note>

## **Parameters**

None.

## **Returns**

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

## **Example**

```typescript {20}
import { AgentBase, FunctionResult } from '@signalwire/sdk';

const agent = new AgentBase({ name: 'assistant', route: '/assistant' });
agent.setPromptText('You are a helpful assistant.');
agent.defineTool({
  name: 'get_weather',
  description: 'Get the current weather for a city',
  parameters: {
    type: 'object',
    properties: {
      city: { type: 'string', description: 'City name' },
    },
  },
  handler: async (args) => {
    const city = args.city ?? 'Unknown';
    const result = new FunctionResult(`The weather in ${city} is sunny.`);
    return result;
  },
});
agent.enableMcpServer();
await agent.serve();
```