> ## Documentation Index
> Fetch the complete documentation index at: https://docs.memcontext.in/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Setup

> Connect MemContext to Claude.ai, Claude Desktop, or your AI coding assistant.

MemContext provides a hosted MCP server. You can connect it directly to Claude.ai or Claude Desktop with OAuth, or use an API key for coding agents like Claude Code, Cursor, OpenCode, and Codex CLI.

## Prerequisites

* A MemContext account at [app.memcontext.in](https://app.memcontext.in)
* An API key if you are connecting a coding agent (create one under **Settings > API Keys**)

<Tip>
  The [MCP page](https://app.memcontext.in/mcp) in your dashboard generates
  ready-to-paste configs with your API key pre-filled.
</Tip>

## Claude.ai & Claude Desktop

Use this path when you want everyday Claude conversations to remember preferences, project context, and recurring details without editing config files.

**Step 1 - Open Connectors**

In Claude.ai or Claude Desktop, open **Settings → Connectors**.

**Step 2 - Add a custom connector**

Choose **Add custom connector**.

**Step 3 - Enter the production URL**

Use:

```text theme={null}
https://mcp.memcontext.in/mcp
```

**Step 4 - Connect and approve access**

Click **Connect**, sign in to MemContext if prompted, then approve the requested scopes on the consent screen.

### Recommended instructions

Paste this into **Claude → Settings → Profile → Instructions for Claude**:

```text theme={null}
- Search MemContext before assuming my preferences, projects, or past decisions.
- Save only stable preferences, recurring facts, and useful project context.
- Do not save one-off questions, random searches, or temporary details unless I ask you to remember them.
- Keep memory updates brief, accurate, and practical.
```

<Note>
  Claude.ai and Claude Desktop use OAuth for this flow. You do not need to paste
  API keys, headers, or config files.
</Note>

## Claude Code

**Step 1 - Add the MCP server via CLI:**

```bash theme={null}
claude mcp add memcontext --scope user --transport http https://mcp.memcontext.in/mcp \
  --header "MEMCONTEXT-API-KEY:mc_your_key"
```

Or add this to `~/.claude.json`:

```json theme={null}
{
  "mcpServers": {
    "memcontext": {
      "url": "https://mcp.memcontext.in/mcp",
      "headers": {
        "MEMCONTEXT-API-KEY": "mc_your_key"
      }
    }
  }
}
```

**Step 2 - Add agent instructions to `~/.claude/CLAUDE.md`:**

```markdown theme={null}
# MemContext

At conversation start, ALWAYS call search_memory to load user context - do not skip.
Before making decisions or assumptions, search_memory to check for past context.
SAVE immediately (do not defer) when any of these happen:

- User shares a preference → save_memory(category: "preference")
- A technology or architecture decision is made → save_memory(category: "decision")
- User corrects you or says "remember" → save_memory(category: "fact")
- Important project fact learned → save_memory(category: "fact", project: "<known-project-name>")
- Significant work completed → save_memory(category: "context")
- MCP tools do not accept scope. Use the REST API or TypeScript SDK when an app needs hard per-user or per-tenant isolation.
- Use project only when a clear project/app name is already known. Good: "memcontext", "carq". Omit if unsure. Never invent vague names like "123" or "abc".
- MCP memories use automatic TTL. Use the REST API, TypeScript SDK, or dashboard when exact expiry is required.
- After using search results, call memory_feedback to rate memories as helpful/not_helpful/outdated/wrong.
- If a retrieved memory is wrong or outdated and you know the corrected fact, call update_memory with the corrected content. Feedback alone only changes retrieval ranking; update_memory changes the saved memory.
- Use delete_memory only when a memory was saved incorrectly and should be removed entirely.
- Duplicates are handled automatically - when in doubt, save.
- Memory persists across all sessions. Use project only for known project-specific context.
```

## Cursor

**Step 1 - Add this to `~/.cursor/mcp.json`:**

```json theme={null}
{
  "mcpServers": {
    "memcontext": {
      "url": "https://mcp.memcontext.in/mcp",
      "headers": {
        "x-api-key": "mc_your_key"
      }
    }
  }
}
```

**Step 2 - Add the [agent instructions](#agent-instructions) to Cursor Settings > Rules and commands > User Rules.**

## OpenCode

**Step 1 - Add the MCP server to `~/.config/opencode/opencode.json`:**

```json theme={null}
{
  "mcp": {
    "memcontext": {
      "type": "local",
      "command": [
        "npx",
        "-y",
        "mcp-remote",
        "https://mcp.memcontext.in/mcp",
        "--header",
        "MEMCONTEXT-API-KEY:mc_your_key"
      ],
      "enabled": true
    }
  }
}
```

**Step 2 - Add the [agent instructions](#agent-instructions) to `~/.config/opencode/AGENTS.md`.**

## Codex CLI

**Step 1 - Add the MCP server to `~/.codex/config.toml`:**

```toml theme={null}
[mcp_servers.memcontext]
url = "https://mcp.memcontext.in/mcp"

[mcp_servers.memcontext.http_headers]
MEMCONTEXT-API-KEY = "mc_your_key"
```

**Step 2 - Add the [agent instructions](#agent-instructions) to `~/.codex/instructions.md`.**

## Agent instructions

These instructions tell your AI assistant how and when to use MemContext. Add them to the preferences file for your client (listed above):

```markdown theme={null}
# MemContext

At conversation start, ALWAYS call search_memory to load user context - do not skip.
Before making decisions or assumptions, search_memory to check for past context.
SAVE immediately (do not defer) when any of these happen:

- User shares a preference → save_memory(category: "preference")
- A technology or architecture decision is made → save_memory(category: "decision")
- User corrects you or says "remember" → save_memory(category: "fact")
- Important project fact learned → save_memory(category: "fact", project: "<known-project-name>")
- Significant work completed → save_memory(category: "context")
- MCP tools do not accept scope. Use the REST API or TypeScript SDK when an app needs hard per-user or per-tenant isolation.
- Use project only when a clear project/app name is already known. Good: "memcontext", "carq". Omit if unsure. Never invent vague names like "123" or "abc".
- MCP memories use automatic TTL. Use the REST API, TypeScript SDK, or dashboard when exact expiry is required.
- After using search results, call memory_feedback to rate memories as helpful/not_helpful/outdated/wrong.
- If a retrieved memory is wrong or outdated and you know the corrected fact, call update_memory with the corrected content. Feedback alone only changes retrieval ranking; update_memory changes the saved memory.
- Use delete_memory only when a memory was saved incorrectly and should be removed entirely.
- Duplicates are handled automatically - when in doubt, save.
- Memory persists across all sessions. Use project only for known project-specific context.
```

| Client      | Preferences file                                  |
| ----------- | ------------------------------------------------- |
| Claude Code | `~/.claude/CLAUDE.md`                             |
| Cursor      | Cursor Settings > Rules and commands > User Rules |
| OpenCode    | `~/.config/opencode/AGENTS.md`                    |
| Codex CLI   | `~/.codex/instructions.md`                        |

## Available tools

Once connected, your assistant has access to five tools:

| Tool              | Purpose                                            |
| ----------------- | -------------------------------------------------- |
| `save_memory`     | Persist preferences, facts, decisions, and context |
| `search_memory`   | Find relevant memories before responding           |
| `memory_feedback` | Rate memory quality after retrieval                |
| `update_memory`   | Correct or refine an existing saved memory         |
| `delete_memory`   | Remove a memory by ID                              |

See the [MCP Tools](/mcp/overview) section for parameter documentation.

## Verifying the connection

After setup, ask Claude or your coding assistant:

> "Search your memory for any information about me."

If the connection is working, it will call `search_memory` and return results (or an empty set if no memories exist yet).
