Token导航 LogoToken导航TokenDH.com
Context Hub MCP logo
文档知识stdio官方级别未说明来源级核验

Context Hub MCP

MCP Server

context-hub-mcp

一个本地优先的MCP服务器,将Markdown文件转换为可搜索的知识层,适用于AI编码代理。

工具数

12

提示词数

0

GitHub Stars

2

资源数

0
知识管理TypeScriptClaudeClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

Nuttapon

提供方

Nuttapon

最后核验

2026/5/17 20:22

运行时

Node.js

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

npx context-hub-mcp init

详细介绍

上下文中心mcp

本地第一台MCP服务器 .context/ 将markdown文件文件夹放入AI编码代理的可搜索知识层。

  • 用markdown写领域知识,用git保存
  • 在本地对其进行索引以实现快速检索
  • 将其作为MCP工具公开给Claude Code、Copilot和其他MCP客户端

降价是真理的源泉。SQLite只是一个本地运行时索引——不要提交它。

快速启动

# 1. Scaffold the .context/ folder
npx context-hub-mcp init

# 2. Build the local index
npx context-hub-mcp reindex

# 3. Generate MCP client config
npx context-hub-mcp config --target claude-code --cwd /absolute/path/to/project

将生成的JSON粘贴到MCP客户端配置中。然后,客户端将调用 serve 自动运行——您不需要手动运行它。

.上下文/结构

.context/
├── schema.md               ← authoring conventions
├── domains/                ← business rules, workflows, state machines
├── integrations/           ← third-party APIs, auth, webhooks
└── pitfalls/               ← gotchas, lessons learned, failure modes

写作知识

每个文档都需要YAML frontmatter:

---
title: Payment Rules
domain: payments
tags: [payments, line-pay]
last_verified: 2026-03-28
confidence: high
---

# Payment Rules

## Key Files

- `src/payments/service.ts` - entrypoint

## Payment State Machine

stateDiagram-v2 pending --> paid

领域: title, domain, tags, last_verified, confidence (high / medium / low), related (相关文档路径的可选列表)

使用 Key Files 源代码引用和状态机标题的部分将进行结构化解析。

related 字段接受相对于的路径 .context/:

related:
  - integrations/stripe-webhooks.md
  - pitfalls/payment-idempotency.md

使用Claude代码导入文档

如果你使用Claude Code,该仓库包括 /import_context 命令,用于将任何URL、wiki或规范转换为格式正确的 .context/ 文件:

/import_context https://stripe.com/docs/webhooks
/import_context the spec at ./docs/payment-rules.md

Claude将获取源代码,提取相关知识,选择正确的子目录,并使用正确的frontmatter编写文件。跑 npx context-hub-mcp reindex 之后更新索引。

MCP工具

工具目的
list_domains发现可用的知识领域
search_context在索引文档中进行全文搜索
get_context阅读特定文档
get_context_structured将文档作为结构化数据读取(keyFiles、stateMachines、陷阱、章节、相关)
get_pitfalls列出陷阱,可选择按域过滤
list_tags列出所有具有文档计数的唯一标签;可选的 domain 过滤器
get_stale_docs列出旧的或丢失的文档 last_verified,或 confidence: low
get_related返回与给定路径相关的文档(双向,深度1或2)
annotate_context在过时或缺失的文档上留下注释
rate_context标记文档是否有用
list_annotations查看累积注释
reindex_context强制重新构建索引

search_context--筛选参数

除了a query 字符串, search_context 接受可选筛选器:

参数类型描述
tagsstring[]OR match:返回具有任何列出标签的文档
confidencestring最低置信水平(low, medium, high)
verified_afterstring仅包含以下内容的文档 last_verified 在此日期或之后(YYYY-MM-DD)
verified_beforestring仅包含以下内容的文档 last_verified 在此日期或之前(YYYY-MM-DD)

get_sale_docs--参数

参数类型默认值描述
domainstring--限制到特定域
days_thresholdnumber90在这几天内未验证的文档被视为过时
limitnumber--限制结果数量

get_related--参数

参数类型描述
pathstring源文档的路径(相对于 .context/)
depth`1 \2`1 返回直接链接的文档; 2 也遵循他们的链接

命令行界面

npx context-hub-mcp init       # scaffold .context/ workspace
npx context-hub-mcp add        # create a new context document with frontmatter
npx context-hub-mcp reindex    # rebuild the local SQLite index
npx context-hub-mcp doctor     # inspect workspace health
npx context-hub-mcp config     # generate MCP client config JSON
npx context-hub-mcp serve      # run the MCP server (usually invoked by the client)

使用以下命令运行任何命令 --help 对于可用的标志。

添加--标志

npx context-hub-mcp add [--domain ] [--title ] [--tags ] \
  [--confidence high|medium|low] [--template domain|integration|pitfall] \
  [--no-edit]
标志描述
--domain用于放置文件的域子文件夹(例如。 payments)
--title文档标题(用于文件名和封面)
--tags以逗号分隔的标签列表
--confidence初始置信水平;默认为 medium
--template初学者模板: domain, integration,或 pitfall
--no-edit跳过在中打开文件 $EDITOR 创作后

客户端设置

克劳德代码

npx context-hub-mcp config --target claude-code --cwd /absolute/path/to/project

Example output

{
  "mcpServers": {
    "context-hub": {
      "command": "npx",
      "args": ["-y", "context-hub-mcp@latest", "serve", "--cwd", "/absolute/path/to/project"]
    }
  }
}

GitHub Copilot

npx context-hub-mcp config --target copilot --cwd /absolute/path/to/project

Example output

{
  "mcpServers": {
    "context-hub": {
      "type": "local",
      "command": "npx",
      "args": ["-y", "context-hub-mcp@latest", "serve", "--cwd", "/absolute/path/to/project"]
    }
  }
}

另请参见: examples/claude-code.mcp.json, examples/copilot.mcp.json

配置

context-hub.config.json 是可选的。默认值:

{
  "contextDir": ".context",
  "dbPath": ".context/context_hub.db",
  "watch": true,
  "reindexDebounceMs": 250,
  "includeGlobs": ["**/*.md"],
  "excludeGlobs": ["**/.git/**"]
}

CLI标志覆盖配置文件值。相对路径解析自 cwd.

故障排除

搜索未返回任何结果 --奔跑 npx context-hub-mcp reindex那么 npx context-hub-mcp doctor常见原因:缺失 .context/,格式错误的frontmatter,文件位于索引球体之外。

文档解析失败 --检查所有5个frontmatter字段是否存在且有效。

数据库文件以git格式显示 --确保 .context/.gitignore 包含 context_hub.db, context_hub.db-shm, context_hub.db-wal.

客户端无法连接 --验证客户端是否使用stdio MCP --cwd 路径正确,并且项目已被索引至少一次。

许可证

麻省理工学院

目录标签

目录标签

知识管理TypeScriptClaude本地部署本地索引AI辅助代码开发

支持客户端

Claude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Node.js

来源包(packageName,安装包名)

context-hub-mcp

工具数量(toolCount,工具数)

12

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP