cogmemai-mcp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +158 -0
- package/build/api.d.ts +7 -0
- package/build/api.js +54 -0
- package/build/index.d.ts +12 -0
- package/build/index.js +28 -0
- package/build/project.d.ts +7 -0
- package/build/project.js +31 -0
- package/build/tools.d.ts +8 -0
- package/build/tools.js +260 -0
- package/build/types.d.ts +71 -0
- package/build/types.js +4 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 HiFriendbot
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# CogmemAi — Cognitive Memory for Claude Code
|
|
2
|
+
|
|
3
|
+
**Claude Code forgets everything between sessions. CogmemAi fixes that.**
|
|
4
|
+
|
|
5
|
+
One command. One env var. Claude Code remembers your architecture, patterns, decisions, bugs, and preferences — permanently.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
npx -y cogmemai-mcp
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## The Problem
|
|
12
|
+
|
|
13
|
+
Every time you start a new Claude Code session, you lose context. You re-explain your tech stack, your architecture decisions, your coding preferences. Claude Code's built-in memory is a 200-line flat file with no search, no structure, and no intelligence.
|
|
14
|
+
|
|
15
|
+
CogmemAi gives Claude Code a real memory system:
|
|
16
|
+
|
|
17
|
+
- **Semantic search** — finds relevant memories by meaning, not keywords
|
|
18
|
+
- **Ai-powered extraction** — automatically identifies facts worth remembering from your conversations
|
|
19
|
+
- **Project scoping** — memories tied to specific repos, plus global preferences that follow you everywhere
|
|
20
|
+
- **Time-aware surfacing** — recent and important memories rank higher
|
|
21
|
+
- **Zero setup** — no databases, no Docker, no Python, no vector stores
|
|
22
|
+
|
|
23
|
+
## Why Not Local Memory?
|
|
24
|
+
|
|
25
|
+
Every local memory solution has the same problems: database corruption, memory leaks, version conflicts, complex setup. [claude-mem](https://github.com/nicobailon/claude-mem) (13K+ stars) leaks 15GB+ of RAM. [mcp-memory-service](https://github.com/doobidoo/mcp-memory-service) released v10.0.0 marked "BROKEN."
|
|
26
|
+
|
|
27
|
+
CogmemAi runs extraction and search server-side. Your MCP server is a thin HTTP client — **zero local databases, zero RAM issues, zero crashes.**
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
### 1. Get your API key
|
|
32
|
+
|
|
33
|
+
Sign up at [hifriendbot.com/developer](https://hifriendbot.com/developer/) and generate an API key.
|
|
34
|
+
|
|
35
|
+
### 2. Add to Claude Code
|
|
36
|
+
|
|
37
|
+
Add to your project's `.mcp.json` (or `~/.claude.json` for global):
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"mcpServers": {
|
|
42
|
+
"memory": {
|
|
43
|
+
"command": "npx",
|
|
44
|
+
"args": ["-y", "cogmemai-mcp"],
|
|
45
|
+
"env": {
|
|
46
|
+
"COGMEMAI_API_KEY": "cm_your_api_key_here"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 3. Done
|
|
54
|
+
|
|
55
|
+
Claude Code now has persistent memory. It will remember your architecture, preferences, and decisions across every session.
|
|
56
|
+
|
|
57
|
+
## Tools
|
|
58
|
+
|
|
59
|
+
CogmemAi provides 8 tools that Claude Code can use automatically:
|
|
60
|
+
|
|
61
|
+
| Tool | Description |
|
|
62
|
+
|------|-------------|
|
|
63
|
+
| `save_memory` | Store a fact explicitly (architecture decision, preference, etc.) |
|
|
64
|
+
| `recall_memories` | Search memories using natural language (semantic search) |
|
|
65
|
+
| `extract_memories` | Ai extracts facts from a conversation exchange automatically |
|
|
66
|
+
| `get_project_context` | Load all relevant memories at session start |
|
|
67
|
+
| `list_memories` | Browse all memories with filters |
|
|
68
|
+
| `update_memory` | Update a memory's content, importance, or scope |
|
|
69
|
+
| `delete_memory` | Permanently delete a memory |
|
|
70
|
+
| `get_usage` | Check your usage stats and tier info |
|
|
71
|
+
|
|
72
|
+
## Memory Types
|
|
73
|
+
|
|
74
|
+
Memories are categorized for better organization and retrieval:
|
|
75
|
+
|
|
76
|
+
- **identity** — Who you are, your role, team
|
|
77
|
+
- **preference** — Coding style, tool choices, conventions
|
|
78
|
+
- **architecture** — System design, tech stack, file structure
|
|
79
|
+
- **decision** — Why you chose X over Y
|
|
80
|
+
- **bug** — Known issues, fixes, workarounds
|
|
81
|
+
- **dependency** — Version constraints, package notes
|
|
82
|
+
- **pattern** — Reusable patterns, conventions
|
|
83
|
+
- **context** — General project context
|
|
84
|
+
|
|
85
|
+
## Scoping
|
|
86
|
+
|
|
87
|
+
- **Project memories** — Architecture, decisions, bugs specific to one repo. Auto-detected from `git remote`.
|
|
88
|
+
- **Global memories** — Your coding preferences, identity, tool choices. Available in every project.
|
|
89
|
+
|
|
90
|
+
## Pricing
|
|
91
|
+
|
|
92
|
+
| | Free | Pro | Team |
|
|
93
|
+
|---|---|---|---|
|
|
94
|
+
| **Price** | $0 | $14.99/mo | $39.99/seat/mo |
|
|
95
|
+
| **Memories** | 50 | 2,000 | 10,000 |
|
|
96
|
+
| **Extractions/mo** | 100 | 2,000 | 5,000 |
|
|
97
|
+
| **Projects** | 2 | 20 | 50 + Shared |
|
|
98
|
+
|
|
99
|
+
Start free. Upgrade when you need more.
|
|
100
|
+
|
|
101
|
+
## Privacy & Security
|
|
102
|
+
|
|
103
|
+
- **No source code leaves your machine.** We store extracted facts (short sentences), never raw code.
|
|
104
|
+
- **API keys hashed** with SHA-256 (irreversible) server-side.
|
|
105
|
+
- **All traffic over HTTPS.**
|
|
106
|
+
- **No model training** on your data. Ever.
|
|
107
|
+
- **Delete everything** instantly via dashboard or MCP tool.
|
|
108
|
+
- **No cross-user data sharing.**
|
|
109
|
+
|
|
110
|
+
Read our full [privacy policy](https://hifriendbot.com/privacy-policy/).
|
|
111
|
+
|
|
112
|
+
## Environment Variables
|
|
113
|
+
|
|
114
|
+
| Variable | Required | Description |
|
|
115
|
+
|----------|----------|-------------|
|
|
116
|
+
| `COGMEMAI_API_KEY` | Yes | Your API key (starts with `cm_`) |
|
|
117
|
+
| `COGMEMAI_API_URL` | No | Custom API URL (default: hifriendbot.com) |
|
|
118
|
+
|
|
119
|
+
## How It Works
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
Your Terminal CogmemAi Cloud
|
|
123
|
+
┌──────────────┐ ┌─────────────────────┐
|
|
124
|
+
│ Claude Code │ │ 3-Layer Memory │
|
|
125
|
+
│ │ │ │
|
|
126
|
+
│ cogmemai-mcp │ ──── HTTPS ────► │ 1. Ai Extraction │
|
|
127
|
+
│ (MCP Server) │ ◄──── JSON ──── │ 2. Semantic Search │
|
|
128
|
+
│ │ │ 3. Time-Aware Rank │
|
|
129
|
+
└──────────────┘ └─────────────────────┘
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
1. **Extraction** — When Claude Code works on your project, CogmemAi's Ai identifies important facts (architecture decisions, preferences, bugs) and stores them.
|
|
133
|
+
2. **Embedding** — Each memory gets a semantic embedding vector for meaning-based search.
|
|
134
|
+
3. **Surfacing** — When you start a new session, relevant memories are surfaced by meaning, importance, and recency.
|
|
135
|
+
|
|
136
|
+
## Works Everywhere
|
|
137
|
+
|
|
138
|
+
CogmemAi works in any terminal that runs Claude Code:
|
|
139
|
+
|
|
140
|
+
- PowerShell
|
|
141
|
+
- bash / zsh
|
|
142
|
+
- Windows Terminal
|
|
143
|
+
- macOS Terminal / iTerm2
|
|
144
|
+
- VS Code terminal
|
|
145
|
+
- Any SSH session
|
|
146
|
+
|
|
147
|
+
## Support
|
|
148
|
+
|
|
149
|
+
- Issues: [GitHub Issues](https://github.com/hifriendbot/cogmemai-mcp/issues)
|
|
150
|
+
- Docs: [hifriendbot.com/developer](https://hifriendbot.com/developer/)
|
|
151
|
+
|
|
152
|
+
## License
|
|
153
|
+
|
|
154
|
+
MIT — see [LICENSE](./LICENSE)
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
Built by [HiFriendbot](https://hifriendbot.com) — Better Friends, Better Memories, Better Ai.
|
package/build/api.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CogmemAi API client — thin HTTP wrapper for the HiFriendbot REST API.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Make an authenticated API request to the CogmemAi backend.
|
|
6
|
+
*/
|
|
7
|
+
export declare function api(path: string, method?: 'GET' | 'POST' | 'PATCH' | 'DELETE', body?: Record<string, unknown>): Promise<unknown>;
|
package/build/api.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CogmemAi API client — thin HTTP wrapper for the HiFriendbot REST API.
|
|
3
|
+
*/
|
|
4
|
+
const API_BASE = process.env.COGMEMAI_API_URL?.replace(/\/+$/, '') ||
|
|
5
|
+
'https://hifriendbot.com/wp-json/hifriendbot/v1';
|
|
6
|
+
const API_KEY = process.env.COGMEMAI_API_KEY || '';
|
|
7
|
+
if (!API_KEY) {
|
|
8
|
+
console.error('Warning: COGMEMAI_API_KEY not set. Get your key at https://hifriendbot.com/developer/');
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Make an authenticated API request to the CogmemAi backend.
|
|
12
|
+
*/
|
|
13
|
+
export async function api(path, method = 'GET', body) {
|
|
14
|
+
const url = `${API_BASE}${path}`;
|
|
15
|
+
const headers = {
|
|
16
|
+
'Content-Type': 'application/json',
|
|
17
|
+
'User-Agent': 'CogmemAi-MCP/1.0',
|
|
18
|
+
};
|
|
19
|
+
if (API_KEY) {
|
|
20
|
+
headers['Authorization'] = `Bearer ${API_KEY}`;
|
|
21
|
+
}
|
|
22
|
+
const options = { method, headers };
|
|
23
|
+
if (body && method !== 'GET') {
|
|
24
|
+
options.body = JSON.stringify(body);
|
|
25
|
+
}
|
|
26
|
+
// For GET with query params, append to URL
|
|
27
|
+
if (body && method === 'GET') {
|
|
28
|
+
const params = new URLSearchParams();
|
|
29
|
+
for (const [key, value] of Object.entries(body)) {
|
|
30
|
+
if (value !== undefined && value !== null && value !== '') {
|
|
31
|
+
params.set(key, String(value));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const qs = params.toString();
|
|
35
|
+
if (qs) {
|
|
36
|
+
const separator = url.includes('?') ? '&' : '?';
|
|
37
|
+
const fullUrl = `${url}${separator}${qs}`;
|
|
38
|
+
const res = await fetch(fullUrl, { method, headers });
|
|
39
|
+
const data = await res.json();
|
|
40
|
+
if (!res.ok) {
|
|
41
|
+
const error = data.error || `HTTP ${res.status}`;
|
|
42
|
+
throw new Error(error);
|
|
43
|
+
}
|
|
44
|
+
return data;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const res = await fetch(url, options);
|
|
48
|
+
const data = await res.json();
|
|
49
|
+
if (!res.ok) {
|
|
50
|
+
const error = data.error || `HTTP ${res.status}`;
|
|
51
|
+
throw new Error(error);
|
|
52
|
+
}
|
|
53
|
+
return data;
|
|
54
|
+
}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* CogmemAi — Cognitive Memory for Claude Code
|
|
4
|
+
*
|
|
5
|
+
* MCP server that gives Claude Code persistent memory across sessions.
|
|
6
|
+
* Developers install with one command, set one env var, and Claude Code
|
|
7
|
+
* remembers architecture, patterns, decisions, bugs, and preferences.
|
|
8
|
+
*
|
|
9
|
+
* Run: npx -y cogmemai-mcp
|
|
10
|
+
* Docs: https://hifriendbot.com/developer/
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
package/build/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* CogmemAi — Cognitive Memory for Claude Code
|
|
4
|
+
*
|
|
5
|
+
* MCP server that gives Claude Code persistent memory across sessions.
|
|
6
|
+
* Developers install with one command, set one env var, and Claude Code
|
|
7
|
+
* remembers architecture, patterns, decisions, bugs, and preferences.
|
|
8
|
+
*
|
|
9
|
+
* Run: npx -y cogmemai-mcp
|
|
10
|
+
* Docs: https://hifriendbot.com/developer/
|
|
11
|
+
*/
|
|
12
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
13
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
14
|
+
import { registerTools } from './tools.js';
|
|
15
|
+
const server = new McpServer({
|
|
16
|
+
name: 'cogmemai',
|
|
17
|
+
version: '1.0.0',
|
|
18
|
+
});
|
|
19
|
+
registerTools(server);
|
|
20
|
+
async function main() {
|
|
21
|
+
const transport = new StdioServerTransport();
|
|
22
|
+
await server.connect(transport);
|
|
23
|
+
console.error('CogmemAi MCP server running on stdio');
|
|
24
|
+
}
|
|
25
|
+
main().catch((err) => {
|
|
26
|
+
console.error('Fatal:', err);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
});
|
package/build/project.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-detect the current project identifier.
|
|
3
|
+
*
|
|
4
|
+
* Tries `git remote get-url origin` first (e.g., "user/repo").
|
|
5
|
+
* Falls back to the current working directory basename.
|
|
6
|
+
*/
|
|
7
|
+
import { execSync } from 'child_process';
|
|
8
|
+
let cachedProjectId = null;
|
|
9
|
+
export function detectProjectId() {
|
|
10
|
+
if (cachedProjectId !== null) {
|
|
11
|
+
return cachedProjectId;
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
const remote = execSync('git remote get-url origin', {
|
|
15
|
+
encoding: 'utf-8',
|
|
16
|
+
timeout: 3000,
|
|
17
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
18
|
+
}).trim();
|
|
19
|
+
// Normalize: remove .git suffix, extract org/repo
|
|
20
|
+
cachedProjectId = remote
|
|
21
|
+
.replace(/\.git$/, '')
|
|
22
|
+
.replace(/^https?:\/\/[^/]+\//, '')
|
|
23
|
+
.replace(/^git@[^:]+:/, '');
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// No git remote — use directory name
|
|
27
|
+
const parts = process.cwd().split(/[\\/]/);
|
|
28
|
+
cachedProjectId = parts[parts.length - 1] || 'unknown';
|
|
29
|
+
}
|
|
30
|
+
return cachedProjectId;
|
|
31
|
+
}
|
package/build/tools.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CogmemAi MCP tool definitions — 8 tools for developer memory.
|
|
3
|
+
*/
|
|
4
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
|
+
/**
|
|
6
|
+
* Register all 8 CogmemAi tools on the MCP server.
|
|
7
|
+
*/
|
|
8
|
+
export declare function registerTools(server: McpServer): void;
|
package/build/tools.js
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CogmemAi MCP tool definitions — 8 tools for developer memory.
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { api } from './api.js';
|
|
6
|
+
import { detectProjectId } from './project.js';
|
|
7
|
+
const MEMORY_TYPES = [
|
|
8
|
+
'identity',
|
|
9
|
+
'preference',
|
|
10
|
+
'architecture',
|
|
11
|
+
'decision',
|
|
12
|
+
'bug',
|
|
13
|
+
'dependency',
|
|
14
|
+
'pattern',
|
|
15
|
+
'context',
|
|
16
|
+
];
|
|
17
|
+
const CATEGORIES = [
|
|
18
|
+
'frontend',
|
|
19
|
+
'backend',
|
|
20
|
+
'database',
|
|
21
|
+
'devops',
|
|
22
|
+
'testing',
|
|
23
|
+
'security',
|
|
24
|
+
'performance',
|
|
25
|
+
'tooling',
|
|
26
|
+
'api',
|
|
27
|
+
'general',
|
|
28
|
+
];
|
|
29
|
+
/**
|
|
30
|
+
* Register all 8 CogmemAi tools on the MCP server.
|
|
31
|
+
*/
|
|
32
|
+
export function registerTools(server) {
|
|
33
|
+
// ─── 1. save_memory ──────────────────────────────────────
|
|
34
|
+
server.tool('save_memory', 'Store a developer memory (fact, preference, decision, architecture detail). Memories persist across all Claude Code sessions and are available in future conversations.', {
|
|
35
|
+
content: z
|
|
36
|
+
.string()
|
|
37
|
+
.min(5)
|
|
38
|
+
.max(500)
|
|
39
|
+
.describe('The fact to remember (complete sentence)'),
|
|
40
|
+
memory_type: z
|
|
41
|
+
.enum(MEMORY_TYPES)
|
|
42
|
+
.default('context')
|
|
43
|
+
.describe('Type: identity, preference, architecture, decision, bug, dependency, pattern, context'),
|
|
44
|
+
category: z
|
|
45
|
+
.enum(CATEGORIES)
|
|
46
|
+
.default('general')
|
|
47
|
+
.describe('Category: frontend, backend, database, devops, testing, security, performance, tooling, api, general'),
|
|
48
|
+
subject: z
|
|
49
|
+
.string()
|
|
50
|
+
.max(100)
|
|
51
|
+
.default('')
|
|
52
|
+
.describe('What this is about, e.g. "auth_system", "react_version", "tab_width"'),
|
|
53
|
+
importance: z
|
|
54
|
+
.number()
|
|
55
|
+
.int()
|
|
56
|
+
.min(1)
|
|
57
|
+
.max(10)
|
|
58
|
+
.default(5)
|
|
59
|
+
.describe('1-10 (10 = core architecture, 1 = trivial)'),
|
|
60
|
+
scope: z
|
|
61
|
+
.enum(['global', 'project'])
|
|
62
|
+
.default('project')
|
|
63
|
+
.describe('global = applies everywhere, project = specific to this codebase'),
|
|
64
|
+
}, async ({ content, memory_type, category, subject, importance, scope }) => {
|
|
65
|
+
const projectId = detectProjectId();
|
|
66
|
+
const result = await api('/cogmemai/store', 'POST', {
|
|
67
|
+
content,
|
|
68
|
+
memory_type,
|
|
69
|
+
category,
|
|
70
|
+
subject,
|
|
71
|
+
importance,
|
|
72
|
+
scope,
|
|
73
|
+
project_id: projectId,
|
|
74
|
+
});
|
|
75
|
+
return {
|
|
76
|
+
content: [
|
|
77
|
+
{ type: 'text', text: JSON.stringify(result, null, 2) },
|
|
78
|
+
],
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
// ─── 2. recall_memories ──────────────────────────────────
|
|
82
|
+
server.tool('recall_memories', 'Search stored memories using semantic search. Returns memories ranked by relevance, importance, and recency. Use this to find relevant context from past sessions.', {
|
|
83
|
+
query: z
|
|
84
|
+
.string()
|
|
85
|
+
.min(2)
|
|
86
|
+
.max(500)
|
|
87
|
+
.describe('What to search for (natural language)'),
|
|
88
|
+
scope: z
|
|
89
|
+
.enum(['global', 'project', 'all'])
|
|
90
|
+
.default('all')
|
|
91
|
+
.describe('Filter by scope'),
|
|
92
|
+
limit: z
|
|
93
|
+
.number()
|
|
94
|
+
.int()
|
|
95
|
+
.min(1)
|
|
96
|
+
.max(20)
|
|
97
|
+
.default(10)
|
|
98
|
+
.describe('Max results'),
|
|
99
|
+
memory_type: z.enum(MEMORY_TYPES).optional().describe('Filter by type'),
|
|
100
|
+
}, async ({ query, scope, limit, memory_type }) => {
|
|
101
|
+
const projectId = detectProjectId();
|
|
102
|
+
const result = await api('/cogmemai/recall', 'POST', {
|
|
103
|
+
query,
|
|
104
|
+
scope,
|
|
105
|
+
limit,
|
|
106
|
+
memory_type: memory_type || undefined,
|
|
107
|
+
project_id: projectId,
|
|
108
|
+
});
|
|
109
|
+
return {
|
|
110
|
+
content: [
|
|
111
|
+
{ type: 'text', text: JSON.stringify(result, null, 2) },
|
|
112
|
+
],
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
// ─── 3. extract_memories ─────────────────────────────────
|
|
116
|
+
server.tool('extract_memories', 'Extract memories from a conversation exchange using AI. Send the developer message and assistant response, and the server identifies facts worth remembering (architecture decisions, preferences, bug fixes, etc.).', {
|
|
117
|
+
user_message: z
|
|
118
|
+
.string()
|
|
119
|
+
.min(1)
|
|
120
|
+
.max(4000)
|
|
121
|
+
.describe("The developer's message"),
|
|
122
|
+
assistant_response: z
|
|
123
|
+
.string()
|
|
124
|
+
.max(4000)
|
|
125
|
+
.optional()
|
|
126
|
+
.describe("The assistant's response"),
|
|
127
|
+
previous_context: z
|
|
128
|
+
.string()
|
|
129
|
+
.max(2000)
|
|
130
|
+
.optional()
|
|
131
|
+
.describe('Previous exchange for context'),
|
|
132
|
+
}, async ({ user_message, assistant_response, previous_context }) => {
|
|
133
|
+
const projectId = detectProjectId();
|
|
134
|
+
const result = await api('/cogmemai/extract', 'POST', {
|
|
135
|
+
user_message,
|
|
136
|
+
assistant_response: assistant_response || '',
|
|
137
|
+
previous_context: previous_context || '',
|
|
138
|
+
project_id: projectId,
|
|
139
|
+
});
|
|
140
|
+
return {
|
|
141
|
+
content: [
|
|
142
|
+
{ type: 'text', text: JSON.stringify(result, null, 2) },
|
|
143
|
+
],
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
// ─── 4. get_project_context ──────────────────────────────
|
|
147
|
+
server.tool('get_project_context', 'Load all stored memories for the current project plus relevant global memories. Use at the start of a session to get full context from previous sessions.', {
|
|
148
|
+
project_id: z
|
|
149
|
+
.string()
|
|
150
|
+
.max(200)
|
|
151
|
+
.optional()
|
|
152
|
+
.describe('Project identifier (auto-detected from git remote if omitted)'),
|
|
153
|
+
include_global: z
|
|
154
|
+
.boolean()
|
|
155
|
+
.default(true)
|
|
156
|
+
.describe('Include global developer preferences'),
|
|
157
|
+
}, async ({ project_id, include_global }) => {
|
|
158
|
+
const pid = project_id || detectProjectId();
|
|
159
|
+
const result = await api('/cogmemai/context', 'GET', {
|
|
160
|
+
project_id: pid,
|
|
161
|
+
include_global: include_global ? 'true' : 'false',
|
|
162
|
+
});
|
|
163
|
+
return {
|
|
164
|
+
content: [
|
|
165
|
+
{ type: 'text', text: JSON.stringify(result, null, 2) },
|
|
166
|
+
],
|
|
167
|
+
};
|
|
168
|
+
});
|
|
169
|
+
// ─── 5. list_memories ────────────────────────────────────
|
|
170
|
+
server.tool('list_memories', 'List all stored memories with optional filters by type, category, scope, or project.', {
|
|
171
|
+
memory_type: z.enum(MEMORY_TYPES).optional().describe('Filter by type'),
|
|
172
|
+
category: z.enum(CATEGORIES).optional().describe('Filter by category'),
|
|
173
|
+
scope: z
|
|
174
|
+
.enum(['global', 'project', 'all'])
|
|
175
|
+
.default('all')
|
|
176
|
+
.describe('Filter by scope'),
|
|
177
|
+
limit: z
|
|
178
|
+
.number()
|
|
179
|
+
.int()
|
|
180
|
+
.min(1)
|
|
181
|
+
.max(100)
|
|
182
|
+
.default(50)
|
|
183
|
+
.describe('Results per page'),
|
|
184
|
+
offset: z.number().int().default(0).describe('Pagination offset'),
|
|
185
|
+
}, async ({ memory_type, category, scope, limit, offset }) => {
|
|
186
|
+
const projectId = detectProjectId();
|
|
187
|
+
const params = {
|
|
188
|
+
limit,
|
|
189
|
+
offset,
|
|
190
|
+
project_id: projectId,
|
|
191
|
+
};
|
|
192
|
+
if (memory_type)
|
|
193
|
+
params.memory_type = memory_type;
|
|
194
|
+
if (category)
|
|
195
|
+
params.category = category;
|
|
196
|
+
if (scope && scope !== 'all')
|
|
197
|
+
params.scope = scope;
|
|
198
|
+
const result = await api('/cogmemai/memories', 'GET', params);
|
|
199
|
+
return {
|
|
200
|
+
content: [
|
|
201
|
+
{ type: 'text', text: JSON.stringify(result, null, 2) },
|
|
202
|
+
],
|
|
203
|
+
};
|
|
204
|
+
});
|
|
205
|
+
// ─── 6. delete_memory ────────────────────────────────────
|
|
206
|
+
server.tool('delete_memory', 'Delete a specific memory by its ID. This is permanent.', {
|
|
207
|
+
memory_id: z.number().int().describe('Memory ID to delete'),
|
|
208
|
+
}, async ({ memory_id }) => {
|
|
209
|
+
const result = await api(`/cogmemai/memory/${memory_id}`, 'DELETE');
|
|
210
|
+
return {
|
|
211
|
+
content: [
|
|
212
|
+
{ type: 'text', text: JSON.stringify(result, null, 2) },
|
|
213
|
+
],
|
|
214
|
+
};
|
|
215
|
+
});
|
|
216
|
+
// ─── 7. update_memory ────────────────────────────────────
|
|
217
|
+
server.tool('update_memory', "Update an existing memory's content, importance, or scope.", {
|
|
218
|
+
memory_id: z.number().int().describe('Memory ID to update'),
|
|
219
|
+
content: z
|
|
220
|
+
.string()
|
|
221
|
+
.min(5)
|
|
222
|
+
.max(500)
|
|
223
|
+
.optional()
|
|
224
|
+
.describe('New content'),
|
|
225
|
+
importance: z
|
|
226
|
+
.number()
|
|
227
|
+
.int()
|
|
228
|
+
.min(1)
|
|
229
|
+
.max(10)
|
|
230
|
+
.optional()
|
|
231
|
+
.describe('New importance (1-10)'),
|
|
232
|
+
scope: z
|
|
233
|
+
.enum(['global', 'project'])
|
|
234
|
+
.optional()
|
|
235
|
+
.describe('New scope'),
|
|
236
|
+
}, async ({ memory_id, content, importance, scope }) => {
|
|
237
|
+
const body = {};
|
|
238
|
+
if (content !== undefined)
|
|
239
|
+
body.content = content;
|
|
240
|
+
if (importance !== undefined)
|
|
241
|
+
body.importance = importance;
|
|
242
|
+
if (scope !== undefined)
|
|
243
|
+
body.scope = scope;
|
|
244
|
+
const result = await api(`/cogmemai/memory/${memory_id}`, 'PATCH', body);
|
|
245
|
+
return {
|
|
246
|
+
content: [
|
|
247
|
+
{ type: 'text', text: JSON.stringify(result, null, 2) },
|
|
248
|
+
],
|
|
249
|
+
};
|
|
250
|
+
});
|
|
251
|
+
// ─── 8. get_usage ────────────────────────────────────────
|
|
252
|
+
server.tool('get_usage', 'Get current usage statistics — memory count, extractions this month, tier info, projects.', {}, async () => {
|
|
253
|
+
const result = await api('/cogmemai/usage', 'GET');
|
|
254
|
+
return {
|
|
255
|
+
content: [
|
|
256
|
+
{ type: 'text', text: JSON.stringify(result, null, 2) },
|
|
257
|
+
],
|
|
258
|
+
};
|
|
259
|
+
});
|
|
260
|
+
}
|
package/build/types.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CogmemAi TypeScript types
|
|
3
|
+
*/
|
|
4
|
+
export interface ApiResponse<T = unknown> {
|
|
5
|
+
error?: string;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
export interface Memory {
|
|
9
|
+
id: number;
|
|
10
|
+
content: string;
|
|
11
|
+
memory_type: string;
|
|
12
|
+
category: string;
|
|
13
|
+
subject: string;
|
|
14
|
+
importance: number;
|
|
15
|
+
scope: string;
|
|
16
|
+
project_id: string | null;
|
|
17
|
+
relevance_score?: number;
|
|
18
|
+
created_at: string;
|
|
19
|
+
updated_at?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface StoreResult {
|
|
22
|
+
memory_id: number;
|
|
23
|
+
stored: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface RecallResult {
|
|
26
|
+
memories: Memory[];
|
|
27
|
+
total: number;
|
|
28
|
+
}
|
|
29
|
+
export interface ExtractResult {
|
|
30
|
+
extracted: number;
|
|
31
|
+
memories: Array<{
|
|
32
|
+
subject: string;
|
|
33
|
+
content: string;
|
|
34
|
+
memory_type: string;
|
|
35
|
+
scope: string;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
export interface ContextResult {
|
|
39
|
+
project_memories: Memory[];
|
|
40
|
+
global_memories: Memory[];
|
|
41
|
+
formatted_context: string;
|
|
42
|
+
total_count: number;
|
|
43
|
+
}
|
|
44
|
+
export interface ListResult {
|
|
45
|
+
memories: Memory[];
|
|
46
|
+
total: number;
|
|
47
|
+
has_more: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface UpdateResult {
|
|
50
|
+
success: boolean;
|
|
51
|
+
updated_fields: string[];
|
|
52
|
+
}
|
|
53
|
+
export interface UsageStats {
|
|
54
|
+
tier: string;
|
|
55
|
+
tier_name: string;
|
|
56
|
+
memory_count: number;
|
|
57
|
+
memory_limit: number;
|
|
58
|
+
extractions_used: number;
|
|
59
|
+
extractions_limit: number;
|
|
60
|
+
recalls_used: number;
|
|
61
|
+
recalls_limit: number;
|
|
62
|
+
stores_used: number;
|
|
63
|
+
stores_limit: number;
|
|
64
|
+
project_count: number;
|
|
65
|
+
project_limit: number;
|
|
66
|
+
projects: Array<{
|
|
67
|
+
project_id: string;
|
|
68
|
+
project_name: string;
|
|
69
|
+
last_used: string;
|
|
70
|
+
}>;
|
|
71
|
+
}
|
package/build/types.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cogmemai-mcp",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CogmemAi — Cognitive Memory for Claude Code. Persistent memory across sessions for developers.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "build/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"cogmemai-mcp": "build/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"build",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"start": "node build/index.js",
|
|
18
|
+
"prepublishOnly": "npm run build"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"mcp",
|
|
22
|
+
"model-context-protocol",
|
|
23
|
+
"memory",
|
|
24
|
+
"claude-code",
|
|
25
|
+
"cognitive-memory",
|
|
26
|
+
"ai-agent",
|
|
27
|
+
"persistent-memory",
|
|
28
|
+
"developer-tools",
|
|
29
|
+
"context",
|
|
30
|
+
"cogmemai"
|
|
31
|
+
],
|
|
32
|
+
"author": "HiFriendbot (https://hifriendbot.com)",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"homepage": "https://hifriendbot.com/developer/",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/hifriendbot/cogmemai-mcp"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=18.0.0"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@modelcontextprotocol/sdk": "^1.11.4",
|
|
44
|
+
"zod": "^3.24.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/node": "^20.0.0",
|
|
48
|
+
"typescript": "^5.3.0"
|
|
49
|
+
}
|
|
50
|
+
}
|