***

title: handleMcpRequest
slug: /reference/typescript/agents/agent-base/handle-mcp-request
description: Handle an MCP JSON-RPC 2.0 request and return the response.
max-toc-depth: 3
---------------------

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

[enable-mcp-server]: /docs/server-sdks/reference/typescript/agents/agent-base/enable-mcp-server

Handle an incoming MCP JSON-RPC 2.0 request. This method is called automatically
by the `/mcp` endpoint when [`enableMcpServer()`][enable-mcp-server] is active. It
supports the `initialize`, `notifications/initialized`, `tools/list`, `tools/call`,
and `ping` methods.

You typically do not need to call this directly -- it is invoked by the Hono route
handler.

## **Parameters**

<ParamField path="body" type={"Record<string, unknown>"} required={true} toc={true}>
  The parsed JSON-RPC 2.0 request body, containing `jsonrpc`, `method`, `params`,
  and `id` fields.
</ParamField>

## **Returns**

`Promise<Record<string, unknown>>` -- The JSON-RPC 2.0 response object.

## **Example**

```typescript {7}
import { AgentBase } from '@signalwire/sdk';

const agent = new AgentBase({ name: 'assistant', route: '/assistant' });
agent.enableMcpServer();

// Manually invoke (normally handled by the /mcp endpoint)
const response = await agent.handleMcpRequest({
  jsonrpc: '2.0',
  id: 1,
  method: 'tools/list',
  params: {},
});
console.log(response);
```