# langchain-ai/langsmith-mcp-server architecture

> Architecture diagram of the GitHub repository langchain-ai/langsmith-mcp-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/langchain-ai/langsmith-mcp-server
- Repository: https://github.com/langchain-ai/langsmith-mcp-server

## Overview

LangSmith MCP Server exposes LangSmith observability and management capabilities to MCP clients. A client request enters the MCP server, whose registered tools obtain request credentials and call domain handlers; handlers query LangSmith and return results, with optional character-budget pagination for thread history and trace runs. The README also documents prompt, dataset, experiment, and billing capabilities. The graph follows shown registration and call references; unsampled implementation details and some indirect runtime wiring are omitted.

Main entry points: [`langsmith_mcp_server/services/register_tools.py`](https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/services/register_tools.py) (Tool registration), [`langsmith_mcp_server/server.py`](https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/server.py) (MCP server), [`langsmith_mcp_server/services/tools/traces.py`](https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/services/tools/traces.py) (Traces and threads), [`langsmith_mcp_server/services/tools/datasets.py`](https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/services/tools/datasets.py) (Datasets and examples)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["MCP Entry"]
  node_server["MCP server<br/>[server.py]"]
  node_auth["API-key middleware<br/>[middleware.py]"]
  node_registration["Tool registration<br/>[register_tools.py]"]
end

subgraph group_domain["LangSmith Capabilities"]
  node_traces["Traces and threads<br/>[traces.py]"]
  node_datasets["Datasets and examples<br/>[datasets.py]"]
  node_experiments["Experiments<br/>[experiments.py]"]
  node_prompts["Prompt management<br/>[prompts.py]"]
  node_usage["Billing usage<br/>[usage.py]"]
end

subgraph group_shared["Shared Services"]
  node_helpers["Client and formatting helpers<br/>[helpers.py]"]
  node_pagination["Character pagination<br/>[pagination.py]"]
  node_monitoring["Optional monitoring<br/>[monitoring.py]"]
end

subgraph group_external["External Systems"]
  node_langsmith[("LangSmith platform")]
end

node_client(("MCP client"))

node_client -->|"sends MCP requests"| node_server
node_server -->|"configures middleware"| node_auth
node_server -->|"registers tools"| node_registration
node_registration -->|"dispatches trace tools"| node_traces
node_registration -->|"dispatches dataset tools"| node_datasets
node_registration -->|"dispatches experiment tools"| node_experiments
node_registration -->|"dispatches prompt tools"| node_prompts
node_registration -->|"dispatches usage tools"| node_usage
node_registration -->|"gets client"| node_helpers
node_registration -->|"traces tool calls"| node_monitoring
node_traces -->|"queries runs"| node_langsmith
node_datasets -->|"queries datasets"| node_langsmith
node_experiments -->|"lists projects"| node_langsmith
node_usage -->|"requests billing API"| node_langsmith
node_traces -->|"paginates results"| node_pagination
node_datasets -->|"parses versions"| node_helpers
node_experiments -->|"finds nested fields"| node_helpers
node_auth -->|"sets session context"| node_monitoring
node_prompts -.->|"manages prompts"| node_langsmith

click node_server "https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/server.py"
click node_auth "https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/middleware.py"
click node_registration "https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/services/register_tools.py"
click node_traces "https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/services/tools/traces.py"
click node_datasets "https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/services/tools/datasets.py"
click node_experiments "https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/services/tools/experiments.py"
click node_prompts "https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/services/tools/prompts.py"
click node_usage "https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/services/tools/usage.py"
click node_helpers "https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/common/helpers.py"
click node_pagination "https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/common/pagination.py"
click node_monitoring "https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/monitoring.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_auth,node_registration,node_client toneBlue
class node_traces,node_datasets,node_experiments,node_prompts,node_usage toneAmber
class node_helpers,node_pagination,node_monitoring toneMint
class node_langsmith toneRose
```

## Components

### MCP Entry

- [MCP server](https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/server.py): `langsmith_mcp_server/server.py`
- [API-key middleware](https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/middleware.py): `langsmith_mcp_server/middleware.py`
- [Tool registration](https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/services/register_tools.py): `langsmith_mcp_server/services/register_tools.py`

### LangSmith Capabilities

- [Traces and threads](https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/services/tools/traces.py): `langsmith_mcp_server/services/tools/traces.py`
- [Datasets and examples](https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/services/tools/datasets.py): `langsmith_mcp_server/services/tools/datasets.py`
- [Experiments](https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/services/tools/experiments.py): `langsmith_mcp_server/services/tools/experiments.py`
- [Prompt management](https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/services/tools/prompts.py): `langsmith_mcp_server/services/tools/prompts.py`
- [Billing usage](https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/services/tools/usage.py): `langsmith_mcp_server/services/tools/usage.py`

### Shared Services

- [Client and formatting helpers](https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/common/helpers.py): `langsmith_mcp_server/common/helpers.py`
- [Character pagination](https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/common/pagination.py): `langsmith_mcp_server/common/pagination.py`
- [Optional monitoring](https://github.com/langchain-ai/langsmith-mcp-server/blob/main/langsmith_mcp_server/monitoring.py): `langsmith_mcp_server/monitoring.py`

### External Systems

- **LangSmith platform**

### Other components

- **MCP client**

## Connections

- MCP client → MCP server: sends MCP requests (evidence: `README.md`)
- MCP server → API-key middleware: configures middleware (evidence: `langsmith_mcp_server/server.py`)
- MCP server → Tool registration: registers tools (evidence: `langsmith_mcp_server/server.py`)
- Tool registration → Traces and threads: dispatches trace tools (evidence: `langsmith_mcp_server/services/register_tools.py`)
- Tool registration → Datasets and examples: dispatches dataset tools (evidence: `langsmith_mcp_server/services/register_tools.py`)
- Tool registration → Experiments: dispatches experiment tools (evidence: `langsmith_mcp_server/services/register_tools.py`)
- Tool registration → Prompt management: dispatches prompt tools (evidence: `langsmith_mcp_server/services/register_tools.py`)
- Tool registration → Billing usage: dispatches usage tools (evidence: `langsmith_mcp_server/services/register_tools.py`)
- Tool registration → Client and formatting helpers: gets client (evidence: `langsmith_mcp_server/services/register_tools.py`)
- Tool registration → Optional monitoring: traces tool calls (evidence: `langsmith_mcp_server/services/register_tools.py`)
- Traces and threads → LangSmith platform: queries runs (evidence: `langsmith_mcp_server/services/tools/traces.py`)
- Datasets and examples → LangSmith platform: queries datasets (evidence: `langsmith_mcp_server/services/tools/datasets.py`)
- Experiments → LangSmith platform: lists projects (evidence: `langsmith_mcp_server/services/tools/experiments.py`)
- Billing usage → LangSmith platform: requests billing API (evidence: `langsmith_mcp_server/services/tools/usage.py`)
- Traces and threads → Character pagination: paginates results (evidence: `langsmith_mcp_server/services/tools/traces.py`)
- Datasets and examples → Client and formatting helpers: parses versions (evidence: `langsmith_mcp_server/services/tools/datasets.py`)
- Experiments → Client and formatting helpers: finds nested fields (evidence: `langsmith_mcp_server/services/tools/experiments.py`)
- API-key middleware → Optional monitoring: sets session context (evidence: `langsmith_mcp_server/middleware.py`)
- Prompt management → LangSmith platform: manages prompts (evidence: `README.md`)
