# OpenCode

[<mark style="color:blue;">OpenCode</mark>](https://opencode.ai) is an open-source terminal-based AI coding agent that supports 75+ model providers and local MCP servers. It is designed for developers who work primarily in the terminal and want AI assistance without leaving the command line.

## Prerequisites

* OpenCode installed. For more information, see [<mark style="color:blue;">opencode.ai/docs/#install</mark>](https://opencode.ai/docs/#install)
* The `ionoscloud-mcp` binary on your `PATH`. For more information, see [<mark style="color:blue;">Quick Start</mark>](/cloud/ai/mcp-server/quick-start.md)
* An <code class="expression">space.vars.ionos\_cloud\_api</code> token. For least-privilege access, see [<mark style="color:blue;">Authentication</mark>](/cloud/ai/mcp-server/configuration/authentication.md#token-scope-by-product-area) to scope the token to only the tools you need.

## Add the MCP server

{% hint style="info" %}
OpenCode uses `"type": "local"` with a `command` array and an `environment` key rather than `env`. The `type` field is OpenCode's own config schema; it maps to a local stdio subprocess internally, not an MCP transport type. The config file is `opencode.json` or `opencode.jsonc`, not `mcp.json`.
{% endhint %}

Add the following to your OpenCode config:

* **Global config:** `~/.config/opencode/opencode.jsonc`
* **Project config:** `opencode.json` or `opencode.jsonc` in your project root (takes precedence over global)

```json
{
  "mcp": {
    "ionoscloud": {
      "type": "local",
      "command": ["/usr/local/bin/ionoscloud-mcp"],
      "environment": {
        "IONOS_TOKEN": "your-api-token"
      }
    }
  }
}
```

Replace `your-api-token` with your <code class="expression">space.vars.ionos\_cloud\_api</code> token. On Windows, use the full path: `C:\\bin\\ionoscloud-mcp.exe`.

To also enable Object Storage tools, add the Object Storage credentials:

```json
{
  "mcp": {
    "ionoscloud": {
      "type": "local",
      "command": ["/usr/local/bin/ionoscloud-mcp"],
      "environment": {
        "IONOS_TOKEN": "your-api-token",
        "IONOS_S3_ACCESS_KEY": "your-access-key",
        "IONOS_S3_SECRET_KEY": "your-secret-key"
      }
    }
  }
}
```

{% hint style="info" %}
**Tip:** A project-level `opencode.json` at your repository root lets teammates share the MCP server definition. Share the server name and command, but **not** the credentials. Each team member sets `IONOS_TOKEN` in their local environment (for example, in a `.env` file that is gitignored) rather than in the shared config file.
{% endhint %}

## Verify the connection

{% stepper %}
{% step %}

### Start OpenCode

Run `opencode` in your terminal. On startup, OpenCode loads MCP servers defined in the config. A confirmation message in the startup output confirms the `ionoscloud` server connected.
{% endstep %}

{% step %}

### Test a tool call

In the OpenCode prompt, type: *List my* <code class="expression">space.vars.ionos\_cloud</code> *data centers.*

{% hint style="success" %}
**Result:** OpenCode calls `list_datacenters` and returns your data centers.
{% endhint %}
{% endstep %}
{% endstepper %}

{% hint style="info" %}
**Note:** If the `ionoscloud-mcp` binary is not in `/usr/local/bin`, update the `command` array to use the correct path. Run `which ionoscloud-mcp` to confirm.

If no confirmation appears on startup, see [<mark style="color:blue;">Troubleshooting</mark>](/cloud/ai/mcp-server/troubleshooting.md).
{% endhint %}

For full OpenCode MCP documentation, see [<mark style="color:blue;">opencode.ai/docs/mcp-servers</mark>](https://opencode.ai/docs/mcp-servers/).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ionos.com/cloud/ai/mcp-server/connect-to-an-ai-client/opencode.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
