Skip to main content
Back to the Mercury MCP server

MCP Gateway · OpenCode

Mercury icon

Connect Mercury to OpenCode

OpenCode users building internal finance tools can read Mercury from the terminal where the tool is being written. That means checking card setup, treasury balances or a payout recipient without asking finance for a screenshot. The OpenCode plugin sends each prompt and Mercury tool call to Speakeasy, which allows or denies it before it runs.

Category
Sales & CRM
Tools
34
Authentication
OAuth
OpenCode
Terminal

Behind the MCP Gateway

Run Mercury MCP behind the MCP Gateway

One URL for every agent, sign-in through your IdP, RBAC down to the tool, and every Mercury call inspected and logged.

Deploy on MCP Gateway

Set up

Add Mercury to OpenCode in 4 steps

  1. 01

    Add Mercury from the catalog

    An admin finds Mercury in the MCP Catalog (MCP Gateway > MCP > Catalog) and clicks Add. Speakeasy registers the vendor's server as a remote MCP server and proxies sessions to it. Nothing is copied or re-hosted.

    Mercury uses OAuth. Servers that support dynamic client registration get their OAuth configuration applied automatically.

    Where MCP-scoped policies are enabled, the install offers a recommended risk policy for the new server that detects secrets and PII and inspects tool requests and responses.

  2. 02

    Choose who can use Mercury

    Give teams the mcp:connect scope on the Mercury server through team access or a role. OpenCode connects to the Mercury server's own URL, and the server's authorization decides who can connect and which tools they can call.

  3. 03

    Connect OpenCode

    Add the server to OpenCode's own mcp config block as a remote server.

    Copy the server's URL from its hosted install page in Speakeasy.

    Add it to the mcp block of your OpenCode config with type set to remote.

    Restart OpenCode and sign in when prompted.

    {
      "mcp": {
        "<server slug>": {
          "type": "remote",
          "url": "<URL from the hosted install page>"
        }
      }
    }
  4. 04

    Sign in and use Mercury from OpenCode

    The first time OpenCode connects, it opens a browser so the person can sign in to Speakeasy through your identity provider.

    Mercury needs its own OAuth grant, so each person connects it once. Until they do, Mercury calls fail while the rest of the gateway keeps working.

    From then on, Mercury's tools appear in OpenCode, limited to what the person's access allows, and every call lands in the gateway's tool logs.

OpenCode doesn't receive MCP servers from plugins. The observability package is installed separately, from a ZIP or with speakeasy-hooks install --provider=opencode, and the device agent can maintain it.

Use cases

What OpenCode users do with Mercury

Check cards for an expense tool

While building an internal expense tracker, OpenCode reads an account and the debit and credit cards attached to it, so the card records in your test fixtures match what the account really has.

getAccountgetAccountCards

Script a daily cash position

OpenCode reads every operating and treasury account, then writes a small script that totals them into the cash position report finance asked for.

getAccountsgetTreasury

Debug a failing payout recipient

When a payout job errors on one recipient, OpenCode looks the recipient up by ID and shows its details next to the job's error output.

getRecipientsgetRecipient

Tools

34 tools

Each Mercury tool can be allowed or denied per team and role at the MCP Gateway before OpenCode sees it.

getAccount

Get account by ID

getAccountCards

Retrieve all debit and credit cards associated with a specific account.

getAccountStatements

Retrieve a paginated list of monthly statements for a specific account. Supports cursor-based pagination with limit, order, start_after, and end_before query parameters, as well as date range filtering with start and end parameters.

getTransaction

Get transaction by ID

getAccounts

Retrieve a paginated list of accounts. Supports cursor-based pagination with limit, order, start_after, and end_before query parameters.

getAttachment

Retrieve attachment details including download URL

See all 34 tools

Control

What Speakeasy can see and stop in OpenCode

The gateway covers every client the same way. The rest depends on what OpenCode exposes to Speakeasy.

Tool logs

Gateway

Every Mercury call is logged with the person and the client that made it.

Access by role

Gateway

People reach only the Mercury tools their team or role allows.

Request and response blocking

Gateway

A risk policy scoped to Mercury can reject a tool request before it reaches the server, or withhold a result from OpenCode. MCP-scoped policies are enabled per organization.

Prompt and tool-call blocking

OpenCode

The OpenCode plugin sends each prompt and tool call to Speakeasy, which allows or denies it before it runs.

Usage telemetry

OpenCode

Token and cost totals flow through the plugin, reported per turn.

Device agent

OpenCode

The device agent installs and maintains the observability package.

  • OpenCode has no OpenTelemetry exporter, so session data comes through the plugin.
  • Tool output is blocked at the gateway rather than in OpenCode's hooks.

Questions

Frequently asked questions

How does OpenCode report usage for Mercury sessions?
OpenCode has no OpenTelemetry exporter, so session data comes through the Speakeasy plugin. Token and cost totals are reported per turn.
Who maintains the Speakeasy package in OpenCode?
The observability package is installed from a ZIP or with speakeasy-hooks install --provider=opencode. The device agent can then install and maintain it on each laptop.
How do OpenCode users get Mercury?
An admin adds Mercury from the Speakeasy MCP Catalog and grants access by team or role. Add the server to OpenCode's own mcp config block as a remote server. Each person then sees only the Mercury tools their access allows.
Are Mercury calls from OpenCode logged?
Yes. Mercury calls go through the MCP Gateway, which logs each tool call and attributes it to the person and the client that made it.

Connect more

Mercury in other clients

AI everywhere.

Control here.