LandingAI ADE MCP服务器
一种模型上下文协议(MCP)服务器,提供与LandingAI的代理文档提取(ADE)API的直接集成。从PDF、图像和office文档中提取文本、表格和结构化数据。
特性
- 📄 文档分析 -解析整个文档并返回markdown输出
- 🔍 数据提取 -使用JSON模式提取结构化数据
- ⚡ 解析作业 -通过后台处理处理大型文档
- 🛡️ 零数据保留 -以隐私为重点的处理支持
安装
先决条件
- Python 3.9或更高版本
- LandingAI API密钥来自 登陆AI
选项1:使用紫外线(推荐-最简单)
紫外线 是一个快速的Python包管理器,可以自动处理虚拟环境。
安装uv(如果尚未安装)
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Or with Homebrew
brew install uv立项
# Clone the repository
git clone https://github.com/avaxia8/landingai-ade-mcp.git
cd landingai-ade-mcp
# Install dependencies with uv
uv sync
# Or if starting fresh:
uv init
uv add fastmcp httpx pydantic python-multipart aiofiles选项2:在虚拟环境中使用pip
# Clone the repository
git clone https://github.com/avaxia8/landingai-ade-mcp.git
cd landingai-ade-mcp
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
# On macOS/Linux:
source venv/bin/activate
# On Windows:
venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt配置
设置API密钥
export LANDINGAI_API_KEY="your-api-key-here"Claude桌面配置
配置文件位置
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Linux:
~/.config/claude/claude_desktop_config.json - 视窗:
%APPDATA%\Claude\claude_desktop_config.json
配置示例
使用紫外线(推荐)
{
"mcpServers": {
"landingai-ade-mcp": {
"command": "uv",
"args": [
"--directory",
"/path/to/landingai-ade-mcp",
"run",
"python",
"-m",
"server"
],
"env": {
"LANDINGAI_API_KEY": "your-api-key-here"
}
}
}
}使用虚拟环境
{
"mcpServers": {
"landingai-ade-mcp": {
"command": "/path/to/landingai-ade-mcp/venv/bin/python",
"args": [
"/path/to/landingai-ade-mcp/server.py"
],
"env": {
"LANDINGAI_API_KEY": "your-api-key-here"
}
}
}
}配置后
- 保存配置文件
- 完全重新启动克劳德桌面 (退出并重新打开)
- 服务器在mcp服务器中应显示为“landingai ade mcp”
可用工具
parse_document
解析整个文档并返回markdown输出。
# Parse a local file
result = await parse_document(
document_path="/path/to/document.pdf",
model="dpt-2-latest", # optional
split="page" # optional, for page-level splits
)
# Parse from URL
result = await parse_document(
document_url="https://example.com/document.pdf"
)extract_data
使用JSON模式从markdown中提取结构化数据。
schema = {
"type": "object",
"properties": {
"invoice_number": {"type": "string"},
"total": {"type": "number"}
}
}
# Extract from markdown content string
result = await extract_data(
schema=schema,
markdown="# Invoice\nInvoice #123\nTotal: $100.00"
)
# Or extract from a markdown file
result = await extract_data(
schema=schema,
markdown="/path/to/document.md" # Will detect if it's a file path
)
# Or extract from URL
result = await extract_data(
schema=schema,
markdown_url="https://example.com/document.md"
)create_parse_job
为大型文档创建解析作业(建议>50MB)。
job = await create_parse_job(
document_path="/path/to/large_document.pdf",
split="page" # optional
)
job_id = job["job_id"]get_parse_job_status
检查解析作业的状态并检索结果。
status = await get_parse_job_status(job_id)
# Check status
if status["status"] == "completed":
# For small files, data is included directly
# For large files (>1MB), data is auto-fetched from output_url
results = status["data"]
elif status["status"] == "processing":
print(f"Progress: {status['progress'] * 100:.1f}%")list_parse_jobs
列出所有具有过滤和分页功能的解析作业。
jobs = await list_parse_jobs(
page=0, # optional, default 0
pageSize=10, # optional, 1-100, default 10
status="completed" # optional filter
)process_folder
处理文件夹中所有支持的文件-解析文档或提取结构化数据。
支持的格式:
- 图像:APNG、BMP、DCX、DDS、DIB、GD、GIF、ICNS、JP2、JPEG、JPG、PCX、PNG、PPM、PSD、TGA、TIFF、WEBP
- 文档:PDF、DOC、DOCX、PPT、PPTX、ODP、ODT
# Parse all PDFs in a folder
result = await process_folder(
folder_path="/path/to/documents",
operation="parse", # or "extract" for structured data
file_types="pdf", # optional filter
model="dpt-2-latest"
)
# Extract structured data from all documents
schema = {
"type": "object",
"properties": {
"invoice_number": {"type": "string"},
"total": {"type": "number"},
"date": {"type": "string"}
}
}
result = await process_folder(
folder_path="/path/to/invoices",
operation="extract",
schema=schema,
file_types="pdf,jpg" # Process PDFs and images
)
# Process everything with defaults
result = await process_folder(
folder_path="/path/to/mixed_documents"
)特征:
- 自动文件大小检测(对\50MB**:始终使用
create_parse_job
错误处理
result = await parse_document(document_path="/path/to/file.pdf")
if result.get("status") == "error":
print(f"Error: {result['error']}")
print(f"Status Code: {result.get('status_code')}")
else:
# Process successful result
markdown = result["markdown"]常见错误代码
401:API密钥无效413:文件太大(使用解析作业)422:验证错误429:超出费率限制
故障排除
常见问题及解决方法
“无法连接到MCP服务器”
- 未找到Python:确保配置中的Python路径正确
# Find your Python path
which python3- 未找到模块错误:Python环境中未安装依赖项
- 如果使用uv:运行 uv sync 在项目目录中 - 如果使用venv:激活它并运行 pip install -r requirements.txt - 检查配置中的Python路径是否与您的环境匹配
- 生成python ENOONT:系统找不到Python
- 使用Python的完整路径(例如。, /usr/bin/python3 而不仅仅是 python) - 对于虚拟环境,请使用venv Python的完整路径
“服务器已断开连接”
- 检查服务器是否可以手动运行:
cd /path/to/landingai-ade-mcp
python server.py
# Should see: "Starting LandingAI ADE MCP Server"- 检查是否设置了API密钥:
echo $LANDINGAI_API_KEY- 检查是否安装了依赖项:
python -c "import fastmcp, httpx, pydantic"
# Should complete without errors“ModuleNotFoundError:没有名为'fastmcp'的模块”
这意味着fastmcp没有安装在正在使用的Python环境中:
- 如果使用虚拟环境:配置指向错误的Python
- 解决方案:使用uv或确保Python路径与您的环境匹配
平台特定问题
macOS:如果你在Homebrew中安装了Python,路径可能是 /opt/homebrew/bin/python3 (苹果硅)或 /usr/local/bin/python3 (英特尔)
视窗:在路径中使用正斜杠或转义反斜杠: C:/path/to/python.exe 或 C:\\path\\to\\python.exe
Linux:某些系统使用 python3 而不是 python。始终使用 python3 为了清楚起见。
调试步骤
- 独立测试服务器:
python server.py- 检查MCP通信:
echo '{"jsonrpc": "2.0", "method": "initialize", "id": 1}' | python server.py- 验证配置:
- 打开Claude Desktop开发人员设置 - 检查日志中的特定错误消息 - 确保所有路径都是绝对的,而不是相对的
- 验证API密钥:
python -c "import os; print('API Key set:', bool(os.environ.get('LANDINGAI_API_KEY')))"