MCP Gateway · OpenCode
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.
Set up
Add Mercury to OpenCode in 4 steps
- 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.
- 02
Choose who can use Mercury
Give teams the
mcp:connectscope 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. - 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
mcpblock of your OpenCode config withtypeset toremote.Restart OpenCode and sign in when prompted.
{ "mcp": { "<server slug>": { "type": "remote", "url": "<URL from the hosted install page>" } } } - 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.
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.
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.
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
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?
Who maintains the Speakeasy package in OpenCode?
How do OpenCode users get Mercury?
Are Mercury calls from OpenCode logged?
Connect more