---
title: "MTS Client Integration MCP"
canonical_url: "https://docs.sportradar.com/resources/transaction/docs/integration-mcp/mts-client-integration-mcp"
markdown_url: "https://docs.sportradar.com/resources/transaction/docs/integration-mcp/mts-client-integration-mcp.md"
last_updated: "2026-11-24T09:55:04Z"
---

# MTS Client Integration MCP

The **MTS Client Integration MCP** is a local [Model Context Protocol](https://modelcontextprotocol.io/) server that helps external developers integrate with **MTS using the Transaction 3.0 API**. It runs on the integrator’s machine and connects to AI-assisted editors such as **Cursor** and **Claude Desktop**, so they can validate tickets, interpret rejections, and test client behavior without guessing at schema rules or wire formats.

The MCP is built around Sportradar’s **Ticket 3.0 JSON Schemas** and complements the public [Transaction 3.0 documentation](https://docs.sportradar.com/resources/transaction.md) and JSON schemas. It does **not** replace production MTS or the **MTS Gate Sandbox** used for hosted scenario testing; it provides **local** tools while a client is designed and debugged.

## Requirements and installation

- Python **3.14+**
- [uv](https://docs.astral.sh/uv/)

```bash
git clone https://github.com/sportradar/mts-client-integration-mcp.git
cd mts-client-integration-mcp
uv sync
```

If PyPI is blocked on your network, use `.envrc.example` → `.envrc` and `direnv allow` as described in the repository [Contributing](https://github.com/sportradar/mts-client-integration-mcp/blob/main/CONTRIBUTING.md) guide.

## MCP client setup

The server runs as a **stdio** MCP process. The client spawns:

`uv run mts-mcp-server`

from the cloned repository (via `uv --directory <repo> run mts-mcp-server`).

**Cursor**

1. **Clone and install**

   Clone the repository and run `uv sync`.

2. **Add the server entry**

   Add a server entry in **workspace** `.cursor/mcp.json` or **global** `~/.cursor/mcp.json`:

   ```json
   {
     "mcpServers": {
       "mts-client-integration": {
         "command": "uv",
         "args": [
           "--directory",
           "/path/to/mts-client-integration-mcp",
           "run",
           "mts-mcp-server"
         ]
       }
     }
   }
   ```

3. **Set the repository path**

   Replace `/path/to/mts-client-integration-mcp` with the **absolute** path to your clone.

4. **Reload MCP servers**

   Restart Cursor or reload MCP servers (**Settings → MCP**, or refresh in the MCP panel).

**Claude Desktop**

On macOS, edit for example `~/Library/Application Support/Claude/claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "mts-client-integration": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/mts-client-integration-mcp",
        "run",
        "mts-mcp-server"
      ]
    }
  }
}
```

Restart Claude Desktop after saving.

### Verify outside an IDE (optional)

**MCP Inspector** (interactive tool browser):

```bash
uv run fastmcp dev inspector src/server.py:create_server --project .
```

Open the URL printed in the terminal (often `http://localhost:6274`), choose **STDIO**, and connect.

**CLI smoke test** (no IDE):

```bash
uv run fastmcp list --command "uv run mts-mcp-server"

uv run fastmcp call \
  --command "uv run mts-mcp-server" \
  --target lookup_rejection_code \
  --input-json '{"code": -702}' \
  --json
```

## Available tools

### Rejection decoder

`lookup_rejection_code`

Look up the **canonical MTS rejection message** for a numeric code returned on the wire.

- Accepts `code` as negative or positive (normalized to negative).
- Pass **`ticket_context.operation`** (or top-level `operation`) when the same code applies to more than one Transaction 3.0 operation — otherwise the tool may return **`ambiguous: true`** and list variants.
- When the catalog entry includes them, returns **`steps_to_reproduce`** and **`fix_suggestions`**.

Typical use: an integrator pasted a rejection from MTS and needs the official wording and next steps.

### Local validator

`validate_ticket_request`

Validate a **single outbound** Ticket 3.0 envelope **before** sending it to MTS. Four layers:

| Layer             | What it checks                                                                                                                                                           |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| JSON Schema       | Structure against packaged Ticket 3.0 request schema                                                                                                                     |
| Envelope          | Typed envelope fields and `operation` consistency                                                                                                                        |
| Business rules    | Stake/odds/currency, selection caps, system/ways/custom-bet rules, partial cash-out cumulation, frame size (32 KB), channel/language expectations, and related MTS rules |
| ACK state machine | Cancellation and ticket-placement ACK/nACK flows when **`session_state`** includes prior wire messages                                                                   |

**`session_state`** is optional: prior messages in chronological order (structured objects or a log string with `->`/`<-` markers). The MCP resource **`mts://schemas/session-state`** documents the shape.

### Golden ticket builder

`build_placement`, `build_cashout`, `build_ext_settlement`, `list_ticket_shapes`

Build **schema-conformant** request JSON for tests and demos (**34 placement/cash-out/settlement shapes**).

- **`list_ticket_shapes`** — discover shape ids, required params, and which build tool to call.
- Each build tool takes **`shape`** + **`params`** (validated by Pydantic; the MCP tool schema is the contract).
- Presets supply **structural** defaults only (`bet_type`, `size`, partial flags, etc.). The integrator must supply **business values** (`operator_id`, `limit_id`, `channel`, selections, stake, cash-out codes, …) — nothing is invented from the environment.

Response shape: `{ "shape", "operation", "payload" }` where **`payload`** is the wire envelope. Always run **`validate_ticket_request`** on the result before production send.

**MCP resources for builders:**

| URI                                  | Purpose                                                      |
| ------------------------------------ | ------------------------------------------------------------ |
| `mts://templates/{shape}`            | Defaults, required params, `example_params` for a shape      |
| `mts://templates/builder-schema`     | JSON Schema for all three param models                       |
| `mts://integration/envelope-context` | How to obtain `operatorId`, `limitId`, channel, end customer |

### Local WebSocket mock — simulator tools

Fixture-driven **local** mock (`ws://127.0.0.1:<port>` plus stub OAuth). Not the hosted **MTS Gate Sandbox**.

| Tool                  | Purpose                                                                                    |
| --------------------- | ------------------------------------------------------------------------------------------ |
| `list_mock_scenarios` | Scenario ids, bundles, injectable events                                                   |
| `start_mock`          | Start mock WebSocket + OAuth stub                                                          |
| `mock_status`         | Check whether the mock is running                                                          |
| `send_to_mock`        | Send ticket JSON over the mock WebSocket; returns replies                                  |
| `inject`              | Drive faults: `connection_blocked`, `force_disconnect`, `fast_forward_timer`, …            |
| `stop_mock`           | Shutdown; returns **`wire_log`** for reuse in `validate_ticket_request(session_state=...)` |

Example sequence:

```
start_mock(scenarios=["realistic_mix"])
→ point your client at ws_url
→ place tickets (or use send_to_mock)
stop_mock() → pass wire_log into validate_ticket_request
```

### MCP resources (schemas and docs)

Read-only context for the agent:

| URI                                     | Content                                  |
| --------------------------------------- | ---------------------------------------- |
| `mts://schemas/ticket3/request`         | Ticket 3.0 request JSON Schema           |
| `mts://schemas/ticket3/response`        | Ticket 3.0 response JSON Schema          |
| `mts://schemas/session-state`           | `session_state` format for the validator |
| `mts://templates/...`                   | Builder presets (see above)              |
| `mts://integration/envelope-context.md` | Markdown guide for envelope fields       |

## Example prompts

After MCP is connected, use natural language in the chat. The agent should call the tools above. Try these to confirm setup:

| Goal             | Example prompt                                                                                                |
| ---------------- | ------------------------------------------------------------------------------------------------------------- |
| Rejection lookup | *I got MTS rejection code -702 on a ticket-placement request. What does it mean?*                             |
| Validator        | *Validate this ticket-placement JSON against MTS rules before I send it:* then paste a full envelope.         |
| Build + validate | *List available ticket shapes, build an accumulator placement with my operator id, and validate the payload.* |
| Mock             | *Start the local MTS mock with realistic\_mix, send a single prematch ticket, and show the reply.*            |
| Mock + validator | *Stop the mock and check the wire log against ACK rules with validate\_ticket\_request.*                      |

More copy-paste scenarios ship in the GitHub repository under `examples/prompts/local_validator/`, `examples/prompts/build_ticket/`, and `examples/prompts/simulator/`.

## Recommended agent workflow

```mermaid
flowchart LR
  A[Discover shape or paste JSON] --> B{Have payload?}
  B -->|No| C[list_ticket_shapes + mts://templates]
  C --> D[build_placement / build_cashout / build_ext_settlement]
  B -->|Yes| E[validate_ticket_request]
  D --> E
  E --> F{All layers OK?}
  F -->|No| G[Fix using rule_id + maps_to_code]
  G --> E
  F -->|Yes| H{Need local wire test?}
  H -->|Yes| I[start_mock → client or send_to_mock]
  I --> J[stop_mock → validate wire_log]
  H -->|No| K[Send to integration or production MTS]
  K --> L[lookup_rejection_code on rejections]
```

1. **Envelope context**

   Read `mts://integration/envelope-context` for operator, limit, channel, and end-customer values your environment expects.

2. **Build or import JSON**

   Use builder tools for greenfield tests, or paste JSON from your client.

3. **Validate locally**

   Run `validate_ticket_request` until schema, business rules, and, if applicable, ACK checks are clean.

4. **Optional mock**

   Exercise reconnect, rate limits, partial cash-out, or cancellation flows locally; reuse **`wire_log`** in the validator.

5. **Target environment**

   Connect to Sportradar integration or production WebSocket per your credentials (see Transaction 3.0 connectivity docs).

6. **On rejection**

   Run `lookup_rejection_code` with the **`operation`** from the failed request; apply **`fix_suggestions`** when present.

For hosted scenario-based testing, continue with **MTS Gate Sandbox** documentation after local validation.

## Troubleshooting

| Symptom                                           | Likely cause                             | What to do                                                                                             |
| ------------------------------------------------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------------ |
| MCP tools not visible in Cursor/Claude            | Server not registered or failed to start | Check JSON path in `args`, run `uv sync` in the repo, reload MCP. Run CLI `fastmcp list` smoke test.   |
| `uv` or Python errors on start                    | Wrong Python version or missing deps     | Use Python 3.14+; run `uv sync` from repo root.                                                        |
| `lookup_rejection_code` returns `ambiguous: true` | Code shared across operations            | Pass `ticket_context.operation` (e.g. `ticket-placement`, `cashout-build`).                            |
| `validate_ticket_request` fails ACK checks        | Missing or wrong `session_state`         | Include prior placement/cancel/cash-out exchanges in order; see `mts://schemas/session-state`.         |
| Partial cash-out rule errors                      | Increment vs cumulative `percentage`     | Follow-up partial cash-out **`percentage`** must be **cumulative**, not incremental.                   |
| Builder tool validation errors                    | Incomplete `params`                      | Open `mts://templates/{shape}` for `required_params` and `example_params`; supply all business fields. |
| Mock connection refused                           | Mock not running or wrong URL            | `mock_status`; use `ws_url` from `start_mock` response.                                                |
| `fastmcp` / Inspector issues                      | Run from repo root                       | Use commands exactly as in README; project path is the clone directory.                                |
| Corporate PyPI / SSL                              | Cannot install packages                  | Configure `.envrc` index per CONTRIBUTING; do not commit lockfile changes from blocked mirrors.        |

> **Warning**
>
> `uv run mts-mcp-server` in a terminal speaks JSON-RPC on stdio — it is not an interactive shell. Use an MCP client, MCP Inspector, or `fastmcp call` for testing.

***

**License:** MIT (open source). Repository: [github.com/sportradar/mts-client-integration-mcp](https://github.com/sportradar/mts-client-integration-mcp).

> **Info**
>
> The local WebSocket mock is for **client-side** integration testing on the integrator’s machine. For Sportradar-hosted sandbox scenarios, use **MTS Gate Sandbox** and its user manual.
