MCP Gateway · OpenCode
Connect Grain to OpenCode
OpenCode users can pull Grain recordings into terminal work without opening the app. The server connects as a remote entry in OpenCode's mcp config, and the OpenCode plugin sends each prompt and tool call to Speakeasy to allow or deny. Identity runs through your provider, so the agent never holds a Grain credential.
- Category
- Productivity
- Tools
- 22
- Authentication
- OAuth
- OpenCode
- Terminal
Behind the MCP Gateway
Run Grain MCP behind the MCP Gateway
One URL for every agent, sign-in through your IdP, RBAC down to the tool, and every Grain call inspected and logged.
Set up
Add Grain to OpenCode in 4 steps
- 01
Add Grain from the catalog
An admin finds Grain 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.
Grain 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 Grain
Give teams the
mcp:connectscope on the Grain server through team access or a role. OpenCode connects to the Grain 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 Grain from OpenCode
The first time OpenCode connects, it opens a browser so the person can sign in to Speakeasy through your identity provider.
Grain needs its own OAuth grant, so each person connects it once. Until they do, Grain calls fail while the rest of the gateway keeps working.
From then on, Grain'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 Grain
Build a playlist of feedback calls
Collect every call where users talked about the CLI into a new Grain collection. It starts restricted to you, and OpenCode adds the recordings it found.
create_collectionadd_recordings_to_collectionsearch_meetings_v2
See what a teammate covered
Look up a colleague in the workspace user list, then get their person ID to list the recordings they attended before you take over their area.
Confirm whose Grain account is connected
When results look wrong, ask OpenCode which Grain user it is signed in as before digging into filters or meeting access.
Tools
22 tools
Each Grain tool can be allowed or denied per team and role at the MCP Gateway before OpenCode sees it.
myself
Get information about the logged-in Grain user.
list_meetings
Returns a filtered list of Grain meetings you have access to, ordered by most recent.
list_attended_meetings
Returns a filtered list of Grain meetings you have attended, ordered by most recent.
fetch_meeting
Fetches information about a single Grain meeting by ID. The response format is the same as is returned by list_meetings.
fetch_meeting_notes
Fetches the AI notes payload from a single Grain meeting by ID. In some cases, older meetings may not have had notes generated for them. In these cases you can use fetch_meeting_transcript instead to determine the content of the meeting.
fetch_meeting_action_items
Fetches the action items extracted from a single Grain meeting by ID. Action items include the task description, timestamp, status (pending or completed), due date, and the person assigned to the action item (if any).
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 Grain call is logged with the person and the client that made it.
Access by role
Gateway
People reach only the Grain tools their team or role allows.
Request and response blocking
Gateway
A risk policy scoped to Grain 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
Does Grain reach OpenCode through a plugin?
Can OpenCode share a Grain collection publicly?
How do OpenCode users get Grain?
Are Grain calls from OpenCode logged?
Connect more