# ContractGate MCP server

> Validates and repairs structured LLM output against schemas and manages data contract ingestion and quarantine.

- Repository: https://github.com/nightmoose/contractgate
- Page: https://hostedmcp.org/servers/nightmoose/contractgate
- Transport: stdio
- Stars: 4
- License: MIT
- Latest version: 0.4.1

## Install

### Claude Code

```sh
claude mcp add --env 'CONTRACTGATE_API_KEY=<YOUR_CONTRACTGATE_API_KEY>' contractgate -- npx -y @nightmoose/contractgate-mcp-server
```

### Cursor (`~/.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "contractgate": {
      "command": "npx",
      "args": [
        "-y",
        "@nightmoose/contractgate-mcp-server"
      ],
      "env": {
        "CONTRACTGATE_API_KEY": "<YOUR_CONTRACTGATE_API_KEY>"
      }
    }
  }
}
```

### VS Code (`.vscode/mcp.json`)

```json
{
  "servers": {
    "contractgate": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@nightmoose/contractgate-mcp-server"
      ],
      "env": {
        "CONTRACTGATE_API_KEY": "<YOUR_CONTRACTGATE_API_KEY>"
      }
    }
  }
}
```

### VS Code CLI

```sh
code --add-mcp '{"name":"contractgate","type":"stdio","command":"npx","args":["-y","@nightmoose/contractgate-mcp-server"],"env":{"CONTRACTGATE_API_KEY":"<YOUR_CONTRACTGATE_API_KEY>"}}'
```

### Claude Desktop (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "contractgate": {
      "command": "npx",
      "args": [
        "-y",
        "@nightmoose/contractgate-mcp-server"
      ],
      "env": {
        "CONTRACTGATE_API_KEY": "<YOUR_CONTRACTGATE_API_KEY>"
      }
    }
  }
}
```

### Codex

```sh
codex mcp add contractgate --env 'CONTRACTGATE_API_KEY=<YOUR_CONTRACTGATE_API_KEY>' -- npx -y @nightmoose/contractgate-mcp-server
```

### Codex config.toml (`~/.codex/config.toml`)

```toml
[mcp_servers.contractgate]
command = "npx"
args = ["-y", "@nightmoose/contractgate-mcp-server"]

[mcp_servers.contractgate.env]
CONTRACTGATE_API_KEY = "<YOUR_CONTRACTGATE_API_KEY>"
```

### Gemini CLI

```sh
gemini mcp add -s user -e 'CONTRACTGATE_API_KEY=<YOUR_CONTRACTGATE_API_KEY>' contractgate npx -- -y @nightmoose/contractgate-mcp-server
```

### Gemini settings.json (`~/.gemini/settings.json`)

```json
{
  "mcpServers": {
    "contractgate": {
      "command": "npx",
      "args": [
        "-y",
        "@nightmoose/contractgate-mcp-server"
      ],
      "env": {
        "CONTRACTGATE_API_KEY": "<YOUR_CONTRACTGATE_API_KEY>"
      }
    }
  }
}
```

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `CONTRACTGATE_API_KEY` | yes | yes | DataContractGate API key (cg_live_...). Create one at https://app.datacontractgate.com/account |
| `CONTRACTGATE_BASE_URL` | no | no | Gateway base URL. Defaults to https://api.datacontractgate.com |

## FAQ

### What does AISchemaGate do?

AISchemaGate validates and repairs structured LLM output against a contract using violation fields like min, max, pattern, enum, and compliance_mode.

### Can I use a custom API URL?

Yes, you can override the default HTTP API endpoint using the CONTRACTGATE_BASE_URL environment variable.

### What are the capabilities of DataContractGate?

DataContractGate allows you to infer and deploy data contracts, validate ingest (including ODCS v3.1.0 and v3.2.0), and inspect quarantine.
