SoMark MCP服务器
A. 模型上下文协议(MCP) 服务器 SoMark的文档解析API。它将PDF和图像文件解析为Markdown、JSON格式,精度很高。
快速开始
1.获取API密钥 → somark.tech/workbench/apikey
2.将以下内容添加到MCP客户端配置中 (克劳德桌面、VS代码、光标等):
{
"mcpServers": {
"somark": {
"command": "npx",
"args": ["-y", "somark-mcp"],
"env": {
"SOMARK_API_KEY": "your-api-key-here"
}
}
}
}3.完成! 让你的AI助手解析任何PDF或图像文件。
可用工具
check_api_key
检查SoMark API密钥是否已配置并准备好使用。
set_api_key
在运行时设置或更新SoMark API密钥(在未设置环境变量时很有用)。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
api_key | string | 是 | 您的SoMark API密钥来自 索马克科技 |
extract_document
将PDF或图像文件(PNG、JPG、JPEG、BMP、TIFF、JP2、DIB、PPM、PGM、PBM、GIF、HEIC、HEIF、WebP、XPM、TGA、DDS、XBM)解析为 markdown, json 格式。
| 参数 | 类型 | 必填 | 默认 | 说明 |
|---|---|---|---|---|
file_path | string | 是 | -- | PDF或图像文件的绝对路径 |
output_formats | Array | 否 | \[“json”、“markdown”\] | 输出格式。允许值: json, markdown。不允许重复值。 |
element_formats | object | 否 | 见下文 | 元素渲染格式。 |
feature_config | object | 否 | 见下文 | 提取选项。 |
element_formats 领域:
image:"url" | "base64" | "none",默认值urlformula:"latex" | "mathml" | "ascii",默认值latextable:"html" | "markdown" | "image",默认值htmlcs:"image",默认值image
feature_config 领域:
enable_text_cross_page:boolean,默认值falseenable_table_cross_page:boolean,默认值falseenable_title_level_recognition:boolean,默认值falseenable_inline_image:boolean,默认值trueenable_table_image:boolean,默认值trueenable_image_understanding:boolean,默认值truekeep_header_footer:boolean,默认值false
支持的文件格式:
- PDF(
.pdf) - PNG(
.png) - JPEG(
.jpg,.jpeg) - BMP(
.bmp,.dib) - TIFF(
.tiff,.tif) - JPEG 2000(
.jp2) - 便携式Pixmap(
.ppm) - 便携式灰色地图(
.pgm) - 便携式位图(
.pbm) - GIF(
.gif) - HEIC(
.heic) - 嘿(
.heif) - WebP(
.webp) - X像素地图(
.xpm) - 塔尔加(
.tga) - DirectDraw表面(
.dds) - X位图(
.xbm)
示例用法:
// Parse a PDF to Markdown
{
"file_path": "/path/to/document.pdf",
"output_formats": ["markdown"]
}
// Parse an image to JSON
{
"file_path": "/path/to/image.png",
"output_formats": ["json"]
}发展
pnpm install # Install dependencies
pnpm build # Build the project
pnpm exec tsc --noEmit # Type check测试
pnpm test # Full MCP server test
pnpm test:api # API connection test故障排除
| 问题 | 解决方案 |
|---|---|
| “未配置API密钥” | 添加 SOMARK_API_KEY 到您的MCP客户端配置,或使用 set_api_key 工具 |
| 连接问题 | 检查您的API密钥是否有效 索马克科技 可访问 |
| 不支持的文件格式 | 支持PDF、PNG、JPG、JPEG、BMP、TIFF、JP2、DIB、PPM、PGM、PBM、GIF、HEIC、HEIF、WebP、XPM、TGA、DDS、XBM格式 |
许可证
国际学生委员会
