Connect OpenCode to MCP tools through a gateway

developer2026-11-14

On this page

OpenCode connects to MCP tools when you add a server entry to its configuration file. Point that entry at your gateway's MCP endpoint, then pass your API key through an environment variable. Restart OpenCode and confirm that the gateway tools appear in its tool list.

What OpenCode needs from an MCP gateway

An MCP gateway sits between the agent and many tool providers. OpenCode sees one server entry. The gateway then exposes the tools behind that entry. This keeps the client configuration short, and you can add tools without editing OpenCode.

OpenCode needs three things from the gateway. It needs a reachable endpoint URL. It needs credentials that the gateway accepts. It needs a transport type that matches the endpoint.

A remote endpoint uses HTTP. A local server runs as a process on your machine and talks over standard input and output. Most gateway setups use the remote type.

Add the gateway to the OpenCode configuration

Open the OpenCode configuration file for your project or for your user profile. Add an entry in the mcp section. Give the server a name, set its type to remote, and set its url to the gateway endpoint.

Keep the API key out of the file. Store the key in an environment variable, then reference that variable in the request header. Commit the configuration file without the secret.

  • Set the server name to something you recognise, such as the gateway name.
  • Set the type to remote for an HTTP endpoint.
  • Set the url to the endpoint shown in your account.
  • Reference the key from an environment variable, not from the file.

For help getting a key, see the connect page.

Check that the gateway tools load

Start OpenCode and open its tool list. The gateway tools appear under the server name you chose. If they are missing, the connection failed before the tool list loaded.

Test with a small, read-only task first. A test call shows whether the endpoint and the credentials both work. A tool that returns JSON confirms the full round trip.

Run one tool call that changes nothing. Check the output before you give the agent write access to any system.

Troubleshoot a failed connection

Most failed connections come from one of four causes. Each cause has a clear check.

  • The url is wrong or has a typo. Compare it with the endpoint in your account.
  • The API key is missing or not read. Confirm that the environment variable is set in the shell that starts OpenCode.
  • The type does not match the endpoint. A remote endpoint needs the remote type.
  • OpenCode still runs an old process. Restart it after every configuration change.

If the tool list stays empty after these checks, read the OpenCode log output. The log names the step that failed.

About the opencode.uk domain in this keyword

The keyword includes the domain opencode.uk. This guide does not rely on that domain. No public documentation for it was checked while writing this page, so the page makes no claim about what that domain offers.

For the OpenCode client itself, read the official OpenCode project documentation. Use this guide for the gateway side of the setup.

Live pricing — developer

Price per call, developer tools Horizontal bar chart of the price per call and the cache-hit price, in US dollars, for 12 developer tools. The same values are in the table below the chart. Price per call Cache-hit price $0.0 $0.0005 $0.001 Usage Time SeriesUsage Time Series $0.0 $0.0 Per-Tool Usage BreakdownPer-Tool Usage Breakdown $0.0 $0.0 Usage SummaryUsage Summary $0.0 $0.0 Discover ToolsDiscover Tools $0.0 $0.0 Batch Tool CallsBatch Tool Calls $0.0 $0.0 Tool Quality MetricsTool Quality Metrics $0.0 $0.0 Tool Quality RankingsTool Quality Rankings $0.0 $0.0 List Programming LanguagesList Programming Languages $0.001 $0.0001 Check CVE ID Reservation Stat…Check CVE ID Reservation Status $0.001 $0.0001 Security Advisories (deps.dev)Security Advisories (deps.dev) $0.001 $0.0001 Dependency Tree (deps.dev)Dependency Tree (deps.dev) $0.001 $0.0001 Package Info (deps.dev)Package Info (deps.dev) $0.001 $0.0001 US dollars per call
Price per call for developer tools, cheapest first.

Data source: live tool catalog snapshot, fetched 2026-11-14.

Chart data as a table
ToolPrice per callCache-hit price
Usage Time Series$0.0$0.0
Per-Tool Usage Breakdown$0.0$0.0
Usage Summary$0.0$0.0
Discover Tools$0.0$0.0
Batch Tool Calls$0.0$0.0
Tool Quality Metrics$0.0$0.0
Tool Quality Rankings$0.0$0.0
List Programming Languages$0.001$0.0001
Check CVE ID Reservation Status$0.001$0.0001
Security Advisories (deps.dev)$0.001$0.0001
Dependency Tree (deps.dev)$0.001$0.0001
Package Info (deps.dev)$0.001$0.0001
ToolProviderPrice/callCache-hit
Usage Time Seriesaccount$0$0
Per-Tool Usage Breakdownaccount$0$0
Usage Summaryaccount$0$0
Discover Toolsapibase$0$0
Batch Tool Callsplatform$0$0
Tool Quality Metricsplatform$0$0
Tool Quality Rankingsplatform$0$0
List Programming Languagesjudge0$0.001$0.0001
Check CVE ID Reservation Statuscve-mitre$0.001$0.0001
Security Advisories (deps.dev)depsdev$0.001$0.0001
Dependency Tree (deps.dev)depsdev$0.001$0.0001
Package Info (deps.dev)depsdev$0.001$0.0001

Connect via MCP

How a tool call worksAn AI agent sends a tool call to the APIbase gateway. The gateway checks payment, calls the provider API, and returns the JSON result to the agent.Your agentAPIbase gatewayProvider API1. tool call2. paid call3. JSON result flows back to the agent
Diagram: the path of one tool call.

Data source: gateway design, no measured values.

$ curl -X POST https://apibase.pro/api/v1/tools/account.timeseries/call \
  -H "Content-Type: application/json" -d '{"params": {}}'

FAQ

Does OpenCode support MCP servers?

OpenCode reads MCP server entries from its configuration file. Check the version you run, because configuration keys can change between releases.

Do I need a separate entry for each tool provider?

No. The gateway exposes tools from many providers behind one endpoint. One server entry in OpenCode covers all of them.

Where should I store the API key?

Store the key in an environment variable. Reference that variable in the request header. Keep the key out of any file you commit.

How much does the gateway cost?

Pricing varies by plan. The current range runs from 0 to 29.99 USD.

Can OpenCode use a local MCP server instead?

Yes. Set the type to local and give a command that starts the server. A local server runs on your machine and does not need the gateway.

  1. STEP 1/2 Connect your MCP client
  2. STEP 2/2 Browse the full catalog

Written with AI assistance from APIbase's published documentation and public data; checked automatically against them. Corrections: https://apibase.pro/

Published: 2026-11-14Source: live apibase.pro catalog snapshot