# Margin

> Margin is a paid MCP server for ai models and llm tooling. Tests a model or prompt change against your own evals before an agent ships it. It runs as a hosted remote server, so there is nothing to install locally.

- **Kind:** MCP server
- **Pricing:** Paid
- **Starting price:** $2000 a month
- **Platforms:** API, CLI, Web, Self-hosted
- **Website:** https://trymargin.io/docs
- **MCP Registry name:** io.trymargin/margin
- **Categories:** [AI models and LLM tooling](https://ai-powered.com/categories/ai-and-llm), [agent testing](https://ai-powered.com/categories/agent-testing)
- **Listing updated:** 2026-11-27

## About

Margin is a measurement service for teams running LLM agents who want to know what each workflow costs per completed outcome. It meters model calls, either through a Python or TypeScript SDK, OpenRouter broadcast, or by recording replies from plain HTTP clients, and pairs that spend with outcomes you define, such as a merged pull request or a passed eval.

The headline use is checking a change before it reaches production. A model swap or prompt edit is replayed against your existing eval cases, and the gate reports whether the candidate holds quality at a lower cost. Margin publishes a promote, hold or revert decision, but your code decides whether to act on it, since there is no runtime routing endpoint.

The product is aimed at engineering and finance leads with agents already in production. It offers an MCP server so coding assistants and scheduled agents can query spend, blind spots and face-off results, with a separate agent key that can request tests within a spend limit.

## Features

- **Model call metering:** Records token counts, cost, request hashes and retry signals from OpenAI, Anthropic, Gemini and litellm calls without proxying requests.
- **Cost per outcome:** Divides measured spend by outcomes you define, such as passed evals or merged changes, per workflow.
- **Eval adapters:** Reads results from promptfoo, Braintrust, LangSmith, Ragas, deepeval, Langfuse, pytest and vitest or jest.
- **Model replay gate:** Replays an eval dataset on a current and candidate model and returns a promote, hold or revert verdict.
- **MCP server for agents:** Exposes read tools for spend, recommendations and blind spots, plus an agent key for requesting tests within a set limit.
- **OpenRouter broadcast:** Accepts OpenRouter traces via an OpenTelemetry endpoint so calls can be metered without the SDK.

## Good for

- Check whether a cheaper model holds quality on your existing eval cases before switching
- Track which agent workflows drive the largest share of LLM spend
- Compare cost per completed task before and after a prompt or system change
- Let a scheduled coding agent open a pull request only when a candidate change passes the gate
- Find unmetered model call sites in a repository before a bill arrives

## Install

### Claude Code: Add with the CLI (Terminal)

```sh
claude mcp add --transport http margin 'https://trymargin.io/api/mcp?tools=core'
```

Add --scope user to use it in every project, or --scope project to share it in .mcp.json.

### Claude Code: Or share it with your project (.mcp.json)

```json
{
  "mcpServers": {
    "margin": {
      "type": "http",
      "url": "https://trymargin.io/api/mcp?tools=core"
    }
  }
}
```

### Claude Desktop (Customize → Connectors → Add → Add custom connector)

```text
https://trymargin.io/api/mcp?tools=core
```

Paste this URL, choose how to sign in, then click Add and Connect. On Team and Enterprise an Owner adds it in Organization settings → Connectors.

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

```json
{
  "mcpServers": {
    "margin": {
      "url": "https://trymargin.io/api/mcp?tools=core"
    }
  }
}
```

Use .cursor/mcp.json in a project to share it with the project.

### VS Code (~/.copilot/mcp-config.json)

```json
{
  "mcpServers": {
    "margin": {
      "type": "http",
      "url": "https://trymargin.io/api/mcp?tools=core"
    }
  }
}
```

Or put the same entry in .mcp.json at your workspace root to share it.

### ChatGPT (chatgpt.com → Plugins → + → Add custom MCP server)

```text
https://trymargin.io/api/mcp?tools=core
```

Paste this URL, set up sign-in, accept the warning and install the plugin. Then type @ in a chat to use it.

### Codex: Add with the CLI (Terminal)

```sh
codex mcp add margin --url 'https://trymargin.io/api/mcp?tools=core'
```

### Codex: Or add to config.toml (~/.codex/config.toml)

```toml
[mcp_servers.margin]
url = "https://trymargin.io/api/mcp?tools=core"
```

### Gemini CLI and Antigravity: Gemini CLI (~/.gemini/settings.json)

```json
{
  "mcpServers": {
    "margin": {
      "httpUrl": "https://trymargin.io/api/mcp?tools=core"
    }
  }
}
```

Or run: gemini mcp add -s user --transport http margin 'https://trymargin.io/api/mcp?tools=core'

### Gemini CLI and Antigravity: Antigravity (~/.gemini/config/mcp_config.json)

```json
{
  "mcpServers": {
    "margin": {
      "serverUrl": "https://trymargin.io/api/mcp?tools=core"
    }
  }
}
```

Use .agents/mcp_config.json to add it to one workspace only.

### Devin Desktop (~/.config/devin/mcp_config.json)

```json
{
  "mcpServers": {
    "margin": {
      "url": "https://trymargin.io/api/mcp?tools=core",
      "transport": "http"
    }
  }
}
```

On Windows the file is %APPDATA%\\devin\\mcp_config.json. Use .devin/mcp_config.json to share it with a project.

### Cline (cline_mcp_settings.json)

```json
{
  "mcpServers": {
    "margin": {
      "type": "streamableHttp",
      "url": "https://trymargin.io/api/mcp?tools=core"
    }
  }
}
```

Open it from the MCP Servers icon → Configure → Configure MCP Servers.

### Zed (Zed settings.json)

```json
{
  "context_servers": {
    "margin": {
      "url": "https://trymargin.io/api/mcp?tools=core"
    }
  }
}
```

Open it with zed: open settings file. Merge context_servers into the settings you already have.

### JetBrains AI Assistant and Junie: AI Assistant (Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add)

```json
{
  "mcpServers": {
    "margin": {
      "url": "https://trymargin.io/api/mcp?tools=core"
    }
  }
}
```

### JetBrains AI Assistant and Junie: Junie (~/.junie/mcp/mcp.json)

```json
{
  "mcpServers": {
    "margin": {
      "url": "https://trymargin.io/api/mcp?tools=core"
    }
  }
}
```

Use .junie/mcp/mcp.json to share it with a project.

### Kiro (~/.kiro/settings/mcp.json)

```json
{
  "mcpServers": {
    "margin": {
      "url": "https://trymargin.io/api/mcp?tools=core"
    }
  }
}
```

Use .kiro/settings/mcp.json to add it to one workspace only.

### Grok Bot (Grok Bot desktop app → Connect apps → Add a custom connector)

```sh
https://trymargin.io/api/mcp?tools=core
```

Enter a Name (for example "Margin"), choose Type: Remote HTTPS, paste this as the Server URL and choose Add plugin.

### Other clients (your client's MCP settings (most use this shape))

```json
{
  "mcpServers": {
    "margin": {
      "type": "http",
      "url": "https://trymargin.io/api/mcp?tools=core"
    }
  }
}
```

## Tools

From the tool list in its README, going by the names, 1 of 9 tools changes data; 7 names don't say. From the server's own tool labels and tool names; not verified by us.

- `margin_portfolio_summary`: How many projects exist and how many emit real economics
- `margin_portfolio_economics`: Cross-project spend, cost-per-outcome and savings at stake
- `margin_fix_this_first`: Ranked highest-impact opportunities across the estate
- `margin_list_projects` (name suggests: reads): Every project and its connection state
- `margin_project_economics`: One project's spend, cost-per-outcome, token yield and retry tax
- `margin_parity_prior`: For a task class, how often a cheaper model has held parity
- `margin_optimize`: Every move Margin can name for a project, ranked by basis
- `margin_test_move` (name suggests: changes): Agent key only: test one listed move on your evals within the key's spend limit
- `margin_test_model`: Agent key only: face off one named model on your evals

## FAQ

### Does Margin sit in the request path?

No. Agents call model providers directly and the SDK reads token counts after the response returns. Emits do not raise into the request path.

### What does the free plan include?

Two measurement runs on one repository and up to $100 of measurement inference, paid by Margin, once per account.

### Is Margin's MCP server read-only?

The ingest key reads only. An agent key can request a test within its spend limit, and opening pull requests happens only in the console.

### Does Margin change my model routing?

No. It publishes decisions and your code applies them or ignores them.

### How do I add Margin to Claude Code?

Run this command in your terminal: claude mcp add --transport http margin 'https://trymargin.io/api/mcp?tools=core'

### What are the best alternatives to Margin?

The closest alternatives to Margin are LLM Margin, SentioGate FinOps & LLM Router, Plzebo, LLM Prover and Agentcents.

## Where this comes from

- Description: written from the project's website and its MCP Registry entry.
- Install steps: from the official MCP Registry entry.

## Alternatives

- [LLM Margin](https://ai-powered.com/mcp/llm-margin): LLM Margin is an MCP server for ai models and llm tooling.
- [SentioGate FinOps & LLM Router](https://ai-powered.com/mcp/sentiogate-finops-and-llm-router): SentioGate FinOps & LLM Router is a free MCP server for ai models and llm tooling.
- [Plzebo](https://ai-powered.com/mcp/plzebo): Plzebo is an open-source MCP server for agent testing.
- [LLM Prover](https://ai-powered.com/mcp/llm-prover): LLM Prover is a paid MCP server for ai models and llm tooling.
- [Agentcents](https://ai-powered.com/mcp/agentcents): Agentcents is a freemium MCP server for ai models and llm tooling.
- [EvalForge Lite](https://ai-powered.com/mcp/evalforge-lite): EvalForge Lite is an open-source MCP server for ai models and llm tooling.
- [Phase Router](https://ai-powered.com/mcp/phase-router): Phase Router is a paid MCP server for ai models and llm tooling.
- [LLM Cutover](https://ai-powered.com/mcp/llm-cutover): LLM Cutover is a freemium MCP server for ai models and llm tooling.

---
Source: https://ai-powered.com/mcp/margin
