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

# Quickstart

> Stand up an instrumented MCP server in under five minutes.

This guide walks you through installing `@sedata-ai/mcp`, wrapping a basic MCP
server, and verifying that traces are flowing.

<Note>
  You need **Node.js ≥ 22.16** and **`@modelcontextprotocol/sdk` ≥ 1.21.1**.
  See [Installation](/installation) for compatibility details.
</Note>

## 1. Install the package

<CodeGroup>
  ```bash npm theme={null}
  npm install @sedata-ai/mcp @modelcontextprotocol/sdk zod
  ```

  ```bash pnpm theme={null}
  pnpm add @sedata-ai/mcp @modelcontextprotocol/sdk zod
  ```

  ```bash yarn theme={null}
  yarn add @sedata-ai/mcp @modelcontextprotocol/sdk zod
  ```

  ```bash bun theme={null}
  bun add @sedata-ai/mcp @modelcontextprotocol/sdk zod
  ```
</CodeGroup>

## 2. Get an API key

Sign in to the [Sedata dashboard](https://app.sedata-ai.tech), open
**Settings → API keys**, and create a new key scoped to your project. Set it as
an environment variable:

```bash theme={null}
export SEDATA_TOKEN="sk_live_xxx"
```

## 3. Wire up `instrumentServer`

Create a file `server.ts`:

```ts server.ts theme={null}
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
import { instrumentServer, safetyCheck } from '@sedata-ai/mcp'
import type { TelemetryConfig } from '@sedata-ai/mcp'
import { z } from 'zod'

const NAME = 'weather-mcp-server'
const VERSION = '1.0.0'

const server = new McpServer({ name: NAME, version: VERSION })

const telemetryConfig: TelemetryConfig = {
  serverName: NAME,
  serverVersion: VERSION,
  exporterEndpoint: 'https://otel.sedata-ai.tech/v1',
  exporterAuth: {
    type: 'bearer',
    token: process.env.SEDATA_TOKEN!,
  },
}

const telemetry = instrumentServer(server, telemetryConfig)
```

<Tip>
  `instrumentServer` returns an [`ObservabilityInstance`](/api-reference/types/observability-instance)
  you can use later to record custom spans, histograms, and counters.
</Tip>

## 4. Register a tool — with optional safety check

```ts server.ts (continued) theme={null}
server.registerTool(
  'calculate-bmi',
  {
    title: 'BMI Calculator',
    description: 'Calculate Body Mass Index',
    inputSchema: { weightKg: z.number(), heightM: z.number() },
    outputSchema: { bmi: z.number() },
  },
  async ({ weightKg, heightM }) => {
    const bmi = weightKg / (heightM * heightM)
    return {
      content: [{ type: 'text', text: JSON.stringify({ bmi }) }],
      structuredContent: { bmi },
    }
  },
)

server.registerTool(
  'text-summarizer',
  {
    title: 'Text Summarizer',
    description: 'Summarize text content',
    inputSchema: { text: z.string() },
    outputSchema: { summary: z.string() },
  },
  // Wrap the handler so the `text` param is validated before the handler runs.
  safetyCheck(
    async ({ text }) => {
      const summary = text.substring(0, 100) + '...'
      return {
        content: [{ type: 'text', text: JSON.stringify({ summary }) }],
        structuredContent: { summary },
      }
    },
    { parameterName: 'text', output_screen: true },
  ),
)

const transport = new StdioServerTransport()
server.connect(transport)
```

## 5. Run it

```bash theme={null}
npx ts-node server.ts
```

Within a few seconds you should see traces in your Sedata dashboard:

<Frame>
  <img src="https://mintcdn.com/sedataai/wSLL-vktaiea1WMS/images/quickstart-trace.svg?fit=max&auto=format&n=wSLL-vktaiea1WMS&q=85&s=0408b2828a779d36f0a99ee3712b41d8" alt="Trace appears in Sedata dashboard" width="1000" height="320" data-path="images/quickstart-trace.svg" />
</Frame>

## What's instrumented automatically

<AccordionGroup>
  <Accordion title="Span per tool call" icon="route">
    Every call to a tool registered via `server.registerTool` is wrapped in a
    span named `tools/call <toolName>` with attributes for tool metadata,
    request id, session id, and client address.
  </Accordion>

  <Accordion title="Operation duration histogram" icon="gauge">
    `mcp.server.operation.duration` records milliseconds per call, tagged by
    method, tool name, and success.
  </Accordion>

  <Accordion title="Operation count" icon="hashtag">
    `mcp.server.operation.count` increments once per invocation.
  </Accordion>

  <Accordion title="Session duration" icon="timer">
    `mcp.server.session.duration` is recorded when you call
    `telemetry.shutdown()` — capturing how long the process ran.
  </Accordion>
</AccordionGroup>

## Next steps

<CardGroup cols={2}>
  <Card title="Add custom spans" icon="code" href="/metrics-and-traces/custom-instrumentation">
    Record domain-specific operations alongside the auto-spans.
  </Card>

  <Card title="Tune sampling" icon="filter" href="/guides/sampling">
    Reduce volume in production while keeping signal in dev.
  </Card>

  <Card title="Configure auth" icon="key" href="/guides/authentication">
    Bearer, API key, or basic auth against your own collector.
  </Card>

  <Card title="Production checklist" icon="rocket" href="/guides/production-deployment">
    What to verify before shipping.
  </Card>
</CardGroup>
