Beyond the page
One business page has three working views: the Todo itself, a protocol inspector, and a public Surface. Codex, Claude, Hermes Agent, or WorkBuddy connects over HTTPS MCP while records, approvals, and business handlers stay in the page.
pnpm dev:examplesSource examples/demos/external-agent-surface/Page https://plingjs.dev/demos/external-agent-surface/Open Example 05 on plingjs.dev. The page has three work areas:
describe / invoke directly and shows what an external client actually receives.This example deliberately has no page chat assistant. It shows how an outside Agent reaches the same business capabilities, not what an in-page assistant feels like.
The public example currently gives both the page session and the Agent token a maximum lifetime of 24 hours. The token stops operating the current page as soon as the page is closed or reloaded, the Agent is revoked, or the session expires.
There is intentionally no “hosted page plus local WebSocket” path: browsers block a public HTTPS page from reaching a loopback socket (ERR_BLOCKED_BY_LOCAL_NETWORK_ACCESS_CHECKS). The hosted example uses the gateway; the loopback bridge is for local development.
The four tabs on the page cover Codex, Claude, Hermes Agent, and WorkBuddy. They connect to the same HTTPS MCP endpoint and share the six capabilities exposed by the current page.
export PLING_AGENT_TOKEN='token shown on the page'
codex mcp remove pling-todo 2>/dev/null || true
codex mcp add pling-todo \
--url https://surface.hunger-valley.com/mcp \
--bearer-token-env-var PLING_AGENT_TOKEN
codex --no-daemoncodex --no-daemon so it does not reuse an older daemon that has no token.pling_surface_describe before invoking a capability. For example:Describe the current Todo page, add “Prepare the customer demo”, then mark the first open task complete.
export PLING_AGENT_TOKEN='token shown on the page'
claude mcp remove pling-todo >/dev/null 2>&1 || true
claude mcp add --transport http pling-todo \
https://surface.hunger-valley.com/mcp \
--header "Authorization: Bearer $PLING_AGENT_TOKEN"
claudeIf your Claude build uses the Connectors screen, choose remote MCP and enter the same URL and Authorization header.
Add a remote HTTP server (also called Remote MCP or Streamable HTTP in some builds) in the client's MCP or connector settings. Name it pling-todo, then use the URL and Authorization: Bearer <token> shown on the page. If the client accepts mcpServers JSON, the page provides a ready-to-copy object too.
Menu names vary by client version; the endpoint, request header, and permission boundary do not.
To use the Codex desktop app's /mcp panel, quit the app completely and run codex app-server daemon stop, then relaunch it from the terminal where the token is set. The --no-daemon CLI path is the most reliable way to verify the integration.
This is the convenience mode for the public demo: the token is visible in the page DOM and can be read by page scripts, browser extensions, or screenshots. Production integrations should use OAuth or device authorization and keep long-lived credentials out of the page. The gateway still never exposes the DOM, script execution, cookies, or model keys to the Agent.
@plingjs/surface owns capability projection, describe, invoke, sessions, and the approval boundary.services/surface-gateway provides public transport, page sessions, Agent tokens, revocation, and audit.click(selector), script evaluator, or approve-on-behalf tool.