trm-mcp
This server provides a local, offline-first read-only MCP interface to search, inspect, and compare PDF datasheets/TRMs through hybrid retrieval, exact pattern matching, page reading, rendering, and document comparison.
list_documents: List indexed documents with stable IDs, titles, page counts, and indexing status, optionally filtered by a query string.
search: Perform hybrid BM25/dense/visual retrieval with local reranking and page citations. Supports mode (hybrid/text/visual), top_k, and document filtering.
grep: Find exact register, field, signal, address, or arbitrary regex occurrences by page, with case-insensitive default and support for case sensitivity and regex mode, plus result limits.
read: Read up to 20 consecutive indexed pages in Markdown, plain text, HTML, or layout JSON.
render: Render 1–4 PDF pages as images (JPEG or PNG) with customizable DPI (default 144).
compare: Retrieve matching passages from two documents for a given query and return aligned unified diffs.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@trm-mcpFind the absolute maximum ratings for the TPS7A4700 regulator and list page numbers."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
TRM MCP
本地、离线优先的超长 datasheet/TRM PDF 检索服务。它将页面级结构化解析、
BM25、Qwen3 dense embedding、Qwen3 reranker 和页面视觉 embedding 融合,
通过 MCP 提供 search、grep、read、render 和 compare。
快速开始
docker compose up -d
python -m venv .venv
.venv/bin/pip install -e '.[dev]'
.venv/bin/trm init
.venv/bin/trm models download
# 默认:只建立文本索引
.venv/bin/trm ingest /path/to/manual.pdf
# 可选:同时建立页面视觉索引
.venv/bin/trm ingest --visual /path/to/manual.pdf
# HTTP 服务必须设置一个固定 Bearer key
export TRM_MCP_API_KEY="$(openssl rand -hex 32)"
.venv/bin/trm serve --transport http直接运行时服务默认监听 http://127.0.0.1:8765/mcp。HTTP 请求必须携带
Authorization: Bearer <TRM_MCP_API_KEY>;stdio 不需要网络认证。所有文档内容和查询均留在本机。
默认数据目录是 ${XDG_DATA_HOME:-~/.local/share}/trm-mcp,可通过
TRM_DATA_DIR 覆盖。
生成数据包括:
trm.sqlite3:文档、页面、布局 JSON、Markdown、切块和 FTS5/BM25;documents/:按内容哈希保存的只读 PDF 副本;images/:用于视觉索引的 144 DPI 页面图;.trm-data/qdrant/:Qdrant 文本和视觉向量,可用TRM_QDRANT_STORAGE覆盖。
Related MCP server: paper-intelligence
MCP 客户端
export TRM_MCP_API_KEY="...与服务端相同的值..."
codex mcp add trm --url http://127.0.0.1:8765/mcp \
--bearer-token-env-var TRM_MCP_API_KEY--bearer-token-env-var 不会把密钥写进 Codex 配置。使用 systemd 部署时,
在启动 Codex 前加载同一私有环境文件:
set -a; . ~/.config/trm-mcp.env; set +a
codexClaude Code 2.1.77 在本机使用 stdio(该版本的 HTTP 健康检查与当前 Streamable HTTP SDK 不兼容):
claude mcp add-json --scope user trm \
'{"type":"stdio","command":"/absolute/path/to/trm-mcp/.venv/bin/trm",
"args":["serve","--transport","stdio"],
"env":{"TRM_DATA_DIR":"/absolute/path/to/trm-data",
"TRM_QDRANT_URL":"http://127.0.0.1:6333","HF_HUB_OFFLINE":"1",
"TRANSFORMERS_OFFLINE":"1",
"TESSDATA_PREFIX":"/absolute/path/to/trm-data/tessdata"}}'把示例中的绝对路径替换为本机仓库和数据目录;Claude Code 的 JSON
配置不会通过 shell 展开 $HOME。
服务本身同时支持 HTTP 与 stdio;较新的 Claude Code 可直接改用 HTTP URL。
管理命令
trm list
trm status
trm reindex DOCUMENT_ID
trm remove DOCUMENT_ID
trm eval evals/golden_queries.json -o eval-report.jsonMCP 接口是只读的。导入、重建、删除只能由本地 CLI 显式执行。
默认混合检索分别召回 BM25、Qwen3 文本向量和 Qwen3-VL 页面向量, 先用 RRF 合并文本候选,再经 Qwen3 reranker 重排,最后以 0.7/0.3 权重融合文本与视觉页排名。所有结果均带稳定文档 ID 和一基页码。
解析器会先检查每页的原生文字、坏字符、已有 OCR 文字层和图像覆盖,只对
确实需要识别的页面启用 OCR。视觉编码默认从 batch 8 开始;如果出现 CUDA
显存不足,会自动按 8 → 4 → 2 → 1 退避,并在当前进程中保持已验证的大小。
可通过 TRM_VISUAL_BATCH_SIZE 设置起始上限,通过
TRM_VISUAL_BATCH_MIN 设置退避下限。
导入默认只建立文本索引,不渲染页面。显式传入 --visual 时,页面渲染使用
与可用逻辑 CPU 数相同的独立 spawn 进程;每个进程独立
打开 PDF,并使用原子文件替换写入 JPEG。SQLite 路径每 25 页批量提交,因此
并行 worker 不会共享数据库连接。本机可通过 TRM_RENDER_WORKERS 指定固定
进程数,0 表示自动;用 TRM_RENDER_PIN_CPUS=0/1 控制 CPU 绑定。
之后可用 trm ingest --visual 或 reindex 补建图片与视觉索引。
PDF 结构化解析默认使用 8 个独立的 spawn 进程;每个进程独立打开 PDF、
绑定自己的 CPU 核集合,并将 ONNX Runtime intra-op 线程限制为 2。子进程
只返回页面结果,SQLite 写入和 Docling fallback 仍由主进程串行完成。可通过
TRM_PARSE_WORKERS、TRM_PARSE_ORT_THREADS 和
TRM_PARSE_PIN_CPUS=0/1 调整。
常驻服务与严格离线
仓库提供 deploy/trm-mcp.service,默认假定仓库位于 ~/trm-mcp。如果
安装位置不同,先修改其中的路径。安装并启动:
mkdir -p ~/.config/systemd/user
cp deploy/trm-mcp.service ~/.config/systemd/user/
systemctl --user daemon-reload
systemctl --user enable --now trm-mcp.service该服务将 Hugging Face 和 Transformers 设置为离线模式,默认同时绑定 IPv6
[::]:8765 和 IPv4 0.0.0.0:8765。安装前创建仅当前用户可读的密钥文件:
install -m 600 /dev/null ~/.config/trm-mcp.env
openssl rand -hex 32 | sed 's/^/TRM_MCP_API_KEY=/' >> ~/.config/trm-mcp.env本机 Codex 使用 IPv6 loopback 时,URL 写作 http://[::1]:8765/mcp。
访问其他主机时必须使用其实际 IPv6 地址,并在 URL 中加方括号。此内置认证是
固定 Bearer key,未提供 TLS;若流量会经过不可信网络,请在反向代理上启用 HTTPS。
首次运行前必须执行一次 trm models download。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityBmaintenanceLocal-first RAG indexing and semantic search MCP server. Enables document retrieval and context-aware queries using local embedding models.Last updated325MIT
- Alicense-qualityBmaintenanceA local MCP server for intelligent PDF management that converts papers to markdown and enables hybrid grep and semantic search, allowing token-efficient exploration of academic documents.Last updated6MIT
- AlicenseAqualityBmaintenanceA local-first MCP server that ingests PDFs, extracts structure, and provides semantic search and sequential navigation tools for AI clients to query and learn from documents.Last updated10MIT
- Alicense-qualityCmaintenanceFast, local PDF parsing as an MCP server with text extraction, bounding boxes, OCR, and visual citations. No cloud or API key required.Last updatedMIT
Related MCP Connectors
Local-first RAG engine with MCP server for AI agent integration.
Serve a folder of Markdown notes as an MCP server: hybrid search, reading, and sourced answers.
Agent-native MCP server over the public saagarpatel.dev corpus. Read-only, stateless.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/strongtz/trm-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server