Skip to main content
Back to the Context7 MCP server

MCP Gateway · OpenCode

Context7 icon

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.

Deploy on MCP Gateway

Set up

Add Context7 to OpenCode in 4 steps

  1. 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.

  2. 02

    Choose who can use Context7

    Give teams the mcp:connect scope 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.

  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 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.

query-docs

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.

resolve-library-id

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.

resolve-library-idquery-docs

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?
OpenCode doesn't receive MCP servers from plugins and has no OpenTelemetry exporter, so session data comes through Speakeasy's OpenCode plugin. It's installed from a ZIP or with speakeasy-hooks install --provider=opencode.
Is text from Context7 inspected before OpenCode sees it?
Prompt injection detection and PII redaction run on every Context7 tool call at the gateway. Tool output is blocked there rather than in OpenCode's hooks.
How do OpenCode users get Context7?
An admin adds Context7 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 Context7 tools their access allows.
Are Context7 calls from OpenCode logged?
Yes. Context7 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

Context7 in other clients

AI everywhere.

Control here.