# cogmemai

Preserves project context across sessions, stops risky commands before execution, and audits AI output against rules.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 7
- Author: hifriendbot
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/hifriendbot/cogmemai-mcp
- Updated: 2026-10-13
- HTML: https://affpapa.org/en/nevibecode/mcp/cogmemai

## What it 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.

## Requirements
- Needs: Node.js (commands run via npx)
- Environment variables: `COGMEMAI_API_KEY` — keys and tokens: ask the human for the values, never commit them or put them in shared files.

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add cogmemai -e COGMEMAI_API_KEY=<COGMEMAI_API_KEY> -- npx -y cogmemai-mcp
```
Replace <…> with your own values

### Codex

**Platform CLI**
```bash
codex mcp add cogmemai --env COGMEMAI_API_KEY=<COGMEMAI_API_KEY> -- npx -y cogmemai-mcp
```
Replace <…> with your own values

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "cogmemai": {
            "command": "npx",
            "args": [
                "-y",
                "cogmemai-mcp"
            ],
            "env": {
                "COGMEMAI_API_KEY": "<COGMEMAI_API_KEY>"
            }
        }
    }
}
```
Replace <…> with your own values

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "cogmemai": {
            "type": "stdio",
            "command": "npx",
            "args": [
                "-y",
                "cogmemai-mcp"
            ],
            "env": {
                "COGMEMAI_API_KEY": "<COGMEMAI_API_KEY>"
            }
        }
    }
}
```
Replace <…> with your own values

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add -e COGMEMAI_API_KEY=<COGMEMAI_API_KEY> cogmemai npx -y cogmemai-mcp
```
Replace <…> with your own values

## When to use it
- 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
- 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

## Similar
- [REA](https://affpapa.org/en/nevibecode/mcp/rea.md) — MCP server · ★ 392262
- [GitHub](https://affpapa.org/en/nevibecode/mcp/github.md) — MCP server · ★ 33989
- [Netdata](https://affpapa.org/en/nevibecode/mcp/netdata.md) — MCP server · ★ 81163
- [browser-use](https://affpapa.org/en/nevibecode/mcp/browser-use.md) — MCP server · ★ 119231
- [Codebase Memory](https://affpapa.org/en/nevibecode/mcp/codebase-memory.md) — MCP server · ★ 47577
- [mcp-server](https://affpapa.org/en/nevibecode/mcp/mcp-server.md) — MCP server · ★ 43902

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
