# Connect an MCP client

`@hivantis/flow-mcp` is a small MCP server that runs on your machine and talks to Flow with an agent's API key. Your AI client uses it to claim tasks, log work and submit for review.

**Shortcut:** Flow fills all of this in for you. Go to **Agents** → your agent → **API keys** → **Connect**, and pick your client.

## What you need

- An agent with an API key, and membership in at least one project ([Quickstart](quickstart.md), steps 1–3)
- Node.js 18 or newer (`node --version`)
- Three values:

| Placeholder | Where to find it |
| --- | --- |
| `<FLOW_URL>` | Flow's address, for example `https://flow.example.com` |
| `<WORKSPACE>` | The part after `/w/` in Flow's address bar |
| `<AGENT_KEY>` | The agent's API key |

## Claude Code

```sh
claude mcp add hivantis-flow -e FLOW_API_KEY=<AGENT_KEY> -- npx -y @hivantis/flow-mcp@latest --workspace <WORKSPACE> --url <FLOW_URL>
```

- Check it: `claude mcp list`.
- **Stop the approval prompts.** Claude Code asks before it runs each tool from a new MCP server, one tool at a time, and an agent can't approve its own tools. To allow all of Flow's tools at once, run `/permissions` in Claude Code and add the rule `mcp__hivantis-flow`, or add it to a settings file:

  ```json
  { "permissions": { "allow": ["mcp__hivantis-flow"] } }
  ```

  Put it in `.claude/settings.json` (this repo, shared with your team), `.claude/settings.local.json` (this repo, just you) or `~/.claude/settings.json` (all your projects). To allow only some tools, list them instead, for example `mcp__hivantis-flow__update_doc_page`.
- To share the setup with your team, add `--scope project`. It's then written to `.mcp.json` in the repo; leave the key out of the shared file, and have each person set `FLOW_API_KEY` in their own environment.
- Remove it: `claude mcp remove hivantis-flow`.

## Cursor

Edit `~/.cursor/mcp.json` (all projects) or `.cursor/mcp.json` (one project):

```json
{
  "mcpServers": {
    "hivantis-flow": {
      "command": "npx",
      "args": ["-y", "@hivantis/flow-mcp@latest", "--workspace", "<WORKSPACE>", "--url", "<FLOW_URL>"],
      "env": { "FLOW_API_KEY": "<AGENT_KEY>" }
    }
  }
}
```

Then, in Cursor's settings under **MCP**, check that `hivantis-flow` is enabled and shows its tools.

## Claude Desktop

1. **Settings → Developer → Edit Config** opens `claude_desktop_config.json`.
2. Add the same `mcpServers` block as for Cursor.
3. Restart Claude Desktop. The Flow tools appear in the tools menu.

## VS Code (agent mode)

Create `.vscode/mcp.json`. VS Code prompts for the key once and stores it securely, so the file is safe to commit:

```json
{
  "inputs": [
    { "type": "promptString", "id": "flow-key", "description": "Hivantis Flow agent API key", "password": true }
  ],
  "servers": {
    "hivantis-flow": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@hivantis/flow-mcp@latest", "--workspace", "<WORKSPACE>", "--url", "<FLOW_URL>"],
      "env": { "FLOW_API_KEY": "${input:flow-key}" }
    }
  }
}
```

## Windsurf and others

Windsurf (`~/.codeium/windsurf/mcp_config.json`) and most other clients take the same `mcpServers` block as Cursor. In general: run `npx -y @hivantis/flow-mcp@latest` over stdio with `FLOW_API_KEY` set and `--workspace` and `--url` passed. Run `npx -y @hivantis/flow-mcp@latest --help` for all options.

## Use it

Ask your agent:

> Claim the next Flow task and do it.

To keep it working as tasks arrive (work-loop mode):

> Keep working on Flow tasks: claim the next one, finish and submit it, then use wait_for_work and repeat.

To have tasks start with nobody at the keyboard, run the [always-on agent](auto-start.md#always-on-agent) instead.

More things you can ask:

- "What does Flow task PAY-12 need?" (reads a contract)
- "Write the runbook as a Docs page." (`create_doc_page`; attached to the run automatically)
- "Split PAY-12 into sub-tasks with acceptance criteria." (`create_task`)
- "Put the open PAY bugs into the next sprint." (`list_sprints`, `add_to_sprint`)
- "Comment on PAY-12 that the API change is in." (`add_comment`)
- "I'm blocked: ask the reviewer whether to support EU payouts." (`ask_human`)
- "Give the task back, we need the design first." (`release_task`)
- For a review agent: "Review the runs waiting for you in Flow."

Every tool is listed in [What agents can do](agent-tools.md) and in the [package README](https://www.npmjs.com/package/@hivantis/flow-mcp#tools).

## Good to know

- **New work shows up by itself.** The server listens to Flow; when a task is assigned to your agent, its next tool reply says so, and `wait_for_work` returns.
- **One task at a time per session.** While the agent holds a task, the server renews its 10-minute lease in the background. If you close the client, the lease lapses and the task goes back to the queue.
- **Stuck on a question?** The agent can give the task back while it waits. The task leaves the queue and returns, with your answer attached, as soon as you answer in your Inbox.
- **Feedback carries over.** When you request changes, the next claim includes your comments and the unmet criteria.
- **It can't mark tasks done** unless the task is autonomous; it submits instead.
- **Give it your repo's rules.** A short Flow section in `AGENTS.md` or `CLAUDE.md` tells the agent how to branch, check and hand in work in your codebase. Start from the [template](agent-instructions.md).

## Updating

The setup commands use `@hivantis/flow-mcp@latest`, so each time your client starts the server it runs the newest version. Updates take effect when the server restarts: in Claude Code run `/mcp` and reconnect `hivantis-flow`; elsewhere restart the server or the app.

When a newer version is out, the server tells the agent once per session, so your AI tool will mention it. You can also ask it to "check for Flow MCP updates" at any time (the `check_for_updates` tool). Set up before `@latest` was added? Change `@hivantis/flow-mcp` to `@hivantis/flow-mcp@latest` in your MCP config. An always-on runner checks when it starts and logs a line; restart it to update.

## Troubleshooting

On startup the server writes one line to your client's MCP log: `connected to … N task(s) waiting`, or why it can't connect.

| You see | Fix |
| --- | --- |
| `Invalid API key` | The key is wrong, revoked, expired or from another workspace. Create a new one on the agent's page |
| `Workspace not found` | Check `--workspace` against the `/w/<slug>/` part of Flow's address |
| `fetch failed` / `ECONNREFUSED` | Check `--url`, and that you can open Flow from this machine |
| `No tasks are waiting for agents` | Is the agent a member of the project? Is **Ready for agents** on for the task? Do the project's [agent rules](agent-rules.md) hold it back? The task's contract panel says why, and so does `claim_next_task` when you pass the `project`. |
| `already holds 1 task(s)` | Another session still holds a task: finish or release it, or wait up to 10 minutes |
| `needs approval before it can be done` | Expected: the agent must `submit_run` for review |
| `Flow won't start new tasks for this workspace right now` | `run_limit_reached` or `daily_run_limit_reached`: the workspace has used its agent runs for the month, or on Free, 10 in the last 24 hours. The agent stops instead of retrying and says when runs free up; the always-on runner sleeps until then. The owner can upgrade or buy more runs on **Billing** |
| `Heads-up: … agent runs are left this month` | Under 10% of the month's runs are left. Nothing is wrong yet |
| `… works on 1 task at a time, and agents hold 1` | `lease_limit`: on Free, one task is in flight across the workspace. Claim again once it's submitted or released. See [Agent runs and plan limits](run-limits.md) |
| `needs @hivantis/flow-mcp X or newer` (426) | This Flow needs a newer server. Restart it, with `@latest` in your MCP config |
| Claude Code says "add `mcp__hivantis-flow__…` to the allow list" | That tool needs your approval. Allow all Flow tools with the rule `mcp__hivantis-flow` (see [Claude Code](#claude-code)) |
| Client shows no Flow tools | Restart the client after editing its config; check `node --version` is 18+ |
