使用说明
LangSmith MCP 服务器
基于FastMCP的MCP服务器暴露(或发布) LangSmith 无需额外安装工具即可查询现有追踪记录(运行、子项、URL)的只读工具。
工具
ls_list_runs(project_name, is_root=True, limit=50, select?)— 列出最近的运行记录并应用过滤条件ls_read_run(run_id, hydrate_children=False, child_limit=100)— 读取单次运行,可选包含子项ls_get_run_url(run_id)— 生成可共享的LangSmith URLls_list_children(parent_run_id, limit=100)— 列出父运行(run)的子区间(span)
要求
- Python 3.10+
LANGSMITH_API_KEY在你的环境中- 可选:
LANGSMITH_ENDPOINT用于本地部署
快速入门
# Clone and setup
git clone <repo-url>
cd langsmith-mcp-server
# Install dependencies (uv manages environment automatically)
uv sync
export LANGSMITH_API_KEY="lsv2_pt_..."
# Run smoke test
uv run python tests/smoke_test.py
# Run unit tests
uv run pytest tests/test_server.py -v
以MCP服务器身份运行
本地开发
推荐 (使用 fastmcp.json (用于配置):
# FastMCP auto-detects fastmcp.json in current directory
fastmcp run
# Or via uv
uv run fastmcp run fastmcp.json
备选方案 (直接使用Python):
uv run python src/server.py
FastMCP 云部署
免费部署到FastMCP云进行托管:
- 推送到GitHub:
don-aie-cohort8/langsmith-mcp-server - 登录到 https://fastmcp.cloud
- 创建新项目:
- 仓库(或存储库):
don-aie-cohort8/langsmith-mcp-server - 分支:
main - 入口点:
src/server.py:app
- 仓库(或存储库):
- 添加环境变量:
LANGSMITH_API_KEY - 部署!
每次向主分支推送时自动部署。
MCP客户端配置
本地开发
在您的MCP客户端配置(如Claude Desktop、Claude Code等)中添加:
{
"mcpServers": {
"langsmith-local": {
"command": "uv",
"args": [
"run",
"--with", "fastmcp",
"fastmcp",
"run",
"/absolute/path/to/langsmith-mcp-server/src/server.py:app"
]
}
}
}
注替换 /absolute/path/to/langsmith-mcp-server 使用您实际的项目路径。
为什么是这个模式?
- 用途
uv run --with fastmcp根据FastMCP的官方建议 - 创建具有清晰依赖管理的隔离环境
- 避免对全局的依赖
fastmcp安装 - 从(某处)拉取的运行时依赖
pyproject.toml通过可编辑安装方式 - 在MCP配置中无需列出所有依赖项
FastMCP Cloud(可译为“FastMCP云平台”或“FastMCP云端服务”,具体根据上下文确定更贴切的表述)
对于云部署:
{
"mcpServers": {
"langsmith-cloud": {
"url": "https://langsmith-mcp-server.fastmcp.app/mcp"
}
}
}
项目结构
遵循FastMCP和Python的最佳实践:
langsmith-mcp-server/
├── src/
│ └── server.py # MCP server implementation (~190 lines)
├── tests/
│ ├── smoke_test.py # Startup validation
│ ├── test_server.py # Unit tests
│ ├── test_integration.py # Integration tests
│ └── README.md # Testing documentation
├── scripts/
│ ├── integration_demo.py # Demo script for testing tools
│ └── claude-agent-sdk-testing/ # Claude Agent SDK integration
├── docs/
│ ├── PRODUCTION_READINESS.md # Production deployment guide
│ ├── MCP_FIX_REPORT.md # Historical fix documentation
│ ├── SERIALIZATION_FIX.md # Pydantic compatibility fixes
│ └── TESTING_REPORT.md # Testing results
├── notebooks/ # Jupyter notebooks for exploration
├── fastmcp.json # Deployment configuration
├── pyproject.toml # Package metadata and dependencies
└── README.md # This file
依赖管理
此项目采用双文件方式处理依赖项:
- `pyproject.toml` 翻译成中文是:`pyproject 配置文件(toml 格式)` 或简称为 `pyproject.toml 文件`。这个文件通常用于配置 Python 项目的构建和打包信息定义了所有Python依赖项(运行时+开发时)
- fastmcp.json 翻译为中文是:“fastmcp.json 文件” 或者简化为 “fastmcp配置文件”(如果上下文明确这是一个配置文件的话)。不过,通常“fastmcp.json”这样的名称直接翻译可能不具有明确的中文意义,因为它是一个特定命名的文件,可能代表某个特定软件或系统中的配置文件、数据文件等。在没有具体上下文的情况下,直接翻译其名称可能不够准确,但上述翻译提供了一种通用的表述方式通过引用 pyproject.toml 的部署配置
"editable": ["."]
当你跑步时 uv sync依赖项从 `pyproject.toml` 中安装。FastMCP 会自动通过可编辑安装方式加载它们。
使用提示
- 使用
select=["id","name","error","extra"]用于最小有效载荷 - LangGraph 自动插桩配置出现在以下位置
run.extra(例如。,graph_id,thread_id,research_model) - 所有工具都是 只读 按设计(无创建/更新/删除操作)
参考文献
客户:
服务器: