somark_mcp

SoMark/somark_mcp
Hosted
4 Stars 23 次浏览 更新于 2026-08-23

一个用于SoMark文档解析API的模型上下文协议(MCP)服务器。它能够以高精度将PDF和图像文件解析为Markdown和JSON格式。

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

{
  "mcpServers": {
    "somark": {
      "args": [
        "-y",
        "somark-mcp"
      ],
      "command": "npx",
      "env": {
        "SOMARK_API_BASE_URL": "https://somark.cn/api/v1",
        "SOMARK_API_KEY": "your-api-key-here"
      }
    }
  }
}

该服务需要配置环境变量:SOMARK_API_BASE_URL、SOMARK_API_KEY

可用工具 (3 个)

该服务在 MCP 协议中暴露的工具,AI 可按需调用

check_api_key

Check if Somark API key is configured. Use this before calling extract_document.

该工具无需必填参数,直接调用即可

set_api_key 1 个参数 需填 1 项

Configure your Somark API key for document parsing. Get your API key from https://somark.tech

必填参数:api_key

extract_document 4 个参数 需填 1 项

Parse PDF or image files (PNG, JPG, JPEG, BMP, TIFF, JP2, DIB, PPM, PGM, PBM, GIF, HEIC, HEIF, WebP, XPM, TGA, DDS, XBM) to markdown or JSON format using Somark's document parsing API

必填参数:file_path

服务介绍

SoMark MCP Server

English | 中文

A Model Context Protocol (MCP) server for SoMark's document parsing API. It parses PDF and image files into Markdown, JSON format with high accuracy.

Quick Start

1. Get your API Key

2. Add the following to your MCP client configuration (Claude Desktop, VS Code, Cursor, etc.):

{
    "mcpServers": {
        "somark": {
            "command": "npx",
            "args": ["-y", "somark-mcp"],
            "env": {
                "SOMARK_API_KEY": "your-api-key-here",
                "SOMARK_API_BASE_URL": "https://somark.cn/api/v1"
            }
        }
    }
}

3. Done! Ask your AI assistant to parse any PDF or image file.

API Base URL Configuration

Set the SOMARK_API_BASE_URL environment variable to choose the server region:

Region SOMARK_API_BASE_URL
Mainland China (default) https://somark.cn/api/v1
Outside mainland China (including Taiwan, China; Hong Kong, China; Macau, China) https://somark.ai/api/v1

The server automatically derives the web, docs, and purchase URLs from SOMARK_API_BASE_URL:

Domain API Base Web Docs Purchase
somark.cn https://somark.cn/api/v1 https://somark.cn https://docs.somark.cn somark.cn/workbench/purchase
somark.ai https://somark.ai/api/v1 https://somark.ai https://docs.somark.ai somark.ai/studio/purchase

Available Tools

check_api_key

Check whether the SoMark API key is configured and ready to use.

set_api_key

Set or update the SoMark API key at runtime (useful when the environment variable is not set).

Parameter Type Required Description
api_key string Yes Your SoMark API key from somark.cn (mainland China) or somark.ai (outside mainland China, including Taiwan, China; Hong Kong, China; Macau, China)

extract_document

Parse PDF or image files (PNG, JPG, JPEG, BMP, TIFF, JP2, DIB, PPM, PGM, PBM, GIF, HEIC, HEIF, WebP, XPM, TGA, DDS, XBM) into markdown, json format.

Parameter Type Required Default Description
file_path string Yes Absolute path to the PDF or image file
output_formats Array<"json" | "markdown"> No ["json", "markdown"] Output formats. Allowed values: json, markdown. Duplicate values are not allowed.
element_formats object No See below Element rendering formats.
feature_config object No See below Extraction options.

element_formats fields:

  • image: "url" | "base64" | "none", default url
  • formula: "latex" | "mathml" | "ascii", default latex
  • table: "html" | "markdown" | "image", default html
  • cs: "image", default image

feature_config fields:

  • enable_text_cross_page: boolean, default false
  • enable_table_cross_page: boolean, default false
  • enable_title_level_recognition: boolean, default false
  • enable_inline_image: boolean, default true
  • enable_table_image: boolean, default true
  • enable_image_understanding: boolean, default true
  • keep_header_footer: boolean, default false

Supported file formats:

  • PDF (.pdf)
  • PNG (.png)
  • JPEG (.jpg, .jpeg)
  • BMP (.bmp, .dib)
  • TIFF (.tiff, .tif)
  • JPEG 2000 (.jp2)
  • Portable Pixmap (.ppm)
  • Portable Graymap (.pgm)
  • Portable Bitmap (.pbm)
  • GIF (.gif)
  • HEIC (.heic)
  • HEIF (.heif)
  • WebP (.webp)
  • X PixMap (.xpm)
  • Targa (.tga)
  • DirectDraw Surface (.dds)
  • X BitMap (.xbm)

Example usage:

// 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"]
}

Development

pnpm install          # Install dependencies
pnpm build            # Build the project
pnpm exec tsc --noEmit  # Type check

Testing

pnpm test             # Full MCP server test
pnpm test:api         # API connection test

Troubleshooting

Problem Solution
"API key not configured" Add SOMARK_API_KEY to your MCP client config, or use the set_api_key tool
Connection issues Check that your API key is valid and somark.cn / somark.ai (depending on region) is accessible. Set SOMARK_API_BASE_URL=https://somark.ai/api/v1 for outside mainland China (including Taiwan, China; Hong Kong, China; Macau, China).
Unsupported file format Supports PDF, PNG, JPG, JPEG, BMP, TIFF, JP2, DIB, PPM, PGM, PBM, GIF, HEIC, HEIF, WebP, XPM, TGA, DDS, XBM formats

License

ISC

相关 MCP 服务