context-hub-mcp

context-hub-mcp

A local-first MCP server that turns a .context/ folder of markdown files into a searchable knowledge layer for AI coding agents.

Category
访问服务器

README

context-hub-mcp

A local-first MCP server that turns a .context/ folder of markdown files into a searchable knowledge layer for AI coding agents.

  • write domain knowledge in markdown, keep it in git
  • index it locally for fast retrieval
  • expose it as MCP tools for Claude Code, Copilot, and other MCP clients

The markdown is the source of truth. SQLite is a local runtime index only — don't commit it.

Quickstart

# 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

Paste the generated JSON into your MCP client config. The client will then invoke serve automatically — you don't need to run it manually.

.context/ Structure

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

Writing Knowledge

Every document needs 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

```mermaid
stateDiagram-v2
  pending --> paid
```

Fields: title, domain, tags, last_verified, confidence (high / medium / low), related (optional list of related doc paths)

Use Key Files sections for source references and state machine headings so structured parsing picks them up.

The related field accepts paths relative to .context/:

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

Importing Docs with Claude Code

If you use Claude Code, the repo includes a /import_context command that lets you turn any URL, wiki, or spec into a properly formatted .context/ document:

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

Claude will fetch the source, distill the relevant knowledge, pick the right subdirectory, and write the file with correct frontmatter. Run npx context-hub-mcp reindex afterward to update the index.

MCP Tools

Tool Purpose
list_domains Discover available knowledge areas
search_context Full-text search across indexed documents
get_context Read a specific document
get_context_structured Read a document as structured data (keyFiles, stateMachines, pitfalls, sections, related)
get_pitfalls List pitfalls, optionally filtered by domain
list_tags List all unique tags with document counts; optional domain filter
get_stale_docs List documents with old or missing last_verified, or confidence: low
get_related Return documents related to a given path (bidirectional, depth 1 or 2)
annotate_context Leave a note on outdated or missing docs
rate_context Mark whether a document was helpful
list_annotations Review accumulated annotations
reindex_context Force a fresh index rebuild

search_context — filtering params

In addition to a query string, search_context accepts optional filters:

Param Type Description
tags string[] OR-match: return docs that have any of the listed tags
confidence string Minimum confidence level (low, medium, high)
verified_after string Only docs with last_verified on or after this date (YYYY-MM-DD)
verified_before string Only docs with last_verified on or before this date (YYYY-MM-DD)

get_stale_docs — params

Param Type Default Description
domain string — Limit to a specific domain
days_threshold number 90 Docs not verified within this many days are considered stale
limit number — Cap the number of results

get_related — params

Param Type Description
path string Path of the source document (relative to .context/)
depth 1 | 2 1 returns directly linked docs; 2 also follows their links

CLI

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)

Run any command with --help for available flags.

add — flags

npx context-hub-mcp add [--domain <name>] [--title <title>] [--tags <a,b>] \
  [--confidence high|medium|low] [--template domain|integration|pitfall] \
  [--no-edit]
Flag Description
--domain Domain subfolder to place the file in (e.g. payments)
--title Document title (used for the filename and frontmatter)
--tags Comma-separated list of tags
--confidence Initial confidence level; defaults to medium
--template Starter template: domain, integration, or pitfall
--no-edit Skip opening the file in $EDITOR after creation

Client Setup

Claude Code

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

<details> <summary>Example output</summary>

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

</details>

GitHub Copilot

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

<details> <summary>Example output</summary>

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

</details>

See also: examples/claude-code.mcp.json, examples/copilot.mcp.json

Configuration

context-hub.config.json is optional. Defaults:

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

CLI flags override config file values. Relative paths resolve from cwd.

Troubleshooting

Search returns no results — run npx context-hub-mcp reindex, then npx context-hub-mcp doctor. Common causes: missing .context/, malformed frontmatter, file outside indexed globs.

Documents fail to parse — check that all 5 frontmatter fields are present and valid.

Database files appear in git — ensure .context/.gitignore contains context_hub.db, context_hub.db-shm, context_hub.db-wal.

Client cannot connect — verify the client uses stdio MCP, the --cwd path is correct, and the project has been indexed at least once.

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选