Skip to content
AFK / Docs

Search page titles and summaries. Shortcut: Ctrl / ⌘ K.

MCP Integration

AFK supports the Model Context Protocol (MCP), letting agents connect to approved external tools and services such as databases, APIs, browsers, and SaaS platforms.

Manage MCP servers

From a session, choose Manage MCP servers. The manager shows configured servers, their source and connection state, and an explicit action for the next step:

  • Choose Add server to browse AFK's curated setup recipes or enter a provider's configuration manually.
  • Choose Edit to change a configured server without affecting unrelated entries.
  • Choose Fix when AFK reports invalid configuration or missing secrets.
  • For OAuth servers, use the separate Connect andDisconnect actions. Opening or selecting a row never changes its authorization state.

Recipes are reviewed setup templates, not a general package marketplace. If the service you need is not listed, use the guided HTTP or local-command form with configuration from the service provider. AFK does not guess a package name, endpoint, or authentication scheme for an unknown service.

Choose where a server is available

Every editable server has an explicit availability scope. A server with the same name in a narrower scope overrides the broader definition:

  1. This checkout only — private, machine-local settings in <projectDir>/.afk/mcp.local.json.
  2. This project — shared project settings in <projectDir>/.afk/mcp.json; review before committing them for the team.
  3. All projects on this daemon — user settings in ~/.afk/mcp.json on the selected daemon.

Use a checkout-only override when your command, path, or endpoint differs from the shared project configuration. The manager calls out when saving will create an override rather than silently changing another scope.

Configure a connection

The form supports local stdio commands and remote HTTP/SSE servers. Store tokens and other sensitive values in Secrets and reference them as ${secrets.name}. The editor shows the secrets available in the current account or organization context, flags missing references, and lets authorized users add a required secret while configuring the server.

Stdio server

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
    }
  }
}

HTTP/SSE server

{
  "mcpServers": {
    "my-api": {
      "url": "https://mcp.example.com/mcp",
      "headers": {
        "Authorization": "Bearer ${secrets.api_token}"
      }
    }
  }
}

Use the advanced JSON editor for provider-specific fields that are not represented in the guided form. Switching between the guided and advanced editors preserves those additional fields when you save.

Built-in providers

AFK includes several runtime-managed providers. They appear as available on demand and start only when needed; do not install another copy through the Add server recipes.

ProviderDescription
playwrightIsolated, repeatable browser automation.
chrome-devtoolsDebugging, inspection, and WebMCP tools for a user-approved running Chrome instance.
tree-sitterStructural code parsing for precise code understanding.

Connecting Chrome DevTools

The chrome-devtools provider attaches to a Chrome session you explicitly approve, so an agent can inspect an authenticated tab and use WebMCP tools exposed by the page. In Chrome 144 or later, open chrome://inspect/#remote-debugging, enable remote debugging, then approve the connection when AFK starts the provider.

Connecting gives the selected agent access to open tabs in that Chrome profile, including authenticated sites. Close sensitive tabs before connecting. For isolated, repeatable automation, use playwrightinstead.

OAuth connections

When a configured HTTP server requires OAuth, choose its explicit Connect action and complete the provider authorization flow. AFK stores the resulting grant securely and uses it for future requests to that server. In an organization workspace, each member authorizes their own external account. Use Disconnect to revoke AFK's saved connection; selecting the row itself does not connect or disconnect anything.

Some providers require an OAuth client ID and client secret in addition to the user authorization. For an HTTP server, add the client ID and the name of a saved secret in the guided form, then save the server before selecting Connect. AFK stores only the secret reference in MCP configuration; it never writes the secret value into the config, preview, or browser callback. You can add or replace the secret value through the same form or in Secrets.

Reloading MCP config

After editing configuration, use the reload tool or the /reload browser command to re-read session capabilities without restarting the session. Idle built-in providers still start on demand; reload is not an installation step.

MCP elicitation

MCP servers can ask for structured mid-task input. AFK shows those requests as browser forms, sends the response back to the server, and keeps the resolved interaction in the session transcript for auditability.

You can also use hooks to apply team-specific handling for repeated MCP prompts. See Hooks Reference.

Interactive tool interfaces

Some MCP servers ship a small interactive interface alongside their tools — a form, a picker, a sign-in panel — instead of returning only text. When a server offers one, it renders inline in the tool card in the conversation, above the raw output that remains available as a fallback.

  • Interfaces run in a sandboxed frame. They cannot read the AFK interface, your stored credentials, or other sessions.
  • A server must declare which external services its interface may reach; anything undeclared is blocked. If an interface needs to fetch data from a service and appears stuck, the server's configuration is missing that declaration.
  • Actions taken inside an interface are shown in the session transcript, so the work remains reviewable after the fact.
  • When a server offers no interface, or the interface cannot start, the tool still reports its normal text output.

You do not configure anything for this. It applies automatically to connected servers that offer an interface.

Plugin MCP servers

The MCP server manager labels every entry with its source, so you can tell a server you configured yourself from one a plugin provides. Each configured entry states which configuration file defines it and whether that file applies to the whole daemon, the current project, or only your local checkout.

Plugins can contribute MCP servers for repeatable team workflows. Store sensitive values in Secrets and reference them from plugin configuration rather than committing raw tokens. Plugin and built-in entries may be visible in the manager without being editable as project, checkout, or daemon-user configuration.

AFK as an MCP server

AFK can also act as an MCP server itself, so another MCP-capable tool — an editor, a CI job, a script, or an agent running somewhere else — can create AFK sessions, send them work, read what they produced, and stop them. This is the reverse of everything above: instead of an AFK agent calling out to an external service, an external client drives AFK.

Endpoint

The endpoint is a single JSON-RPC 2.0 URL on your AFK server host — the same host your daemons connect to. On the hosted service:

POST https://afk-server.mooglest.com/mcp

Use the server host, not the web app host. They are separate hostnames, and a POST to /mcp on the web app host answers with a plain 405, which reads like a routing fault rather than a wrong URL. A self-hosted deployment uses its own server host, the same value as server= in your daemon configuration.

Authentication

Every request carries an AFK API key from Account → Daemon API keys, in either header form:

X-AFK-API-Key: afk_...
Authorization: Bearer afk_...

A signed-in browser session cookie is also accepted, so you can try the endpoint from a browser session you already have. Unauthenticated requests get HTTP 401 with a JSON-RPC error, never a redirect or an empty body. Use one key per integration and revoke it like any other key when you retire the integration.

Tools

ToolWhat it doesParameters
spawn_sessionStart a new session and return its session_id.project_path (required), task, model, mode, machine_id, request_id
send_messageSend a user message to a session; the agent processes it asynchronously. delivery_mode: "steer" delivers at the next safe tool boundary to redirect work in progress; the default queue waits for an idle turn.session_id, message, delivery_mode
get_outputRead a session's conversation as plain text, plus whether it is still running. Pass the last_seq of one response as since_seq to read only what is new.session_id, since_seq, limit
wait_sessionBlock until the session stops, then return its output and final status. This is the tool to use in CI.session_id, timeout_seconds (default 300)
list_sessionsSessions this key can see, most recent first. Use spawn_request_id to reconnect with earlier work when a session id was lost.status, project_path, limit
interruptStop the current turn while leaving the session alive, so it can then be redirected with send_message.session_id
close_sessionStop a running session while keeping its history and record.session_id, force
resume_sessionRestart a previously closed session from its stored setup.session_id

Pass request_id to spawn_session when a retry is possible. Two agents editing one checkout is worse than a failed call, so repeating a spawn with the same request_id returns the session the first call created instead of starting a second one.

Approvals

A session started in auto mode stops before running bash, write_file, edit_file or apply_patch until a human approves. An unattended caller therefore needs to be able to answer, or the agent waits and then gives up:

ToolWhat it does
list_pending_approvalsTool calls in a session waiting for approval, each with the tool_call_id the other two need.
approveLet the agent run that call.
denyRefuse it; the agent receives your reason instead of the result.

Approval requires the same permission a person in the browser needs, not the weaker permission for sending a message: approving is what lets code run. A decision also fails visibly when no agent is connected, rather than reporting success for something that was never delivered.

Read-only account tools

A second set of tools answers questions about the caller's own setup without changing anything:

ToolReturns
list_machinesThe daemons this key may run sessions on, so machine_id can be chosen rather than assumed.
get_account_settingsActive connections, git identities, model mixes, and the connection list.
list_connectionsProvider, base URL, and whether credentials are present for each connection.
list_secretsSecret names, so configuration can reference them.
list_api_keysKey labels and creation times.
list_agentsAgent personas on your machines, with the model and tools each declares.
list_skillsInstalled skills with descriptions; bodies are not returned.
list_lsp_serversLanguage servers currently active on your machines.
list_orgsYour organisations with your role and each policy flag.

Credential values are never returned. A connection reports api_key_present and oauth_present instead, the same signals the browser uses, so a redacted connection is not mistaken for an unconfigured one. Nothing in this set changes settings: changing a connection, an MCP command, or a hook stays a browser action, because those are credential and code-execution changes rather than preferences.

Connect a client

Any MCP client that supports remote HTTP servers needs only the URL and the key header. Reference the key through Secrets rather than pasting the raw value into a file you commit:

{
  "mcpServers": {
    "afk": {
      "url": "https://afk-server.mooglest.com/mcp",
      "headers": {
        "X-AFK-API-Key": "${secrets.afk_api_key}"
      }
    }
  }
}

For direct HTTP calls, send JSON with Accept: application/json, text/event-stream. AFK answers both the classic initialize handshake and the stateless style where every request carries its own _meta, so native MCP clients need no special compatibility setting.

What the caller is allowed to do

  • The key decides the scope. A client sees and drives the sessions and machines that key may access, and nothing outside it.
  • machine_id must name a daemon that key may use; omitted, AFK picks the first connected one. A machine you cannot use is rejected rather than silently substituted.
  • Sessions spawned this way are attributed to the key's owner, so they appear in the normal session list with the usual history.
  • spawn_session defaults to the auto permission mode, not yolo, because the caller is unattended. Pass mode: "yolo" deliberately if you want unattended agents to run tools without approval.

Do AFK sessions need this?

No. An AFK agent already has these capabilities as built-in tools — spawning and messaging sessions, stopping and resuming them, and reading their output — so pointing a session at AFK's own MCP endpoint adds a second copy of tools it already has. Use this endpoint for tools outside AFK.