# MCP Integration

This guide explains how to use AgentPlaybooks with the Model Context Protocol (MCP).

## What is MCP?

The [Model Context Protocol](https://modelcontextprotocol.io/) (MCP) is an open standard developed by Anthropic that enables AI assistants to securely connect to external data sources and tools.

AgentPlaybooks provides a direct MCP endpoint for each playbook and a user-level
control plane that can create a playbook and immediately apply it.

| Scope | MCP endpoint | Playbook identity |
|-------|--------------|-------------------|
| User control plane | `https://agentplaybooks.ai/api/mcp/manage` | Required `playbook_id` tool argument |
| Direct playbook | `https://agentplaybooks.ai/api/mcp/YOUR_GUID` | Bound in the URL |
| Scripts, no MCP | `https://agentplaybooks.ai/api/mcp/YOUR_GUID/llms.txt` | Bound in the URL |

The third row is for agents that write code instead of calling tools one at a
time — some of them cannot call MCP tools from inside their scripts at all.
`llms.txt` is one fetch that explains authentication and the one-POST calling
convention (`POST /api/playbooks/YOUR_GUID/operations/TOOL_NAME` with JSON arguments), with a
one-shot example per tool. The dashboard's Integrations tab shows all three.

OAuth 2.1 with PKCE is the default for interactive clients. The endpoint
publishes protected-resource metadata, discovers the AgentPlaybooks
authorization server, and shows a consent screen before account access is
granted. User and playbook API keys remain supported for headless automation
and clients without OAuth.

Both scopes project the same canonical playbook operations. The user control
plane is the endpoint published to registries such as Glama because it supports
the full account-to-playbook lifecycle in one connection.

## Quick Start

### 1. Get Your MCP Endpoint

After creating and publishing a playbook, your MCP endpoint is:

```
https://apbks.com/api/mcp/YOUR_GUID
```

### 2. Configure Your MCP Client

#### One-click install (Cursor, VS Code)

Both editors accept an install link that opens their own dialog with the
server already filled in. The endpoint signs you in with your AgentPlaybooks
account (OAuth), so the link carries only the URL — no key is written into the
editor's config.

**Your whole account** — every playbook you own or have been given:

- [Add AgentPlaybooks to Cursor](cursor://anysphere.cursor-deeplink/mcp/install?name=agentplaybooks&config=eyJ0eXBlIjoiaHR0cCIsInVybCI6Imh0dHBzOi8vYWdlbnRwbGF5Ym9va3MuYWkvYXBpL21jcC9tYW5hZ2UifQ%3D%3D)
- [Add AgentPlaybooks to VS Code](vscode:mcp/install?%7B%22name%22%3A%22agentplaybooks%22%2C%22type%22%3A%22http%22%2C%22url%22%3A%22https%3A%2F%2Fagentplaybooks.ai%2Fapi%2Fmcp%2Fmanage%22%7D)

**One playbook** — open the playbook's **Integrations** tab and use **Add to
Cursor** or **Add to VS Code** there; those links carry that playbook's own URL.

To build a link yourself, the formats are:

```text
cursor://anysphere.cursor-deeplink/mcp/install?name=<entry>&config=<base64 of {"type":"http","url":"<endpoint>"}>
vscode:mcp/install?<URL-encoded {"name":"<entry>","type":"http","url":"<endpoint>"}>
```

`src/lib/mcp-install-links.ts` builds both, with tests. If the editor's sign-in
does not open, use the manual configuration below with an API key instead.

#### Cursor IDE

Add to your project's `.cursor/mcp.json` or global `~/.cursor/mcp.json`:

```json
{
  "mcpServers": {
    "apb-my-playbook": {
      "url": "https://apbks.com/api/mcp/YOUR_GUID"
    }
  }
}
```

For **private playbooks**, include your API key in the headers:

```json
{
  "mcpServers": {
    "apb-my-playbook": {
      "url": "https://apbks.com/api/mcp/YOUR_GUID",
      "headers": {
        "Authorization": "Bearer YOUR_API_KEY"
      }
    }
  }
}
```

After saving, restart Cursor or reload the window. Your playbook's tools and resources will appear in the MCP tools panel.

> **Tip:** You can find the ready-to-copy config in the **Integrations** tab of your playbook's dashboard. The server name uses the short `apb-` prefix to stay within Cursor's 60-character combined name limit.

#### Claude (web, Desktop, Cowork, mobile)

Add the endpoint as a custom connector — no API key needed, because the endpoint
signs you in with your AgentPlaybooks account over OAuth:

1. Open [Customize → Connectors](https://claude.ai/customize/connectors) and
   choose **Add custom connector**.
2. Paste `https://agentplaybooks.ai/api/mcp/YOUR_GUID`, or
   `https://agentplaybooks.ai/api/mcp/manage` for every playbook in your account.
3. Select **Add**, then **Connect**, and sign in.

Or install the **AgentPlaybooks plugin**, which adds the account connector and a
skill for using it. [AgentPlaybooks in Claude](/docs/claude) covers both routes,
Team and Enterprise plans, and self-hosted servers.

> **Not `claude_desktop_config.json`.** That file describes local stdio servers
> only — a `command` and its arguments. A `url` and `headers` written there are
> ignored, and nothing reports an error: the server never appears. Earlier
> versions of this page recommended it; it could not have worked.

#### Claude Code (CLI)

```bash
claude mcp add --transport http apb-my-playbook https://agentplaybooks.ai/api/mcp/YOUR_GUID
```

Then run `/mcp` and choose **Authenticate** to sign in.

Verify the connection:

```bash
claude mcp list
```

#### Custom MCP Client

```typescript
import { Client } from "@modelcontextprotocol/sdk/client";

const client = new Client({
  name: "my-app",
  version: "1.0.0"
});

// Connect to playbook
await client.connect({
  transport: "http",
  url: "https://apbks.com/api/mcp/YOUR_GUID"
});

// List available tools
const tools = await client.listTools();

// Read resources
const memory = await client.readResource({
  uri: "playbook://YOUR_GUID/memory"
});
```

## Agent Usage Pattern (Recommended)

To match AgentPlaybooks goals (portable, up-to-date, self-improving agents), run MCP in this loop:

1. **Initialize and inspect once**
   - `initialize`
   - `tools/list`
   - `resources/list`
2. **Read the guide first**
   - `resources/read` for `playbook://YOUR_GUID/guide`
3. **Fetch only what you need**
   - `read_memory` for known keys
   - `search_memory` for discovery
   - `read_canvas` / `get_canvas_toc` for longer docs and plans
4. **Execute work with tools**
   - Use built-in playbook tools and skill tools
5. **Write back outcomes**
   - `write_memory` for compact facts/state
   - `write_canvas` / `patch_canvas_section` for detailed runbooks, postmortems, or long plans

This keeps context fresh, avoids token waste, and prevents repeating the same mistakes across sessions.

## MCP Server Manifest

When you access the MCP endpoint, it returns a server manifest:

```json
{
  "protocolVersion": "2024-11-05",
  "serverInfo": {
    "name": "My AI Assistant",
    "version": "1.0.0",
    "description": "A helpful coding assistant"
  },
  "capabilities": {
    "tools": {},
    "resources": {}
  },
  "tools": [
    {
      "name": "code_review",
      "description": "Review code for bugs and improvements",
      "inputSchema": {
        "type": "object",
        "properties": {
          "code": { "type": "string" },
          "language": { "type": "string" }
        }
      }
    }
  ],
  "resources": [
    {
      "uri": "playbook://abc123/personas",
      "name": "Personas",
      "description": "AI personalities and system prompts",
      "mimeType": "application/json"
    },
    {
      "uri": "playbook://abc123/memory",
      "name": "Memory",
      "description": "Persistent key-value memory storage",
      "mimeType": "application/json"
    }
  ],
  "_playbook": {
    "guid": "abc123",
    "personas": [
      {
        "name": "Coder",
        "systemPrompt": "You are a helpful coding assistant..."
      }
    ]
  }
}
```

## Available Tools

The MCP server exposes built-in tools for interacting with the playbook. Skills are **not** exposed as separate tools — they are instructions and knowledge that agents read via the `list_skills`, `get_skill` tools or the Skills resource.

### Built-in Tool Categories

| Category | Tools |
|----------|-------|
| **Skills** | `list_skills` (metadata), `get_skill` (main document and file manifest), `get_skill_reference` (one file/section), `create_skill`, `update_skill`, `delete_skill`, `list_skill_versions`, `rollback_skill` |
| **Memory** | `read_memory`, `write_memory`, `search_memory`, `delete_memory`, `consolidate_memories`, `promote_memory`, `get_memory_context`, `archive_memories`, `get_memory_tree`, `create_task_graph`, `update_task_status` |
| **Canvas** | `list_canvas`, `read_canvas`, `write_canvas`, `patch_canvas_section`, `get_canvas_toc`, `lock_canvas_section`, `unlock_canvas_section` |
| **Workflow runs** | `list_runs`, `create_run`, `update_run`, `delete_run` |
| **Connected MCP/OpenAPI** | `list_mcp_servers`, `create_mcp_server`, `update_mcp_server`, `delete_mcp_server`, `call_connected_tool` |
| **Secrets** | `list_secrets`, `use_secret`, `use_secret_write`, `reveal_secret`, `store_secret`, `rotate_secret`, `delete_secret` |
| **Playbook** | `update_playbook` |
| **Discovery** | `find_tools` |

Canvas documents are isolated by workflow run. Pass `run_id` to document-level
canvas tools; create one first with `create_run`. The control plane additionally
requires `playbook_id`, while the direct endpoint gets the playbook from its URL.

### Toolsets: advertise less, keep everything callable

A connected client pays tokens for every advertised tool on every call. The
`toolset` query parameter narrows what `tools/list` returns:

```text
https://agentplaybooks.ai/api/mcp/YOUR_GUID?toolset=runtime
```

| Toolset | Advertises | Calls outside it |
|---------|-----------|------------------|
| *(none)* / `full` | everything, plus `find_tools` | allowed — the default view is ergonomics, not policy |
| `runtime` | everything except the 12 playbook-administration tools (skill/server/secret/playbook CUD), plus `find_tools` | **refused** |
| `memory` | the 9 memory tools only | **refused** |
| `admin` | the 12 administration tools only | **refused** |

One connection is enough. On an unpinned connection the agent discovers what it
needs with `find_tools(query)` — keyword search over the full catalog, built-in
and federated alike, returning name, description, and input schema — and then
calls the result if the host exposes it. The server accepts supported names
even when they are omitted from its advertised view, but schemas returned by
`find_tools` do not register new functions in the host. Clients that call only
advertised tools can use the authenticated REST operation route when an HTTP
executor is available. The full catalog remains an opt-in compatibility fallback. Add the same
playbook twice only when you *want* differently scoped connections: a pinned
toolset is a deliberate boundary, and `find_tools` on a pinned connection
searches only within it. An unknown toolset name is a 400, never a silent
fallback to `full`.

### API contract versioning

Plugin releases, AgentPlaybooks API contracts and MCP wire-protocol versions
are independent. The existing operation contract is the `1.0.0` baseline;
the additive discovery and secret diagnostics are API `1.1.0`.

| Surface | Version selection | Compatibility |
|---------|-------------------|---------------|
| Released plugin `0.9.1` | Existing URL, no API header | API `1.x`; captured legacy contract tests remain required |
| Plugin compatibility manifest | Minimum `1.0.0`, maximum exclusive `2.0.0` | New optional features declare their own `since` version |
| REST operations | `/api/v1/control/{operation}` or `/api/v1/playbooks/{guid}/operations/{operation}` | Explicitly pinned to major `1`; same handlers and permission checks |
| MCP | Existing canonical endpoint plus optional `X-AgentPlaybooks-API-Version: 1` | No OAuth resource URL change; omitted header remains pinned to v1 |

`GET /api/versions` is a small public compatibility document. It reports the
current API revision, supported majors, the permanent unversioned-v1 alias,
feature introduction versions, and the versioning policy. It contains no tool
schemas, account data or vault data. `get_connection_info` also reports this
information on demand. Neither endpoint can establish which plugin version a
host actually installed.

Request `X-AgentPlaybooks-API-Version: 1` to select the **major**, not the
full revision. Responses report the major in that header and the full revision
in `X-AgentPlaybooks-API-Revision: 1.1.0`. The unrelated
`MCP-Protocol-Version` selects the MCP transport protocol; it does not select
the AgentPlaybooks operation contract. Unsupported API majors fail before
execution with `reason=unsupported_api_version`, supported majors and a next
step. A v1 path with a conflicting header fails with `api_version_conflict`.
There is no silent downgrade or credential-bearing redirect.

Each packaged plugin includes
`skills/agentplaybooks/references/api-compatibility.json`, alongside its own
plugin release version. This declares its API bounds and optional capabilities
without using unsupported fields in host-owned MCP manifests. Release checks
reject a plugin/server API-range mismatch or disagreement on feature versions.
A server without API metadata is reported as unversioned/unknown, not assumed
to support every new feature.

Breaking changes require a new major **and separate handlers** plus contract
tests; adding a number to the supported list is not a migration. Existing v1
URLs, permissions, required arguments, response envelopes and defaults remain
stable. Additive capabilities use minor releases; compatible bug fixes use
patch releases. Plugin releases can change independently while their declared
API range stays the same. Upstream connected services retain their own API
contracts; their changing schemas or permissions are not covered by the APB
version number. Deprecation requires advance documentation and an
explicit migration; the unversioned aliases must never silently follow v2.

### Compatibility with existing plugins

Existing MCP endpoints, OAuth resources, tool names, required arguments and
response envelopes remain supported. The compact view retains the previously
advertised tools and their input/output schemas. New diagnostics are additive.
Legacy `find_tools` calls without `include_schemas` still return full schemas;
short results are requested explicitly with `include_schemas=false`. Existing
REST operation status codes and text-result precedence are preserved, with
additional diagnostic fields in error bodies. New secret operations require a
catalog refresh or updated skill to discover, not a credential migration.

### Account connection diagnostics

The default account `core` catalog advertises `get_secret_status`, `use_secret`
and `use_secret_write` directly, with `playbook_id` required. Status checks are
value-free; proxy calls inject credentials on the server. Existing account and
playbook authorization and read/write effect annotations still apply.
`reveal_secret` and vault administration remain outside the compact catalog.

When deploying a catalog fix, verify that these names appear in both
`get_connection_info.advertised_tools` and MCP `tools/list` on the existing OAuth
connection. Then refresh the client's tool catalog and verify that the host
registers the functions, opening a new chat if needed. A new chat alone cannot
fix an unchanged server catalog, and `find_tools` cannot register host functions.
No new API key or OAuth credential is needed for this catalog change.

The account endpoint `/api/mcp/manage` defaults to 20 common operations with
short descriptions. Existing input/output schemas and safety annotations are
retained for compatibility; full descriptions are loaded on demand; the full view currently has 56 operations. Safety annotations
remain present in both views. A pinned domain view still restricts calls; the
public `directory` profile excludes secret handling and catalog diagnostics.

`find_tools({query, include_schemas:false})` returns short summaries and effect
annotations. Request `include_schemas=true` only for the selected operation.
For backward compatibility, omitting the option returns full schemas as before. Exact operation
names rank first, then coverage of query terms; partial matches report
`match=partial` and `missing_terms` instead of implying full support.

Public documentation is available without an account:

- `/api/tools?query=secret&limit=5` — short built-in summaries, paged by offset.
- `/api/tools/get_secret_status` — the complete schema for one operation.
- Add `?format=markdown` for a web-readable explanation, or `?format=openapi`
  for just that operation's OpenAPI document.

These public endpoints never inspect accounts, connected private servers,
playbooks or secrets. The short catalog links to deeper documentation rather
than loading it into every MCP connection.

When a host cannot register a discovered MCP function, a credentialed HTTP
executor can call `POST /api/control/{operation}` with the same arguments,
including `playbook_id` for scoped operations. A direct playbook credential can
use `POST /api/playbooks/{guid}/operations/{operation}` without `playbook_id`.
These routes share the MCP permission checks and return its structured failure
reasons. Do not copy host-owned OAuth tokens or change transport to bypass a
denial. Without an authorized HTTP executor, a full catalog and host refresh
remain a compatibility option rather than the default.

After a failure, `get_connection_info` reports `catalog_revision`, `toolset`,
`credential_kind`, `account_permissions`, `advertised_tools` and `callable_tools`.
The server reports host registration as unknown: a local `TypeError: ... is not
a function` means the host sent no request. It does not establish a server,
permission or reveal-policy failure.

`apb connection check --json` checks the HTTP/MCP path and reports server
identity/version, advertised secret capabilities and RPC error codes without
copying error bodies. It does not inspect the desktop OAuth token store or
prove that the host registered a particular function. Missing secret tools
from the compact startup catalog are expected; load the selected documentation
only when the operation is needed.

Tool execution failures include `error.data.catalog_revision`, `phase`,
`reason` and `next_steps`. Secret diagnostics distinguish `secrets_read_required`,
`proxy_only`, `expired`, `secret_not_found`, `secret_metadata_query_failed`,
`secret_query_failed`, `secret_decryption_failed` and `audit_unavailable`.
Legacy failures without a specific classification use `tool_execution_failed`.

## Available Resources

Each playbook exposes these resources:

| Resource URI | Description |
|--------------|-------------|
| `playbook://GUID/personas` | All personas with system prompts |
| `playbook://GUID/memory` | All stored memories |
| `playbook://GUID/skills` | All skills with definitions |

## JSON-RPC Methods

The MCP endpoint supports standard JSON-RPC 2.0:

### Initialize

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "initialize",
  "params": {
    "protocolVersion": "2024-11-05",
    "clientInfo": {
      "name": "my-client",
      "version": "1.0.0"
    }
  }
}
```

### List Tools

```json
{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/list"
}
```

### List Resources

```json
{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "resources/list"
}
```

### Read Resource

```json
{
  "jsonrpc": "2.0",
  "id": 4,
  "method": "resources/read",
  "params": {
    "uri": "playbook://abc123/memory"
  }
}
```

## Adding MCP Servers to Your Playbook

You can define custom MCP server configurations within your playbook:

1. Go to the **MCP Servers** tab in the Playbook Editor
2. Click **"Add MCP Server"**
3. Define tools and resources

These will be merged into your playbook's MCP manifest.

### Example MCP Server Definition

```json
{
  "name": "file_tools",
  "tools": [
    {
      "name": "read_file",
      "description": "Read contents of a file",
      "inputSchema": {
        "type": "object",
        "properties": {
          "path": { "type": "string" }
        },
        "required": ["path"]
      }
    }
  ],
  "resources": [
    {
      "uri": "file:///workspace",
      "name": "Workspace",
      "mimeType": "text/plain"
    }
  ]
}
```

## Secrets Vault

AgentPlaybooks includes a built-in secrets vault for encrypted credential storage. Secrets are encrypted with AES-256-GCM using per-user derived keys.

### Security Design

By default, agents use the `use_secret` tool as a server-side proxy instead of reading secret values directly. Owners can separately opt a secret into API-key reveal access.

For incremental model output, browsers and HTTP clients can bypass MCP using [`POST /api/playbooks/:guid/secrets/proxy` with `response_mode: "stream"`](./api-reference.md#streaming-without-mcp). The provider key is still injected server-side. MCP supports SSE transport, but APB's current secret tools buffer the upstream response into a final tool result; direct HTTP streaming avoids that buffering.

1. Agent calls `use_secret` with a secret name and target URL
2. Server decrypts the secret internally
3. Server makes the HTTP request with the secret injected as a header
4. Only the HTTP response is returned to the agent

Proxy use keeps the credential out of the tool result. Optional reveal explicitly
returns a raw value and therefore requires a separate decision about raw access.

### Optional raw access

`get_secret_status({secret_name})` checks one known name without decrypting
it. After authorization, a missing name returns `exists=false` and
`reason=secret_not_found`. If the lookup is refused or fails, existence is
unknown; it must not be reported as absence. For an existing secret,
`capabilities.reveal.reason=proxy_only` identifies disabled reveal and includes
a next step the agent can discuss with the user.

`list_secrets` never decrypts a value. Its `capabilities.reveal` reports
`supported`, `allowed`, `reason` and `next_steps`; proxy eligibility is reported
separately, and the requested destination still has to pass `allowed_hosts`
and network checks. `allow_api_key_reveal=false` produces `proxy_only`, even
for owner OAuth through MCP. Proxy requests do not require reveal.

Use `reveal_secret({secret_name})` only when the user needs raw access. The owner
or an editor must first enable **Allow API keys to reveal the raw value** in the
vault UI. MCP also refuses expired secrets and withholds plaintext if the audit
write fails. The dashboard retains its owner/editor recovery behavior for
expired or proxy-only secrets; that exception does not apply to MCP.
Do not echo or persist revealed values. Header injection is separate from web
form login, which additionally needs a suitable client workflow.

### Available MCP Tools

| Tool | Description |
|------|-------------|
| `get_secret_status` | Check one name without decryption: authorized absence, existing policy, or unknown existence on a permission/server error |
| `list_secrets` | Names, metadata, `allow_api_key_reveal`, `allowed_hosts`, and value-free proxy/reveal capabilities |
| `reveal_secret` | Return a raw value only with per-secret opt-in, secrets:read access, valid expiry and a successful audit write |
| `use_secret_write` | POST/PUT/PATCH/DELETE with server-side credential injection |
| `use_secret` | Make HTTP request with secret injected server-side |
| `store_secret` | Store a new encrypted secret |
| `rotate_secret` | Replace a secret's value |
| `delete_secret` | Permanently remove a secret |

### Example: Using a Secret

```json
{
  "method": "tools/call",
  "params": {
    "name": "use_secret",
    "arguments": {
      "secret_name": "OPENAI_API_KEY",
      "url": "https://api.openai.com/v1/models",
      "method": "GET",
      "header_name": "Authorization",
      "header_prefix": "Bearer "
    }
  }
}
```

The agent receives only the API response — the secret value stays on the server.

### Adding a Secret Without Exposing It to the Agent

Do not ask the user to send a value in chat or place it in a `store_secret` /
`rotate_secret` tool argument: tool inputs can remain in the agent transcript.
Prepare a small program that requests hidden input and uploads directly from
the user's own terminal, or reuse the reviewed helper in the
[secure input guide](./secure-secret-input.md). It refuses echoed input and
redirects, verifies HTTPS, avoids plaintext files and sanitizes output/errors.
Confirm the destination and create/rotate choice using metadata only. Users
without a local terminal can enter the value directly in the **Secrets** web UI.
Verify success by metadata rather than revealing the secret.

## Authentication

**Public playbooks** require no authentication for read access. Anyone can connect to the MCP endpoint and use the playbook's tools and resources.

**Private playbooks** require a Playbook API Key. Generate one from the **Integrations** tab in your playbook's dashboard.

Include the key in the `Authorization` header:

```
Authorization: Bearer apb_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```

**Write-back operations** (writing memory, canvas, etc.) always require an API key, even for public playbooks. The key must have the appropriate permissions (e.g. `memory:write`).

Anonymous public connections advertise only callable read-only tools in the JSON
manifest, `tools/list`, and `find_tools`. Credential-backed tools such as
`list_secrets` and `use_secret`, connection configuration (`list_mcp_servers`),
write tools, and `read_memory` (which updates
access counters) require authentication and are omitted from that public catalog.
Use `search_memory` to read public memory without updating access counters.
The same restriction applies to direct calls by name, including federated REST
calls. Connected tools are public only when the owner explicitly sets the
connection's `access` to `public` and the upstream declares a read-only tool.
Unknown or destructive tools require authentication; OpenAPI calls are checked
against their actual HTTP method (GET or HEAD). A valid credential for the
playbook restores the authenticated catalog; existing per-operation permissions
still apply.

On a private playbook, any active key of that playbook reaches the MCP endpoint. Each operation then checks its own permission:

- Memory reads need `memory:read`, skill reads `skills:read`, canvas and run reads `canvas:read`, and the connected servers list `playbooks:read`.
- A key that holds `memory:read` can read everything, as it always could.
- A write permission includes reading the same area: `memory:write` also reads memory, `skills:write` also reads skills (likewise `personas`, `canvas` and `playbooks`). It does not read anything else.
- Secrets are the exception: `secrets:write` stores, rotates and deletes credentials but does not use them; using a secret through the proxy needs `secrets:read`.
- A key with no read or write of an area, for example one that only uses secrets, reaches the endpoint but reads nothing.

The read-only manifest (`GET /api/mcp/:guid`) and `llms.txt` still need a key with `memory:read`.

| Access Level | Public Playbook | Private Playbook |
|---|---|---|
| Read tools/resources | No auth needed | API key required |
| Write memory/canvas | API key required | API key required |
| Manage playbook | User API key | User API key |

API keys come in four roles:
- **Viewer** — Read-only access
- **Proposer** — Read access; memory and skill changes wait for review
- **Coworker** — Read and write access
- **Admin** — Full access to modify playbook structure

### Proposals

A key with `memory:propose` or `skills:propose` (the Proposer role) may suggest changes it is not allowed to make. `write_memory`, `create_skill` and `update_skill` (and `PUT /api/playbooks/:guid/memory/:key`, which answers `202`) then save the change as a proposal instead of applying it:

```json
{ "status": "pending_review", "kind": "memory", "proposal_id": "…", "target": "lesson/check-the-register" }
```

A proposal changes nothing until it is approved. It is not returned by memory reads, search, context or history, nor listed as a skill version. The owner and editors see pending proposals at the top of the Memory and Skills tabs and approve or reject them there. Approving applies the proposal as an ordinary write, so the previous content stays in the history. Keys can review too: a key with `memory:write` reviews memory proposals, and one with `skills:write` reviews skill proposals:

```bash
GET  /api/playbooks/:guid/proposals?kind=memory|skill
POST /api/playbooks/:guid/proposals/:id   {"kind": "memory", "decision": "approve" | "reject"}
```

A propose permission never grants reading. Give a proposer `memory:read` / `skills:read` as well when it needs to see what is already there; the Proposer role does.

## Best Practices

1. **Keep tools focused** - Each tool should do one thing well
2. **Write clear descriptions** - MCP clients use these to understand capabilities
3. **Define schemas carefully** - Well-defined input schemas help AI use tools correctly
4. **Use resources for data** - Resources are better than tools for read-only data access
5. **Start with the guide resource** - Read `playbook://GUID/guide` before complex tasks
6. **Fetch minimally** - Read targeted resources/keys first, not full dumps by default
7. **Close the loop** - Save discovered constraints/workarounds to memory or canvas
8. **Test with Claude Desktop or Cursor** - Verify your MCP configuration works before deploying

## Troubleshooting

### Connection Issues

**"Playbook not found" (404)**
- Ensure the playbook is set to **Public**, or include a valid API key for private playbooks
- Verify the GUID in the URL is correct (check the Integrations tab)

**Authentication failures (401/403)**
- Verify your API key starts with `apb_live_`
- Ensure the key has not been revoked
- Check the `Authorization: Bearer` header format

### Cursor-Specific Issues

**MCP server not appearing**
- Ensure the JSON in `.cursor/mcp.json` is valid (no trailing commas)
- Restart Cursor after saving configuration changes
- Check Cursor's MCP logs for connection errors

**"Naming issues" warning — Combined server and tool name length exceeds 60 characters**
- Cursor limits `server_name + tool_name` to 60 characters total
- Use the short `apb-` prefix for your server name (e.g. `apb-my-playbook` instead of `agentplaybooks-my-playbook`)
- The ready-to-copy configs in the Integrations tab already use the short prefix

**Tools not loading**
- Verify the playbook has data (skills, memory, etc.) — use `list_skills` or `get_memory_context` to confirm
- Test the endpoint directly: `curl -s https://apbks.com/api/mcp/YOUR_GUID | head -c 200`

### Claude Issues

**Nothing appears after editing `claude_desktop_config.json`**
- That file cannot hold a remote server. Add the endpoint as a custom connector
  or install the plugin instead — see [AgentPlaybooks in Claude](/docs/claude).

**The connector shows Connect or Reconnect, not Connected**
- The sign-in did not finish. Select it again and complete the AgentPlaybooks
  sign-in in the window that opens.

**A tool call is refused**
- The refusal names the missing permission or the reason. A playbook shared with
  you as a viewer, for example, cannot be written.

---

## Clawdbot Integration

[Clawdbot](https://github.com/steipete/clawdbot) is a popular open-source, self-hosted AI assistant that connects messaging platforms (WhatsApp, Telegram, Discord) with LLM APIs. It has full MCP support.

### Connecting AgentPlaybooks to Clawdbot

Add to Clawdbot's `config.yaml`:

```yaml
mcp_servers:
  - name: agent-playbook
    transport: http
    url: https://apbks.com/api/mcp/YOUR_GUID
    description: My custom AI playbook with skills and memory

messaging:
  whatsapp:
    enabled: true
    phone_number: "+1234567890"
  telegram:
    enabled: true
    bot_token: "your_bot_token"
```

### With Authentication (for Memory Write-back)

```yaml
mcp_servers:
  - name: agent-playbook
    transport: http
    url: https://apbks.com/api/mcp/YOUR_GUID
    auth:
      type: bearer
      token: apb_live_xxx
    write_enabled: true
```

### Benefits of Clawdbot + AgentPlaybooks

| Feature | Description |
|---------|-------------|
| **Multi-platform** | Same playbook across WhatsApp, Telegram, Discord |
| **Shared memory** | Updates sync across all platforms instantly |
| **Self-hosted privacy** | Runs on your own hardware |
| **Flexible backend** | Switch between Claude, ChatGPT, Gemini |

See [Platform Integrations](./platform-integrations.md) for Claude Coworker and other integrations.

