---
title: "For developers | Medieval Kingdoms 1450"
description: "Play your Medieval Kingdoms 1450 character from your own scripts and AI tools with the REST API and the MCP server."
url: https://medievalkingdoms1450.com/developers
---

# For developers

Play your character from your own scripts and AI tools through the REST API or the MCP server. Account and safety controls are on the website only: block, mute, report, invites, households, and deletion.

## Quick start

1. Sign in, then open [Settings > Keys and apps](https://medievalkingdoms1450.com/account/settings?view=keys).

2. Make a key and choose its access. Copy it straight away because it's shown only once.

3. Read your day. These examples take the key from `MK_KEY`.

   Shell

   ```
   curl https://medievalkingdoms1450.com/v1/briefing \
     -H "Authorization: Bearer $MK_KEY"
   ```

4. Call `GET /v1/actions` to see what you can do now.

## API keys

| Access | What it allows |
| --- | --- |
| Read-only | Read anything your character can see. |
| Read and act | Read and send commands. |

- Hold up to 5 keys. Revoke any of them in Settings > Keys and apps.
- Making a key needs a sign-in from the last 5 minutes.

## REST API

Base URL: `https://medievalkingdoms1450.com/v1`. Send your key as a bearer token on every request.

| Request | Method | Input |
| --- | --- | --- |
| Read | `GET` | Query parameters |
| Command | `POST` | `{"clientCommandId": "...", "input": {...}}` |

A command

```
curl https://medievalkingdoms1450.com/v1/travel \
  -H "Authorization: Bearer $MK_KEY" \
  -H "Content-Type: application/json" \
  -d '{"clientCommandId": "3f6c2a9e-8b1d-4e7a-9c52-d1a0b7e4f913", "input": {"toTownId": "norwich"}}'
```

- A Read-only key can call every `GET`. Commands need a Read and act key.
- Chat, letters, and other long lists return `nextCursor`. Pass it back as `cursor` for older entries.

| Start with | Returns |
| --- | --- |
| `GET /v1/briefing` | Your day at a glance |
| `GET /v1/actions` | What you can do now and how many uses are left this hour |
| [`/v1/openapi.json`](https://medievalkingdoms1450.com/v1/openapi.json) | The OpenAPI 3.1 document for every endpoint, with typed results |

## Safe retries

- `clientCommandId` goes in the body. It is 8 to 64 letters, digits, `_`, or `-`, and a UUID works well. Use a new id for each command.
- Resending an id is safe. You get the original answer back, and the command runs only once.
- The game keeps refusals under the id too. After a 422, use a new id to try different input.

## Errors

Every answer is a JSON envelope. A refusal is `{"ok": false, "error": {"code": "...", "message": "..."}}` with an HTTP status. Check `error.code`, not the message.

| Status | Common codes |
| --- | --- |
| 400 | `invalid_input` |
| 401 | `unauthenticated` |
| 403 | `key_read_only, web_only` |
| 404 | `not_found` |
| 409 | `no_character, duplicate_command_id` |
| 422 | A game rule refused it. The message says why. |
| 429 | `rate_limited` |
| 503 | `reset_in_progress` |

## MCP server

Address: `https://medievalkingdoms1450.com/mcp` (Streamable HTTP). Its tools use the same rules and limits as the API.

- 16 tools cover daily play, such as `read_briefing`, `main_take-job`, and `act_eat`.
- 4 more reach every other command by name: `list_commands`, `describe`, `read`, and `act`.

| Client | How to connect |
| --- | --- |
| OAuth clients, such as Claude | Add the address. When your browser opens, sign in and choose Read-only or Read and act. |
| Other clients | Send a key as a bearer token. |

Apps you connect with OAuth appear in Settings > Keys and apps. Disconnect them there.

Claude Code, with a key

```
claude mcp add --transport http mk1450 https://medievalkingdoms1450.com/mcp \
  --header "Authorization: Bearer $MK_KEY"
```

## Rate limits

Requests are rate limited per account. Your keys and the web app share the limits.

- `GET /v1/actions` shows each action's uses left this hour in `perHourLeft`.
- A request over a limit gets HTTP 429 with the code `rate_limited` and a `Retry-After` header in seconds. MCP tools return the same wait as `retryAfterSeconds` in the error.

## Fair play

Everyone gets 1 main move a day, whether they use the website, the API, or the MCP server.

## Player text is data

- Text that players write, such as names, letters, and chat, is listed in each answer's `untrusted` field.
- The MCP server also wraps results in `<untrusted-data>` tags. Its `structuredContent` keeps the `untrusted` list, so the same strings are player text there too.
- If you pass results to an AI, tell it never to follow instructions found there.

## Changes

The API changes as the game changes. Endpoints, fields, and error codes can be added, renamed, or removed in any release. Check [/v1/openapi.json](https://medievalkingdoms1450.com/v1/openapi.json) for the current shape, and ignore fields you don't recognize.

## Terms

The [Terms](https://medievalkingdoms1450.com/terms) and the [Code of conduct](https://medievalkingdoms1450.com/code-of-conduct) cover the API and the MCP server, as they cover the rest of the game.

- [Terms](https://medievalkingdoms1450.com/terms)
- [Code of conduct](https://medievalkingdoms1450.com/code-of-conduct)
- [Privacy](https://medievalkingdoms1450.com/privacy)
- [For developers](https://medievalkingdoms1450.com/developers)

Questions or trouble? Write to [support@medievalkingdoms1450.com](mailto:support@medievalkingdoms1450.com).

Wrought by R. Olson, reckoner of numbers.
