Metadata-Version: 2.5
Name: dxrp-mcp
Version: 1.0.1
Summary: MCP server and typed client for the DXRP network API
License-Expression: MIT
License-File: LICENSE
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Requires-Dist: mcp<3,>=2.3
Description-Content-Type: text/markdown

# DXRP MCP server

<!-- mcp-name: io.github.THEROCKSSS/dxrp-mcp -->

<p align="center">
  <img src="./assets/banner.svg" alt="DXRP MCP — every API operation, one tool: 333 tools, 10 groups, 154 read, 179 write, 74 verified live." width="100%">
</p>

An MCP server that lets an AI agent drive the DXRP network API — read players,
servers, ranks, factions, sanctions, items, maps and audit logs, and (with the
right scopes) act on them.

This repository is built in three layers, in this order:

| Layer | What it is | Where |
|---|---|---|
| 1. API reference | Every endpoint, verb, parameter and response DTO, extracted from the portal's own generated client and verified against the live API | [`docs/api/`](docs/api/README.md), [`spec/openapi.yaml`](spec/openapi.yaml) |
| 2. Typed client | One typed function per operation, scope-aware, rate-limit-aware | [`src/dxrp_client/`](src/dxrp_client/) |
| 3. MCP server | Tools, resources and prompts an agent can call | [`src/dxrp_mcp/`](src/dxrp_mcp/) |

The API reference comes first because everything else consumes it: the MCP
tools, the optional Discord bot, and any future admin tooling all read the same
generated contract.

The MCP server is the primary product. The Discord bot is an optional side
project that reuses the same client — you do not need it to use the MCP tools.

## Install

```bash
uv build
uvx --from dist/dxrp_mcp-1.0.1-py3-none-any.whl dxrp-mcp --list-tools
```

`--list-tools` needs no credentials and prints the read-only catalog (115 tools;
the catalog holds 154 read operations, and the other 39 are session-only and hidden
by default). Set `DXRP_API_KEY` and `DXRP_TENANT` to call the API. Once `1.0.1`
is on PyPI, the equivalent command is
`uvx --from dxrp-mcp==1.0.1 dxrp-mcp --list-tools`.
Client-specific instructions: [`docs/install/`](docs/install/README.md).
Hermes users can install the portable package with
`hermes plugins install agentsoul/dxrp-mcp/integrations/hermes`.

## Why the docs exist at all

The public docs at <https://dxrp.net/docs/api/api-documentation> cover
authentication and scopes but state, in their own words, that *"the full
endpoint schema isn't documented yet"*. The DXRP portal is an Angular app that
ships an NSwag-generated TypeScript client — one method per API operation — so
the complete surface is recoverable, and this repo recovers it. The point-by-point
comparison — what the official page covers, what it omits, and which of its examples
are wrong — is [`docs/api/official-docs-coverage.md`](docs/api/official-docs-coverage.md).
The ready-to-apply upstream proposal is
[`docs/api/official-docs-update.md`](docs/api/official-docs-update.md); it has not been
submitted.

| Number | Meaning |
|---|---|
| 333 | operations (verb + path pairs) |
| 263 | distinct paths |
| 321 | response DTOs with their field lists |
| 230 | operations with a known response DTO |

`tools/extract_from_portal.py` regenerates the inventory whenever the portal
ships a new bundle; `tools/probe_api.py` re-verifies it against the live API.

## Quick start

```bash
# regenerate the inventory from the live portal bundle (no credentials needed)
python tools/extract_from_portal.py --out spec/inventory.json

# probe the live API (needs a key; see docs/api/authentication.md)
export DXRP_API_KEY=...   # never commit this
export DXRP_TENANT=...
python tools/probe_api.py --inventory spec/inventory.json --out spec/probes.json

# render spec/openapi.yaml and docs/api/endpoints/*.md
python tools/build_docs.py

# fail if any hand-written doc names a route the API does not have
python tools/check_docs.py
```

## Run the client and the MCP server

```bash
export PYTHONPATH=src DXRP_API_KEY=... DXRP_TENANT=...

python -m dxrp_client.ping players        # typed client: live roster
python -m dxrp_mcp                        # stdio, read-only (official SDK)
python -m dxrp_mcp --allow-writes         # write tools; each still needs confirm=true
python -m dxrp_mcp --transport http       # Streamable HTTP on 127.0.0.1:8765/mcp
python -m dxrp_mcp --doctor               # identity, tenant and scope diagnosis
python -m dxrp_mcp --list-tools           # catalog as JSON, no credentials needed
```

The server is built on the official MCP SDK and negotiates protocol **2026-07-28**
alongside the older `initialize` handshake. It is read-only by default: a write tool
appears only with `--allow-writes`, refuses without `confirm=true`, and `dry_run=true`
previews the request. A tool whose scope the key does not hold is not listed;
`--toolsets players,servers` narrows the surface further.

## Layout

```
docs/api/          the API reference (overview, auth, scopes, errors, endpoints)
docs/tools/        the tool catalog — what an agent can call, grouped, with counts
docs/plan/         the MCP server and Discord bot designs
spec/              generated inventory, probes, tool catalog and OpenAPI document
src/dxrp_client/   the generated typed client (one function per operation)
src/dxrp_mcp/      the stdio MCP server (tools, resources, prompts)
tests/             contract tests for the client and end-to-end tests for the server
tools/             extractor, prober, client generator, catalog builder, docs and SVGs
```

## Credentials

Nothing in this repository needs a credential to read the API *surface* — the
bundle is public. Only `tools/probe_api.py` needs a key, and it reads
`DXRP_API_KEY` / `DXRP_TENANT` from the environment. Keys are never written to
the repo, a commit, or an issue.

## Status

Documentation layer: generated and live-verified. Tool catalog: 333 tools across
10 groups, published as [`docs/tools/index.html`](docs/tools/index.html). Typed
client and MCP server: implemented in `src/`, exercised by `tests/`. Packaging,
protocol 2026-07-28, stdio + Streamable HTTP and the wheel are implemented and
verified. CI is green on the self-hosted VM100 runner. The project is MIT licensed; PyPI `1.0.1` publication is pending; the MCP Registry listing follows. See

[`ROADMAP.md`](ROADMAP.md), [`AGENTS.md`](AGENTS.md),
[`ARCHITECTURE.md`](ARCHITECTURE.md), [`SECURITY.md`](SECURITY.md) and
[`CONTRIBUTING.md`](CONTRIBUTING.md). The DXRP recognition pack and outreach
draft are in [`docs/integrations/dxrp.md`](docs/integrations/dxrp.md).

## Tool catalog

<p align="center">
  <img src="./assets/tools.svg" alt="Tile map of DXRP API groups as agent tools" width="100%">
</p>


Every API operation becomes exactly one MCP tool, named
`dxrp_<domain>_<operation>`. The catalog is generated, so the counts on the page
cannot drift from the contract:

```bash
python tools/build_catalog.py     # spec/tools.json + docs/tools/index.html
```

Counts, read/write splits and live-verification state live in the generated page:
[`docs/tools/index.html`](docs/tools/index.html). It is rebuilt from
`spec/tools.json`, so the numbers cannot drift; this README intentionally does
not repeat them.

### The endpoint map

![Every DXRP API operation as an MCP tool](assets/endpoint-map.svg)

Every one of the 333 operations is listed once in
[`assets/endpoint-index.svg`](assets/endpoint-index.svg), grouped the same way.
Both files are generated by `python tools/build_diagrams.py`. The Discord bot is
not part of this map: it is an optional client of the same tools.

### Architecture, lifecycle and protocol

![dxrp-mcp architecture](assets/architecture.svg)

![A tool call from tools/call to a typed result](assets/tool-lifecycle.svg)

![Protocol revision matrix](assets/protocol-matrix.svg)

The searchable, filterable version is [`docs/map/index.html`](docs/map/index.html):
every tool, its group, verb, path, scope and session-only flag.
