Authenticated browsing through Foragent

RockBot gets a signed-in, interactive browser by calling Foragent as an MCP server (#872). Foragent runs the browser, holds the site credentials and the saved sessions, and asks the user to step in when a site needs a person. RockBot never sees a password, a cookie or a takeover link.

The anonymous RockBot.Browser sidecar (web_browse, render_screenshot) is unchanged and is still the right tool for public pages.

Why an MCP server and not the sidecar

  • Credentials stay in Foragent. It keeps the secrets and saved sessions and lists only ids and kinds at foragent://credentials. The agent passes a credentialId.
  • The user steps in through Foragent’s browser. A login, captcha or 2FA step is a URL-mode elicitation: the user gets a link and finishes the step in Foragent’s browser. The sidecar has no way to hand a live browser to a person.
  • Confirmation before a post or submit. Foragent asks the user to confirm the concrete action (a form-mode elicitation) before it clicks, on top of RockBot’s own action gate.
  • Annotated tools. browser_task and execute_form_batch are readOnlyHint: false, destructiveHint: true; learn_form_schema is read-only. RockBot’s action gate follows those annotations, so browser_task is gated though its name has no write verb.

1. The mcp.json entry

mcp.json lives on the agent’s data volume (the PVC), not in the Helm chart. Add Foragent’s entry:

{
  "mcpServers": {
    "foragent": {
      "type": "http",
      "url": "http://foragent.foragent.svc.cluster.local:8080/mcp",
      "transportMode": "streamable-http",
      "headers": { "X-Api-Key": "${FORAGENT_API_KEY}" },
      "tasks": true,
      "toolTimeoutMs": 120000,
      "elicitation": { "mode": "auto", "url": true }
    }
  }
}
  • headers: ${FORAGENT_API_KEY} is read from the agent’s environment. The agent loads its Kubernetes Secret with envFrom, so the key has to be in that Secret. With secrets.create: true (Helm owns the Secret), set it in your values file:

    secrets:
      extra:
        FORAGENT_API_KEY: "..."
    

    With secrets.create: false, add a FORAGENT_API_KEY key to your own Secret (secrets.existingSecretName). Don’t kubectl patch a Helm-owned Secret: the key isn’t in the release values, so a reinstall drops it. Changing only the Secret doesn’t restart the agent; run kubectl rollout restart deploy/rockbot-agent. Never put the key in mcp.json itself.

  • tasks: true: Foragent runs browser_task as a background task. Its result, and any question it asks meanwhile, arrive on their own.
  • elicitation.url: true: lets Foragent send the user links (URL-mode elicitation). Only a server’s own entry can set this; McpBridge:DefaultElicitation can’t. Without it, takeovers are declined and the task can’t finish a login that needs the user. A plain (non-task) call that fails with -32042 UrlElicitationRequired sends its links to the user the same way, and the model is told to call the tool again once the user is done.

The bridge picks up an edited mcp.json on its own.

2. What the user sees

  • A takeover (sign-in, captcha, 2FA): an Open card in the chat that asked (Blazor), or CUSTOM rockbot.mcp_url (AG-UI), or a line with the link (CLI). From a scheduled task or patrol it lands in Background tasks, the session every client shows. The card closes when Foragent reports the step done. The link opens in a new tab; RockBot never opens it.
  • A confirmation (“Post this?”): a question form in the chat, as for any MCP question. A run with no user present can’t answer it, so Foragent returns rejected with nothing done.
  • A hold that times out: the task comes back status: suspended with a sessionRef. The agent calls browser_task again with it once the user is ready (the browser-task starter guide tells it to).

3. The action gate

With the annotations, browser_task and execute_form_batch are consequential actions: on a turn whose message only gave information, the call is queued for the user’s approval (#871), and scheduled runs act on their own as before.

Annotations count only for servers in the operator’s mcp.json. A server the model registered itself with mcp_register_server is judged by tool names alone, so it can’t exempt its own writes by marking them read-only.

A Foragent build without annotations needs the gate told instead. In agent.extraEnv:

agent:
  extraEnv:
    AgentHost__ConsequentialActionGate__ConsequentialTools__0: "foragent/browser_task"
    AgentHost__ConsequentialActionGate__ConsequentialTools__1: "foragent/execute_form_batch"

Patterns are globs (*) matched against the tool name (browser_task) or server/tool. A match is consequential whatever its name or annotations say.

Optional: always ask before a browser task, even when the user asked for it, with an action rule (#871). Only the user can set one: tell the agent in chat (“always ask me before a browser task”), and it calls

set_action_rule(level: "ask", tool: "browser_task")

Add origins: "scheduled" to make only scheduled and patrol runs ask.

4. Checking it

  1. Ask for a login-gated task from Blazor, with a test credential configured in Foragent. Expect an Open card, then the result once you’ve signed in.
  2. Do the same from a scheduled task. The card arrives in Background tasks.
  3. Grep the agent’s logs and traces for the credential value and the takeover URL; neither appears. The bridge logs only the link’s host and elicitation id.

© 2026 Marimer LLC. RockBot is released under the MIT license.

This site uses Just the Docs, a documentation theme for Jekyll.