# Claude Code

Add the Data MCP server to Claude Code with one command, using OAuth sign-in or an API key header.

## Prerequisites

- Claude Code installed and signed in.
- For OAuth: a verified AutoUncle account that is a member of the workspace you want to use.
- For an API key: a key from **API keys** in the console. Start with a test key (`au_test_...`).

Claude Code stores MCP servers in one of three scopes. `--scope local` (the default) and `--scope user` live in `~/.claude.json`; `--scope project` writes `.mcp.json` in the repository root so your team shares the configuration.

## Connect with OAuth

```bash
claude mcp add --transport http autouncle-data https://data-services.autouncle.com/mcp
```

Then sign in: run `/mcp` inside a Claude Code session and complete the browser flow, or run this from your shell:

```bash
claude mcp login autouncle-data
```

Claude Code discovers the authorization server from the server's `401` response and registers itself automatically. On the AutoUncle consent page, choose the organization and approve the scopes. OAuth valuations are **live** and use that organization's credits.

## Connect with an API key

The quickest way is a header on the command line:

```bash
claude mcp add --transport http autouncle-data https://data-services.autouncle.com/mcp \
  --header "Authorization: Bearer $AUTOUNCLE_API_KEY"
```

Your shell expands `$AUTOUNCLE_API_KEY` before Claude Code sees it, so **the literal key is stored in the configuration**. That is acceptable for a personal `local` or `user` scope on your own machine, but never for a project file you commit.

To keep only a reference to the variable, use a project `.mcp.json`. Claude Code expands `${VAR}` in `url` and `headers` when it loads the file:

```json
{
  "mcpServers": {
    "autouncle-data": {
      "type": "http",
      "url": "https://data-services.autouncle.com/mcp",
      "headers": { "Authorization": "Bearer ${AUTOUNCLE_API_KEY}" }
    }
  }
}
```

- `type` is required; a `url` without a `type` is a configuration error.
- Each developer sets `AUTOUNCLE_API_KEY` in their own environment, ideally to their own test key.
- If the variable is not set, Claude Code still loads the file and shows a warning. The server then rejects the connection with `401`.

## Verify the connection

Run `/mcp` to see the server's status, then ask:

> Call get_account on autouncle-data and tell me the key mode, scopes and remaining credits.

You should see your workspace name and `"mode": "test"` for a test key. Then try a free valuation:

> Use autouncle-data to value a 2020 Volkswagen Golf in Denmark with 60,000 km. Use a test valuation and explain the precision grade.

## Troubleshooting

| Symptom | Fix |
| --- | --- |
| Server shows as needing authentication | Run `/mcp` or `claude mcp login autouncle-data` and finish the sign-in. |
| `401 invalid_api_key` | Check that `AUTOUNCLE_API_KEY` holds the full key without quotes or spaces, and that the key is not revoked. |
| You expected test results but got live ones | You are connected with OAuth or a live key. OAuth is always live; switch to a test key header for free results. |
| `insufficient_scope` on a tool | The key or the OAuth grant lacks that scope. Create a key with the scope, or reconnect and approve it. |
| Old OAuth connection stops working | Tokens are bound to `https://data-services.autouncle.com/mcp`. Remove the server and add it again with that exact URL. |

To remove the server: `claude mcp remove autouncle-data`.

## Next steps

- Install the [agent skill](/docs/skill) so Claude Code also knows how to integrate the REST API.
- Read [safety & spend control](/docs/mcp/safety) before you connect a live key.

Sources: [Claude Code MCP documentation](https://code.claude.com/docs/en/mcp).
