CogMemory MCP Server
CogMemory MCP 服务器
一个统一的模型上下文协议服务器,为 AI 编码代理提供四个上下文子系统:
记忆 — 决策、约定、错误、活动上下文、变更日志、计划、任务、会话
知识图谱 — 实体、关系、观察
规格文档 — 长文文档(PRD/SRS),可选地链接到知识图谱实体
代码图谱 — 静态结构图(符号/边)+ 命名执行轨迹 + AI 生成的注释
存储:SQLite,通过 better-sqlite3。每个作用域一个 .db 文件。
快速开始
安装
git clone <repo> && cd cogmemory-mcp
pnpm install
pnpm run build在 VS Code 中配置
添加到 .vscode/mcp.json(工作区作用域):
{
"servers": {
"cogmemory": {
"command": "node",
"args": ["/absolute/path/to/cogmemory-mcp/dist/index.js"]
}
}
}或者添加到你的用户 mcp.json 以实现全局可用。
使用 MCP Inspector 运行(开发)
pnpm run inspectRelated MCP server: LumenCore
作用域配置
CogMemory 按优先级顺序解析作用域:
工作区根目录下的
.cogmemory/config.json:{ "scope": "global" }环境变量:
COGMEMORY_SCOPE=global默认值:
workspace
路径
作用域 | 数据库路径 |
workspace |
|
global |
|
工作区解析与多根支持
CogMemory 按优先级顺序解析工作区根目录(.cogmemory/memory.db 所在位置):
--workspace <path>命令行参数(最高优先级)COGMEMORY_WORKSPACE环境变量从当前工作目录向上查找,寻找最近的包含
.cogmemory/目录的父目录回退到当前工作目录
多根 VS Code 工作区
在 VS Code 多根工作区中,每个文件夹是一个独立的工作区根目录。CogMemory 的处理方式如下:
单根 — 自动工作。VS Code 将当前工作目录设置为工作区文件夹,
--workspace通过mcp.json传入。多根 — 每个工作区文件夹可以有自己的
.cogmemory/。通过不同的--workspace路径将每个指向 CogMemory,或者在父目录中放置一个共享的.cogmemory/。
推荐的多根 mcp.json(按文件夹):
{
"servers": {
"cogmemory-frontend": {
"command": "node",
"args": [
"/path/to/cogmemory-mcp/dist/index.js",
"--workspace",
"/path/to/frontend"
]
},
"cogmemory-backend": {
"command": "node",
"args": [
"/path/to/cogmemory-mcp/dist/index.js",
"--workspace",
"/path/to/backend"
]
}
}
}或者使用共享数据库(所有根共用一个位置):
{
"servers": {
"cogmemory": {
"command": "node",
"args": [
"/path/to/cogmemory-mcp/dist/index.js",
"--workspace",
"/shared/root"
]
}
}
}或者使用全局作用域以跨所有工作区共享:
{
"servers": {
"cogmemory": {
"command": "node",
"args": ["/path/to/cogmemory-mcp/dist/index.js"]
}
}
}export COGMEMORY_SCOPE=global工具参考
记忆工具
工具 | 描述 |
| 开始一个工作会话(返回会话 ID) |
| 结束会话,存储摘要 |
| 回忆会话详情,包括决策、错误、变更日志 |
| 记录一个决策及其理由和标签 |
| 记录/更新约定(设计令牌、模式、命名风格) |
| 记录一个错误及其签名和解决方案 |
| 按键更新当前活动上下文/任务 |
| 按键读取当前活动上下文 |
| 追加变更日志条目 |
| 添加一个计划项 |
| 更改计划项状态 |
| 创建一个任务,可选地链接到计划 |
| 更改任务状态 |
| 跨决策/约定/错误/变更日志的统一搜索 |
知识图谱工具
工具 | 描述 |
| 添加实体(按名称+类型去重) |
| 用类型化关系链接两个实体 |
| 为实体附加一个事实 |
| 查询实体、关系、观察 |
规格文档工具
工具 | 描述 |
| 存储一个长文文档 |
| 按 ID 或精确标题检索 |
| 更新内容/标题,自动递增版本 |
代码图谱工具
工具 | 描述 |
| 遍历工作区,通过 ts-morph 提取符号 + 边(JS/TS) |
| 查找符号的调用者/被调用者/导入(1 跳) |
| 从入口符号开始 BFS,有界子图,可选轨迹 + 注释 |
| 为符号或轨迹附加叙述性文本 |
架构
cogmemory-mcp/
├── src/
│ ├── index.ts # entry point, server bootstrap
│ ├── config.ts # scope resolution, path resolution
│ ├── types.ts # shared TS types mirroring schema
│ ├── db/
│ │ ├── connection.ts # DB open/close, pragma setup
│ │ ├── schema.sql # full schema (reference)
│ │ └── migrate.ts # idempotent schema application
│ ├── tools/
│ │ ├── memory.ts # decisions/conventions/errors/context/changelog/recall
│ │ ├── plan-tasks.ts # plan + tasks tools
│ │ ├── sessions.ts # start/end session, summary
│ │ ├── knowledge-graph.ts # entities/relations/observations
│ │ ├── specs.ts # spec CRUD
│ │ ├── code-graph.ts # index_codebase, query_code_graph
│ │ └── codemap.ts # generate_codemap, annotate_symbol
│ └── indexing/
│ ├── ts-analyzer.ts # ts-morph symbol/edge extraction
│ └── walker.ts # file discovery, gitignore respect
├── schema.sql # reference copy
├── package.json
├── tsconfig.json
└── README.md模式(15 张表)
记忆(8):
sessions、decisions、conventions、errors、context、changelog、plan、tasks知识图谱(3):
entities、relations、observations规格文档(1):
specs代码图谱(4):
symbols、edges、execution_traces、codemap_annotations
编译指示
在每次打开连接时设置:
PRAGMA journal_mode = WAL;
PRAGMA foreign_keys = ON;开发
pnpm run dev # Run with tsx (no build step)
pnpm run build # Compile TypeScript
pnpm run start # Run compiled output
pnpm run inspect # Launch MCP Inspector
pnpm run smoke-test # Run smoke test script许可证
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides AI agents with persistent, searchable memory using a knowledge graph stored in SQLite. Features semantic search, temporal awareness, and workflow-aware prompts for development projects.13MIT
- AlicenseNot gradedqualityCmaintenanceProvides AI coding assistants with persistent project memory to retain architectural decisions, code patterns, and domain knowledge across sessions. It stores data locally in a SQLite database, allowing agents to remember, recall, and manage project-specific context using full-text search.8Apache 2.0
- AlicenseNot gradedqualityAmaintenanceEnables AI coding agents to maintain persistent, cross-session memory of codebase architecture, naming conventions, and decisions through MCP tools. Eliminates repetitive project re-explanation by automatically injecting stored context into every session with local-first SQLite storage and optional team sharing capabilities.4MIT
- AlicenseAqualityBmaintenanceProvides persistent cross-session memory and full-text search for AI coding assistants, storing project context, decisions, and preferences while enabling searchable access to conversation history via local SQLite.81MIT
Related MCP Connectors
Persistent memory and knowledge graphs for AI agents. Hybrid search, context checkpoints, and more.
Universal memory for AI agents and tools. Save, organize and search context anywhere.
Give your AI agent a persistent map of your project's structure, dependencies, and bugs.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/skylarng89/cogmemory-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server