# Use DevTune with Claude Code

Canonical: https://devtune.ai/integrations/claude-code

Connect Claude Code to your DevTune project, then ask it what AI platforms say about your product, what to fix next, and whether a shipped fix moved the numbers.

## Before you start

- A DevTune project on a plan that includes API access. No account yet? [Let your agent set one up](https://docs.devtune.ai/getting-started/agent-setup).
- Claude Code 2.1.275 or later for the plugin install command below. Run `claude --version` to check.
- For the API key route: a project API key from **API Keys** in the account sidebar. DevTune shows the key once, so copy it when you create it.

## Connect by signing in

Install the DevTune plugin. It adds the DevTune server and the DevTune skills:

```text
/plugin install devtune --marketplace devtunehq/claude-plugins
```

1. Confirm the marketplace when Claude Code asks, then choose where to install the plugin.
2. Run `/mcp` and choose **devtune**.
3. Sign in to DevTune in the browser, select the project, choose the scopes the connection may use, and approve.

To add the server without the plugin, run `claude mcp add --transport http devtune https://devtune.ai/api/mcp`, then run `/mcp` and sign in.

The connection reaches the project you select, with your own DevTune permissions.

## Connect with an API key

Use a key for scripts, scheduled runs and machines without a browser.

Put the key in an environment variable and add the server. The single quotes keep the key out of the file. Claude Code saves the variable name and reads the key when it connects.

```bash
export DEVTUNE_API_KEY='dtk_live_YOUR_KEY'
claude mcp add --transport http --scope project devtune https://devtune.ai/api/mcp \
  --header 'Authorization: Bearer ${DEVTUNE_API_KEY}'
```

`--scope project` writes `.mcp.json` in the current folder, which you can commit. Leave it out to keep the server to yourself in this folder, or use `--scope user` for every project.

A key reaches the one project it was created for, with the scopes you gave it. A change made with a key acts as the member who created it.

## Check the connection

Run `claude mcp list`. A working connection shows `devtune` with `✔ Connected`. `! Needs authentication` means you still need to run `/mcp` and sign in. A project-scoped server shows `⏸ Pending approval` until you start `claude` in that folder and approve it.

Then ask Claude Code:

```text
Which DevTune project are you connected to?
```

It answers with your project's name, read with `devtune_get_connection_context`. If it names the wrong project, connect again and select the right one.

## Measure

Ask Claude Code what AI platforms say and what AI systems fetch from your site:

```text
What is our share of voice across AI platforms over the last 30 days, and how has it changed?
```

```text
Which pages and domains do AI platforms cite for our topics, and which competitors get cited where we are not?
```

```text
What are AI systems fetching from our site, and which pages do they ask for that do not exist?
```

Claude Code answers from `devtune_get_visibility_summary`, `devtune_get_visibility_diff`, `devtune_get_competitive_position`, `devtune_get_top_citation_pages`, `devtune_get_content_gaps`, `devtune_get_traffic_summary` and `devtune_get_404_demand`. Measurement windows are 30 or 90 days.

## Fix

Ask for the ranked fixes, then work one through:

```text
List the top five actions DevTune suggests for this project, with the evidence behind each.
```

```text
Accept the first action, generate its brief and show me the brief.
```

```text
Mark that action live. The page is published at https://example.com/your-page.
```

1. `devtune_get_actions` lists the queue with its evidence.
2. `devtune_change_action_status` accepts an action, and `devtune_generate_action_brief` writes its brief. Generating a brief spends credits.
3. Claude Code reads the brief with `devtune_get_action_brief`. Writing and publishing the page is your work and the agent's, in your own repository or content system. DevTune drafts and never publishes.
4. `devtune_change_action_status` with `mark_live` and the published URL starts the before/after measurement.

## Prove

```text
Which of our shipped actions have results, and what moved?
```

`devtune_get_outcomes_ledger` returns each measured action as improved, mixed, no clear change, declined, still measuring or unmeasured. Results show what moved after a fix shipped, not what caused it. Results windows are 7, 30, 90 or 365 days.

## What needs your approval

- Reading never changes your project or spends credits.
- Accepting an action, changing prompts or competitors, and every other change acts as you. Have the agent say what it will change before it does.
- Briefs, drafts, managed-agent runs, Agent Picks tests and prompt-set analysis spend credits. Approve the spend before the agent starts one.
- DevTune steers suggestions around locked pages and says when it did.

## How Claude Code runs DevTune tools

Claude Code names the tools `mcp__devtune__<tool>`, for example `mcp__devtune__devtune_get_visibility_summary`. Tools from the plugin are named `mcp__plugin_devtune_devtune__<tool>`. Claude Code asks before it runs a tool unless you have allowed it.

For a scripted run, allow the tools you need by name:

```bash
claude -p "Summarize my DevTune visibility for the last 30 days" \
  --allowedTools "mcp__devtune__devtune_get_connection_context,mcp__devtune__devtune_get_visibility_summary"
```

## Skills

The DevTune skills tell the agent which DevTune tool answers which question and how to report the numbers the way DevTune measures them.

The plugin includes the DevTune skills. Without the plugin, add them yourself:

```bash
npx skills add devtunehq/skills
```

## Limits

- `claude -p` cannot open the browser sign-in. Sign in from an interactive session first, or use an API key.
- Claude Code cuts a tool result off at 25,000 tokens by default. Ask for a narrower window or fewer rows, or raise `MAX_MCP_OUTPUT_TOKENS`.
- A connection reaches one project. Connect again, or use another key, for a second project.
- Tools your connection has no scope for do not appear in the agent. A connection never gains scopes added later. Edit the key, or disconnect and sign in again.

## If something goes wrong

| Symptom                                                                  | What to do                                                                                                                                                                        |
| ------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `claude mcp list` shows `✘ Failed to connect` after you added an API key | Claude Code does not fall back to sign-in when a key is rejected. Check that `DEVTUNE_API_KEY` is set in the shell that starts Claude Code and that the key is active.            |
| Claude Code lists no DevTune tools                                       | Check the connection as described above. With an API key, confirm the key is active under **API Keys** and has not expired.                                                       |
| A tool is missing, or a call is refused with `403`                       | The connection lacks that tool's scope, or the plan lacks the feature. Ask the agent which scopes the connection has, then edit the key or sign in again with the scope selected. |
| Changes are refused but reads work                                       | The connection has read scopes only, or the project is paused. Add the scope to the key or sign in again with it selected; resume a paused project in DevTune.                    |
| A figure comes back empty or as `Unmeasured`                             | DevTune has no measurement for that window. Report it as unmeasured, not as zero.                                                                                                 |

## Next steps

- [Claude Code documentation](https://code.claude.com/docs/en/mcp): how Anthropic documents connecting outside tools
- [MCP server](https://docs.devtune.ai/api-reference/mcp-server): every tool, its inputs and its scope
- [Code mode](https://docs.devtune.ai/api-reference/mcp-server#code-mode): two tools in place of the full list, for agents short on context
- [API authentication](https://docs.devtune.ai/api-reference/authentication): keys and scopes
- [Use DevTune with your agent](https://devtune.ai/integrations): setup guides for other agents
