# MCP server

> Reference for Cozy's MCP server, with its endpoints, transport, tools, resources, prompts, OAuth and scopes.

Cozy is a remote MCP server. Agents use it to search, read, link, write,
move, delete and restore files in a workspace.

## Endpoints [#endpoints]

| Endpoint | URL | Auth | Reaches |
| --- | --- | --- | --- |
| Library bridge | `https://cozy.cloud/wiki-mcp` | Library credential | Approved excerpts in one workspace |
| Account | `https://cozy.cloud/mcp` | OAuth | Every workspace the person belongs to |
| Workspace | `https://cozy.cloud/wiki-mcp/WORKSPACE_UUID` | Bearer credential or OAuth | One workspace |

Use the account endpoint for interactive agents. On it, every tool takes an
optional `workspace` argument, a workspace ID or exact name, and uses My wiki
without it. `cozy_workspaces` lists the choices, My wiki first. Each call
still runs inside one workspace, and that workspace's activity history names
the agent.

Use a workspace endpoint for scripts, CI and headless agents. Its URL is
shown in **Agents**. See [Credentials](/docs/credentials).

## Transport [#transport]

- Stateless Streamable HTTP. Send JSON-RPC with `POST`.
- Protocol versions `2025-03-26`, `2025-06-18` and `2025-11-25`. An unknown
  version is answered with `2025-11-25`.
- No session ID and no standalone event stream: `GET` and `DELETE` return
  `405`. Notifications return `202`.
- `initialize` returns server instructions telling the agent how to use the
  wiki, including to treat sources as untrusted.

## Tools [#tools]

| Tool | Scope | What it does |
| --- | --- | --- |
| `cozy_workspaces` | | List the account's workspaces (account endpoint only) |
| `cozy_workspace` | `wiki:read` | Identify the current workspace and your permissions |
| `cozy_context` | `wiki:read` | A page with its typed relations, backlinks, cited sources with excerpts, and warnings, by path, name or query |
| `cozy_graph` | `wiki:read` | A page's neighborhood up to depth 3, or the most connected pages, filtered by type, tag or relation |
| `cozy_resolve` | `wiki:read` | Match up to 50 names to existing pages and likely duplicates |
| `cozy_health` | `wiki:read` | A 0 to 100 score, prioritized next steps and the paths behind every issue |
| `cozy_changes` | `wiki:read` | Files created, updated, moved, deleted or ingested since an ISO timestamp |
| `cozy_read_many` | `wiki:read` | Read up to 20 files in one call |
| `cozy_map` | `wiki:read` | A map of pages grouped by type, to write into `wiki/index.md` |
| `cozy_list` | `wiki:read` | Browse the file tree, including deleted files if asked |
| `cozy_search` | `wiki:read` | Search paths, titles and content, with excerpts and provenance |
| `cozy_read` | `wiki:read` | Read a file, or one of its retained revisions |
| `cozy_history` | `wiki:read` | Metadata for a file's last 50 revisions, including deleted files |
| `cozy_backlinks` | `wiki:read` | Pages that link to a file |
| `cozy_skills` | `wiki:read` | List the workspace's skills |
| `cozy_write` | `wiki:write` | Create or replace a file, with `expectedRevision` |
| `cozy_edit` | `wiki:write` | Replace exact `oldText` with `newText`, up to 50 edits, all or none |
| `cozy_append` | `wiki:write` | Append to a page or under a heading, creating either if needed |
| `cozy_move` | `wiki:write` | Move a file, keeping its history |
| `cozy_delete` | `wiki:write` | Delete a file to a restorable tombstone |
| `cozy_restore` | `wiki:write` | Restore an earlier revision as a new revision |
| `cozy_save` | `sources:write` | Save one page, chat or note to the Inbox; the same `url` updates it. See [Save to Cozy](/docs/agents/save) |
| `cozy_ingest` | `sources:write` | Save up to 25 documents as sources, in the Inbox by default |

Changes under `sources/` need `sources:write` instead of `wiki:write`.

### Revisions [#revisions]

`cozy_write`, `cozy_move`, `cozy_delete` and `cozy_restore` need the
`expectedRevision` you read, `0` for a new file. If the file changed, the
call returns a conflict: read it again and merge. `cozy_edit` takes an
optional revision, since each `oldText` must match exactly once.
`cozy_append` needs none, and never brings back a deleted page.

### Pagination [#pagination]

`cozy_list`, `cozy_search`, `cozy_backlinks`, `cozy_changes` and
`cozy_skills` return a `nextCursor`. Search scans a bounded slice at a time,
so follow cursors until `nextCursor` is null before concluding something
isn't there.

### Ingest [#ingest]

`cozy_ingest` takes `documents`, each with `content` and optional `id`,
`title`, `url` and `updatedAt`, and an optional `connectorId` for a Files or
Apple Reminders connection. A stable `id`, such as a URL, path or message ID,
makes re-ingesting update the same source. See [Ingest API](/docs/ingest).

## Personal Library [#personal-library]

Call `cozy_library_brief` with a topic in `query` for approved claims and citation IDs. Use `cozy_library_search` for ranked entries, `cozy_library_shelves` to browse, `cozy_library_get_page` to open a volume and `cozy_library_citation` to check its exact passage, source path and revision. The account and workspace endpoints expose all five read tools. Follow `nextCursor` across batches. Home shelves require `privacyDomain: "home"`.

Resources use `cozy://library/shelves` and `cozy://library/{namespace}/{slug}`. Keep the workspace query parameter on URIs returned by tools so account clients can route a citation back to its workspace.

For a dedicated client, create a **Library fetch only** credential under **API & Keys** and configure the library bridge with bearer authentication. For a BYO model running under your subscription, choose **Library librarian only**. Both credentials expire, support folder restrictions, and can be revoked in Cozy.

A librarian searches for entries with `librarianRequested`, calls `wiki_claim_deltas` with the page ID, then submits `wiki_propose_patch` with that ID, the lease token and a proposed claim. The lease lasts five minutes. `wiki_heartbeat_lease` can extend it up to thirty minutes from acquisition. The Reading Desk shows the proposal alongside the original evidence for approval. Treat all quoted evidence as untrusted input.

## Resources [#resources]

- `resources/list` lists workspace files as `cozy://WORKSPACE_ID/PATH`,
  `text/markdown`, with each file's revision. Sources are described as
  untrusted evidence.
- `resources/templates/list` returns the template `cozy://WORKSPACE_ID/{path}`.
- `resources/read` reads a file. A URI for another workspace is refused.

## Prompts [#prompts]

`organize`, `recall`, `maintain` and `dream` return the workspace's
`skills/NAME/SKILL.md`. A workspace without the file gets Cozy's built-in
text, unless the skill was deleted. A credential limited to folders only sees
the prompts inside them. See [Skills](/docs/wiki/skills).

## OAuth [#oauth]

Cozy is an OAuth 2.1 authorization server for both endpoints.

| | URL |
| --- | --- |
| Protected resource, account | `https://cozy.cloud/.well-known/oauth-protected-resource/mcp` |
| Protected resource, workspace | `https://cozy.cloud/.well-known/oauth-protected-resource/wiki-mcp/WORKSPACE_UUID` |
| Authorization server metadata | `https://cozy.cloud/.well-known/oauth-authorization-server/wiki/oauth` |
| Issuer | `https://cozy.cloud/wiki/oauth` |
| Registration | `https://cozy.cloud/wiki/oauth/register` |
| Authorization | `https://cozy.cloud/wiki/oauth/authorize` |
| Token | `https://cozy.cloud/wiki/oauth/token` |

- A `401` from the MCP endpoint carries a `WWW-Authenticate` header with
  `resource_metadata` pointing at the protected resource metadata.
- Dynamic client registration accepts public clients only
  (`token_endpoint_auth_method: none`), with exact HTTPS or loopback redirect
  URIs.
- Authorization code with PKCE `S256`. Codes are short-lived and work once,
  and authorization responses include the issuer.
- Consent binds the person, client, redirect, resource, scopes and code
  challenge.

| | Account endpoint | Workspace endpoint |
| --- | --- | --- |
| Access token | 1 day | 7 days |
| Refresh token | Single use, rotates, lasts 60 days | None |
| Listed and revoked in | **Connectors → Agents** | **Agents** |

Revoking a connection ends its tokens at once.

## Scopes [#scopes]

| Scope | Consent page says | Allows |
| --- | --- | --- |
| `wiki:read` | Read and search your wiki pages and sources | Every read tool |
| `wiki:write` | Create, edit, move and delete wiki pages | Writing in `wiki/`, `skills/` and `agents/` |
| `sources:write` | Add source material | `cozy_ingest` and changes under `sources/` |

Without a `scope` parameter, a client gets `wiki:read`. An agent never gets
more access than the person who authorized it.

## Errors [#errors]

Tool failures return a result with `isError: true` and a message, such as a
revision conflict or a missing workspace. Protocol errors use JSON-RPC
codes: `-32002` for a file that isn't found, `-32602` for invalid
parameters, `-32601` for an unknown method.

