Mcp File Processor

io.github.Opafex由 GitHub 账号 Opafex 发布v0.1.1更新于 Oct 26, 2026

Text extraction, keyword extraction, language detection, and chunking for RAG

已验证STDIO仅桌面文件与存储知识与记忆

概览

AI 生成的概览

本地 MCP 服务器,可从 PDF、DOCX 及文本/代码文件中提取文本,并做关键词提取、内容类型识别和面向 RAG 的文本分块。

可以做什么
  • 从 PDF、DOCX、CSV、JSON、Markdown、HTML 和代码文件中提取文本,并返回词数与页数
  • 从文本中提取按词频排序的关键词,并过滤停用词
  • 判断内容是代码、自然语言还是混合,可选识别编程语言
  • 将文本切分为带位置元数据的重叠分块,供 RAG 或向量化流程使用
  • 一次调用完成单个文件的全部处理
  • 返回服务器元数据、已注册工具与资源,并提供受支持类型的资源列表
适用场景
适合需要让助手读取 PDF 或 Word 文档、为文本打标签或建立索引、以及为嵌入与检索准备文档的场景。也适合希望文件留在本机处理的本地 RAG 准备工作。
运行要求
通过 npx 从 npm 包 @opafex/mcp-file-processor 以 stdio 在本地运行,需要 Node.js 20 或更高版本。无需 API 密钥、环境变量或请求头,仅支持桌面端。
安装前请注意
文件内容以 base64 或原始文本形式传给工具,助手发送的内容都会由该服务器处理;README 说明全部在本地运行且无需 API 密钥。这些工具只读取和转换内容,不会写入、发送或删除数据。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Mcp File Processor,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

@opafex/mcp-file-processor

MCP server for universal text extraction, keyword extraction, language detection, and text chunking — designed for RAG pipelines.

Supports PDF, DOCX, CSV, JSON, Markdown, HTML, and code files. Zero platform dependencies.

Installation

bash
npm install @opafex/mcp-file-processor

Requires Node.js 20+.

Quick Start

Add to Claude Code / Claude Desktop

json
{  "mcpServers": {    "file-processor": {      "command": "npx",      "args": ["@opafex/mcp-file-processor"]    }  }}

No API keys needed — everything runs locally.

Tools

extract_text

Extract text content from a file.

ParameterTypeRequiredDescription
contentstringYesFile content — base64 for binary formats (PDF, DOCX), raw text for text formats
fileTypestringYesMIME type (e.g. "application/pdf") or extension (e.g. ".pdf", "pdf")
Example response
json
{  "success": true,  "text": "Extracted text content here...",  "wordCount": 142,  "pageCount": 3,  "processingTimeMs": 45}

extract_keywords

Extract ranked keywords from text. Filters stop words, sorted by frequency.

ParameterTypeRequiredDescription
textstringYesText to extract keywords from
limitnumberNoMax keywords to return (default: 20)
Example response
json
{  "success": true,  "keywords": [    { "word": "javascript", "frequency": 8 },    { "word": "framework", "frequency": 4 },    { "word": "react", "frequency": 3 }  ],  "totalWords": 156}

detect_language

Detect whether content is code, natural language, or mixed.

ParameterTypeRequiredDescription
textstringYesText to analyse
fileNamestringNoFile name for extension-based detection (e.g. "app.ts")
Example response
json
{  "success": true,  "contentType": "code",  "programmingLanguage": "typescript"}

chunk_text

Split text into overlapping chunks for RAG/embedding pipelines.

ParameterTypeRequiredDescription
textstringYesText to chunk
chunkSizenumberNoTarget chunk size in characters (default: 1000)
overlapnumberNoOverlap between chunks in characters (default: 200)
Example response
json
{  "success": true,  "chunks": [    { "index": 0, "text": "...", "startOffset": 0, "endOffset": 1000, "wordCount": 167 },    { "index": 1, "text": "...", "startOffset": 800, "endOffset": 1800, "wordCount": 172 }  ],  "totalChunks": 5,  "totalCharacters": 4200}

process_file

All-in-one: extract text, detect content type, extract keywords, and chunk.

ParameterTypeRequiredDescription
contentstringYesFile content (base64 or raw text)
fileTypestringYesMIME type or file extension
chunkSizenumberNoChunk size in characters (default: 1000)
chunkOverlapnumberNoOverlap in characters (default: 200)
keywordLimitnumberNoMax keywords (default: 20)

server_info (built-in)

Returns server metadata, registered tools, and resources.

Resources

ResourceDescription
file-processor://supported-typesLists all supported MIME types and file extensions

Supported Formats

FormatExtensionInput
PDF.pdfbase64
Word.docx, .docbase64
Plain text.txtraw text
Markdown.mdraw text
CSV.csvraw text
JSON.jsonraw text
HTML.htmlraw text
XML.xmlraw text
JavaScript.js, .jsx, .mjsraw text
TypeScript.ts, .tsxraw text
Python.pyraw text
Java.javaraw text
Go.goraw text
Rust.rsraw text
C/C++.c, .cpp, .hraw text

Development

bash
npm run build    # Compile TypeScriptnpm run dev      # Run with tsxnpm test         # Run testsnpm start        # Run compiled server

Library Usage

typescript
import { FileProcessorService } from '@opafex/mcp-file-processor/service';
const service = new FileProcessorService();
const result = await service.processFile(  'Hello world, this is a document.',  '.txt',  500,  // chunk size  100   // overlap);

Contributing

Found a bug or have a feature request? Open an issue.

License

MIT — see LICENSE.

来源:packages/file-processor/README.md,提交 f85607b

工具

6

extract_text

Extract text content from a file. Supports PDF, DOCX, CSV, JSON, Markdown, HTML, and code files. Pass file content as base64 (for binary formats like PDF/DOCX) or raw text (for text formats). Returns extracted text, word count, and processing time.

输入参数content必填fileType必填

extract_keywords

Extract ranked keywords from text. Returns keywords sorted by frequency, useful for tagging, search indexing, and topic identification.

输入参数text必填limit

detect_language

Detect whether content is code, natural language, or mixed. Optionally detects the programming language from file extension. Useful for routing content to appropriate processing pipelines.

输入参数text必填fileName

chunk_text

Split text into overlapping chunks suitable for RAG/embedding pipelines. Configurable chunk size and overlap. Returns chunks with positional metadata.

输入参数text必填overlapchunkSize

process_file

All-in-one file processing: extract text, detect content type, extract keywords, and chunk for RAG. Returns the complete processed result in a single call.

输入参数content必填fileType必填chunkSizechunkOverlapkeywordLimit

server_info

Returns server metadata: name, version, registered tools, and registered resources. Useful for introspection and health checks.

无需输入参数。

版本历史

1
  1. v0.1.1最新Oct 25, 2026

评分

已满足适用检查项的 90%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分
  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分