MCP Gateway · OpenCode
Connect Context7 to OpenCode
OpenCode can answer library questions from current documentation when Context7 is connected. Speakeasy hosts Context7 behind its MCP Gateway, so you add it as a remote server in the mcp block of your OpenCode config. The OpenCode plugin sends each prompt and tool call to Speakeasy before it runs, and reports token and cost totals per turn.
- Category
- Developer tools
- Tools
- 2
- Authentication
- None
- OpenCode
- Terminal
Behind the MCP Gateway
Run Context7 MCP behind the MCP Gateway
One URL for every agent, sign-in through your IdP, RBAC down to the tool, and every Context7 call inspected and logged.
Set up
Add Context7 to OpenCode in 4 steps
- 01
Add Context7 from the catalog
An admin finds Context7 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.
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 Context7
Give teams the
mcp:connectscope on the Context7 server through team access or a role. OpenCode connects to the Context7 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 Context7 from OpenCode
The first time OpenCode connects, it opens a browser so the person can sign in to Speakeasy through your identity provider.
From then on, Context7'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 Context7
Look up options mid-session
Ask OpenCode how a function's options work and it answers from the library's current documentation instead of guessing at parameter names.
Resolve an ambiguous package name
When several packages share a name, OpenCode resolves the one your project imports to its Context7 library ID before it queries anything.
Port a script to another library
Switching HTTP or argument-parsing libraries? OpenCode reads the target library's docs and examples, then rewrites the script to use it.
Tools
2 tools
Each Context7 tool can be allowed or denied per team and role at the MCP Gateway before OpenCode sees it.
resolve-library-id
Resolves a package/product name to a Context7-compatible library ID and returns matching libraries.
query-docs
Retrieves and queries up-to-date documentation and code examples from Context7 for any programming library or framework.
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 Context7 call is logged with the person and the client that made it.
Access by role
Gateway
People reach only the Context7 tools their team or role allows.
Request and response blocking
Gateway
A risk policy scoped to Context7 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
Why does OpenCode need a separate observability package?
Is text from Context7 inspected before OpenCode sees it?
How do OpenCode users get Context7?
Are Context7 calls from OpenCode logged?
Connect more