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

# Local MCP server

> chance-mcp: a stdio bridge that forwards MCP messages to the hosted Chance server with your API key.

[`chance-mcp`](https://www.npmjs.com/package/chance-mcp) (MIT) is a stdio process for MCP clients that launch local servers. It forwards every JSON-RPC message to `https://harness.chance.cc/api/mcp` with `Authorization: Bearer $CHANCE_API_KEY` and returns the reply. It defines no tools of its own: the tool list, schemas and results come from the [hosted server](https://docs.chance.cc/connectors.md). An API key carries both the `mcp` and `wallet` scopes, so every hosted tool is available.

* Requires Node 18 or later.
* Each request times out after 300 seconds.
* Clients that support remote HTTP servers can connect to the hosted server directly and sign in with OAuth instead. See [Connectors](https://docs.chance.cc/connectors.md).

## Setup

**1. Create an API key**

Sign in at [harness.chance.cc/login](https://harness.chance.cc/login), open [harness.chance.cc/keys](https://harness.chance.cc/keys) and click **Create key**.

**2. Add the server to your MCP client**

```json theme={null}
{
  "mcpServers": {
    "chance": {
      "command": "npx",
      "args": ["-y", "chance-mcp"],
      "env": { "CHANCE_API_KEY": "chance_sk_live_..." }
    }
  }
}
```

> [accordion] Claude Desktop
>
> **Settings → Developer → Edit Config**, add the block to `claude_desktop_config.json`, and restart Claude Desktop.

> [accordion] Claude Code
>
> ```bash theme={null}
> claude mcp add chance -e CHANCE_API_KEY=chance_sk_live_... -- npx -y chance-mcp
> ```

> [accordion] Cursor and Windsurf
>
> Add the same `mcpServers` block to the client's MCP config and reload.

**3. Confirm the connection**

Ask the agent to call `check_connection`. It is free and returns the account, remaining credits and whether the wallet tools are available. Do not use `verify_intent` as a test: it costs a credit.

## Environment

| Variable | Required | Default | Description |
| - | - | - | - |
| `CHANCE_API_KEY` | Yes | None | A `chance_sk_live_…` key. |
| `CHANCE_BASE_URL` | No | `https://harness.chance.cc` | The server to forward to. Messages go to `<CHANCE_BASE_URL>/api/mcp`. |

## Errors

| Condition | JSON-RPC code | Message starts with |
| - | - | - |
| `CHANCE_API_KEY` is not set | `-32001` | `CHANCE_API_KEY is not set.` Nothing is sent to the server. |
| The server rejected the key (HTTP `401`) | `-32001` | `Chance rejected the API key (401).` |
| Any other HTTP error | `-32000` | `Chance returned HTTP <status>:` |
| Network failure or timeout | `-32000` | `Could not reach Chance at <base URL>:` |

On start the process writes `chance-mcp proxying to <endpoint>` to stderr.

## Tools

The tools are the hosted server's. See the [MCP tool reference](https://docs.chance.cc/api-reference/mcp-tools.md).

A standing instruction for the agent:

```
Before you place any order, call verify_intent with my rules as the intent and the exact order payload as the action. Do not execute unless the verdict is ALLOW, and tell me the reasoning when it is not.
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.