TypeScript SDK Installation
The @mcpwatch/sdk package provides first-class TypeScript support for MCPWatch. It works with any MCP server built on the official MCP TypeScript SDK.
Requirements
- Node.js 18 or later
- TypeScript 5.0+ (recommended, but not required)
- An MCP server using
@modelcontextprotocol/sdk
Install
npm install @mcpwatch/sdk
Or with your preferred package manager:
# yarn
yarn add @mcpwatch/sdk
# pnpm
pnpm add @mcpwatch/sdk
# bun
bun add @mcpwatch/sdk
The SDK has a peer dependency on @modelcontextprotocol/sdk >= 1.0.0.
Basic setup
Instrument your MCP server with a single instrument() call:
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { instrument } from "@mcpwatch/sdk";
const server = instrument(
new McpServer({ name: "my-server", version: "1.0.0" }),
{
apiKey: process.env.MCPWATCH_API_KEY ?? "",
endpoint: "https://api.mcpwatch.dev",
}
);
The instrument() function returns the same server instance with wrapped methods. Your existing tool, resource, and prompt registrations work exactly as before.
Configuration options
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | — | Your MCPWatch API key (required) |
endpoint | string | "https://api.mcpwatch.dev" | MCPWatch ingestion endpoint |
debug | boolean | false | Enable debug logging to console |
sampleRate | number | 1.0 | Event sampling rate from 0.0 to 1.0 |
maxBatchSize | number | 50 | Max events per batch before flush |
flushInterval | number | 1000 | Time in ms between automatic flushes |
onQuotaWarning | (info: QuotaInfo) => void | — | Callback when quota status is “warning” or “exceeded” |
Verify installation
Enable debug mode to confirm events are being captured and sent:
const server = instrument(
new McpServer({ name: "my-server", version: "1.0.0" }),
{
apiKey: process.env.MCPWATCH_API_KEY ?? "",
debug: true,
}
);
You’ll see log lines like:
[mcpwatch] Server instrumented: my-server v1.0.0
[mcpwatch] Batch sent: 3 events accepted
Next steps
- Usage Guide — Learn how to use the SDK’s full feature set
- API Reference — Complete function and type documentation
Last updated — MCPWatch Documentation