> ## Documentation Index
> Fetch the complete documentation index at: /llms.txt
> Use this file to discover all available pages before exploring further.

# Agent setup

> Connect a host to the SohoPay staging MCP server and store the terminal identity.

An agent spends a borrower's credit through the hosted MCP server. You connect the host, complete OAuth, and keep the terminal ids that `register_borrower` returns. Signing and policy stay outside this page: keys are in [Key management](/guides/key-management.md), and the person-in-the-loop steps are in [Borrower onboarding](/guides/borrower-onboarding.md).

## Connect

1. Read setup-staging (`https://agents.sohopay.ai/skills/v1/setup-staging.md`) and mcp-connect-staging (`https://agents.sohopay.ai/skills/v1/mcp-connect-staging.md`).
2. Point the host at `https://staging.mcp.sohopay.ai/mcp`.
3. Finish OAuth in the browser. The server id for staging is `sohopay-staging`.

> [!WARNING]
>
> Do not clone `sohopay-mcp-server` and run it locally, and do not run `npx @sohopay/mcp-server login`. The supported path is the hosted server.

One MCP host is one `terminal_id`. If two clients share a remote MCP connection, pass a distinct `terminal_id` on `register_borrower`.

## What to store

`register_borrower` returns:

* `borrower_id` — the canonical borrower UUID. Do not substitute a principal id from the OAuth token.
* `operational_agent_id` — the UUID for this terminal. Pass it on spend, balance, and repayment tools when the borrower has more than one terminal.
* `terminal_id` — the host's terminal. Persist it with the workload key.

Prefer `get_context` when you need identity, credit, authorization, and the next step in one call. `whoami` returns JWT claims only and does not call the backend.

## Workload key

Generate an Ed25519 key on the host with [`@sohopay/agent-signer`](/sdks/agent-signer) and register it with `register_agent_workload_key` plus a proof-of-possession signature. The private key never goes to SohoPay. Until that key is registered, `prepare_x402_payment` returns `X402_AGENT_KEY_NOT_REGISTERED`.

## Next steps

> [card] [Borrower onboarding](/guides/borrower-onboarding.md)
>
> Wallet proof, agent grant, and handle.

> [card] [Payment flow](/guides/payment-flow.md)
>
> What to do on HTTP 402.
