# Working with ControlVector Hub

This repository is hosted on ControlVector Hub (https://dev-next.controlvector.io). Agents working in it can query its code graph
and search index over MCP, and can take tasks dispatched to a machine that runs the ControlVector Hub agent.

## Connect over MCP

Endpoint: https://api.dev-next.controlvector.io/mcp (streamable HTTP). Authenticate with a personal access token
(`cv_pat_...`) from your account settings, or sign in from a client that supports OAuth.

Claude Code:

    claude mcp add --transport http cv-hub https://api.dev-next.controlvector.io/mcp \
      --header "Authorization: Bearer cv_pat_YOUR_TOKEN"

Add a custom connector in claude.ai and paste the MCP endpoint URL. claude.ai signs in with OAuth: it asks you to sign in to ControlVector Hub and approve access. The claude.ai OAuth connector is newer. If it does not connect, use the Claude Code command with a personal access token.

## Run the agent (cva)

    npm install -g @controlvector/cv-agent
    cva auth login --api-url https://api.dev-next.controlvector.io    # paste a personal access token (repo:read, repo:write)
    cd <your-repository>
    cva agent --auto-approve    # takes tasks dispatched to this machine

`cva auth login` keeps the token in `~/.config/cv-hub/credentials` (mode 0600) and sets up git's
credential helper for the host. Do not write tokens into remote URLs.

cva runs each task with one engine, chosen when the agent starts:

- Claude Code, the default. Needs Claude Code installed and signed in. Start: `cva agent --auto-approve`. Check: `cva doctor`.
- cv-code. Needs cv-code (cvc) with a model endpoint added by cvc endpoint add; Claude Code is not needed. Runs only with --auto-approve. Start: `cva agent --engine cv-code --model <provider>/<model> --auto-approve`. Check: `cvc endpoint test <provider>`.

## Before changing code here

- Ask the graph who calls a function before you edit it (`find_callers`, `get_impact_context`),
  and search the code (`search_code`) before adding something that may exist.
- Work on a branch and open a pull request; do not push to the default branch.

## Documentation

Connecting agents and tools: https://dev-next.controlvector.io/docs/connect/
Everything else: https://dev-next.controlvector.io/docs/
