> ## 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'],
  }),
});
```

Use a stable pseudonymous `userId` and non-sensitive traits. Avoid forwarding raw email, name, or other personal data unless your team has approved that data flow. If tool inputs or outputs may contain sensitive data, set `disableInput` or `disableOutput` to `true`, or redact before returning tool results. See [Data Governance](/data-governance).

## 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.

## What appears in Agnost

* **Tools** for MCP tool invocations.
* **Raw logs** for every tracked call.
* **Checkpoint timeline** for calls that use `checkpoint()`.
* **Errors** when a tool call fails.

## Verify

Call one MCP tool from your client, then open [app.agnost.ai](https://app.agnost.ai). Check **Raw logs** first, then **Tools**.

## Troubleshooting

* Call `trackMCP` after creating your server and before connecting transport.
* Confirm the org ID is correct.
* Use `disableInput` / `disableOutput` if tool args or results are sensitive.
