copilot-memory-mcp

copilot-memory-mcp

Cross-session memory layer for GitHub Copilot agent mode that stores fixes/decisions in SQLite and provides tools for save, search, and recall via MCP.

Category
访问服务器

README

copilot-memory-mcp (Python)

Cross-session memory layer for GitHub Copilot agent mode: SQLite for storage, an MCP server (Python SDK) for on-demand recall, and hooks for automatic capture — so a new Copilot session doesn't re-read the whole project or re-diagnose a bug you already fixed.

No Node required, and no LLM API key required either — Copilot does its own summarizing (see "Capture strategy" below). The only third-party dependency is mcp (the official Python SDK), and only server.py needs it — db.py and cli.py are pure stdlib (sqlite3, subprocess), so the hooks work with plain python3 and no virtualenv activation needed at hook-run time if you point them at a venv's interpreter directly.

Capture strategy

Copilot itself calls save_memory before finishing a substantial task — it's instructed to in copilot-instructions.md, and since it already has full conversation context, it writes a better summary than any script staring at a bare diff could. This needs no external API call.

The Stop hook is a safety net only: if a session ends without any memory saved (Copilot forgot, or the task was trivial), it records a plain "these files changed" fallback — no summarization, just enough to grep later. It checks session_has_memory() first so it never duplicates a proper entry Copilot already wrote.

Two files handle two different problems, deliberately kept separate:

  • PROJECT_MAP.md — static-ish reference (module structure, entry points). Always loaded, cheap, updated manually when structure changes.
  • .copilot-memory/memory.db (SQLite) — episodic fix/decision history. Only a short recent-index is always loaded; full detail is pulled via search_memory only when relevant.

Setup

  1. Copy this folder into your repo as .copilot-memory-mcp/ (or wherever — just keep paths in .vscode/mcp.json and hooks/hooks.json consistent).

  2. Create a venv and install the one dependency:

    cd .copilot-memory-mcp
    python3 -m venv venv
    venv/bin/pip install -r requirements.txt
    

    If your VS Code python3 on PATH already has mcp installed globally (e.g. via pip install --user mcp), you can skip the venv and use python3 directly in the configs below.

  3. Register the MCP server — copy .vscode/mcp.json into your repo's .vscode/ folder (merge if one exists). If you used a venv, point command at ${workspaceFolder}/.copilot-memory-mcp/venv/bin/python3 instead of the bare python3. Commit this file so your whole team gets the same server.

  4. Wire up the hooks — hooks/hooks.json uses the same SessionStart / Stop hook schema as Claude Code / Copilot CLI. Hook registration location has moved around across VS Code releases, so confirm the exact spot for your version via the /hooks slash command in chat, or Developer: Open Agent Debug Panel to verify it's actually firing. Same venv note applies here if you used one — point python3 at the venv's interpreter.

  5. Drop in the templates — copy templates/PROJECT_MAP.md and the contents of templates/copilot-instructions.md into your repo root and .github/copilot-instructions.md respectively. Fill in PROJECT_MAP.md for real (have Copilot draft it, then trim).

  6. Gitignore the database:

    .copilot-memory/
    __pycache__/
    

    It's personal/session history, not something to commit — unlike the MCP config, instructions, and project map, which should all be checked in.

Tools exposed to Copilot

  • save_memory — record a fix/decision, called by Copilot itself before finishing a substantial task (see "Capture strategy" above).
  • search_memory — look up past fixes by keyword, filename, or error signature before re-investigating something.
  • get_recent_context — short recent-fix index (normally already injected by the SessionStart hook, but callable directly too).

Schema

CREATE TABLE memories (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    created_at TEXT NOT NULL DEFAULT (datetime('now')),
    session_id TEXT,
    summary TEXT NOT NULL,
    root_cause TEXT,
    fix TEXT,
    files_touched TEXT,      -- JSON array
    error_signature TEXT,    -- normalized string for lookup
    tags TEXT                 -- JSON array
);

Notes / known rough edges

  • MCP for Copilot Business/Enterprise requires the org-level "MCP servers in Copilot" policy to be enabled — already the case for you, but worth knowing if you take this to other teams.
  • Hooks are a newer VS Code feature (landed 1.109, Jan 2026) — behavior and config location may still shift between releases. Re-check after any VS Code update if capture silently stops firing.
  • Quality of memory depends on Copilot actually following the instruction to call save_memory — it's a prompt, not a guarantee. Skim search_memory results occasionally and see how many are tagged unsummarized/fallback; a high rate means the instruction isn't landing and may need to be more prominent or repeated closer to task completion.
  • Verified locally: db.py round-trips insert/search/recent correctly, and server.py starts cleanly under the mcp SDK.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选