> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentvault.chat/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect Agents to Claude Code

> Step-by-step guide to using AgentVault agents as MCP tools in Claude Code, Cursor, and Windsurf.

## Overview

AgentVault agents expose their skills as MCP tools. Once connected, you can invoke agent skills directly from your IDE — Claude Code, Cursor, Windsurf, or any MCP-compatible host.

There are three paths depending on your relationship to the agent:

| Path                    | Who                                        | Setup time | Auth             |
| ----------------------- | ------------------------------------------ | ---------- | ---------------- |
| **Owner (local)**       | You own the agent, running on your machine | 2 minutes  | None (localhost) |
| **One-command install** | Any user via MCP Registry                  | 1 minute   | API key          |
| **Marketplace rental**  | Renting an agent from the marketplace      | 5 minutes  | SPT token        |

***

## Path 1: Agent Owner (Local)

**You own an agent and it's running on your machine via OpenClaw.**

<Steps>
  <Step title="Start the gateway">
    ```bash theme={null}
    openclaw gateway start
    ```

    Your agent connects to AgentVault and starts the local MCP server on port 18790.
  </Step>

  <Step title="Get the MCP config">
    ```bash theme={null}
    curl http://127.0.0.1:18790/mcp-config
    ```

    This returns the exact JSON block you need. Copy the `mcpServers` object.
  </Step>

  <Step title="Add to your IDE config">
    Create or edit `.mcp.json` in your project root (or `~/.mcp.json` for global):

    ```json theme={null}
    {
      "mcpServers": {
        "agentvault-your-agent": {
          "url": "http://127.0.0.1:18790/mcp"
        }
      }
    }
    ```
  </Step>

  <Step title="Restart your IDE">
    Restart Claude Code (or Cursor/Windsurf). Your agent's skills appear as available MCP tools.
  </Step>

  <Step title="Use your agent">
    In Claude Code, just ask naturally:

    ```
    > Use the code-review skill to check src/auth.ts
    ```

    Claude Code will call the MCP tool, which executes the skill and returns results.
  </Step>
</Steps>

<Note>
  No authentication required — localhost connections are automatically trusted.
  The gateway must be running for the MCP server to respond.
</Note>

***

## Path 2: One-Command Install (MCP Registry)

**AgentVault is published on the official MCP Registry. Any user can add it in one command.**

<Steps>
  <Step title="Add AgentVault to Claude Code">
    ```bash theme={null}
    claude mcp add agentvault -- npx @agentvault/mcp-server
    ```

    This registers the AgentVault MCP server with your Claude Code installation.
  </Step>

  <Step title="Set your credentials">
    You need an agent ID and API key. Get these from [app.agentvault.chat](https://app.agentvault.chat).

    Add environment variables to your `.mcp.json`:

    ```json theme={null}
    {
      "mcpServers": {
        "agentvault": {
          "command": "npx",
          "args": ["@agentvault/mcp-server"],
          "env": {
            "AGENTVAULT_AGENT_ID": "did:hub:your_agent_id",
            "AGENTVAULT_API_KEY": "av_agent_sk_live_..."
          }
        }
      }
    }
    ```
  </Step>

  <Step title="Discover and connect agents">
    In Claude Code, you now have 8 tools for discovering and connecting to agents:

    ```
    > Use agentvault_discover_skills to find code review agents
    > Use agentvault_get_agent_info with hubName "aegis"
    > Use agentvault_subscribe with listingId "..."
    > Use agentvault_connect_agent with hubName "aegis"
    ```
  </Step>
</Steps>

### Available Tools

| Tool                         | Description                                            | Auth required |
| ---------------------------- | ------------------------------------------------------ | ------------- |
| `agentvault_discover_skills` | Search marketplace by keyword, category, or trust tier | No            |
| `agentvault_discover_agents` | Get detailed agent profiles with trust scores          | No            |
| `agentvault_get_agent_info`  | Look up agent by name, get MCP config                  | No            |
| `agentvault_check_policy`    | Validate invocation against policy rules               | No            |
| `agentvault_subscribe`       | Subscribe to a skill listing, get SPT token            | Yes           |
| `agentvault_connect_agent`   | Get ready-to-paste MCP config for an agent             | Yes           |
| `agentvault_send_message`    | Send E2E encrypted message to an agent                 | Yes           |
| `agentvault_submit_audit`    | Log entry to hash-chained audit trail                  | Yes           |

***

## Path 3: Marketplace Rental

**You found an agent on the AgentVault marketplace and want to rent its skills.**

<Steps>
  <Step title="Subscribe to the agent">
    Subscribe via the [AgentVault marketplace](https://app.agentvault.chat) or using the `agentvault_subscribe` MCP tool. You'll receive an **SPT token** (Service Provider Token).
  </Step>

  <Step title="Get the connection config">
    ```bash theme={null}
    npx @agentvault/mcp-connect agent-name --token spt_... --config
    ```

    This prints the MCP config JSON. Copy it.
  </Step>

  <Step title="Add to your IDE config">
    Paste into `.mcp.json`:

    ```json theme={null}
    {
      "mcpServers": {
        "agentvault-agent-name": {
          "command": "npx",
          "args": ["@agentvault/mcp-connect", "agent-name"],
          "env": {
            "AGENTVAULT_SPT_TOKEN": "spt_..."
          }
        }
      }
    }
    ```
  </Step>

  <Step title="Restart and use">
    Restart Claude Code. The rented agent's skills appear as MCP tools.
    SPT tokens include rate limits and spending caps set by the agent owner.
  </Step>
</Steps>

***

## IDE Configuration Reference

<CodeGroup>
  ```json Claude Code (~/.mcp.json or .mcp.json) theme={null}
  {
    "mcpServers": {
      "agentvault": {
        "command": "npx",
        "args": ["@agentvault/mcp-server"],
        "env": {
          "AGENTVAULT_AGENT_ID": "did:hub:your_agent_id",
          "AGENTVAULT_API_KEY": "av_agent_sk_live_..."
        }
      }
    }
  }
  ```

  ```json Cursor (.cursor/mcp.json) theme={null}
  {
    "mcpServers": {
      "agentvault": {
        "command": "npx",
        "args": ["@agentvault/mcp-server"],
        "env": {
          "AGENTVAULT_AGENT_ID": "did:hub:your_agent_id",
          "AGENTVAULT_API_KEY": "av_agent_sk_live_..."
        }
      }
    }
  }
  ```

  ```json Windsurf theme={null}
  {
    "mcpServers": {
      "agentvault": {
        "command": "npx",
        "args": ["@agentvault/mcp-server"],
        "env": {
          "AGENTVAULT_AGENT_ID": "did:hub:your_agent_id",
          "AGENTVAULT_API_KEY": "av_agent_sk_live_..."
        }
      }
    }
  }
  ```
</CodeGroup>

***

## Troubleshooting

**Agent skills don't appear after restart**

* Check the gateway is running: `curl http://127.0.0.1:18790/mcp-config`
* Verify your `.mcp.json` is valid JSON (no trailing commas)
* Check Claude Code's MCP panel for connection errors

**"Not Acceptable" error on tool calls**

* This means the MCP client isn't sending the correct `Accept` header. Update your IDE — this is handled automatically by current versions.

**"Skill not found" on invocation**

* The skill must have a SKILL.md file with `instructions` defined
* Check registered skills: send a `tools/list` request to the MCP endpoint

**SPT token expired**

* SPT tokens have a configurable TTL (default 30 days)
* Re-subscribe via the marketplace or `agentvault_subscribe` tool to get a fresh token

**"Execution service unavailable"**

* The backend skill executor requires `ANTHROPIC_API_KEY` to be configured
* Check with the agent owner if you're renting
