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

# MCP

> Serve remember and query as tools of an MCP server, so MCP clients can use gligabao as their memory.

gligabao can serve `remember` and `query` as tools of an [MCP](https://modelcontextprotocol.io) (Model Context Protocol) server, so that MCP clients (Claude Desktop, Claude Code, IDE agents, ...) can use it as their memory. It is built on the official Go SDK, [`modelcontextprotocol/go-sdk`](https://github.com/modelcontextprotocol/go-sdk).

> [!WARNING]
>
> **It is off by default and has no authentication.** Enable it with `mcp = true` in the config file (`build/gligabao.toml`) or `serve --mcp`. Callers choose the `user_id` themselves (an argument of every tool, which the tool sends to the handler as the `gb-user-id` header), exactly as with the REST API when no `Auth` hook is set, so turn it on only on a trusted network. The endpoint is **not** covered by the `Auth` hook (a warning is logged at startup if both are set); when gligabao is [mounted](https://gligabao.mintlify.site/embedding/go-library.md#mounting-on-your-own-http-server) on a host's mux, `MountOptions.Wrap` does cover it, as it is under `/v1/gb/`.

## Endpoint

`/v1/gb/mcp`, the MCP *streamable HTTP* transport (`POST`; `GET` and `DELETE` are answered too, as the transport requires). The server is stateless: no session is kept between calls, and answers are plain JSON (no event stream).

```sh theme={null}
claude mcp add --transport http gligabao http://localhost:7878/v1/gb/mcp
```

For a client that takes a JSON config:

```json theme={null}
{"mcpServers": {"gligabao": {"type": "http", "url": "http://localhost:7878/v1/gb/mcp"}}}
```

## Tools

`remember` and `query`, and the three tools of the [research agents](#research-agents). Each runs the handler of the matching REST endpoint in process, so validation, limits, errors, monitoring events (`remember.completed`, `query.completed`, ...) and results are those of the endpoint; see its page for the details of every field.

### `remember`

Stores a text in memory, like [`POST /v1/gb/remember`](https://gligabao.mintlify.site/api-reference/remember) with a text.

| Argument | | |
| - | - | - |
| `user_id` | required | The user that owns the dataset |
| `text` | required | The text to remember (at most 1 MiB) |
| `dataset` | optional | The dataset to store into, created if missing (default `main`) |
| `kind` | optional | `knowledge` (default) or `episode` |
| `session_id` | optional | A label for the user/agent session ([Sessions](https://gligabao.mintlify.site/concepts/sessions.md)) |
| `reference_time` | optional | When the text was written, RFC 3339 (default now) |

The other options of the endpoint (`image`, `models`, `reasoning`, `web_search`, `timeseries`) are not available through MCP yet.

### `query`

Answers a question from the graph, like [`POST /v1/gb/query`](https://gligabao.mintlify.site/api-reference/query).

| Argument | | |
| - | - | - |
| `user_id` | required | The user that owns the dataset |
| `query` | required | The question |
| `dataset` | optional | The dataset to search (default `main`) |
| `session_id` | optional | A label for the user/agent session |
| `reasoning` | optional | `none` (default), `low`, `medium` or `high` |

### Research agents

Three tools run the handlers of the [research agent](https://gligabao.mintlify.site/guides/research.md) endpoints: `research_start` is [`POST /v1/gb/research`](https://gligabao.mintlify.site/guides/research#post-v1gbresearch), `research_list` is `GET /v1/gb/research` and `research_get` is `GET /v1/gb/research/{id}`. A research runs in the background and costs money (model calls and web searches): start it, then read it with `research_get` until its `status` is `completed` (the `report` is in it, with every `state` the agent went through) or `failed`.

| Tool | Arguments |
| - | - |
| `research_start` | `user_id` (required), `topic` (required), `agent` (optional: the [agent definition](https://gligabao.mintlify.site/guides/agent-defs.md) to run, default `default`), `agent_version` (optional: a version constraint such as `1.2.0`, `>=1.0` or `^1.2`), `max_steps` (optional, default: the agent's, 20 for `default` and 60 for `investigator`; at most 40 for the simple loop, 300 for the investigative one), `model` (optional: default the agent's, else the server's), `max_cost_usd` (optional: a cap in USD on the whole research, sub-agents included, see [cost caps](https://gligabao.mintlify.site/guides/agent-defs.md#limits-cost-caps)), `dataset` (optional: the dataset of the knowledge base the agent queries and remembers into, default `main`), `runner` (optional: `local`, the default, runs the agent in the server; `modal` runs the `gligabao_agent` binary in Modal through the sidecar, see [research.md](https://gligabao.mintlify.site/guides/research.md#where-the-agent-runs-the-runner)) |
| `research_list` | `user_id` (required), `active` (optional: only the agents working now), `status` (optional: `running`, `completed`, `failed` or `stopped`), `limit` (optional) |
| `research_get` | `user_id` (required), `id` (required: the id `research_start` returned) |

### Results

On success the result is the JSON response of the endpoint, both as the tool's structured content and as text. If the endpoint answers with an error status (invalid argument `400`, dataset not found `404`, no LLM key `503`, failed LLM call `502`, ...) the result is a tool error (`isError: true`) whose text is the endpoint's message and status, so that the model can see what went wrong and correct the call. Arguments that do not match the tool's input schema (a missing `user_id` or `text`) are rejected by the MCP layer before the handler runs.

## Not included yet

Authentication, the other endpoints (datasets, timeseries, ontologies) as tools, cancelling a research, MCP resources and prompts. See the [roadmap](https://github.com/deepblue-phoenix/gligabao/blob/main/docs/roadmap/ROADMAP.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.