Skip to main content
Glama

mcp-han · 中文校对 MCP

AI 写完中文,让它自己再读一遍。

License: MIT Python 3.10+ MCP

mcp-han 是一个 MCP 服务:把「中文校对与排版」注册成模型可以直接调用的工具。 接上它,Claude / Cursor / Hermes 写完中文文案之后会自己检查、自己修,不用你再手工过一遍。

- 我们用github和deepseek api做了个工具, 结果准确率是95 %左右... 既使这样, 因该也没问题 。
+ 我们用 GitHub 和 DeepSeek API 做了个工具,结果准确率是 95%左右……即使这样,应该也没问题。

一行接入 · 4 个工具 · 18 条规则 · 零第三方依赖(只用标准库 + MCP SDK)


为什么需要它

中文排版工具其实早就有:zhlint(1.0k★)、pangu.js(4.8k★)、autocorrect(1.6k★)。 但它们都是给CI 用的:装在编辑器里、跑在命令行上,需要有人记得去按那一下。

AI 写作把这件事翻了过来——文案既然是模型写的,检查就该由模型在交付前自己做完。 mcp-han 就是这一步:不新增编辑器插件,不新增流水线,只是把中文校对变成一个模型会主动调用的工具。

和上面那些工具相比,它不试图更聪明,只求接入成本为零、误报足够少

谁触发

什么时候

zhlint / pangu / autocorrect

人、编辑器、CI

你想起来的时候

mcp-han

模型自己

每次写完中文之后


Related MCP server: mcp-korean-spell

快速开始

1. 接进 Claude Desktop

claude_desktop_config.json(macOS:~/Library/Application Support/Claude/;Windows:%APPDATA%\Claude\):

{
  "mcpServers": {
    "mcp-han": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/zzmmgg654321-dev/mcp-han", "mcp-han"]
    }
  }
}

2. 接进 Cursor

~/.cursor/mcp.json(或项目里的 .cursor/mcp.json)写同样的内容即可,见 examples/

3. 接进 Hermes

hermes mcp add mcp-han --command uvx --args --from git+https://github.com/zzmmgg654321-dev/mcp-han mcp-han
hermes mcp test mcp-han

4. 本地跑 / 开发

git clone https://github.com/zzmmgg654321-dev/mcp-han
cd mcp-han
uv run mcp-han          # 以 stdio 方式启动服务
uv run pytest           # 43 项测试(含一次真实 stdio 协议往返)

测试矩阵在 .github/workflows/ci.yml:ubuntu / windows / macOS × Python 3.10 / 3.13。

还没发到 PyPI,所以上面统一用 git+https://... 的形式安装。装成本地命令: uv tool install --from git+https://github.com/zzmmgg654321-dev/mcp-han mcp-han


四个工具

工具

干什么

什么时候用

check_text

报告问题:行号、列号、上下文、修改建议

想先看看哪里不对,或复核

fix_text

直接给出修复后的全文 + 改动清单 + 仍需人工确认的地方

交付前一把梭

count_text

字数、段落、句子、预计阅读时长,以及小红书 / 公众号 / 短信 / X 的超限情况

卡字数的时候

list_rules

列出全部规则(id、级别、能否自动修、说明)

想只跑某几条规则时

check_text 的实际输出长这样:

发现 19 处问题(error 2 / warn 3 / style 14)

第 1 行 · 第 4 列 · [warn] 专有名词大小写
  「github」应写作「GitHub」
  建议:'GitHub'
  上下文:我们用github和deepseek api做了个工具…

第 6 行 · 第 4 列 · [error] 常见错别字 / 成语误写
  「既使」应为「即使」
  建议:'即使'
  上下文:…2. 既使写完了,因该也要再检查一遍…

第 7 行 · 第 11 列 · [style] 全角字母数字
  全角应写成半角:HTML → HTML
  建议:'HTML'
  上下文:…3. 用了全角字符 HTML 做测试…

提示:其中 19 处可以直接用 fix_text 自动修掉。

fix_text 会把清单读完的部分一次改掉,并告诉你哪些还得人来定:

已修复 18 处。

【修复后的全文】
我们用 GitHub 和 DeepSeek API 做了个工具,结果准确率是 95%左右……即使这样,应该也没问题。

【改动清单】
第 1 行 · 第 4 列 · [warn] 专有名词大小写  「github」应写作「GitHub」…
…

【仍需人工确认】
第 3 行 · 第 11 列 · [warn] 引号不配对
  直引号数量是奇数,有一处没有闭合(跨行引号不会自动转换)

规则清单

规则 id

检查项

级别

默认

typo

常见错别字 / 成语误写(72 条词表)

error

✅ 自动修

latin-case

专有名词大小写(69 条词表)

warn

✅ 自动修

pangu-space

中英文之间空格

style

✅ 自动修

punct-halfwidth

半角标点

style

✅ 自动修

paren-halfwidth

半角括号

style

✅ 自动修

ellipsis

省略号写法

style

✅ 自动修

dash

破折号写法

style

✅ 自动修

quote-style

引号风格

style

✅ 自动修

quote-switch

引号风格切换

style

点名才跑

fullwidth-alnum

全角字母数字

style

✅ 自动修

punct-space

标点前多余空格

style

✅ 自动修

space-after-punct

标点后多余空格

style

✅ 自动修

bracket-padding

括号内多余空格

style

✅ 自动修

percent-space

百分号前空格

style

✅ 自动修

trailing-space

行尾空白

style

✅ 自动修

dup-punct

重复标点

style

只报告

fullwidth-space

全角空格

style

只报告

unpaired-quote

引号不配对

warn

只报告

这张表由 uv run python scripts/gen_rules_table.pyRULES 生成,改规则后跑一次即可同步, CI 里会用 --check 校验它没跑偏。

点名与排除——所有接受 rules 参数的工具都支持这两种写法:

rules="typo,latin-case"     # 只跑这两条
rules="-dup-punct"          # 除了它,其余全跑
rules="dup-punct"           # 平时只报告不自动修的规则,点名后 fix_text 也会改
rules="quote-switch"        # 默认关闭的规则,点名才跑

fix_textquote_style 决定半角直引号变成什么:

quote_style

直引号 "…" 变成

已写好的中文引号

curly(默认)

“…”

不动

corner

「…」

不动

keep

不动

不动

有意用了直角引号「」的文档不会被默认规则报错——那是一种合法风格。 要让整个文档统一换风格,点名 quote-switchfix_text(text, rules="quote-switch", quote_style="corner") 就能把全文的 “…” 全换成 「…」(反向同理)。


三个设计取舍

1. 绝不改你的代码。 围栏代码块、行内代码、URL、邮箱、HTML 标签、行内公式会先被替换成同长度的占位符, 规则只在剩下的正文上跑。所以 offset / 行号 / 列号与原文严格对齐,而 pip install xxxhttps://a.com/x... 这类内容一根毫毛都不会动。

2. 一轮到位,且可重复。 每条规则只产出「在这里替换成什么」,统一从后往前套用,重叠的编辑只留第一个。 所以 fix(fix(x)) == fix(x)(测试里有这条),而且它不会把 3.5 当成句号、不会把 ---(Markdown 分隔线)当成破折号。

3. 宁可不报,不要误报。 只收高置信度的错别字词表;歧义大的专有名词(aiuiosgonode)故意不收; 词表匹配要求真正的词边界,所以 mcp-hannode.jsmy-github-fork 这类带连字符的名字不会被改; 「的/地/得」这类需要语义判断的一律不碰;有意使用直角引号「」的文档也不会被判成错误。 判断不了的(例如引号不配对)只报告、不自动改。


当库用

核心引擎不依赖 MCP SDK,可以当普通 Python 库用:

from mcp_han import check, fix, count

result = fix("我们用github写了个工具, 结果...")
print(result.text)          # 我们用 GitHub 写了个工具,结果……
print(len(result.changes))  # 6

for item in check("因该没问题", severity="error"):
    print(item.line, item.column, item.message, "→", item.suggestion)

print(count("你好,世界。", platforms="xhs_title")["platforms"])

已知边界(诚实版)

  • 只针对大陆简体规范;港台用字(如「帳號」)不在范围内,这类词条可按需删掉。

  • 不检查语义错误:「的 / 地 / 得」「度过 / 渡过」这类需要上下文判断的一律不碰。

  • 跨行的引号不会自动转换,只会提示你人工确认。

  • 平台字数限制会变(会员等级也会放宽),脚本按非空白字符数估算,发布前请以平台提示为准。

  • 专有名词词表是主观的:DockerJavaRust 这类写法在不同团队里标准不同,改 src/mcp_han/data.py 即可。

表格想改动?三张数据表(错别字、专有名词、平台限制)都在 src/mcp_han/data.py,纯数据,欢迎 PR。


Roadmap

  • 拼音注音(pypinyin)、繁简互转(opencc)——做成可选依赖 mcp-han[zh],保持核心零依赖

  • 命令行模式:mcp-han check 文案.md,方便接进 pre-commit

  • 更多平台字数模板(知乎、B 站、抖音)

  • 发布到 PyPI


English

mcp-han is an MCP server that gives an LLM a Chinese proofreading toolkit: spacing between CJK and Latin, half-width punctuation, common typos, proper-noun casing, quote style, and character limits for Chinese platforms (Xiaohongshu, WeChat, SMS, X).

Why: Chinese typography linters exist (zhlint, pangu.js, autocorrect), but they are tools humans run. When the model writes the Chinese, the model should check it — before handing it over.

Zero third-party dependencies (stdlib + the MCP SDK). Code blocks, inline code, URLs, emails, HTML tags and inline math are masked out, so it never touches your code. Fixes are single-pass and idempotent.

uv run mcp-han   # stdio MCP server
uv run pytest    # 43 tests, including a real stdio handshake

Tools: check_text, fix_text, count_text, list_rules. Contributions to the data tables in src/mcp_han/data.py are very welcome.

许可证

MIT

Available Tools

4 tools
check_textA

检查中文文本的排版、标点、常见错别字和专有名词大小写。

这是只读操作,不会修改任何东西。

Args:
    text: 要检查的文本。Markdown 也行;代码块、行内代码、URL、邮箱、
        HTML 标签和公式会被自动跳过。
    rules: 只跑指定规则,逗号分隔(如 "typo,pangu-space");用 "-" 前缀排除
        (如 "-dup-punct");留空表示默认规则集(18 条里除 quote-switch 之外的全部)。
    severity: 只看某个级别,逗号分隔,可选 error / warn / style。
    limit: 最多列出多少条问题,默认 30。
ParametersJSON Schema
NameRequiredDescriptionDefault
textYes
limitNo
rulesNo
severityNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden and does it well: it explicitly states the operation is read-only, will not modify anything, and automatically skips code blocks, inline code, URLs, emails, HTML tags, and formulas. It also reveals default rule behavior and the default issue limit.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose and read-only guarantee, then presents parameters as a clean Args block with concrete examples. Every sentence adds useful information, and the formatting makes scanning easy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 4-parameter tool with no annotations, the description covers required and optional parameters, defaults, allowed severity values, rule syntax, and ignored content. Since an output schema exists, there is no need to explain return values; what an agent needs to invoke the tool correctly is present.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, and the description compensates thoroughly. For each parameter it adds meaning absent from the schema: text accepts Markdown and defines skipped elements; rules documents comma-separated inclusion, '-' prefix exclusion, and the default set; severity enumerates valid values; limit states default 30.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb ('检查') and resource ('中文文本'), and enumerates the exact scope: 排版、标点、常见错别字、专有名词大小写. It also notes the operation is read-only, which distinguishes it from sibling fix_text without requiring schema inspection.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description establishes a clear context—this is a read-only checker that does not modify text—so an agent can infer it is for analysis rather than fixing. However, it never explicitly names or contrasts the sibling tools (fix_text, count_text, list_rules) or states conditions for choosing one over another; guidance remains implied.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

count_textA

统计字数、段落、句子、预计阅读时长,并检查常见平台的字数限制。

具体平台(小红书、公众号、短信、X)的超限情况会一起返回。

Args:
    text: 要统计的文本。
    platforms: 只看指定平台,逗号分隔,如 "xhs_title,mp_digest";留空表示全部。
ParametersJSON Schema
NameRequiredDescriptionDefault
textYes
platformsNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the disclosure burden. It states that per-platform limit status will be returned together with the stats, which is useful, but it does not mention side effects, permissions, error behavior, or the exact output structure. For a read-only counting tool this is adequate but not rich.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The main functionality is front-loaded in the first sentence, followed by a brief note on the included platforms and a compact Args section. Every sentence adds information; there is no filler or repetition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description provides enough for correct invocation: required text, optional platform filtering, and the general nature of the returned data. The output schema covers the return shape. The only minor gap is that the full list of valid platform codes is not enumerated, only examples.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description compensates fully: 'text' is defined as the text to count, and 'platforms' is explained as an optional comma-separated filter with an example ('xhs_title,mp_digest') and a clear default ('empty means all'). This exceeds what the schema alone provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function: counting characters, paragraphs, sentences, reading time, and checking platform-specific length limits. It is distinct from fix_text and list_rules, and the counting focus differentiates it from check_text, though no sibling is explicitly named.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The intended use is implied by the purpose: call this when a text's statistics or platform-limit status is needed. There is no explicit guidance on when not to use it or which sibling tool to prefer, leaving the comparison to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

fix_textA

自动修复中文文案的排版问题,返回修复后的全文。

默认只套用「安全」规则(不会动代码块、行内代码、URL),
并会告诉你改了哪些地方、还有哪些需要人工确认。

Args:
    text: 要修复的文本。
    rules: 只跑指定规则,逗号分隔;用 "-" 前缀排除。点名某条平时不自动跑的
        规则(例如 "dup-punct")时它也会被套用。
    quote_style: 引号风格——curly(默认,“”)/ corner(「」)/ keep(不动)。
ParametersJSON Schema
NameRequiredDescriptionDefault
textYes
rulesNo
quote_styleNocurly

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.8/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the transparency burden and does so well: it states the default safe rule scope, what is explicitly left untouched (code blocks, inline code, URLs), that it will report changes, and that some items need manual confirmation. This is strong for a pure text transformation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact and structurally clear, starting with purpose and then behavior, followed by parameter explanations. Every sentence carries information; no fluff. Slight density from the in-description argument block is the only reason it doesn't reach 5.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given a pure text-processing tool with 3 simple parameters and an output schema, the transparency is mostly complete. It explains default behavior, rules selection, and quote style. It fails to point at sibling tools like list_rules for available rule names, but that is not required for a correct invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must fully compensate. It does: text is explained, rules details comma-separated exclusion and forced inclusion with an example, and quote_style enumerates all three modes with symbols. No meaningful parameter definition is left to inference.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific action (自动修复) and resource (中文文案的排版问题) and says it returns the full fixed text. This clearly marks the tool as a fixer rather than a checker/counter, but it doesn't name sibling tools, so differentiation is implicit rather than explicit.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives no guidance on when to use this tool instead of its siblings (check_text, count_text, list_rules). It provides parameter-level usage details, but not when-to-use/exclusion guidance, which is the key here.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_rulesA

列出全部校对规则(id、级别、能否自动修复、说明)。

想知道 rules 参数里能写什么,或者想了解某条规则的边界时用这个。

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. '列出全部' explicitly states the tool lists all rules (read-only, no side effects), and the field list (id, level, auto-fixable, description) tells the agent what to expect in the result. This sufficiently covers behavior for a simple zero-parameter list tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two short sentences with no filler. The first sentence states the core function and output fields; the second provides concrete usage guidance. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a zero-parameter tool with an output schema, the description is nearly complete: it states scope, returned fields, and a concrete use case. It could have added a note about behavior (e.g., always returns all rules rather than paginated), but given the simple read-only nature and existing output schema, it is sufficiently complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters, so the baseline is 4. The description adds extra context that this tool serves to explain the 'rules' parameter used elsewhere, which is semantically useful beyond the empty schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('列出'/'list') and resource ('全部校对规则'/'all proofreading rules') and enumerates the returned fields (id, level, auto-fixable status, description). This clearly distinguishes it from siblings like check_text, fix_text, and count_text.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The second sentence gives explicit conditions for use: when you need to know what values the 'rules' parameter accepts or understand a rule's boundaries. It does not name sibling tools or exclusions, but the context is clear enough for an agent to route to this tool versus the siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 4 tool updatesv0.1.0
    • First observedcheck_text
    • First observedcount_text
    • First observedfix_text
    • First observedlist_rules

TDQS

A4.3/5.0

Scored across 4 tools

Disambiguation5/5

Each tool targets a distinct operation: checking reports issues, fixing applies corrections, counting provides statistics, and listing rules exposes metadata. There is no meaningful overlap between them.

Naming Consistency5/5

All tool names follow a consistent verb_noun snake_case pattern: check_text, fix_text, count_text, list_rules. The pattern is uniform and predictable.

Tool Count5/5

Four tools is well-scoped for a text proofreading utility. Each tool fills a clear role with no redundancy or bloat.

Completeness5/5

The set covers the full workflow of text proofreading: inspect, fix, quantify, and learn about available rules. There are no obvious dead ends or missing core operations for this domain.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    Content moderation and profanity detection MCP server with 19 tools, 24 language support, leetspeak/Unicode obfuscation detection, context-aware analysis, batch processing, and user tracking for AI-powered content safety.
    23
    60
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    MCP server that counts the number of Chinese characters (excluding punctuation, spaces, English, and numbers) in a given text, compatible with Streamable HTTP and JSON-RPC.
    MIT