# Claude Code

[<mark style="color:blue;">Claude Code</mark>](https://code.claude.com) is Anthropic's CLI for AI-assisted software engineering. It supports MCP servers at three scopes: local (your machine), project (shared through `.mcp.json` in a repo), and user (your global `~/.claude.json`).

## Prerequisites

* Claude Code installed. For more information, see [<mark style="color:blue;">claude.ai/code</mark>](https://claude.ai/code).
* The `ionoscloud-mcp` binary built and available. 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

### Option A: CLI (recommended)

Use the `claude mcp add` command to register the server:

```bash
claude mcp add ionoscloud /usr/local/bin/ionoscloud-mcp \
  --env IONOS_TOKEN=your-api-token
```

To also enable Object Storage tools:

```bash
claude mcp add ionoscloud /usr/local/bin/ionoscloud-mcp \
  --env IONOS_TOKEN=your-api-token \
  --env IONOS_S3_ACCESS_KEY=your-access-key \
  --env IONOS_S3_SECRET_KEY=your-secret-key
```

By default, this registers the server at **local** scope (your machine only). To share the config with a team via source control, use `--scope project` instead; this writes to a `.mcp.json` file in the current directory.

### Option B: Project config file

Create or edit `.mcp.json` in your repository root:

```json
{
  "mcpServers": {
    "ionoscloud": {
      "command": "/usr/local/bin/ionoscloud-mcp",
      "env": {
        "IONOS_TOKEN": "your-api-token"
      }
    }
  }
}
```

Commit this file to share the server configuration with your team. Each team member supplies credentials via their own environment variables; never commit tokens to the file. Use `${env:IONOS_TOKEN}` in the config to reference an environment variable instead of hardcoding the value:

```json
{
  "mcpServers": {
    "ionoscloud": {
      "command": "/usr/local/bin/ionoscloud-mcp",
      "env": {
        "IONOS_TOKEN": "${env:IONOS_TOKEN}"
      }
    }
  }
}
```

Each team member then exports `IONOS_TOKEN` in their shell profile (`~/.zshrc`, `~/.bashrc`) and the token is never stored in the committed file.

{% hint style="info" %}
**Note:** Claude Code prompts you to approve a project-scoped `.mcp.json` on first use. When the prompt appears, review the `command` path and `env` block; confirm the binary path is correct and no unexpected variables are present. Select **Allow** to proceed or **Deny** to cancel (the server will not load if denied). For CI/CD environments, use the `--allowedTools` flag or a pre-approved trust policy instead of interactive approval.
{% endhint %}

## Verify the connection

{% stepper %}
{% step %}

### List available MCP servers

```bash
claude mcp list
```

`ionoscloud` appears in the output when the server is registered.
{% endstep %}

{% step %}

### Start Claude Code and test

```bash
claude
```

Then type: *List my* <code class="expression">space.vars.ionos\_cloud</code> *data centers.*

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

{% hint style="info" %}
**Note:** All tools are registered at startup by default, so Compute Engine and Object Storage tools appear immediately. To reduce the startup tool count, pass `--env IONOS_MCP_LOAD_MODE=lazy` when adding the server (or add it to `.mcp.json`) and call the `ionos_load_compute_tools` or `ionos_load_objectstorage_tools` sentinels on demand. For more information, see [<mark style="color:blue;">Selective Tool Loading</mark>](/cloud/ai/mcp-server/configuration/selective-tool-loading.md).
{% endhint %}

## Deploying for a team

The project-scoped `.mcp.json` file is the recommended way to share the MCP server configuration across a team. Because the server is read-only, sharing access to production account data carries no risk of accidental modifications.

**Recommended setup:**

1. Add `.mcp.json` to the repository root using `${env:IONOS_TOKEN}` interpolation so no credentials are committed:

   ```json
   {
     "mcpServers": {
       "ionoscloud": {
         "command": "/usr/local/bin/ionoscloud-mcp",
         "env": {
           "IONOS_TOKEN": "${env:IONOS_TOKEN}"
         }
       }
     }
   }
   ```
2. Each team member exports their own token in their shell profile:

   ```bash
   export IONOS_TOKEN="their-own-api-token"
   ```
3. Commit `.mcp.json` to the repository. Claude Code prompts each team member to approve it on first use; they review the config and select **Allow**.

**For CI/CD pipelines:** Pass the token as an environment variable in your pipeline and use `claude --allowedTools ionoscloud` to pre-approve the server non-interactively.

For full Claude Code MCP documentation including transport options and dynamic tool updates, see [<mark style="color:blue;">Connect Claude Code to tools via MCP</mark>](https://docs.anthropic.com/en/docs/claude-code/mcp).


---

# 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/claude-code.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.
