# MCP server

The Chamber MCP server exposes vault management operations to any AI agent that speaks the [Model Context Protocol](https://modelcontextprotocol.io) — Claude Desktop, Cursor, Windsurf, Cline, VS Code, Gemini CLI, ChatGPT Desktop. It's the integration surface behind [AI-assisted management](/manage/ai-assisted-management.md) — the product story is there, this page is the developer reference.

**Package:** [`@dhedge/chamber-mcp`](https://www.npmjs.com/package/@dhedge/chamber-mcp) on npm. **Model:** local-first. There is no hosted server, no user account, no API key. Vault private keys are AES-256 encrypted on the user's machine in `~/.chamber/vaults.json` and never leave it.

> Package name and tool names remain `dhedge`/`chamber`-prefixed in code until those surfaces themselves rename. Prose rebrands; code identifiers don't.

## What it does

The Chamber MCP server wraps the [SDK](/build/sdk.md) and exposes a set of tools that an AI agent can call to:

* Inspect vault composition, holdings, and metadata.
* Estimate the cost of a proposed trade before signing anything.
* Execute trades within the [Guard System](/security/guard-system.md)'s rules.
* Interact with supported integrations: Toros leveraged tokens, Aave, Compound, Fluid, Uniswap V3 / Velodrome / Aerodrome / Pancake CL, Hyperliquid.

The model never sees the private key directly — it calls tool names, and the local server signs with the trader wallet.

## Supported chains

Polygon, Optimism, Arbitrum, Base, Ethereum, Plasma, Hyperliquid. See the [deployment matrix](/build/deployment-matrix.md) for the full network picture.

## Install and link a vault

The private key is collected by the CLI, never by the agent.

```bash
# Link a vault (prompts for trader private key)
npx @dhedge/chamber-mcp vault link --address 0xYourVault --network arbitrum

# List linked vaults
npx @dhedge/chamber-mcp vault list

# Remove a vault
npx @dhedge/chamber-mcp vault unlink --address 0xYourVault --network arbitrum
```

The trader wallet is the EOA the vault manager has authorised to execute trades — see [trader delegation](/manage/trader-delegation.md). It's not the manager wallet and not a fresh wallet.

## Configure your MCP client

Add the server to your MCP client config. For Claude Desktop:

```json
{
  "mcpServers": {
    "chamber": {
      "command": "npx",
      "args": ["-y", "@dhedge/chamber-mcp", "mcp", "-s", "all"]
    }
  }
}
```

Cursor, Windsurf, Cline, VS Code, Gemini CLI, and ChatGPT Desktop accept the same command in their MCP settings.

## Scopes

Tools are gated by the `-s` flag so an agent only gets what you want it to have.

| Flag                                        | Mode                   | What's enabled                                             |
| ------------------------------------------- | ---------------------- | ---------------------------------------------------------- |
| `mcp` (no flag)                             | Read-only              | Vault info, composition, Toros products, Hyperliquid state |
| `mcp -s trade`                              | + Trade + asset config | Approvals, swaps, enabled-asset changes                    |
| `mcp -s trade,toros`                        | + Toros                | Toros withdrawals and limit orders                         |
| `mcp -s trade,toros,lending`                | + Lending              | Aave V3, Compound V3, Fluid                                |
| `mcp -s trade,toros,lending,lp`             | + Liquidity            | Uniswap V3, Velodrome CL, Aerodrome CL, Pancake CL         |
| `mcp -s trade,toros,lending,lp,hyperliquid` | + Hyperliquid perps    | Deposit, perp/spot routing, market orders, close positions |
| `mcp -s all`                                | Everything             | All tools enabled                                          |

Read-only is safe to grant to any MCP client. Use `-s all` only with trusted agents.

## Tools

### Read-only (always available)

| Tool                                  | Purpose                                   |
| ------------------------------------- | ----------------------------------------- |
| `chamber_list_linked_vaults`          | Vaults linked on this machine             |
| `chamber_get_vault_info`              | Name, manager, total value                |
| `chamber_get_composition`             | Current holdings and balances             |
| `chamber_estimate_trade`              | Dry-run a trade — gas and expected output |
| `chamber_get_toros_products`          | Browse Toros leveraged token products     |
| `chamber_get_toros_deposit_assets`    | Valid deposit assets for a Toros pool     |
| `chamber_toros_get_limit_order`       | Read active limit order                   |
| `chamber_toros_has_limit_order`       | Check if a limit order exists             |
| `chamber_get_nft_manager_address`     | NFT manager address for LP protocols      |
| `chamber_price_to_tick`               | Convert price range to ticks for CL pools |
| `chamber_hyperliquid_get_positions`   | Perp + spot positions and PnL             |
| `chamber_hyperliquid_get_open_orders` | Unfilled Hyperliquid orders               |

### `-s trade`

| Tool                      | Purpose                                                  |
| ------------------------- | -------------------------------------------------------- |
| `chamber_approve_token`   | Approve token for a DEX aggregator                       |
| `chamber_approve_spender` | Approve token for an arbitrary spender                   |
| `chamber_execute_trade`   | Swap via Odos, 1inch, KyberSwap, Toros, Pendle, CoW Swap |
| `chamber_change_assets`   | Update the vault's enabled asset list                    |

### `-s toros`

| Tool                                | Purpose                               |
| ----------------------------------- | ------------------------------------- |
| `chamber_complete_toros_withdrawal` | Claim tokens after Toros redemption   |
| `chamber_toros_approve_limit_order` | Approve token for limit-order manager |
| `chamber_toros_create_limit_order`  | Set stop-loss / take-profit           |
| `chamber_toros_modify_limit_order`  | Update existing limit order           |
| `chamber_toros_delete_limit_order`  | Cancel limit order                    |

### `-s lending`

| Tool                        | Purpose                            |
| --------------------------- | ---------------------------------- |
| `chamber_aave_lend`         | Supply to Aave V3                  |
| `chamber_aave_withdraw`     | Withdraw from Aave V3              |
| `chamber_aave_borrow`       | Borrow from Aave V3                |
| `chamber_aave_repay`        | Repay Aave V3 loan                 |
| `chamber_compound_lend`     | Supply to Compound V3 or Fluid     |
| `chamber_compound_withdraw` | Withdraw from Compound V3 or Fluid |

### `-s lp`

| Tool                    | Purpose                              |
| ----------------------- | ------------------------------------ |
| `chamber_lp_add`        | Open concentrated liquidity position |
| `chamber_lp_increase`   | Add liquidity to existing position   |
| `chamber_lp_remove`     | Remove liquidity (partial or full)   |
| `chamber_lp_claim_fees` | Collect trading fees                 |

Supported LP venues: Uniswap V3, Velodrome CL, Aerodrome CL, Pancake CL.

### `-s hyperliquid`

| Tool                                 | Purpose                             |
| ------------------------------------ | ----------------------------------- |
| `chamber_hyperliquid_deposit`        | Deposit USDC into Hyperliquid       |
| `chamber_hyperliquid_perp_to_spot`   | Move USDC perp → spot wallet        |
| `chamber_hyperliquid_withdraw`       | Withdraw USDC back to the EVM vault |
| `chamber_hyperliquid_order`          | Open a market order (long or short) |
| `chamber_hyperliquid_close_position` | Close position by percentage        |

Hyperliquid trading requires the vault to be deployed on the Hyperliquid network and whitelisted by dHEDGE.

`chamber_estimate_trade` is the dry-run gate. Call it before `chamber_execute_trade` so the agent can surface expected cost and gas, and the user can confirm before anything is signed.

## Configuration

Everything lives under `~/.chamber/`:

| File          | Purpose                                               |
| ------------- | ----------------------------------------------------- |
| `.env`        | RPC URLs and aggregator API keys (loaded on startup)  |
| `.key`        | Machine-local AES-256 encryption key (auto-generated) |
| `vaults.json` | Encrypted trader private keys                         |

Common env vars:

| Variable                                                                                                             | Description                                                         |
| -------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `ODOS_API_KEY`                                                                                                       | Required for Toros trades. Get one at [odos.xyz](https://odos.xyz). |
| `ONEINCH_API_KEY`                                                                                                    | Required if routing via 1inch.                                      |
| `ARBITRUM_RPC_URL`, `BASE_RPC_URL`, `POLYGON_RPC_URL`, `OPTIMISM_RPC_URL`, `ETHEREUM_RPC_URL`, `HYPERLIQUID_RPC_URL` | Private RPCs per chain. Public RPCs are used as fallback.           |

## Safety model

* **Guard System.** Every trade is bound by the [Guard System](/security/guard-system.md). The MCP server can't execute anything a human trader couldn't.
* **Trader, not manager.** Signing uses the trader wallet. The manager can revoke the trader, change enabled assets, or toggle trader permissions at any time.
* **Local key storage.** Keys are AES-256-CBC encrypted with a machine-local key. They never transit the agent, the network, or a hosted service.
* **CLI-only linking.** Private keys are entered at the terminal, never typed into the agent chat.
* **Read-only default.** Launch without `-s` for a tool surface that cannot move funds.
* **Dry-run first.** `chamber_estimate_trade` is idempotent and free; agents should always call it before execution.

## See also

* [AI-assisted management](/manage/ai-assisted-management.md) — product framing and manager setup
* [Trader delegation](/manage/trader-delegation.md) — how the manager/trader permission split works
* [Guard system](/security/guard-system.md) — the rules every MCP-originated call is subject to
* [SDK](/build/sdk.md) — the layer MCP wraps


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.chamberfi.com/build/mcp-server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
