Mnemosyne MCP
THIS IS A WORK IN PROGRESS AND THE DOCUMENTATION IS AI-GENERATED AND WILL BE REWRITTEN BY HUMAN BEFORE PEOPLE ARE WIDELY ENCOURAGED TO READ IT AND USE THIS CODE. THANK YOU FOR YOUR ATTENTION TO THIS MATTER XOXO VERA
AI-powered knowledge graph integration for Claude Code, Goose & Codex
The Mnemosyne MCP (neem) historically exposed a full suite of graph management tools. We are currently rebuilding those tools from scratch against a new FastAPI backend that runs inside our local kubectl context.
Status: The MCP server now provides 10 tools for knowledge graph management, SPARQL queries, and real-time document editing via Hocuspocus/Y.js.
Features:
- 🔌 Reliable connectivity to a local FastAPI backend (via env vars or kubectl port-forward)
- 🩺 Automatic startup health probe so you know whether the backend is reachable
- 🔐 Browser-based OAuth authentication (
neem init) - 📊 Full graph CRUD operations (create, list, delete)
- 🔍 SPARQL query and update support
- 📝 Real-time document editing via Y.js CRDT
Installation
uv tool install -e .
While developing locally with uv:
uv sync
uv run neem --help
Commands
neem init # Authenticate (run browser-based OAuth)
neem status # Show token status and Claude Code config
neem logout # Remove saved token (optional: keep config)
neem config # Inspect config details (with optional --show-token)
Quick Start
Step 1: Install and authenticate
# Install the package
uv tool install -e .
# Authenticate with Mnemosyne
neem init # Opens your browser to log in
neem inithandles authentication only—the next steps show how to connect each MCP client manually.
Before registering the MCP server, expose the FastAPI backend from your kubectl context (adjust service/namespace/ports as needed):
kubectl port-forward svc/mnemosyne-fastapi 8001:8000
Step 2: Add MCP server to your agent
Skaffold’s default profile port-forwards mnemosyne-api on 8080 for HTTP and mnemosyne-ws on 8001 for WebSockets. Point MNEMOSYNE_FASTAPI_URL at the HTTP port and the MCP server will automatically assume the split WebSocket port on localhost (you can override it with MNEMOSYNE_FASTAPI_WS_PORT or MNEMOSYNE_FASTAPI_WS_URL if your layout differs).
Using Claude Code:
claude mcp add mnemosyne --scope user \
--env MNEMOSYNE_FASTAPI_URL=http://127.0.0.1:8001 \
--env LOG_LEVEL=ERROR \
-- uv run neem-mcp-server
Using Codex
codex mcp add mnemosyne -- uv run neem-mcp-server \
--env MNEMOSYNE_FASTAPI_URL=http://127.0.0.1:8001 \
--env LOG_LEVEL=ERROR
> Dev-mode shortcut: append `--env MNEMOSYNE_DEV_TOKEN=<user>` and `--env MNEMOSYNE_DEV_USER_ID=<user>` to the commands above when the backend runs with `MNEMOSYNE_AUTH__MODE=dev_no_auth`. Both transports will impersonate that user without going through OAuth.
Dev Mode (skip OAuth)
If the backend runs with MNEMOSYNE_AUTH__MODE=dev_no_auth, set both env vars before launching the MCP server to bypass the OAuth flow entirely:
export MNEMOSYNE_DEV_USER_ID=alice
export MNEMOSYNE_DEV_TOKEN=alice # many clusters treat the token string as the user id
uv run neem-mcp-server
Both HTTP requests and the WebSocket handshake will send X-User-ID: alice plus Sec-WebSocket-Protocol: Bearer.alice, satisfying the backend’s dev-mode guards. Unset these envs when targeting production.
Usage Examples
After registering the server, ask your MCP client to run list_graphs. It submits a job, streams realtime events over /ws, and falls back to HTTP polling when the backend does not advertise push hints.
FastAPI Backend Configuration
The MCP server now assumes it should talk to the FastAPI backend that runs in your local kubectl context.
- Point
kubectlat the desired cluster (kubectl config use-context ...). - Port-forward the FastAPI service so it is reachable on your workstation (example:
kubectl port-forward svc/mnemosyne-fastapi 8001:8000). - Start
neem-mcp-serverwith one of the supported backend configuration options:MNEMOSYNE_FASTAPI_URL(preferred) or the legacyMNEMOSYNE_API_URL.MNEMOSYNE_FASTAPI_HOST,MNEMOSYNE_FASTAPI_PORT, and optionalMNEMOSYNE_FASTAPI_SCHEMEif you want to supply host/port separately (handy for kubectl port-forward scripts).MNEMOSYNE_FASTAPI_HEALTH_PATHif the FastAPI app exposes a non-standard health endpoint (defaults to/health).
If none of these environment variables are set the server defaults to http://127.0.0.1:8001, which lines up with the sample port-forward above. On startup we issue a lightweight health probe so you immediately know whether the backend is reachable.
Token Management
Tokens expire after a day. Re-run neem init --force whenever you need a fresh token, and restart Claude Code afterwards.
Important: Set LOG_LEVEL=ERROR for Codex CLI to avoid any stderr interference with the stdio protocol.
Available MCP Tools
Graph Management
list_graphs– List all knowledge graphs owned by the authenticated usercreate_graph– Create a new knowledge graph with ID, title, and optional descriptiondelete_graph– Permanently delete a graph and all its contents
SPARQL Operations
sparql_query– Execute read-only SPARQL SELECT/CONSTRUCT queries against your graphssparql_update– Execute SPARQL INSERT/DELETE/UPDATE operations to modify graph data
Document Operations (via Hocuspocus/Y.js)
get_active_context– Get the currently active graph and document from the Mnemosyne UIget_workspace– Get the folder/file structure of a graphread_document– Read document content as TipTap XMLwrite_document– Replace document content with TipTap XMLappend_to_document– Add a paragraph to an existing document
TipTap XML Format
Documents use TipTap's XML representation with full formatting support:
Blocks: paragraph, heading (level="1-3"), bulletList, orderedList, blockquote, codeBlock (language="..."), taskList, taskItem (checked="true"), horizontalRule
Marks (nestable): strong, em, strike, code, mark (highlight), a (href="...")
Annotation Marks: Special inline marks that reference external content:
footnote– Self-contained annotation withdata-footnote-contentattributecommentMark– Reference annotation withdata-comment-idattribute
Example:
<paragraph>Text with <mark>highlight</mark> and a note<footnote data-footnote-content="This is a footnote"/></paragraph>
All tools submit jobs to the FastAPI backend, stream realtime updates via WebSocket when available, and fall back to HTTP polling otherwise.
Configuration
- Tokens are stored at
~/.mnemosyne/config.json(override withMNEMOSYNE_CONFIG_DIR).
Architecture
This package contains two main components:
1. CLI Tool (neem)
Located in neem.cli:
- OAuth PKCE authentication flow (
neem.utils.oauth) - Secure token storage (
neem.utils.token_storage) - Claude Code configuration management (
neem.utils.claude_config)
2. MCP Server (neem-mcp-server)
Located in neem.mcp.server:
- Stdio transport – Communicates with Claude Code via stdin/stdout
- Backend resolver – Determines the FastAPI base URL from env vars or kubectl service hosts
- Health probe – Pings the FastAPI backend on startup so you know whether the port-forward/context is correct
- Realtime job wiring –
neem.mcp.jobsships a websocket-friendly client that tools can use to subscribe to job progress once the backend emits hints - Structured logging – All logs go to stderr (stdio-safe) with optional file output
Key design principles for this reset:
- Local-first loops – Assume developers are targeting a FastAPI pod through kubectl
- Minimal surface area – Keep the server slim until the new tool contract is finalized
- Explicit configuration – Prefer environment variables over hidden defaults so CLI harnesses can inject settings
Development
Local Development
# Install in development mode
uv sync
uv pip install -e .
# Run the CLI
uv run neem init
# Test the MCP server
uv run neem-mcp-server
Project Structure
src/neem/
├── cli.py # CLI commands
├── mcp/
│ ├── server/
│ │ ├── standalone_server.py # FastAPI backend resolver + health probe (no tools yet)
│ │ └── standalone_server_stdio.py # Stdio transport wrapper
│ ├── session.py # Session management
│ ├── errors.py # MCP-specific errors
│ └── response_objects.py # Formatted MCP responses
└── utils/
├── oauth.py # OAuth PKCE flow
├── token_storage.py # Token persistence
├── claude_config.py # Claude Code config management
├── logging.py # Structured logging
├── deployment_context.py # Environment configuration
└── errors.py # Base error classes
Environment Variables
MNEMOSYNE_FASTAPI_URL– Preferred FastAPI base URL (defaults tohttp://127.0.0.1:8001). The legacyMNEMOSYNE_API_URLis still honored if set.MNEMOSYNE_FASTAPI_HOST,MNEMOSYNE_FASTAPI_PORT,MNEMOSYNE_FASTAPI_SCHEME– Specify host/port separately (handy for scripted kubectl port-forwards).MNEMOSYNE_FASTAPI_HEALTH_PATH– Alternate health-check path if your FastAPI app doesn't expose/health.MNEMOSYNE_FASTAPI_WS_URL– Override the WebSocket gateway directly (defaults tows(s)://<host>/wsderived from the HTTP base).MNEMOSYNE_FASTAPI_WS_PATH– Custom path appended to the derived WebSocket URL whenMNEMOSYNE_FASTAPI_WS_URLis unset.MNEMOSYNE_FASTAPI_WS_PORT– Override just the WebSocket port while keeping the same host/path (useful when HTTP and WS are forwarded on different local ports).MNEMOSYNE_FASTAPI_WS_DISABLE– Set totrueto opt out of WebSocket streaming (falls back to HTTP polling).MNEMOSYNE_CONFIG_DIR– Token storage location (default:~/.mnemosyne)MNEMOSYNE_DEV_TOKEN– Optional dev-only override that skips the OAuth flow by injecting the provided bearer token directly (use only on trusted local stacks).CLAUDE_CODE_SETTINGS_PATH– Claude settings file (default:~/.claude/settings.json)LOG_LEVEL– Logging verbosity (default:INFO)DEBUG– Verbose logging for troubleshootingINFO– Normal operational logging (default)WARNING– Quiet mode, only warnings and errorsERROR– Silent mode, only errors (recommended for Codex CLI)CRITICAL– Minimal logging, critical errors only
Sessions are stored in-memory by default; no external cache service is required.
Troubleshooting
MCP Server Not Loading
For Claude Code:
- Check configuration:
cat ~/.claude.json | grep mnemosyne-graph - Test server directly:
echo '{"jsonrpc": "2.0", "method": "initialize", "id": 1}' | neem-mcp-server - Check logs: Look for stderr output when Claude Code starts
- Verify token:
neem statusshould show "Active" authentication - Restart Claude Code: Configuration changes require a complete restart
For Goose CLI:
- Check configuration:
cat ~/.config/goose/config.yaml | grep mnemosyne-graph - Verify extension is enabled:
enabled: truein the config - Check timeout: Increase to 600 seconds if server is slow to start
- Test in session: Start a new Goose session and ask it to list available tools
- Check environment: Ensure
MNEMOSYNE_FASTAPI_URL(or legacyMNEMOSYNE_API_URL) is set correctly
For Codex CLI:
- Enable debug logging: Codex intentionally silences stderr, making debugging difficult
- Set LOG_LEVEL: Use
LOG_LEVEL=ERRORin the environment to prevent stderr interference - Test manually: Run
echo '{"jsonrpc":"2.0","method":"initialize","id":1}' | neem-mcp-serverto verify it works - Check configuration: Ensure
codex.jsonor your config file has the correct command and environment variables
Authentication Issues
- Token expired: Run
neem init --forceto get a fresh token - Check token:
neem configto see token details - Verify API access: The token should have access to the API endpoint
Upload Issues
- File not found: Ensure the file path is absolute or relative to working directory
- Format detection: Explicitly specify format with
rdf_formatparameter if auto-detection fails - Validation errors: Try
validation_level="lenient"for less strict parsing
Schema/Proto Errors (Goose/Gemini)
If you see errors like "Unknown name 'type'" or "Proto field is not repeating, cannot start list":
- Cause: This was caused by using JSON Schema reserved keywords (
format,type, etc.) as parameter names - Fixed in: Latest version uses
result_formatandrdf_formatinstead offormat - Solution: Update to latest version with
pip install --upgrade neem
Note: Parameter names were changed to avoid conflicts with JSON Schema keywords:
format→result_format(insparql_query)format→rdf_format(inupload_file_to_graph)validation→validation_level(inupload_file_to_graph)
Goose + Gemini users: If you get proto errors even with the latest version, disable Goose's built-in extensions temporarily:
# In ~/.config/goose/config.yaml
extensions:
computercontroller:
enabled: false # Temporarily disable
developer:
enabled: false # Temporarily disable
This is a known issue with Goose's built-in extensions and Gemini compatibility (not a Mnemosyne MCP issue).
See the docs/ directory for end-user quick start and detailed guides that can
ship with the package or be published separately.