Skip to main content

SCNet Document Parser (Python / stdio MCP)

本地 stdio MCP 服务,封装 SCNet 文档 OCR 能力。
相对 Java SSE 版的关键差异:upload_file 接收本机文件路径,由进程直接读盘上传,不再把文件 base64 塞进工具参数

特性

工具 说明
upload_file 传入本地路径 → presign + OSS multipart 上传 → 返回 file_url
submit_parse file_url / 外网直链提交 OCR,返回 task_id
get_parse_task_status 单次查状态,不阻塞、不下载结果
get_parse_result 取结果;max_wait_seconds=0 非阻塞,正数显式轮询(上限 30s)

推荐流程:

upload_file(path) → file_url
submit_parse(file_url) → task_id
轮询 get_parse_task_status 直到 result_ready
get_parse_result(task_id, format="markdown", max_wait_seconds=0)

环境要求

  • Python 3.10+
  • uv(推荐,用于 uvx 一键运行)
  • SCNet API Key

用 uvx 运行(推荐)

1)本地开发(未发布到 PyPI 时)

在项目根目录:

cd /Users/haojie/workspace/project/mcp-document-parsing-py
uv sync
SCNET_API_KEY=sk-xxx uv run scnet-document-parser

或用路径直接 uvx

SCNET_API_KEY=sk-xxx uvx --from /Users/haojie/workspace/project/mcp-document-parsing-py scnet-document-parser

2)发布到 PyPI 之后

# 用户侧只需:
uvx scnet-document-parser
# 或固定版本
uvx scnet-document-parser==0.1.0

uvx 会从 PyPI 拉包、建临时环境、执行入口脚本 scnet-document-parser

MCP 客户端配置

Claude Code / Claude Desktop

{
  "mcpServers": {
    "scnet-document-parser": {
      "command": "uvx",
      "args": [
        "--from",
        "/Users/haojie/workspace/project/mcp-document-parsing-py",
        "scnet-document-parser"
      ],
      "env": {
        "SCNET_API_KEY": "sk-your-key"
      }
    }
  }
}

发布到 PyPI 后可简化为:

{
  "mcpServers": {
    "scnet-document-parser": {
      "command": "uvx",
      "args": ["scnet-document-parser"],
      "env": {
        "SCNET_API_KEY": "sk-your-key"
      }
    }
  }
}

Cursor

在 MCP 设置中同样使用 command + args + env 即可(stdio 模式,不是 URL)。

可选环境变量

变量 默认 说明
SCNET_API_KEY 必填 SCNet Key(可带或不带 Bearer 前缀)
SCNET_BASE_URL https://api.scnet.cn API 根地址
SCNET_POLL_INTERVAL_MS 3000 显式轮询间隔
SCNET_MAX_EXPLICIT_WAIT_SECONDS 30 正数 max_wait_seconds 上限
SCNET_RESULT_DOWNLOAD_TIMEOUT_MS 30000 结果 JSON 下载超时

与 Java SSE 版对比

Java mcp-document-parsing 本项目 (Python stdio)
传输 HTTP/SSE 远程服务 stdio 本地子进程
安装 起 Spring Boot 服务 uvx / uv run
鉴权 每个 HTTP 请求 Authorization 环境变量 SCNET_API_KEY
上传 byte[](客户端常 base64) 本地路径直接读文件
适用 团队共享中台 个人 Agent 读本机文档

业务链路一致:presign → OSS multipart → submit → query → 下载结果 → full/markdown/blocks。

开发

cd /Users/haojie/workspace/project/mcp-document-parsing-py
uv sync --group dev
uv run pytest

发布到 PyPI(供他人 uvx)

# 构建
uv build

# 上传(需 PyPI token)
uv publish

# 验证
uvx scnet-document-parser --help   # 入口会启动 stdio;无 key 时会报错退出

包名:scnet-document-parser
控制台入口:scnet-document-parserscnet_document_parser.server:main

支持的文件类型

ai-sugon-long-document-parsingFileType / TaskController.submit 对齐:

类别 扩展名 默认大小上限
PDF .pdf 100MB
Word .doc .docx 100MB
Excel .xls .xlsx .csv .xlsm .xlsb 50MB
PPT .ppt .pptx 100MB
图片 .jpg .jpeg .png .bmp .tiff .tif .webp 10MB

大小上限可通过环境变量覆盖:SCNET_MAX_FILE_SIZE / SCNET_MAX_EXCEL_FILE_SIZE / SCNET_MAX_IMAGE_FILE_SIZE

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scnet_document_parser-0.1.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scnet_document_parser-0.1.0-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file scnet_document_parser-0.1.0.tar.gz.

File metadata

  • Download URL: scnet_document_parser-0.1.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for scnet_document_parser-0.1.0.tar.gz
Algorithm Hash digest
SHA256 68c2ac0d9f9f3e315ab758d18df10a05ea59cb9e3884e69ece4a4d7903ec0209
MD5 01ee9434c9d0b7a53cf66e8651eeccec
BLAKE2b-256 6851a875bcf71403662cf15e10ad6d8a57ed9295a0058d7747eda9d106721519

See more details on using hashes here.

File details

Details for the file scnet_document_parser-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: scnet_document_parser-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for scnet_document_parser-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 80fc1ac9efa94f9160fe7e961403940436f43eea556efa310470eae6f2e040de
MD5 fe51ed38cdb9f5c5fda9cc623fd1b300
BLAKE2b-256 257aa33423d3ddfb64ddf0369a897344cc53cbe5e0064f3b13d144dc86f37713

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page