# Margin Guard: Profit Alerts MCP server

Connect Claude, ChatGPT, Gemini, Grok, Cursor, VS Code, and other AI assistants to Margin Guard: Profit Alerts over MCP. Checks a Shopify discount against your minimum gross margin before it goes live, reports the prices and discounts that miss the floor, and blocks checkout when a cart line would.

- Server URL: `https://marginguard.agntwrk.com/mcp`
- Transport: Streamable HTTP
- Sign-in: OAuth 2.1 in your browser on first use; no API key

## Connect your assistant

### Claude Code

1. Add the server. Use `--scope user` to make it available in every project, or `--scope project` to write it to `.mcp.json` for your team.
2. Run `/mcp` inside Claude Code and follow the browser sign-in (or run `claude mcp login marginguard`).

Terminal:

```bash
claude mcp add --transport http marginguard https://marginguard.agntwrk.com/mcp
```

Vendor documentation: https://code.claude.com/docs/en/mcp

### Claude Desktop, claude.ai on the web, and Claude mobile

1. Open Customize, then Connectors.
2. Click +, then Add custom connector.
3. Enter the server URL https://marginguard.agntwrk.com/mcp and click Add, then sign in when asked.
4. On Team and Enterprise plans an owner adds it first under Organization settings, then Connectors; members then sign in individually.

Anthropic connects to the server from its own network, so the URL must be reachable from the public internet. Connectors you add on the web also appear in the mobile apps. Custom connectors are available on all plans; the free plan allows one.

Vendor documentation: https://support.claude.com/en/articles/11175166-get-started-with-custom-connectors-using-remote-mcp

### ChatGPT

1. On the web, open Settings, then Security and login, and turn on Developer mode.
2. In the Plugins section select the plus button to create a developer-mode app for a remote MCP server.
3. Enter the server URL https://marginguard.agntwrk.com/mcp and choose OAuth for authentication, then sign in when asked.

Developer mode is offered on paid web plans; your workspace admin may need to enable it. Write actions ask for confirmation by default.

Vendor documentation: https://developers.openai.com/api/docs/guides/developer-mode

### OpenAI API

1. Add an `mcp` tool to a Responses API request.
2. The API does not run the OAuth sign-in: your application obtains an access token for this server and passes it as `authorization` on every request.

Responses API tool:

```json
{
  "type": "mcp",
  "server_label": "marginguard",
  "server_url": "https://marginguard.agntwrk.com/mcp",
  "authorization": "<access token>"
}
```

Vendor documentation: https://developers.openai.com/api/docs/guides/tools-connectors-mcp

### OpenAI Codex CLI

1. Add the server to `~/.codex/config.toml`.
2. Run `codex mcp login marginguard` and finish the sign-in in the browser.

~/.codex/config.toml:

```toml
[mcp_servers.marginguard]
url = "https://marginguard.agntwrk.com/mcp"
```

Terminal:

```bash
codex mcp login marginguard
```

Vendor documentation: https://learn.chatgpt.com/docs/extend/mcp?surface=cli

### Gemini CLI

1. Add the server.
2. Run `/mcp auth marginguard` inside Gemini CLI and finish the sign-in in the browser.

Terminal:

```bash
gemini mcp add --transport http marginguard https://marginguard.agntwrk.com/mcp
```

Vendor documentation: https://geminicli.com/docs/tools/mcp-server/

### Gemini app

1. On gemini.google.com, open Settings, then Connected Apps.
2. Under Custom apps choose Add a custom app.
3. Enter the server URL https://marginguard.agntwrk.com/mcp, then continue and sign in.

Google limits custom apps to personal Google accounts for adults in the US; work and school accounts are not supported. Connections made on the web also work in the mobile app.

Vendor documentation: https://support.google.com/gemini/answer/17209137

### Grok and the xAI API

1. In the Grok app, open grok.com/connectors, choose New Connector, then Custom, enter the server URL, and complete the sign-in.
2. In the xAI API, add an `mcp` tool to a Responses API request at `https://api.x.ai/v1/responses`. Pass an access token for this server as `authorization`; the API does not run the sign-in.

xAI API tool:

```json
{
  "type": "mcp",
  "server_label": "marginguard",
  "server_url": "https://marginguard.agntwrk.com/mcp",
  "authorization": "<access token>"
}
```

Vendor documentation: https://docs.x.ai/docs/guides/tools/remote-mcp-tools, https://docs.x.ai/grok/connectors

### Cursor

1. Use the install link, or add the server to `~/.cursor/mcp.json` (all projects) or `.cursor/mcp.json` (this project).
2. Complete the sign-in if Cursor asks for it.

mcp.json:

```json
{
  "mcpServers": {
    "marginguard": {
      "url": "https://marginguard.agntwrk.com/mcp"
    }
  }
}
```

Add to Cursor: cursor://anysphere.cursor-deeplink/mcp/install?name=marginguard&config=eyJ1cmwiOiJodHRwczovL21hcmdpbmd1YXJkLmFnbnR3cmsuY29tL21jcCJ9

Vendor documentation: https://cursor.com/docs/context/mcp/install-links

### VS Code and GitHub Copilot

1. Use the install link, run the command, or add the server to `.vscode/mcp.json`.
2. Start the server from the MCP view or the file's inline Start action and complete the sign-in.

.vscode/mcp.json:

```json
{
  "servers": {
    "marginguard": {
      "type": "http",
      "url": "https://marginguard.agntwrk.com/mcp"
    }
  }
}
```

Terminal:

```bash
code --add-mcp '{"name":"marginguard","type":"http","url":"https://marginguard.agntwrk.com/mcp"}'
```

Install in VS Code: vscode:mcp/install?%7B%22name%22%3A%22marginguard%22%2C%22type%22%3A%22http%22%2C%22url%22%3A%22https%3A%2F%2Fmarginguard.agntwrk.com%2Fmcp%22%7D

Vendor documentation: https://code.visualstudio.com/docs/copilot/customization/mcp-servers

### Any other MCP client

1. Add a remote (HTTP) MCP server with the URL https://marginguard.agntwrk.com/mcp.
2. It speaks Streamable HTTP and signs in with OAuth 2.1 (authorization code with PKCE S256, dynamic client registration). Clients that follow the MCP authorization spec discover everything from the URL.
3. To test a connection, run the MCP Inspector and choose the Streamable HTTP transport.

Terminal:

```bash
npx @modelcontextprotocol/inspector --server-url https://marginguard.agntwrk.com/mcp --transport http
```

Vendor documentation: https://modelcontextprotocol.io/docs/tools/inspector

## Tools

- `health` (read-only): Report that the app is up, its name, and the enabled features.
- `whoami` (read-only): Return the signed-in user (id, email, name) and the scope (store or tenant) every other tool acts on. Use it to confirm which account an answer is about.
- `sync_status` (read-only): For each resource this app mirrors from the store (products, inventory, ...): how many objects are mirrored and when the mirror last changed. Use to judge how fresh the data behind findings and product lookups is.
- `search_products` (read-only): Search the store's mirrored products by a substring of the title, a variant SKU, or a variant barcode (case-insensitive). Returns compact rows, sorted by title, paged with offset. Use get_product for the full record of one.
- `get_product` (read-only): One mirrored product with all its variants (SKU, barcode, price, weight). Takes the id from search_products, a numeric Shopify id, or a product GID. Reads the mirror, not live store data.
- `list_findings` (read-only): List the findings (problems the checks found) for this store, newest first. Filter by status, severity, or check id; page with offset. Use findings_summary first for the big picture and get_finding for one finding's evidence.
- `get_finding` (read-only): Get one finding in full: its evidence, dates, what its check looks for and why it matters, and links to where it can be fixed. Use after list_findings when you need detail.
- `findings_summary` (read-only): Counts of this store's findings: all by status, and the open ones by severity and by check. Start here to see how bad things are before listing anything.
- `list_checks` (read-only): List the checks this app can run: id, what each looks for, the plan that unlocks it, and whether it is enabled. Use to find a valid check id for run_check or list_findings.
- `run_check` (changes data): Run one check now for this store and update its findings: new problems are created, fixed ones resolved. Returns how many findings were created, seen again, and resolved. Use run_scan to run every enabled check; do not call this repeatedly.
- `run_scan` (changes data): Run every enabled check now for this store (as the dashboard's Run checks now button does) and return how many findings were created, how many are reported in total, and how many checks failed. Can take a while; use run_check for one check.
- `resolve_finding` (changes data): Mark a finding resolved. It reopens by itself if a later scan sees the problem again. Use after the problem is fixed or accepted.
- `snooze_finding` (changes data): Hide an open finding for a number of days (1 to 365); it reopens after that. Use for problems that will be dealt with later. A resolved finding cannot be snoozed.
- `reopen_finding` (changes data): Set a snoozed or resolved finding back to open. Use when a problem was closed by mistake or is back.
- `margin_summary` (read-only): Where the store stands on margin: products and variants covered, variants with no cost, variants whose regular price is already below the margin floor or below cost, the retail value of the stock that is below the floor, and when this was computed. Start here. Reads the stored summary, which refreshes after each catalog sync.
- `get_margin_rules` (read-only): The margin policy in force (minimum gross margin, shipping and fee loading, what to do about a missing cost), the other named policies, and the per-product and per-collection overrides. Use to explain why a variant has the floor it has. Change the minimum margin with set_minimum_margin.
- `check_discount` (read-only): The Discount Check: test a proposed percentage or fixed-amount discount (every plan), or an existing discount by id (from list_discounts; needs the Pro plan), against every variant's cost and margin floor. Returns how many variants stay safe, fall below the floor, or sell below cost, the largest percentage every variant can take, and a page of rows (problems first by default). Optionally stacks a 10% order discount. Use before creating a promotion. Reads only; creates nothing.
- `list_discounts` (read-only): The store's discounts as mirrored from Shopify, worst first, each with its audit severity (below_cost, at_risk, approaching, safe) or why it could not be evaluated (unsupported, unevaluable). Only active discounts of a supported kind are audited. Needs the Pro plan. Use check_discount with a discount's id for the variant-level detail.
- `get_product_margin` (read-only): Per-variant cost, gross margin, margin floor (and which rule set it), and the largest discount that keeps the variant at its floor, for one product. Takes a product id (a number, Product_123, or a product GID) or a variant SKU. A missing cost is reported as null (unknown), never zero.
- `set_minimum_margin` (changes data): Set the minimum gross margin of the policy in force, as a percentage (20 means 20%). Every other policy field is kept. Then queues a checkout-protection update (shared with other recent changes, so it may already be queued) and refreshes the margin summary. Per-product and per-collection overrides are not touched. Changes what check_discount and the checkout guard treat as safe.

## Prompts

- `triage_findings`: Summarize the open findings by severity and propose an order of work.
- `explain_finding` (id): Explain one finding in plain words and say how to fix it.

## Things to ask

- Who am I signed in as, and which store are you looking at?
- Find the product with SKU ABC-123 and show its variants.
- How many open findings do I have, and which are the most severe?
- Show me the evidence for the highest-severity open finding and tell me how to fix it.
- Run all checks and tell me what is new.
- Snooze the low-severity findings for two weeks.
- How is my store doing on margin?
- Can I run a 30% off sale on the whole store without losing money?
- Which of my active discounts are cutting below my margin floor?
- What is the biggest discount I can give on SKU MUG-BLUE?
- Set my minimum margin to 25%.
