Bun Novel Processor MCP
A Bun-based MCP server designed for processing and segmenting long-form novel text files. It enables AI agents to incrementally read novels, validate chapter drafts, and manage cleaned chapter metadata through standard stdio transport.
README
mcp(Bun + MCP 标准 stdio)
这是一个基于 Bun 的 MCP 基础项目框架,使用标准 stdio 传输协议,适合接入 Claude Desktop / Cursor 等 MCP 客户端。
安装依赖
bun install
启动方式
开发模式(热更新):
bun run dev
标准启动:
bun run start
当前内置工具
read_novel_line:按游标增量读取小说文本get_progress:获取已切分进度(下一章节号/下一游标)validate_chapter_draft:章节草稿质检(提示建议,不拦截)save_chapter:同时保存原文章节与清洗后章节,并写入元信息索引
小说文件放置
默认从 novels 目录读取文本文件:
/Users/tietiezhi/Project/mcp/novels
例如小说名传 斗破苍穹,默认读取:
novels/斗破苍穹.txt
也可通过环境变量覆盖目录:
NOVELS_DIR=/your/path bun run start
工具入参
novel_name:小说名(或.txt文件名)cursor:起始字符索引(首次通常传0)max_lines:本次最多返回行数(可选,默认1,最大20)target_chars:本次目标读取字符数(可选,达到即停止,最大5000)- 返回包含
batch_text与batch_chars,方便智能体直接累计 - 若文本无换行,工具会优先按标点等语义边界切片,必要时再按字符硬切
get_progress:
novel_name:小说名称- 返回
next_chapter_no与next_cursor,用于断点续跑
validate_chapter_draft:
clean_text:待质检章节正文min_chars/max_chars:建议字数范围(默认600/1000)- 返回
issues、in_range、标题/作者/前言/网址检测结果与建议
save_chapter:
novel_name:小说名称chapter_no:章节序号(从 1 开始)start_cursor:章节起始游标end_cursor:章节结束游标chapter_chars:章节字数min_chars:章节最小字数(可选,默认600)max_chars:章节最大字数(可选,默认1000)allow_out_of_range:允许超范围保存(可选,默认true)enforce_clean_guard:启用 clean 文本前部质检(可选,默认false)split_reason:切分理由(可选)raw_text:原始章节正文(未清洗)clean_text:清洗后的章节正文
章节输出目录
默认写入:
/Users/tietiezhi/Project/mcp/chapters/<novel_name>/
文件说明:
0001.raw.txt:原始章节正文(含头部元信息)0001.clean.txt:清洗后章节正文(含头部元信息)index.jsonl:章节索引,每行一条 JSON 元信息
可通过环境变量覆盖:
CHAPTERS_DIR=/your/output/path bun run start
推荐调用流程(智能体)
- 先调用
get_progress获取next_chapter_no与next_cursor。 - 循环调用
read_novel_line(建议结合max_lines+target_chars控制批次)。 - AI 在对话内完成去杂质与章节切分。
- 每章保存前调用
validate_chapter_draft做自检。 - 每章调用
save_chapter写入raw_text与clean_text。 - 重复步骤 2-5,直到
eof=true。
save_chapter 内置一致性校验:
- 章节号必须连续
start_cursor必须等于上一章end_cursorchapter_chars必须等于clean_text.length- 可选开启字数范围限制(
allow_out_of_range=false) - 可选开启 clean 文本前部拦截(
enforce_clean_guard=true)
目录结构
.
├── index.ts # 根入口,启动 MCP 服务
└── src
├── main.ts # stdio transport 启动逻辑
├── server.ts # MCP Server 创建与工具注册
├── config.ts # 服务基础配置(name/version)
├── tools
│ ├── getProgress.ts
│ ├── readNovelLine.ts
│ ├── validateChapterDraft.ts
│ └── saveChapter.ts
└── types
└── tool.ts # 工具返回类型
类型检查
bunx tsc --noEmit
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.