Integrations
GitHub Copilot
AI Tool

GitHub Copilot

Use Memaster with GitHub Copilot Chat through repository instructions, workflow scripts, or MCP when available.

InstructionsScriptsMCP optional

GitHub Copilot Chat 可以通过仓库 instructions 和本地脚本配合 Memaster。instructions 规定“何时检索/写入”,本地脚本负责实际调用 Memaster API;如果你的 Copilot 环境支持 Remote HTTP MCP,也可以直接连接 Memaster 托管 endpoint。

Repository-aware把仓库规范、模块边界和调试结论保存到长期记忆。
Instruction driven用 Copilot instructions 触发检索和写入流程。
Team friendly团队共享 instructions,但每个人用自己的 .env.local API Key。

推荐接入方式

  • Repository Instructions —— 在仓库 instructions 中写明 Memaster 使用规则。
  • 本地脚本 —— 通过 memaster_memory.py 执行检索和写入。
  • MCP 接入 —— 如果 Copilot Chat 环境支持 Remote HTTP MCP,直接配置 https://api.memaster.cn/mcpX-API-Key;否则继续使用 repository instructions 与本地脚本。

建议把 instructions 提交到仓库,但不要提交 .env.local。API Key 应保存在本机或组织 secret 中。

MCP 可选配置

如果当前 GitHub Copilot Chat 环境支持 Remote HTTP MCP,可使用统一的托管 endpoint:

mcp.json
{
  "mcpServers": {
    "memaster": {
      "type": "http",
      "url": "https://api.memaster.cn/mcp",
      "headers": {
        "X-API-Key": "msk_xxx"
      }
    }
  }
}

如果当前 Copilot 环境不支持 Remote HTTP MCP,继续使用下面的 repository instructions 与本地脚本方式。

安装

复制 Skill 或脚本目录

mkdir -p .github/memaster
cp -R skills/memaster-memory .github/memaster/memaster-memory

配置本机环境

cp .github/memaster/memaster-memory/.env.example .github/memaster/memaster-memory/.env.local
MEMASTER_API_KEY=msk_xxx
MEMASTER_USER_ID=alice
MEMASTER_AGENT_ID=github-copilot
MEMASTER_SOURCE=github-copilot
MEMASTER_PROJECT=my-repo
MEMASTER_AREA=workspace

验证脚本

python3 .github/memaster/memaster-memory/scripts/memaster_memory.py doctor

Instructions 模板

.github/copilot-instructions.md
# Memaster Memory
 
For complex tasks, use Memaster memory before planning:
 
1. Search for project facts, coding conventions, user preferences and debugging history.
2. Before changing central abstractions or creating files, search for related implementation patterns.
3. After completing a task, save only stable and validated conclusions.
4. Never save API keys, tokens, private keys, passwords or raw `.env` values.
5. Include project, area, source, memory_type and tags when writing memory.
 
Use the local helper when available:
 
```bash
python3 .github/memaster/memaster-memory/scripts/memaster_memory.py search --query "..."
python3 .github/memaster/memaster-memory/scripts/memaster_memory.py add --title "..." --content "..." --memory-type project_info --tags "..."

## 常用命令

```bash copy
python3 .github/memaster/memaster-memory/scripts/memaster_memory.py search \
  --query "这个仓库有哪些工程约定?" \
  --top-k 5

python3 .github/memaster/memaster-memory/scripts/memaster_memory.py add \
  --title "Copilot 仓库约定" \
  --content "复杂变更前应先检索长期记忆,完成后保存已验证结论。" \
  --memory-type project_info \
  --tags "Copilot,仓库,规范"

metadata 建议

字段示例说明
projectmemasterGitHub 仓库或产品名
areaserver-golang/docs当前修改区域
sourcegithub-copilot来源工具
memory_typeproject_info / debug / implementation记忆类型
tags["Copilot", "文档"]过滤标签

故障排查

现象检查项
Copilot 没有自动执行脚本instructions 只提供行为约束,需要用户或工具环境允许运行命令
.env.local 不应提交确认 .gitignore 包含 .env.local
检索为空检查 user、project、area 是否与写入一致
401API Key 是否有效,是否使用 X-API-Key

下一步