xiaotonng/lc2mcp 是从 https://github.com/xiaotonng/lc2mcp. 导入的 MCP 服务器候选
概览
xiaotonng/lc2mcp 是从 https://github.com/xiaotonng/lc2mcp. 导入的 MCP 服务器候选
概述(AI 翻译)
只需一行代码即可将LangChain工具转换为FastMCP工具。
别再重写你的工具了。只要调整它们就行。
lc2mcp 是一款轻量级适配器,可将现有的 LangChain 工具转换为 FastMCP 工具,使您能够快速构建对 Claude、Cursor 及任何兼容 MCP 客户端可访问的 MCP 服务器。
✨ 特色
| 特色 | 描述 |
|---|---|
| 🔄 即时转换 | 一个函数调用即可将任何LangChain工具转换为FastMCP工具 |
| 📦 生态系统访问 | 解锁1000+ LangChain社区工具(搜索、维基百科、SQL、APIs…) |
| 🎯 零样板 | 自动 Pydantic → JSON 模式转换 |
| 🔐 上下文注入 | 传递授权、用户信息并请求上下文给工具 |
| 📊 进度与日志 | 对MCP进度通知和日志的全面支持 |
| 🏷️ 命名空间支持 | 前缀工具名称和处理冲突自动 |
🚀 快速启动
安装
3 向MCP的线路
你的工具现在对Claude、光标以及任何MCP客户端开放。
工具参数描述
要在MCP工具模式中包含参数描述,你有两个选项:
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
lc2mcp
Convert LangChain tools to FastMCP tools — in one line of code.
Stop rewriting your tools. Just adapt them.
lc2mcp is a lightweight adapter that converts existing LangChain tools into FastMCP tools, enabling you to quickly build MCP servers accessible to Claude, Cursor, and any MCP-compatible client.
✨ Features
| Feature | Description |
|---|---|
| 🔄 Instant Conversion | One function call to convert any LangChain tool to FastMCP tool |
| 📦 Ecosystem Access | Unlock 1000+ LangChain community tools (Search, Wikipedia, SQL, APIs…) |
| 🎯 Zero Boilerplate | Automatic Pydantic → JSON Schema conversion |
| 🔐 Context Injection | Pass auth, user info, and request context to tools |
| 📊 Progress & Logging | Full support for MCP progress notifications and logging |
| 🏷️ Namespace Support | Prefix tool names and handle conflicts automatically |
🚀 Quick Start
Installation
pip install lc2mcp
3 Lines to MCP
from langchain_core.tools import tool
from fastmcp import FastMCP
from lc2mcp import register_tools
@tool
def get_weather(city: str) -> str:
"""Get current weather for a city."""
return f"Sunny, 25°C in {city}"
mcp = FastMCP("weather-server")
register_tools(mcp, [get_weather]) # ← That's it!
if __name__ == "__main__":
mcp.run()
Your tool is now available to Claude, Cursor, and any MCP client.
Tool Parameter Descriptions
To include parameter descriptions in the MCP tool schema, you have two options:
Option 1: Use parse_docstring=True (Recommended for simplicity)
@tool(parse_docstring=True)
def get_weather(city: str, unit: str = "celsius") -> str:
"""Get current weather for a city.
Args:
city: The name of the city to query
unit: Temperature unit (celsius or fahrenheit)
"""
return f"Sunny, 25°C in {city}"
Option 2: Use args_schema (Recommended for complex types)
from pydantic import BaseModel, Field
class WeatherInput(BaseModel):
city: str = Field(description="The name of the city to query")
unit: str = Field(default="celsius", description="Temperature unit")
@tool(args_schema=WeatherInput)
def get_weather(city: str, unit: str = "celsius") -> str:
"""Get current weather for a city."""
return f"Sunny, 25°C in {city}"
Note: Without
parse_docstring=Trueorargs_schema, parameter descriptions from docstrings will not be extracted.
🔌 How It Works
┌─────────────────┐ ┌─────────────┐ ┌─────────────────┐
│ LangChain Tool │ ───▶ │ lc2mcp │ ───▶ │ FastMCP Tool │
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →