Context Pilot
Smart context and memory management for AI workflows
Web App + MCP Server for Claude Code
Website • Quick Start • Features • Docker • MCP Server • API Reference
______________________________________________________________________
什么是上下文引导?
Context Pilot为您的AI助手 持久结构化存储器它将知识存储为带有标签的可搜索记忆,连接到外部资源(GitHub、Gitea、Paperless ngx、电子邮件、本地文件夹),并通过MCP服务器向Claude Code提供上下文——所有这些都是通过一个干净的web UI完成的。
核心思想: 与其重复自己,不如教你的人工智能一次。上下文飞行员记得。
______________________________________________________________________
快速开始
Docker(推荐)
docker pull applehell/contextpilot:latest
docker run -d --name context-pilot \
-p 8080:8080 -p 8400:8400 \
-v context-pilot-data:/data \
applehell/contextpilot:latestWeb用户界面: http://localhost:8080 | 健康: http://localhost:8080/health
Docker Compose
services:
context-pilot:
image: applehell/contextpilot:latest
container_name: context-pilot
restart: unless-stopped
ports:
- "8080:8080" # Web UI
- "8400:8400" # MCP SSE Server
volumes:
- context-pilot-data:/data
- /path/to/docs:/mnt/docs:ro # optional: folder for indexing
environment:
- CONTEXTPILOT_DATA_DIR=/data
volumes:
context-pilot-data:docker compose up -d来源
git clone https://github.com/applehell/contextpilot.git
cd contextpilot
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
python -m src.webCLI选项
python -m src.web # Web UI + MCP Server
python -m src.web --no-mcp # Web UI only
python -m src.web --port 9090 # Custom web port
python -m src.web --mcp-port 8500 # Custom MCP port______________________________________________________________________
特性
Web UI——8个选项卡
| 选项卡 | 说明 |
|---|---|
| 仪表板 | 统计卡、顶部标签、尺寸分布、连接器健康状况、导入、实时活动(SSE)、上下文预览 |
| 回忆 | 全CRUD,带Markdown编辑器、搜索、过滤器、标签、TTL、pin、批量操作、紧凑视图、可折叠侧边栏 |
| 技能 | 连接带有状态指示器的MCP技能注册表 |
| 图 | 交互式知识图(vis.js),带有搜索、物理切换、导航按钮、节点详细信息面板 |
| 秘密 | 扫描内存中的API密钥、密码、令牌(OWASP模式) |
| 来源 | 连接器存储(17个源)、文件夹映射、webhooks、自动同步调度程序 |
| 汇编器 | 模板、自动建议、6个压缩器、手动块组装、导出(CLAUDE.md、Markdown) |
| 设置 | 配置文件、MCP服务器控制、数据库维护、导入/导出中心、调度器、系统信息 |
回忆
| 能力 | 详细信息 |
|---|---|
| 创建和编辑 | 支持Markdown的模态编辑器(EasyMDE),实时预览 |
| 搜索 | 通过SQLite FTS5+混合语义搜索进行全文搜索 |
| 标签 | 可点击标签过滤、颜色编码顶部标签、批量标签操作 |
| 分类 | persistent, session (24小时TTL), ephemeral (1h TTL)——自动到期 |
| 生存时间 | 自动到期的生存时间,颜色编码的生命周期指示器(紧急/即将/有限/永久) |
| 针 | 把重要的回忆钉在上面 |
| 关系 | 存储器之间的交叉引用,双向图边 |
| 版本控制 | 使用差异视图跟踪更改,还原以前的版本 |
| 紧凑视图 | 在细节和紧凑模式之间切换(保存在本地存储中) |
| 批量操作 | 多选、批量删除、批量TTL、批量标签编辑 |
| 备份 | 通过API创建、列出、恢复和删除备份 |
| 出口 | JSON、CLAUDE.md、Markdown导出(全部或按标签过滤) |
连接器存储区——17个来源
| 类别 | 连接器 | 它同步的内容 |
|---|---|---|
| 文件 | 无纸-ngx | OCR文档通过REST API |
| Microsoft Excel | 电子表格作为标记表(openpyxl) | |
| 谷歌云端硬盘 | 通过服务帐户提供文档、表格、幻灯片 | |
| 发展 | GitHub | 仓库、发布、自述文件、问题 |
| Gitea | 自托管仓库、维基、软件包 | |
| 知识 | 黑曜石金库 | 带封面的Markdown笔记 |
| 书签 | 提取并索引网页 | |
| RSS/Atom订阅源 | 订阅文章(无外部依赖) | |
| 通知 | 通过API的页面和数据库 | |
| KeePass | 仅提供注释、标题和URL(从不提供密码) | |
| Bitwarden | 仅限安全笔记(从不登录) | |
| 沟通 | 电子邮件(IMAP) | 来自任何IMAP服务器的电子邮件 |
| 电报 | 通过Bot API发送Bot消息 | |
| Microsoft Teams | 通过Graph API传递消息 | |
| 基础设施 | Kubernetes | 部署、服务、配置映射(从不保密) |
| Dockge | Docker编写堆栈(修改了环境值) | |
| 智能家居 | 家庭助理 | 自动化、场景、实体 |
| 本地 | 文件夹映射 | 带扩展过滤器的目录,PDF提取 |
每个连接器轨道 同步历史记录 (最近20次运行),支持 生存时间 用于自动过期同步内存,并公开 健康仪表板 (GET /api/connectors/health).
导入
直接从仪表板或设置上传文件:
| 格式 | 来源 |
|---|---|
CLAUDE.md | Claude代码指令文件 |
Copilot.md | GitHub Copilot指令文件 |
SQLite .db | 内存mcp mcp服务器数据库 |
JSON | 上下文引导JSON导出 |
配置文件——完全隔离
每个配置文件都是一个完全隔离的工作区:
profiles/{name}/
data.db MCP Server (SSE, Port 8400)
|
|-- Memory CRUD
| memory_set / memory_get / memory_delete
| memory_search / memory_list
|
|-- Skills
| register_skill / unregister_skill
| list_registered_skills / heartbeat
| get_skill_context
|
|-- Context Assembly
| assemble_context / list_blocks
| assemble_template / list_templates / suggest_templates
| get_context_for_task
|
|-- Intelligence
| capture_learnings / get_related_memories
| submit_feedback / get_block_weight配置文件感知: MCP服务器实时跟踪配置文件切换,无需重新启动。
它是如何工作的:
- 启动上下文引导->MCP服务器在端口8400上启动
- 自动注册
~/.claude.json - Claude Code现在可以读取/写入您的记忆
- 停止应用->自动注销
______________________________________________________________________
Claude代码插件
这 上下文引导插件 添加了与Claude Code的深度集成——自动配置文件检测、斜线命令和一个技能文件,该文件教Claude如何最佳地使用ContextPilot。
安装
git clone https://github.com/applehell/context-pilot-plugin.git \
~/.claude/plugins/cache/context-pilot/1.0.0它的作用
| 组件 | 描述 |
|---|---|
| 会话启动挂钩 | 自动根据您的工作目录检测正确的配置文件 |
/context-pilot | 仪表板、模板组装、搜索、配置文件切换、建议、状态 |
/context-pilot-learn | 快速保存会话中的内存 |
| 技能档案 | 向Claude教授所有20种MCP工具、最佳实践以及何时使用什么 |
| MCP配置 | 自动注册ContextPilot MCP服务器 |
命令
/context-pilot # Show dashboard (profile, memories, templates)
/context-pilot bugfix-context # Assemble the "bugfix-context" template
/context-pilot search docker # Search memories for "docker"
/context-pilot profile smarthome # Switch to smarthome profile
/context-pilot suggest # Auto-suggest new templates
/context-pilot status # Show connector health
/context-pilot-learn infra/nginx Reverse proxy config for port 443 || infra,nginx轮廓自动检测
| 工作目录包含 | 配置文件 |
|---|---|
contextpilot 或 context-pilot | software-development |
homeassistant 或 home-assistant | smarthome |
| *(默认)* | 保持当前配置文件 |
配置
# Shell config (~/.claude/context-pilot.conf)
CONTEXTPILOT_URL=http://your-server:8080
CONTEXTPILOT_MCP_URL=http://your-server:8400/sse______________________________________________________________________
码头工人
可用的
| 标签 | 描述 |
|---|---|
applehell/contextpilot:latest | 最新稳定版本 |
卷
| 安装 | 目的 |
|---|---|
/data | 数据库、配置文件、配置(持久) |
/mnt/docs | 可选:用于索引的本地文件夹(只读) |
从源代码构建
git clone https://github.com/applehell/contextpilot.git
cd contextpilot
docker build -t contextpilot .
docker compose up -d______________________________________________________________________
建筑
Browser --> Web UI (FastAPI, Port 8080)
|-- Dashboard Stats, Import, Live Activity SSE, Context Preview
|-- Memories CRUD, Search, Editor, Tags, TTL, Compact View
|-- Skills Skill Registry, Status Indicators
|-- Knowledge Graph Interactive vis.js network, Search, Navigation
|-- Secrets Scanner, Redacted View
|-- Sources Connector Store (17), Folder Mapping, Webhooks, Scheduler
|-- Assembler Templates, Auto-Suggest, Compression, Export
|-- Settings Profiles, MCP, DB, Import/Export, Scheduler
Claude Code --> MCP Server (SSE, Port 8400)
|-- 20 tools: memory CRUD, search, templates, assembly,
| skill registry, feedback, context-for-task, learnings
|
--> Plugin (context-pilot)
|-- SessionStart hook (auto-profile detection)
|-- /context-pilot + /context-pilot-learn commands
|-- Skill file (best practices + tool guidance)
Connectors --> 17 sources (GitHub, Gitea, Paperless, Obsidian, Email,
Notion, Teams, Telegram, RSS, Excel, Google Drive,
KeePass, Bitwarden, Kubernetes, Dockge, Bookmarks, HA)
Storage --> SQLite (WAL mode + FTS5, Schema v13)数据路径
# Local
~/.contextpilot/
profiles.json /data.db /data.db______________________________________________________________________
API 参考
Core
| 端点 | 方法 | 描述 |
|---|---|---|
/health | GET | 系统指标和健康检查 |
/api/dashboard | GET | 汇总仪表板统计数据 |
/api/dashboard/stats | GET | 详细统计数据(标签、尺寸、增长) |
/api/mcp-status | GET | MCP服务器注册状态 |
/api/setup-status | GET | 新安装检测 |
Memories
| 端点 | 方法 | 描述 |
|---|---|---|
/api/memories | GET | 列出内存(分页、排序、源过滤器) |
/api/memories | POST | 创建内存 |
/api/memories/{key} | GET | 读取单个内存 |
/api/memories/{key} | PUT | 更新内存 |
/api/memories/{key} | DELETE | 软删除内存(垃圾) |
/api/memories/search | GET | 全文搜索+标签/源过滤器 |
/api/memories/sources | GET | 列出具有计数的内存源 |
/api/memories/category-stats | GET | 每个类别的内存计数 |
/api/memories/{key}/related | GET | 相关记忆(交叉引用) |
/api/memories/{key}/versions | GET | 版本历史记录 |
/api/memories/{key}/pin | POST | 固定/取消固定内存 |
/api/memories/bulk-delete | POST | 批量删除 |
/api/memories/bulk-ttl | POST | 批量TTL更新 |
/api/memories/bulk-tag | POST | 批量标记操作 |
/api/semantic-search | GET | 混合/语义/关键字搜索(模式参数) |
/api/export-memories | GET | 导出为JSON |
/api/memory-tags | GET | 所有标签 |
/api/memory-presets | GET | 快速过滤器预设 |
Connectors
| 端点 | 方法 | 描述 |
|---|---|---|
/api/connectors | GET | 列出所有具有配置和架构的连接器 |
/api/connectors/{name} | GET | 连接器详细信息+架构 |
/api/connectors/{name}/setup | POST | 配置连接器 |
/api/connectors/{name} | PUT | 更新连接器配置 |
/api/connectors/{name}/test | POST | 测试连接 |
/api/connectors/{name}/sync | POST | 同步数据 |
/api/connectors/{name}/enable | POST | 启用/禁用 |
/api/connectors/{name}/history | GET | 同步历史记录(最近20次) |
/api/connectors/{name} | DELETE | 删除连接器配置 |
/api/connectors/health | GET | 所有连接器的运行状况仪表板 |
/api/folders | GET/POST | 列出/添加文件夹源 |
/api/folders/{name} | PUT/DELETE | 更新/删除文件夹源 |
/api/folders/{name}/scan | POST | 扫描单个文件夹 |
/api/folders/scan-all | POST | 扫描所有文件夹 |
Templates & Assembly
| 端点 | 方法 | 描述 |
|---|---|---|
/api/templates | GET/POST | 列出/创建模板 |
/api/templates/{name} | DELETE | 删除模板 |
/api/templates/{name}/assemble | POST | 压缩+称重组装 |
/api/templates/suggest | GET | 从内存集群中自动建议模板 |
/api/assemble | POST | 手动块组装 |
/api/estimate | POST | 令牌估计 |
/api/test-compress | POST | 测试压缩机 |
/api/duplicates | GET | 查找重复记忆 |
/api/preview-context | POST | 预览带有预算的上下文程序集 |
/api/export-claude-md | GET | 导出为CLAUDE.md |
/api/export-markdown | GET | 导出为Markdown |
Profiles
| 端点 | 方法 | 描述 |
|---|---|---|
/api/profiles | GET/POST | 列出/创建配置文件 |
/api/profiles/{id}/switch | POST | 切换活动配置文件(按ID) |
/api/profiles/{name} | PUT/DELETE | 重命名/删除 |
/api/profiles/{name}/duplicate | POST | 重复配置文件 |
/api/profiles/{name}/export | GET | 将配置文件导出为ZIP |
/api/profiles/import | POST | 从ZIP导入配置文件 |
Events & Security
| 端点 | 方法 | 描述 |
|---|---|---|
/api/events | GET | 最近事件 |
/api/events/stream | GET | SSE实时流 |
/api/events/stats | GET | 事件统计 |
/api/sensitivity | GET | 秘密扫描 |
/api/redacted?key=... | GET | 已编辑内存视图 |
/api/knowledge-graph | GET | 图形数据(vis.js格式) |
Import
| 端点 | 方法 | 描述 |
|---|---|---|
/api/import/claude-md | POST | 上传CLAUDE.md |
/api/import/copilot-md | POST | 上传Copilot.md |
/api/import/sqlite | POST | 上传SQLite数据库 |
/api/import/json | POST | 上传JSON导出 |
Analytics, Backup & Webhooks
| 端点 | 方法 | 描述 |
|---|---|---|
/api/analytics/summary | GET | 概述仪表板数据 |
/api/analytics/top-memories | GET | 访问次数最多的内存 |
/api/analytics/top-tags | GET | 最常见的标签 |
/api/analytics/connector-stats | GET | 每个连接器的统计信息 |
/api/analytics/memory-growth | GET | 每日内存计数增长 |
/api/backups | GET/POST | 列出/创建备份 |
/api/backups/{filename}/restore | POST | 恢复备份 |
/api/backups/{filename} | DELETE | 删除备份 |
/api/webhooks | GET/POST | 列出/创建webhooks |
/api/webhooks/{id} | PUT/DELETE | 更新/删除webhook |
/api/inbound/{token} | POST | 入站webhook(推送记忆) |
Maintenance
| 端点 | 方法 | 描述 |
|---|---|---|
/api/maintenance/db-stats | GET | 数据库统计 |
/api/maintenance/vacuum | POST | 紧凑型数据库 |
/api/maintenance/rebuild-fts | POST | 重建搜索索引 |
/api/maintenance/cleanup-trash | POST | 删除旧垃圾条目 |
/api/maintenance/cleanup-expired | POST | 删除过期的记忆 |
/api/trash | GET | 列出被破坏的记忆 |
/api/trash/{key}/restore | POST | 从回收站还原 |
/api/trash/purge | POST | 清除所有垃圾 |
/api/mcp/register | POST | 在~/.claude.json中注册MCP |
/api/mcp/deregister | POST | 注销MCP |
/api/scheduler/* | GET/POST | 自动同步调度程序控制 |
______________________________________________________________________
项目结构
src/
core/ Core logic
assembler.py 3-phase token-budget assembler
analytics.py Usage analytics engine
backup.py Backup & restore manager
block.py Block data model
claude_config.py ~/.claude.json reader/writer
compress_detect.py Shared compression hint detection
compressors/ 6 compressors (bullet, code, yaml, mermaid, table, dedup)
context.py Context builder for auto-assembly
dependency_detector.py Cross-memory dependency detection
duplicates.py Duplicate / near-duplicate finder
embeddings.py TF-IDF embeddings + hybrid search
events.py Global EventBus with SSE broadcast
relevance.py Relevance scoring engine
scheduler.py Auto-sync scheduler (APScheduler)
secrets.py Secrets detector (OWASP patterns)
skill_registry.py MCP skill lifecycle tracker
token_budget.py tiktoken wrapper
webhooks.py Inbound webhook processor
weight_adjuster.py Usage-based weight adjustment
connectors/ 17 external service connectors
github.py, gitea.py Development sources
paperless.py, excel.py Document sources
gdrive.py Google Drive (service account JWT)
obsidian.py, notion.py Knowledge sources
rss.py, bookmarks.py Web sources
keepass.py, bitwarden.py Secure notes (never passwords)
email_imap.py, telegram.py Communication sources
teams.py Microsoft Teams (Graph API)
kubernetes.py, dockge.py Infrastructure sources
homeassistant.py Smart Home source
storage/ SQLite persistence (Schema v13)
db.py DB engine + migrations (v1-v13)
memory.py MemoryStore (CRUD + FTS5)
memory_activity.py Access tracking & usage stats
profiles.py Profile manager
folders.py Folder source manager + file indexer
relations.py Cross-reference / relation store
templates.py Assembly template store
versions.py Memory version history
usage.py Usage-based weighting store
settings.py Key-value settings store
project.py Project context store
web/ Web app (FastAPI + vanilla JS)
app.py API endpoints (~27k lines)
templates/index.html Single-page frontend
static/app.js Frontend logic (~4.6k lines)
static/style.css Themes (light + dark, ~2.7k lines)
interfaces/ External interfaces
mcp_server.py MCP Server (20 tools, SSE transport)
cli.py Click CLI
importers/ Memory import
claude.py CLAUDE.md parser
copilot.py copilot-instructions.md parser
sqlite.py memory-mcp SQLite importer
tests/ 2100+ tests发展
python3 -m venv .venv && source .venv/bin/activate
pip install -e '.[dev]'
pytest tests/ -v
python -m src.web --reload # Hot-reload______________________________________________________________________
技术栈
| 层 | 技术 |
|---|---|
| 后端 | Python 3.11+、FastAPI、Uvicorn |
| 前端 | Vanilla JS、vis.JS(图形)、EasyMDE(编辑器)、DOMPurify(XSS) |
| 数据库 | SQLite(WAL模式,FTS5,模式v13) |
| 实时 | 服务器发送事件(SSE) |
| 人工智能集成 | MCP服务器(FastMCP,20个工具),tiktoken |
| 连接器 | 请求、openpyxl、PyJWT、pykeepass、PyYAML |
| 安全 | DOMPurify、安全头、秘密扫描器、非根Docker |
| 部署 | Docker(arm64+amd64),2100+测试 |
______________________________________________________________________
contextpilot.net — Screenshots, demos, and detailed documentation
Built with Claude Code
