Skip to main content
The LangWatch MCP Server gives your AI coding assistant (Cursor, Claude Code, Codex, etc.) full access to all LangWatch and Scenario documentation and features via the Model Context Protocol.
  • Set up agent testing with Scenario to test agent behavior through user simulations and edge cases
  • Automatically instrument your code with LangWatch tracing for any framework (OpenAI, Agno, Mastra, DSPy, and more)
  • Set up evaluations to test and monitor your LLM outputs
  • Search and inspect traces from your LangWatch project directly in your editor
  • Query analytics to understand performance trends, costs, and error rates
  • Manage prompts: list, create, update, and version prompts without leaving your IDE
Instead of manually reading docs and writing boilerplate code, just ask your AI assistant to instrument your codebase with LangWatch, and it will do it for you.
The server URL is https://app.langwatch.ai/mcp. If you added LangWatch to your AI client before October 2026, update the connector’s URL to this one. Self-hosted deployments use their own host followed by /mcp.

Setup

Connect to the hosted server at https://app.langwatch.ai/mcp. Sign in with OAuth (recommended): your client opens a browser window, you sign in to LangWatch and approve a project, and the client refreshes its access on its own, with no key to manage. Clients that cannot sign in can send a personal API key as an Authorization: Bearer <key> header instead.
The Authorize MCP Connection page, asking to allow a client to use a LangWatch projectThe Authorize MCP Connection page, asking to allow a client to use a LangWatch project

The approval page your client opens after you sign in: pick the project it may use, then Allow.

  1. Go to Customize → Connectors, click + Add, then Add custom connector. On Team and Enterprise plans, an owner adds it under Organization settings → Connectors → Add → Custom → Web.
  2. Enter the server URL: https://app.langwatch.ai/mcp
  3. Click Connect: you’ll be redirected to sign in and approve access to a project
The same steps work in Claude Cowork and in Claude chat on the web.Requires a paid Claude plan.

Run it locally instead

Coding assistants can also run the MCP server on your machine with your API key and the project to work in. For Claude Code:
For other editors, add an entry named langwatch under your editor’s MCP servers with these fields:
  • command: npx
  • args: -y, then the package name @langwatch/mcp-server on a separate token
  • env.LANGWATCH_API_KEY: your LangWatch API key
  • env.LANGWATCH_PROJECT_ID: your LangWatch project ID
This page intentionally describes the config in prose rather than as a JSON snippet. Some CLI agents (notably Gemini CLI 0.36.0 and earlier) parse @-prefixed runs as file paths and can crash with ENAMETOOLONG when a multi-line JSON snippet wraps the scoped package name in double quotes. See #3104 for details. The bash claude mcp add form above is safe: the package name is followed by a whitespace terminator.
Once connected, open your AI assistant’s chat and ask it to help with LangWatch tasks.

Local server configuration

Two Modes

The MCP server runs in two modes:
  • Remote (Streamable HTTP): Recommended, for every client. Hosted at https://app.langwatch.ai/mcp. Sign in with OAuth (Authorization Code + PKCE) in your browser and approve a project, or send a personal API key as a Bearer token.
  • Local (stdio): Runs as a subprocess of your coding assistant. API key set via --apiKey flag or LANGWATCH_API_KEY env var.

Usage Examples

Write Agent Tests with Scenario

Ask your AI assistant to write scenario tests for your agents:
The AI assistant will:
  1. Fetch the Scenario documentation and best practices
  2. Create test files with proper imports and setup
  3. Write scenario scripts that simulate user interactions
  4. Add verification logic to check agent behavior
  5. Include judge criteria to evaluate conversation quality
Example scenario test: Here’s an example scenario that checks for tool calls and includes criteria validation:
The LangWatch MCP automatically handles fetching the right documentation, understanding your agent’s framework, and generating tests that follow Scenario best practices.

Instrument Your Code with LangWatch

Ask your AI assistant to add LangWatch tracking to your existing code:
The AI assistant will:
  1. Fetch the relevant LangWatch documentation for your framework
  2. Add the necessary imports and setup code
  3. Wrap your functions with @langwatch.trace() decorators
  4. Configure automatic tracking for your LLM calls
  5. Add labels and metadata following best practices
Example transformation: Before:
After (automatically added by AI assistant):

Set Up Evaluations

Ask your AI assistant to set up evaluation code for your LLM outputs:
The AI assistant will:
  1. Fetch the relevant LangWatch evaluation documentation
  2. Create evaluation notebooks or scripts with proper setup
  3. Add evaluation metrics and criteria for your use case
  4. Include code to run evaluations following Evaluating via Code

Search and Debug Traces

Ask your AI assistant to find and analyze traces from your project:
The AI assistant will use search_traces to find matching traces and get_trace to drill into individual ones. Traces are returned as AI-readable digests by default, showing the full span hierarchy with timing, inputs, outputs, and errors.

Query Analytics

Ask about performance trends, costs, and usage patterns:
The assistant starts with discover_schema to understand available metrics and filters, then uses get_analytics to query timeseries data.

Manage Prompts

Ask your AI assistant to work with prompts:
The AI assistant will guide you through creating, versioning, and using prompts from LangWatch’s Prompt Management.

Advanced: Self-Building AI Agents

An AI agent can use the LangWatch MCP to instrument itself while it is being built, which lets it track and debug its own behavior.

MCP Tools Reference

The MCP server provides tools organized into categories. Your AI assistant automatically chooses the right tools based on your request.

Documentation and Support

Observability (requires API key)

Prompts (requires API key)

Evaluations (requires API key)

Dataset tools are listed on the datasets page. Annotation tools are platform_list_annotations, platform_get_annotation, platform_create_annotation and platform_delete_annotation.

Organization Management (requires org-level API key)

Organization management tools require an API key with org-level permissions. If the configured key lacks organization permissions, these tools will return a clear error message.

Tool Details

discover_schema

Discover available filter fields, metrics, aggregation types, and group-by options for LangWatch queries. Call this before using search_traces or get_analytics to understand available options. Parameters:
  • category (required): One of "filters", "metrics", "aggregations", "groups", or "all"

search_traces

Search traces with filters, text query, and date range. Returns AI-readable trace digests by default. Parameters:
  • query (optional): Text search query
  • startDate (optional): Start date, ISO string or relative like "24h", "7d", "30d". Default: 24h ago
  • endDate (optional): End date, ISO string or relative. Default: now
  • filters (optional): Filter object (e.g. {"metadata.labels": ["production"]})
  • pageSize (optional): Results per page (default: 25, max: 1000)
  • scrollId (optional): Pagination token from previous search
  • format (optional): "digest" (default, AI-readable) or "json" (full raw data)

get_trace

Get full details of a single trace by ID. Returns AI-readable trace digest by default. Parameters:
  • traceId (required): The trace ID to retrieve
  • format (optional): "digest" (default, AI-readable) or "json" (full raw data)

get_analytics

Query analytics timeseries from LangWatch. Metrics use "category.name" format (e.g., "performance.completion_time"). Parameters:
  • metric (required): Metric in "category.name" format (e.g., "metadata.trace_id", "performance.total_cost")
  • aggregation (optional): avg, sum, min, max, median, p90, p95, p99, cardinality, terms. Default: avg
  • startDate (optional): Start date, ISO string or relative. Default: 7 days ago
  • endDate (optional): End date. Default: now
  • groupBy (optional): Group results by field
  • filters (optional): Filters to apply
  • timeZone (optional): Timezone. Default: UTC

platform_list_prompts

List all prompts configured in the LangWatch project. No parameters required.

platform_get_prompt

Get a specific prompt by ID or handle, including messages, model config, and version history. Parameters:
  • idOrHandle (required): Prompt ID or handle
  • version (optional): Specific version number (default: latest)

platform_create_prompt

Create a new prompt in the LangWatch project. Parameters:
  • name (required): Prompt name
  • messages (required): Array of {role, content} messages
  • model (required): Model name (e.g., "gpt-6-luna", "claude-sonnet-4-5-20250929")
  • modelProvider (required): Provider name (e.g., "openai", "anthropic")
  • handle (optional): URL-friendly handle
  • description (optional): Prompt description

platform_update_prompt

Update an existing prompt or create a new version. Parameters:
  • idOrHandle (required): Prompt ID or handle to update
  • messages (optional): Updated messages array
  • model (optional): Updated model name
  • modelProvider (optional): Updated provider
  • createVersion (optional): If true, creates a new version instead of updating in place
  • commitMessage (optional): Commit message for the change

fetch_langwatch_docs

Fetches LangWatch documentation pages to understand how to implement features. Parameters:
  • url (optional): The full URL of a specific doc page. If not provided, fetches the docs index.

fetch_scenario_docs

Fetches Scenario documentation pages to understand how to write agent tests. Parameters:
  • url (optional): The full URL of a specific doc page. If not provided, fetches the docs index.
Your AI assistant will automatically choose the right tools based on your request. You don’t need to call these tools manually.
Found broken or outdated docs? Use Report outdated or broken docs next to Edit this page below. Agents: include the page URL, the failing step and a proposed fix in a GitHub issue. For CLI diagnostics, ask your user before running npx langwatch report --user-approved. See the reporting guide.
Last modified on October 29, 2026