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

# Cognee Cloud & MCP

> Connect Cognee MCP to your Cognee Cloud tenant with an API base URL and API key.

## Connecting MCP to Cognee Cloud

The Cognee MCP server can connect to your Cognee Cloud tenant using the `--serve-url` and `--serve-api-key` flags (or their environment variable equivalents `COGNEE_BASE_URL` and `COGNEE_API_KEY`). This lets any MCP-compatible client (Claude Desktop, Cursor, VS Code Copilot) work with your cloud-hosted knowledge graph.

|                    | Cognee MCP                                                                    | Cognee Cloud                           |
| ------------------ | ----------------------------------------------------------------------------- | -------------------------------------- |
| **Where it runs**  | Locally on your machine                                                       | Hosted by Cognee                       |
| **Access method**  | MCP protocol                                                                  | `cognee` SDK via `serve()` or Cloud UI |
| **Authentication** | Bearer token (self-hosted)                                                    | `X-Api-Key` header                     |
| **API endpoints**  | Self-hosted backend endpoints such as `/api/v1/remember` and `/api/v1/recall` | Hosted SDK/client flow via `serve()`   |
| **Use case**       | AI IDE tools (Cursor, Claude Code, etc.)                                      | Cloud-managed knowledge graphs         |

### Why `API_URL` only works with self-hosted Cognee backends

The MCP server's `API_URL` / `API_TOKEN` mechanism is designed for **self-hosted Cognee backends**. When the MCP server runs in API mode, it:

* Sends requests to self-hosted Cognee endpoints such as `/api/v1/remember`, `/api/v1/recall`, `/api/v1/improve`, and `/api/v1/forget`
* Authenticates with `Authorization: Bearer <token>`

<Note>
  The older `API_URL` / `API_TOKEN` environment variables are designed for **self-hosted Cognee backends**, not Cognee Cloud. Use `--serve-url` / `COGNEE_BASE_URL` and `--serve-api-key` / `COGNEE_API_KEY` for Cloud connections.
</Note>

## End-to-end walkthrough

<Steps>
  <Step title="Get your API credentials">
    Open the [API Keys](/cognee-cloud/ui/api-keys) page in the Cognee Cloud console. Copy:

    * **API Base URL** — looks like `https://your-tenant.aws.cognee.ai`
    * **API Key** — a long token used to authenticate requests
  </Step>

  <Step title="Start the MCP server">
    Pass your credentials via CLI flags or environment variables:

    <Tabs>
      <Tab title="CLI flags">
        ```bash theme={null}
        cognee-mcp --transport sse --port 8001 \
          --serve-url https://your-tenant.aws.cognee.ai \
          --serve-api-key your-api-key
        ```
      </Tab>

      <Tab title="Environment variables">
        ```bash theme={null}
        export COGNEE_BASE_URL="https://your-tenant.aws.cognee.ai"
        export COGNEE_API_KEY="your-api-key"

        cognee-mcp --transport sse --port 8001
        ```

        You can also place these in your `.env` file alongside other configuration.
      </Tab>
    </Tabs>

    The server is ready when you see output like:

    ```
    INFO: Started server process
    INFO: Waiting for connections on http://127.0.0.1:8001
    ```
  </Step>

  <Step title="Add Cognee to your MCP client">
    Add the server to your client's MCP configuration. The config file location varies by client — see the [integrations](/cognee-mcp/integrations) section for your specific tool.

    ```json theme={null}
    {
      "mcpServers": {
        "cognee": {
          "url": "http://localhost:8001/sse"
        }
      }
    }
    ```
  </Step>

  <Step title="Verify the connection">
    Test that memory operations reach your Cloud tenant. In your MCP client, ask:

    > "Use Cognee to remember: cloud connection test successful"

    Then retrieve it:

    > "Use Cognee to recall the cloud connection test"

    If Cognee returns the stored value, the end-to-end connection is working. You can also confirm the data appeared in the [Cognee Cloud UI](/cognee-cloud/ui/datasets).
  </Step>
</Steps>

## Available tools

Once connected, your MCP client gets the Cognee API v1 memory tools:

| Tool       | Description                                      |
| ---------- | ------------------------------------------------ |
| `remember` | Store data in memory (add + cognify in one step) |
| `recall`   | Search memory with auto-routing                  |
| `forget`   | Delete data from memory                          |

## Other connection options

<AccordionGroup>
  <Accordion title="Use Cognee MCP for local AI memory (standalone)">
    Run the MCP server in **standalone mode** (no Cloud connection). The server manages its own local knowledge graph.

    ```bash theme={null}
    # Standalone mode — requires LLM_API_KEY
    LLM_API_KEY=sk-... cognee-mcp --transport sse --port 8001
    ```

    This is the simplest way to add persistent memory to Cursor, Claude Code, Cline, and other MCP-compatible tools.
  </Accordion>

  <Accordion title="Use the Python SDK instead">
    Access Cognee Cloud programmatically using the [`cognee` SDK](/cognee-cloud/connections/cloud-sdk) connected through `serve()`, which handles authentication and communication with the hosted service.

    ```bash theme={null}
    export COGNEE_BASE_URL="https://your-tenant.aws.cognee.ai"
    export COGNEE_API_KEY="your-cognee-cloud-api-key"
    ```

    ```python theme={null}
    import asyncio
    import cognee

    async def main():
        await cognee.serve()  # Reads COGNEE_BASE_URL and COGNEE_API_KEY
        await cognee.remember("...", dataset_name="my_dataset")
        results = await cognee.recall("...", datasets=["my_dataset"])
        print(results)

    asyncio.run(main())
    ```

    If you prefer not to use environment variables, pass both values directly:

    ```python theme={null}
    await cognee.serve(
        url="https://your-tenant.aws.cognee.ai",
        api_key="your-api-key",
    )
    ```

    See the [Cloud SDK guide](/cognee-cloud/connections/cloud-sdk) for a complete walkthrough.
  </Accordion>

  <Accordion title="Connect MCP to a self-hosted Cognee backend">
    If you want multiple AI clients to share a single knowledge graph, run a self-hosted Cognee backend and point the MCP server at it using `API_URL` and `API_TOKEN`:

    ```bash theme={null}
    # 1. Start a self-hosted Cognee backend
    docker run -e LLM_API_KEY=your_key -p 8080:8000 --rm -it cognee/cognee:main

    # 2. Start MCP in API mode pointing to your backend
    docker run \
      -e TRANSPORT_MODE=sse \
      -e API_URL=http://localhost:8080 \
      -e API_TOKEN=your_backend_token \
      -p 8000:8000 --rm -it cognee/cognee-mcp:main
    ```

    See the [MCP Quickstart](/cognee-mcp/mcp-quickstart#api-mode-shared-knowledge-graph) for full details on this pattern.
  </Accordion>
</AccordionGroup>
