---
title: MCP Server & Tools
description: Powering AI agents with payment capabilities via Model Context Protocol.
---

Delegare provides an official MCP Server that enables LLMs (like Claude or GPT-4) to perform economic actions autonomously using Intent Mandates.

The server is available in the `packages/mcp-server` directory of the Vault repository.

## Available Tools

The MCP server exposes the following tools to the agent:

### 1. `setup_spending_mandate`
Generates a setup URL for the human user.
- **Input:** `maxAmountPerTxCents`, `maxMonthlySpendCents`, `railPreference`
- **Output:** A markdown link for the user to authorize.

### 2. `check_mandate_balance`
Allows the agent to see how much it can spend.
- **Input:** `mandateId`
- **Output:** Remaining monthly balance.

### 3. `authorize_agent_payment`
The core tool for making purchases.
- **Input:** `amountCents`, `currency`, `description`, `recipient`
- **Output:** A cryptographic Intent Mandate (SD-JWT-VC) or a success receipt if the server handles the execution.

### 4. `delegare_fetch`
A tool for scraping or fetching data from third-party APIs that may be monetized.
- **Input:** `url`, `method`, `body`, `bundleToken` (optional)
- **Output:** The fetched HTTP response content.
- **x402 Auto-Payment:** If the target URL returns a `402 Payment Required` challenge, this tool intercepts it. It evaluates the payment options (Crypto USDC vs. Fiat Credit Bundle), resolves the payment using the agent's mandate or bundle token, and resubmits the request to fetch the data.

### 5. `purchase_bundle`
Allows the agent to purchase an API credit bundle if a merchant requires fiat payment or if the agent doesn't have a crypto wallet.
- **Input:** `merchantBundleUrl`
- **Output:** A checkout link for the user to complete the fiat payment via Stripe, plus available tiers.

### 6. `check_bundle_balance`
Checks the remaining requests on a purchased API credit bundle.
- **Input:** `merchantBalanceUrl`, `bundleToken`
- **Output:** Remaining credits and tier details.

## MCP Authentication Guard
To prevent unauthorized tool calls, the MCP server implements an `mcpAuthGuard`. 
- Every tool call must be authorized by an OAuth session.
- Credentials (`merchantId`, `apiKey`) are never exposed to the LLM prompt.
- The guard injects the required metadata into the tool context based on the bearer token in the request header.


### Running Locally with Python
The Delegare MCP Server is also published to PyPI, allowing you to run it locally or embed it within your own orchestration environments.

```bash
pip install delegare-mcp
```

To run the MCP server locally over `stdio`:

```bash
export DELEGARE_MERCHANT_ID="your_merchant_id"
export DELEGARE_API_KEY="your_api_key"

python -m delegare_mcp.server
```

#### Claude Desktop Local Config
If you prefer to run the server locally rather than connecting to the remote endpoint, configure Claude Desktop to spawn the Python process:

```json
{
  "mcpServers": {
    "delegare": {
      "command": "python",
      "args": ["-m", "delegare_mcp.server"],
      "env": {
        "DELEGARE_MERCHANT_ID": "your_merchant_id",
        "DELEGARE_API_KEY": "your_api_key"
      }
    }
  }
}
```


## Usage with Claude.ai

Connect Delegare as a remote MCP connector on Claude.ai:

1. Go to **Settings** → **Connectors** → **Add custom connector**.
2. Set the **Name** to `Delegare`.
3. Set the **Remote MCP server URL** to:

| Environment | URL |
|---|---|
| Sandbox | `https://api.sandbox.delegare.dev/mcp` |
| Production | `https://api.delegare.dev/mcp` |

4. Click **Add**. Claude.ai will automatically handle OAuth authentication when you first use a Delegare tool.

## Usage with ChatGPT

1. Go to **Settings** → **Apps** and enable **Developer mode**.
2. Click **Add app** and paste the MCP URL from the table above.
3. Open a new chat, click **+**, select **Delegare**, and start a conversation.

## Usage in Claude Desktop

Add Delegare as a remote MCP server in your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "delegare": {
      "type": "streamableHttp",
      "url": "https://api.sandbox.delegare.dev/mcp"
    }
  }
}
```
