Skip to main content
Glama

LangSmith MCP Server (TypeScript)

License: MIT Node.js 18+

A TypeScript implementation of the Model Context Protocol (MCP) server for LangSmith. This is a full port of the official Python LangSmith MCP Server with 100% functional parity.

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"

Related MCP server: Orchestration MCP

Quick Start

LANGSMITH_API_KEY=your-key npx langsmith-mcp-server

Available Tools

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

Conversation & Threads

Tool Name

Description

get_thread_history

Retrieve 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 Name

Description

list_prompts

Fetch prompts from LangSmith with optional filtering by visibility (public/private) and limit.

get_prompt_by_name

Get a specific prompt by its exact name, returning the prompt details and template.

push_prompt

Documentation-only: how to create and push prompts to LangSmith.

Traces & Runs

Tool Name

Description

fetch_runs

Fetch 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. All results are automatically paginated by character budget. Always pass limit and page_number.

list_projects

List LangSmith projects with optional filtering by name, dataset, and detail level (simplified vs full).

Datasets & Examples

Tool Name

Description

list_datasets

Fetch datasets with filtering by ID, type, name, name substring, or metadata.

list_examples

Fetch examples from a dataset by dataset ID/name or example IDs, with filter, metadata, splits, and optional as_of version.

read_dataset

Read a single dataset by ID or name.

read_example

Read a single example by ID, with optional as_of version.

create_dataset

Documentation-only: how to create datasets in LangSmith.

update_examples

Documentation-only: how to update dataset examples in LangSmith.

Experiments & Evaluations

Tool Name

Description

list_experiments

List experiment projects (reference projects) for a dataset. Requires reference_dataset_id or reference_dataset_name. Returns key metrics (latency, cost, feedback stats).

run_experiment

Documentation-only: how to run experiments and evaluations in LangSmith.

Usage & Billing

Tool Name

Description

get_billing_usage

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

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

Installation

From npm

npx langsmith-mcp-server

MCP Client Integration

Cursor / Claude Code

Add to your MCP settings:

{
  "mcpServers": {
    "langsmith": {
      "command": "npx",
      "args": ["langsmith-mcp-server"],
      "env": {
        "LANGSMITH_API_KEY": "your-key"
      }
    }
  }
}

Environment Variables

Variable

Required

Description

Example

LANGSMITH_API_KEY

Yes

Your LangSmith API key for authentication

lsv2_pt_1234567890

LANGSMITH_WORKSPACE_ID

No

Workspace ID for API keys scoped to multiple workspaces

your_workspace_id

LANGSMITH_ENDPOINT

No

Custom API endpoint URL (for self-hosted or EU region)

https://eu.api.smith.langchain.com

Notes:

  • Only LANGSMITH_API_KEY is required for basic functionality

  • LANGSMITH_WORKSPACE_ID is useful when your API key has access to multiple workspaces

  • LANGSMITH_ENDPOINT allows you to use custom endpoints for self-hosted LangSmith installations or the EU region

Development and Contributing

Setup

# Clone the repository
git clone https://github.com/langchain-ai/langsmith-mcp-server-js.git
cd langsmith-mcp-server-js

# Install dependencies
npm install

# Build
npm run build

# Run in development mode
LANGSMITH_API_KEY=your-key npm run dev

# Run production build
LANGSMITH_API_KEY=your-key npm start

Testing

# Run unit tests
npm test

MCP Inspector

For interactive development and debugging, use the MCP Inspector:

LANGSMITH_API_KEY=your-key npx @modelcontextprotocol/inspector npx .

This opens a browser UI where you can browse all tools, inspect their schemas, and invoke them interactively.

Verify the server responds

echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"0.1.0"}}}' | LANGSMITH_API_KEY=test npx . 2>/dev/null

Architecture

This is a direct port of the Python LangSmith MCP Server with the same module structure:

src/
  index.ts                    # Entry point (stdio transport)
  server.ts                   # McpServer setup
  common/
    helpers.ts                # Client creation, data conversion utilities
    pagination.ts             # Char-based stateless pagination
    formatters.ts             # Message extraction and formatting
  services/
    register-tools.ts         # MCP tool registration with Zod schemas
    tools/
      prompts.ts              # Prompt management tools
      traces.ts               # Trace/run/project tools
      datasets.ts             # Dataset and example tools
      experiments.ts          # Experiment listing tools
      usage.ts                # Billing/usage REST API tools

Contributing

This TypeScript implementation is a community port of the official Python LangSmith MCP Server by LangChain.

Contributions are welcome! Please open an issue or pull request on GitHub.

License

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

Available Tools

15 tools
create_datasetA

Call this tool when you need to understand how to create datasets in LangSmith. This is a documentation-only tool.

Inputs: no named parameters.

fetch_runsA

Fetch LangSmith runs from one or more projects with flexible filters and automatic pagination.

All results are paginated by character budget to keep responses manageable. Use page_number and total_pages from the response to iterate through multiple pages.

Args: project_name (str): The project name. For multiple projects, use JSON array string. limit (int): Max runs to fetch from LangSmith API (capped at 100). These runs are then paginated by character budget into pages. page_number (int): 1-based page index. Use with total_pages from response to iterate through pages. trace_id (str, optional): Return only runs that belong to this trace. run_type (str, optional): Filter by type: "llm", "chain", "tool", "retriever". error (str, optional): "true" for errored runs, "false" for successful. is_root (str, optional): "true" for only top-level traces. filter (str, optional): Filter Query Language (FQL) expression. trace_filter (str, optional): Filter applied to the root run. tree_filter (str, optional): Filter applied to any run in the trace tree. order_by (str, optional): Sort field; prefix with "-" for descending. Default "-start_time". reference_example_id (str, optional): Filter runs by reference example ID. max_chars_per_page (int): Max chars per page, capped at 30000. Default 25000. preview_chars (int): Truncate long strings to this length. Default 150.

Inputs: limit (required), project_name (required), error, filter, +10 more.

get_billing_usageA

Fetch organization billing usage (trace counts) with workspace names inline.

Args: starting_on (str): Start of date range (ISO 8601) ending_before (str): End of date range (ISO 8601) workspace (str, optional): Optional workspace UUID or display name to filter on_current_plan (str): "true" to include only usage on current plan (default: "true")

Inputs: starting_on (required), ending_before (required), workspace, on_current_plan.

get_prompt_by_nameA

Get a specific prompt by its exact name.

Args: prompt_name (str): The exact name of the prompt to retrieve

Returns: Dict containing the prompt details and template, or an error message

Inputs: prompt_name (required).

get_thread_historyA

Retrieve one page of message history for a specific conversation thread.

Uses char-based pagination: pages are built by character budget (max_chars_per_page). Long strings are truncated to preview_chars. Supply page_number (1-based) on every call; use the returned total_pages to request further pages.

Args: thread_id (str): The unique ID of the thread to fetch history for project_name (str): The name of the project containing the thread page_number (int): 1-based page index (required) max_chars_per_page (int): Max character count per page, capped at 30000 (default: 25000) preview_chars (int): Truncate long strings to this length (default: 150)

Returns: Dict with result (list of messages), page_number, total_pages, etc.

Inputs: thread_id (required), page_number (required), project_name (required), preview_chars, +1 more.

list_datasetsA

Fetch LangSmith datasets.

If no arguments are provided, all datasets will be returned.

Args: dataset_ids (str, optional): Dataset IDs as JSON array string or single ID data_type (str, optional): Filter by dataset data type (e.g., 'chat', 'kv') dataset_name (str, optional): Filter by exact dataset name dataset_name_contains (str, optional): Filter by substring in dataset name metadata (str, optional): Filter by metadata as JSON object string limit (int): Max number of datasets to return (default: 20)

Inputs: limit, metadata, data_type, dataset_ids, +2 more.

list_examplesA

Fetch examples from a LangSmith dataset with advanced filtering options.

Either dataset_id, dataset_name, or example_ids must be provided.

Args: dataset_id (str, optional): Dataset ID to retrieve examples from dataset_name (str, optional): Dataset name to retrieve examples from example_ids (str, optional): Example IDs as JSON array string or single ID filter (str, optional): Filter string using LangSmith query syntax metadata (str, optional): Metadata filter as JSON object string splits (str, optional): Dataset splits as JSON array string or single split inline_s3_urls (str, optional): "true" or "false" include_attachments (str, optional): "true" or "false" as_of (str, optional): Dataset version tag or ISO timestamp limit (int): Max examples to return (default: 10) offset (str, optional): Number of examples to skip

Inputs: as_of, limit, filter, offset, +7 more.

list_experimentsA

List LangSmith experiment projects (reference projects) with mandatory dataset filtering.

Requires either reference_dataset_id or reference_dataset_name.

Args: reference_dataset_id (str, optional): Dataset ID to filter experiments by reference_dataset_name (str, optional): Dataset name to filter experiments by limit (int): Maximum number of experiments to return (default: 5) project_name (str, optional): Filter by name (partial match)

Inputs: limit, project_name, reference_dataset_id, reference_dataset_name.

list_projectsB

List LangSmith projects with optional filtering and detail level control.

Args: limit (int): Maximum number of projects to return (default: 5) project_name (str, optional): Filter projects by name (partial match) more_info (str): "true" for full details, "false" for simplified (default: "false") reference_dataset_id (str, optional): Filter by reference dataset ID reference_dataset_name (str, optional): Filter by reference dataset name

Inputs: limit, more_info, project_name, reference_dataset_id, +1 more.

list_promptsB

Fetch prompts from LangSmith with optional filtering.

Args: is_public (str): Filter by prompt visibility - "true" for public prompts, "false" for private prompts (default: "false") limit (int): Maximum number of prompts to return (default: 20)

Returns: Dict with prompts and metadata

Inputs: limit, is_public.

push_promptA

Call this tool when you need to understand how to create and push prompts to LangSmith.

This is a documentation-only tool that explains how to:

  • Create prompts using LangChain's prompt templates

  • Push prompts to LangSmith for version control and management

  • Handle prompt creation vs. version updates

Use the LangSmith Client's push_prompt() method. See LangSmith documentation for details.

Inputs: no named parameters.

read_datasetA

Read a specific dataset from LangSmith.

Either dataset_id or dataset_name must be provided.

Args: dataset_id (str, optional): Dataset ID to retrieve dataset_name (str, optional): Dataset name to retrieve

Inputs: dataset_id, dataset_name.

read_exampleA

Read a specific example from LangSmith.

Args: example_id (str): Example ID to retrieve as_of (str, optional): Dataset version tag or ISO timestamp

Inputs: example_id (required), as_of.

run_experimentA

Call this tool when you need to understand how to run experiments and evaluations in LangSmith. This is a documentation-only tool.

Inputs: no named parameters.

update_examplesA

Call this tool when you need to understand how to update dataset examples in LangSmith. This is a documentation-only tool.

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 15 tools

    Disambiguation4/5

    Most tools have distinct purposes (list vs. get vs. read vs. fetch), but some pairs like list_prompts/get_prompt_by_name and list_datasets/read_dataset could be confused without carefully reading descriptions. The documentation-only tools (push_prompt, create_dataset, etc.) are clearly different in role but still add a bit of ambiguity.

    Naming Consistency3/5

    Tool names use a consistent snake_case verb_noun pattern, but the verbs are not uniform: list_*, get_*, fetch_*, read_* are used interchangeably (e.g., list_projects vs. fetch_runs, get_prompt_by_name vs. read_dataset). This mixed style is readable but not fully consistent.

    Tool Count4/5

    15 tools is at the upper boundary of the recommended range. The count is reasonable for a platform like LangSmith, but 4 of the tools are documentation-only, which reduces the effective functional tool count. Still, the scope is not excessive.

    Completeness2/5

    The tool surface is heavily read-oriented: prompts, runs, projects, datasets, examples are mostly list/get/fetch. Write operations like creating datasets or running experiments are only documentation tools, not actual operations. Missing update/delete for prompts and datasets, and no way to create examples. Significant gaps for workflow completion.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      C
      quality
      A
      maintenance
      MCP server for Langfuse observability. Query traces, debug exceptions, analyze sessions, and manage prompts and datasets for your LLM applications.
      48
      2,574 PyPI
      112
      MIT
    • F
      license
      A
      quality
      D
      maintenance
      A TypeScript MCP server for launching, tracking, and managing external coding-agent runs across local and remote backends like Codex and Claude Code. It allows top-level agents to orchestrate subagents through tools for spawning tasks, polling events, and handling interactive sessions.
      7
      2
      -
    • A
      license
      A
      quality
      C
      maintenance
      Comprehensive MCP server for Langfuse, enabling AI assistants to access and manage traces, observations, scores, datasets, and sessions for observability.
      24
      10 npm
      1
      MIT