cogmemai — Claude Code MCP server: what it does, how to install
Preserves project context across sessions, stops risky commands before execution, and audits AI output against rules.
claude mcp add cogmemai -e COGMEMAI_API_KEY=<COGMEMAI_API_KEY> -- npx -y cogmemai-mcpWhat cogmemai does
CogmemAi functions as a cross-session memory layer for coding agents. It retains project knowledge across editors and machines. Guard policies inspect proposed actions beforehand, intercepting destructive shell commands or unvetted credential exports before they run.
Context usage stays bounded. The recall_memories tool accepts a max_chars limit, returning top matches in full while trimming secondary records to 400-character previews. You can read any truncated item in full with expand_ids or make the ceiling permanent via COGMEMAI_RECALL_MAX_CHARS.
The setup requires a COGMEMAI_API_KEY or an OAuth 2.1 sign-in at https://hifriendbot.com/mcp/. Without the environment key, the server cannot persist records or evaluate incoming rules.
What it helps with
- retain project context and architecture choices across sessions
- block dangerous terminal operations before they execute
- audit assistant work against project constraints
- reduce token overhead when loading multiple memory records
Example prompts for the agent
- Recall our database migration constraints from past sessions
- Check this command against the devsecops rule pack before running it
- Save a persistent rule that cloud storage buckets must remain private
How to install cogmemai
Platform CLI
claude mcp add cogmemai -e COGMEMAI_API_KEY=<COGMEMAI_API_KEY> -- npx -y cogmemai-mcpReplace <…> with your own values
Platform CLI
codex mcp add cogmemai --env COGMEMAI_API_KEY=<COGMEMAI_API_KEY> -- npx -y cogmemai-mcpReplace <…> with your own values
Config file
{
"mcpServers": {
"cogmemai": {
"command": "npx",
"args": [
"-y",
"cogmemai-mcp"
],
"env": {
"COGMEMAI_API_KEY": "<COGMEMAI_API_KEY>"
}
}
}
}Replace <…> with your own values
Config file
{
"servers": {
"cogmemai": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"cogmemai-mcp"
],
"env": {
"COGMEMAI_API_KEY": "<COGMEMAI_API_KEY>"
}
}
}
}Replace <…> with your own values
Platform CLI
gemini mcp add -e COGMEMAI_API_KEY=<COGMEMAI_API_KEY> cogmemai npx -y cogmemai-mcpReplace <…> with your own values
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about cogmemai
How to install cogmemai in Claude Code?
Run claude mcp add cogmemai -e COGMEMAI_API_KEY=<COGMEMAI_API_KEY> -- npx -y cogmemai-mcp.
What does cogmemai do?
It gives coding assistants persistent memory across sessions and inspects tool calls against security rules to prevent destructive actions.
How do you control token usage when fetching memories?
Pass max_chars to recall_memories or configure COGMEMAI_RECALL_MAX_CHARS (such as 8000) in the server environment to get truncated previews instead of full texts.