Skip to content

Agents and MCP

Connect Claude Code, Cursor, Codex or any MCP client to Perafly, choose what an agent may do, and approve the changes that matter.

On this page

Ways to connect

ConnectionHowFiles
Local MCPperafly mcp over stdio, with your CLI sign-in or PERAFLY_TOKEN.Reads the working folder directly.
Bridgeperafly mcp proxy: stdio to the hosted server with your CLI key.Sent inline.
Hosted MCPhttps://mcp.perafly.com (Streamable HTTP) with OAuth.Sent inline.
Handoff linkA single-use link from the dashboard gives a local agent a key for one project.—

Set up your agent

perafly setup agent finds Claude Code, Cursor and Codex on your machine, writes their MCP configuration and installs the perafly skill, which tells the agent how to work with Perafly safely. Sign in first.

Terminal
perafly login --access agent
perafly setup agent
FlagMeaning
--agent <id>claude-code, cursor, codex, auto or all; repeatable. Default: detect.
--localLocal server perafly mcp (default).
--remoteThe hosted server through the bridge perafly mcp proxy.
--remote --oauthThe client connects to the hosted server itself, with OAuth.
--scope user|projectInstall the skill for your user (default) or this project.
--skip-mcp, --skip-skillOnly the skill, or only the MCP configuration.
--force, --dry-runReplace a changed configuration or skill; show what would be written.

perafly mcp install takes the same flags and writes only the MCP configuration. Claude Code is configured with claude mcp add, Cursor in ~/.cursor/mcp.json (or .cursor/mcp.json with --scope project) and Codex in ~/.codex/config.toml. To configure a client by hand, this is the server entry:

Local MCP configuration
{
  "mcpServers": {
    "perafly": { "command": "perafly", "args": ["mcp"] }
  }
}
Hosted MCP configuration (OAuth)
{
  "mcpServers": {
    "perafly": { "url": "https://mcp.perafly.com" }
  }
}

The credential is never written into these files: the local server and the bridge use your CLI sign-in, and the client handles OAuth itself.

MCP tools

The tools are generated from the open API and carry its operation names, such as listProjects or promoteProjectVersion. A credential only sees the operations its permissions allow. Three tools are added:

ToolWhat it does
publishPublishes files and waits for the result. The local server reads a folder, file or archive from the workspace; the hosted server takes files inline (up to 500 files and 25 MB).
operation_statusStatus of an operation; with wait: true it waits up to 60 seconds.
resume_executionContinues an action a teammate approved.

The local server only reads inside its workspace root (--workspace-root, PERAFLY_MCP_WORKSPACE_ROOT, the root the client reports, or the folder it started in). Paths outside it, symbolic links and credential-like files are refused, and files that are never published stay out.

Hosted MCP and OAuth

The hosted server at https://mcp.perafly.com speaks Streamable HTTP and answers in JSON. A request without credentials gets 401 with a WWW-Authenticate header that points to the protected resource metadata, so MCP clients start OAuth on their own.

  • OAuth 2.1 with PKCE (S256) and dynamic client registration; public clients only.
  • You approve the app on perafly.com: pick the team and the profile, agent or read. The full profile is never given over OAuth.
  • Access tokens (pfo_…) last one hour; refresh tokens (pfr_…) last 30 days and change on every use.
  • An access token can call the open API too, with the connection's profile and your current role.

API keys and profiles

Every credential acts for a person in a team and can never do more than that person's role allows. If the person leaves the team or their role changes, the key follows.

CredentialWhere it comes fromLifetime
API key pfa_…Team Settings in the dashboard, or perafly api-keys create <name> with a full sign-in. The secret is shown once; at most 20 per team.Until revoked.
CLI sign-in pfa_…perafly login30 days; lapses after 7 days without use.
OAuth pfo_…An app you approved for hosted MCP.1 hour, refreshed.
Project key pfc_…Publishing without an account; one project only.Until the project is claimed or deleted.

Profiles

ProfileWhat it may do
fullEverything the person's role allows. Only for the person's own terminal; the default for perafly login.
agentRead projects, logs and usage; create projects, publish and promote, with approval where it changes what's live. No deleting, keys, billing, members, access, domains or writing environment variables.
readRead projects, domains, logs and usage.

Choose the profile with perafly login --access full|agent|read; with PERAFLY_AGENT=1 the CLI asks for agent. On the approval page you can narrow the profile and pick the team, never widen it.

Approvals

When a credential with the agent profile tries to change what's live, a teammate has to approve it first. New projects and previews never wait. A person's dashboard session, a full CLI sign-in and the key of a project published without an account don't wait either.

ActionWhat happens
Promote or roll backNothing changes. The answer is 403 approval_required with an execution (exe_…) and an approvalUrl.
Publish to live over a live versionThe version is built and ready but not made live. Approving makes it live.

Teammates who can approve get a notification in the dashboard and on mobile. The request lasts 10 minutes; a declined or expired request can't be reused, and asking again for the same action returns the pending one. After approval, continue the action instead of starting it again:

Terminal
perafly operations resume exe_…   # or POST /v1/executions/{id}/resume, MCP resume_execution

The CLI waits for the decision by itself; with --no-wait it exits with approval_required and the execution id. A team owner or admin can turn approvals off on the Agents page ("Approval for live changes").

Handoff links

A handoff link gives a local agent an agent-profile key for one project, without your own sign-in on that machine. Create it on the Agents page; it works once and lasts 15 minutes. Pass it on stdin, never as an argument:

Terminal
echo '<handoff link>' | npx perafly login --handoff

The key is stored in .perafly/state.json of that folder, lasts 30 days and lapses after 7 days without use.

Revoke access

The Agents page lists connected apps, agent sign-ins and agent keys; revoke them one by one or all at once with "Stop all agent access". That revokes every OAuth connection, every agent-profile key and unused handoff links, and declines waiting approval requests. Full CLI sign-ins and API keys made in the dashboard stay.