> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agnost.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript MCP SDK

> Add Agnost AI analytics to your TypeScript MCP server

## Install

<CodeGroup>
  ```bash npm theme={null}
  npm install agnost
  ```

  ```bash pnpm theme={null}
  pnpm add agnost
  ```

  ```bash yarn theme={null}
  yarn add agnost
  ```
</CodeGroup>

## Integrate

Call `trackMCP` after creating your server, before connecting transport:

```typescript theme={null}
import { trackMCP } from 'agnost';

// your existing server setup...

trackMCP(server, 'your-org-id');
```

Get your org ID from [app.agnost.ai](https://app.agnost.ai).

## Options

```typescript theme={null}
trackMCP(server, 'your-org-id', {
  disableInput: false,   // set true to skip tracking tool inputs
  disableOutput: false,  // set true to skip tracking tool outputs
  identify: (request, env) => ({
    userId: request?.headers?.['x-user-id'] || 'anonymous',
    email: request?.headers?.['x-user-email'],
  }),
});
```

## Checkpoints

Use `checkpoint()` inside tool handlers to get per-step latency breakdowns:

```typescript theme={null}
import { trackMCP, checkpoint } from 'agnost';

server.setRequestHandler(CallToolRequestSchema, async (request) => {
  checkpoint('db_query_start');
  const rows = await db.query(/* ... */);
  checkpoint('db_query_done', { rowCount: rows.length });

  checkpoint('format_start');
  const result = format(rows);
  checkpoint('format_done');

  return result;
});

trackMCP(server, 'your-org-id');
```

Checkpoints appear as a timeline in your dashboard.
