使用说明
🔍 LangExtract MCP 服务器
使用LangExtract和Gemini AI的结构化数据提取MCP服务器。
🎯 功能
8款强大工具:
extract_structured_data- 从文本中提取主要内容extract_from_url- 直接从URL提取save_results_to_jsonl- 将结果保存为JSONL格式generate_visualization- 创建交互式HTML可视化list_stored_results- 列出所有提取结果get_extraction_details- 获取详细的提取信息create_example_template- 生成示例模板get_supported_models- 列出可用模型
🚀 部署到FastMCP云
1. 获取Gemini API密钥
访问:https://aistudio.google.com/app/apikey
点击“创建API密钥”并复制它。
2. 在FastMCP上部署
- 访问 https://fastmcp.com/dashboard
- 使用GitHub登录
- 点击“创建新项目”
- 选择此存储库
- 配置:
- 服务器文件:
server.py - 环境变量:
- 名字:
LANGEXTRACT_API_KEY - 值:(粘贴您的Gemini API密钥)
- 名字:
- 服务器文件:
- 点击“部署”
- 复制您的部署URL:
https://your-project.fastmcp.cloud
3. 配置Claude桌面版
Windows: %APPDATA%\Claude\claude_desktop_config.json
Mac: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
加上这个:
{
"mcpServers": {
"langextract": {
"url": "https://your-project.fastmcp.cloud"
}
}
}
替换 your-project.fastmcp.cloud 使用您实际的网址。
重启Claude桌面版 保存后。
💡 快速使用示例
在Claude Desktop中,尝试:
Extract people and medications from this text:
"Dr. Sarah Johnson prescribed 50mg aspirin to patient John Doe."
Use extract_structured_data with examples:
- Person: "Dr. Smith" with role="doctor"
- Medication: "aspirin" with dosage="50mg"
📊 示例格式
{
"text": "Dr. Smith prescribed 50mg aspirin.",
"extractions": [
{
"extraction_class": "person",
"extraction_text": "Dr. Smith",
"attributes": {"role": "doctor"}
},
{
"extraction_class": "medication",
"extraction_text": "aspirin",
"attributes": {"dosage": "50mg"}
}
]
}
🔧 高级参数
更高的召回率(更准确)
extraction_passes=3
max_workers=10
max_char_buffer=2000
更快的处理速度
extraction_passes=1
max_workers=20
max_char_buffer=8000
🏠 本地开发
# Install
pip install -r requirements.txt
# Set API key
export LANGEXTRACT_API_KEY="your-key"
# Run server
fastmcp run server.py
# Test in another terminal
fastmcp client server.py
📚 资源
- **LangExtract(可译为“语言提取工具”或根据具体上下文调整为更贴切的名称,如“语言抽取器”等)**https://github.com/google/langextract 的中文翻译是:“https://github.com 上的 google 项目 langextract” 或者简化为 “GitHub 上 google 的 langextract 项目”
- FastMCPhttps://gofastmcp.com(该网址可直接翻译为中文,但网址本身不改变,故保持原样)
- Gemini APIhttps://ai.google.dev/gemini-api/docs(中文可译为):谷歌AI开发平台Gemini API文档
- 获取API密钥https://aistudio.google.com/app/apikey(这个网址的中文翻译可以保持原样,因为它是一个网址链接,直接翻译没有实际意义,但为了符合中文语境,可以简单表述为:“谷歌AI Studio的API密钥页面链接”。不过,通常我们还是会直接使用原网址链接。)
🐛 故障排除
服务器无响应?
- 检查FastMCP Cloud日志
- 验证
LANGEXTRACT_API_KEY被设定 - 确保服务器文件是
server.py
克劳德无法连接?
- 验证配置中的URL是否正确(必须以https://开头)
- 配置更改后重启Claude桌面版
- 检查配置JSON语法是否有效
提取错误?
- 验证API密钥是否有效
- 检查示例是否格式正确
- 使用
create_example_template以寻求帮助
📄 许可证
麻省理工学院(MIT)