Labsco
langchain-ai logo

LangSmith MCP Server

β˜… 127

from langchain-ai

An MCP server for fetching conversation history and prompts from the LangSmith observability platform.

πŸ”₯πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedPaid serviceAdvanced setup

πŸ¦œπŸ› οΈ LangSmith MCP Server

LangSmith MCP Hero

A production-ready Model Context Protocol (MCP) server that provides seamless integration with the LangSmith observability platform. This server enables language models to fetch conversation history, prompts, runs and traces, datasets, experiments, and billing usage from LangSmith.

πŸ“‹ Example Use Cases

The server enables powerful capabilities including:

  • πŸ’¬ Conversation History: "Fetch the history of my conversation from thread 'thread-123' in project 'my-chatbot'" (paginated by character budget)
  • πŸ“š Prompt Management: "Get all public prompts in my workspace" / "Pull the template for the 'legal-case-summarizer' prompt"
  • πŸ” Traces & Runs: "Fetch the latest 10 root runs from project 'alpha'" / "Get all runs for trace <uuid> (page 2 of 5)"
  • πŸ“Š Datasets: "List datasets of type chat" / "Read examples from dataset 'customer-support-qa'"
  • πŸ§ͺ Experiments: "List experiments for dataset 'my-eval-set' with latency and cost metrics"
  • πŸ“ˆ Billing: "Get billing usage for September 2025"

πŸ› οΈ Available Tools

The LangSmith MCP Server provides the following tools for integration with LangSmith.

πŸ’¬ Conversation & Threads

Tool NameDescription
get_thread_historyRetrieve message history for a conversation thread. Uses char-based pagination: pass page_number (1-based), and use returned total_pages to request more pages. Optional max_chars_per_page and preview_chars control page size and long-string truncation.

πŸ“š Prompt Management

Tool NameDescription
list_promptsFetch prompts from LangSmith with optional filtering by visibility (public/private) and limit.
get_prompt_by_nameGet a specific prompt by its exact name, returning the prompt details and template.
push_promptDocumentation-only: how to create and push prompts to LangSmith.

πŸ” Traces & Runs

Tool NameDescription
fetch_runsFetch LangSmith runs (traces, tools, chains, etc.) from one or more projects. Supports filters (run_type, error, is_root), FQL (filter, trace_filter, tree_filter), and ordering. When trace_id is set, returns char-based paginated pages; otherwise returns one batch up to limit. Always pass limit and page_number.
list_projectsList LangSmith projects with optional filtering by name, dataset, and detail level (simplified vs full).

πŸ“Š Datasets & Examples

Tool NameDescription
list_datasetsFetch datasets with filtering by ID, type, name, name substring, or metadata.
list_examplesFetch examples from a dataset by dataset ID/name or example IDs, with filter, metadata, splits, and optional as_of version.
read_datasetRead a single dataset by ID or name.
read_exampleRead a single example by ID, with optional as_of version.
create_datasetDocumentation-only: how to create datasets in LangSmith.
update_examplesDocumentation-only: how to update dataset examples in LangSmith.

πŸ§ͺ Experiments & Evaluations

Tool NameDescription
list_experimentsList experiment projects (reference projects) for a dataset. Requires reference_dataset_id or reference_dataset_name. Returns key metrics (latency, cost, feedback stats).
run_experimentDocumentation-only: how to run experiments and evaluations in LangSmith.

πŸ“ˆ Usage & Billing

Tool NameDescription
get_billing_usageFetch organization billing usage (e.g. trace counts) for a date range. Optional workspace filter; returns metrics with workspace names inline.

πŸ“„ Pagination (char-based)

Several tools use stateless, character-budget pagination so responses stay within a size limit and work well with LLM clients:

  • Where it’s used: get_thread_history and fetch_runs (when trace_id is set).
  • Parameters: You send page_number (1-based) on every request. Optional: max_chars_per_page (default 25000, cap 30000) and preview_chars (truncate long strings with "… (+N chars)").
  • Response: Each response includes page_number, total_pages, and the page payload (result for messages, runs for runs). To get more, call again with page_number = 2, then 3, up to total_pages.
  • Why it’s useful: Pages are built by JSON character count, not item count, so each page fits within a fixed size. No cursor or server-side stateβ€”just integer page numbers.

πŸ§ͺ Development and Contributing

Prerequisites

  • Python 3.10+ (3.11+ recommended)
  • uv – install with curl -LsSf https://astral.sh/uv/install.sh | sh
  • LangSmith API key – from smith.langchain.com
  • Node.js (optional) – only if you want to use MCP Inspector to test the server (stdio or streamable-http)

Setup

git clone https://github.com/langchain-ai/langsmith-mcp-server.git
cd langsmith-mcp-server

uv sync                    # Install dependencies
uv sync --group test       # Include test dependencies (pytest, ruff, mypy)

uvx langsmith-mcp-server   # Verify CLI runs (stdio)

Development workflow

  1. Edit code in langsmith_mcp_server/ or tests/.
  2. Format and lint (required before committing):
    make format
    make lint
  3. Run tests:
    make test
    # Or a single file:
    make test TEST_FILE=tests/tools/test_dataset_tools.py
  4. Type-check (optional): uv run mypy langsmith_mcp_server/

Testing with MCP Inspector

You can test the server with MCP Inspector using either stdio or streamable-http.

  1. Start MCP Inspector:

    npx @modelcontextprotocol/inspector@latest

    Open http://localhost:6274 in your browser.

  2. Connect in the Inspector:

    • Stdio: Choose stdio transport and configure the server command (e.g. uv run langsmith-mcp-server) and set LANGSMITH_API_KEY in the environment.
    • Streamable HTTP: Start the server first (uv run uvicorn langsmith_mcp_server.server:app --host 0.0.0.0 --port 8000 or Docker), then choose streamable-http, URL http://localhost:8000/mcp, and add header LANGSMITH-API-KEY = your API key.

Load testing

A session-based load test opens many MCP sessions and calls the list_prompts tool in each, using langchain-mcp-adapters. Run from the CLI (no UI). The server must be running first.

uv sync --group load
# Terminal 1: start the server
uv run uvicorn langsmith_mcp_server.server:app --host 0.0.0.0 --port 8000
# Terminal 2: run the load test
uv run python tests/load_test_sessions.py --sessions 20 --calls-per-session 3

Options

OptionDefaultDescription
--urlhttp://localhost:8000/mcpMCP endpoint URL
--api-keyfrom .envLANGSMITH_API_KEY (or set in project root .env)
--sessions10Number of concurrent sessions
--calls-per-session3list_prompts calls per session
--debugoffPrint step-by-step logs and first error traceback
--report PATHβ€”Write a report after the run (see below)

Report

Use --report PATH to write a JSON report after the test (e.g. --report load_test_report creates load_test_report.json with config, summary, per-session results, and first error).

uv run python tests/load_test_sessions.py --sessions 5 --report load_test_report
# Creates: load_test_report.json (in current directory)

Contributing checklist

Before opening a PR:

  • make format and make lint pass
  • make test passes
  • New tools or behavior are documented (e.g. in CLAUDE.md if you change architecture or tools)
  • Error handling in tools returns {"error": "..."} rather than raising

For more detail (adding tools, code standards, troubleshooting), see CLAUDE.md.

πŸ“„ License

This project is distributed under the MIT License. For detailed terms and conditions, please refer to the LICENSE file.

Made with ❀️ by the LangChain Team