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

# MCP Server

> Connect any MCP client to BaseLayer.

# MCP Server

BaseLayer exposes your knowledge graph via [MCP (Model Context Protocol)](https://modelcontextprotocol.io). Any MCP-compatible client can connect to search, store, and recall your knowledge.

## Connect via OAuth (recommended)

The easiest way to connect any MCP client to BaseLayer is via OAuth. No API keys needed.

### Remote MCP (Claude.ai, ChatGPT, etc.)

For cloud-based AI tools that support remote MCP:

1. In your AI tool's settings, add a new MCP integration
2. Enter the server URL:
   ```
   https://api.baselayer.id/mcp
   ```
3. You'll be redirected to BaseLayer to sign in and authorize the connection
4. Click **Allow** — done

### CLI tools (Claude Code, Gemini CLI, etc.)

CLI-based tools connect to the remote MCP endpoint via SSE:

```bash theme={null}
# Claude Code
claude mcp add --transport sse baselayer https://api.baselayer.id/mcp

# Gemini CLI
gemini mcp add baselayer https://api.baselayer.id/mcp
```

### IDE tools (Cursor, Windsurf, Copilot)

Add BaseLayer to your IDE's MCP configuration file:

```json theme={null}
{
  "mcpServers": {
    "baselayer": {
      "url": "https://api.baselayer.id/mcp"
    }
  }
}
```

See specific setup guides:

* [Claude.ai](/integrations/claude-ai)
* [ChatGPT](/integrations/chatgpt)
* [Claude Code](/integrations/claude-code)
* [Cursor](/integrations/cursor)
* [Windsurf](/integrations/windsurf)
* [GitHub Copilot](/integrations/copilot)
* [Gemini CLI](/integrations/gemini-cli)

## Available tools

Once connected, your AI can use these tools:

### Querying

| Tool              | What it does                                                                  |
| ----------------- | ----------------------------------------------------------------------------- |
| **ask\_question** | Ask a natural language question and get a synthesized answer from your memory |

### Searching

| Tool                        | What it does                                                       |
| --------------------------- | ------------------------------------------------------------------ |
| **memory\_search**          | Semantic search across entities and fact edges                     |
| **get\_entity**             | Fetch a full entity dossier (overview, facts, timeline, relations) |
| **get\_entity\_relations**  | Explore connections between entities                               |
| **get\_entity\_provenance** | Trace where a piece of knowledge came from                         |
| **list\_entities**          | Browse all entities of a given type                                |
| **recent\_conversations**   | Load recent conversation context                                   |
| **retrieve\_evidence**      | Search raw conversation history for exact quotes                   |

### Writing

| Tool               | What it does                                   |
| ------------------ | ---------------------------------------------- |
| **record\_memory** | Store a new observation or memory              |
| **vault\_fact**    | Assert a specific fact connecting two entities |
| **update\_plan**   | Create or update a persistent plan scratchpad  |

## OAuth scopes

MCP clients are granted the `mcp:tools` scope by default, which provides access to all available tools.

## Verify the connection

Ask your AI:

> "What do you know about me?"

It should call `ask_question` and return knowledge from your memory.

<Accordion title="Advanced: Manual API Key Setup">
  OAuth is recommended for most users. Only use API keys for custom integrations or self-built MCP clients.

  1. Go to [baselayer.id/credentials](https://baselayer.id/credentials)
  2. Click **Create API Key**
  3. Copy the key and configure your MCP client:

  ```json theme={null}
  {
    "mcpServers": {
      "baselayer": {
        "url": "https://api.baselayer.id/mcp",
        "headers": {
          "Authorization": "Bearer YOUR_API_KEY"
        }
      }
    }
  }
  ```

  <Note>API keys are for advanced integrations. OAuth is simpler and more secure for standard MCP clients.</Note>
</Accordion>
