AxemaVaka-MCP
# AxemaVaka-MCP
An MCP server and a small Python client for the web admin of an Axema Vaka access control
system. It lets an AI agent do the work a Vaka administrator does: look up people, tags and
access groups, read the event log, handle bookings, change door codes and PINs, and upload
or remove the PDFs shown on the information screens.
Unofficial. Not made by, endorsed by or supported by Axema, and it contains no code from
Axema. It talks to the same JSON API the Vaka web app itself uses, with an operator account
you create for it in Vaka.
## Why this exists
Vaka is administered through a Java client or a web app, and neither offers an interface a
program can use. We run Vaka in a housing cooperative and wanted our agent to take over the
routine admin: who has which tag, who booked the laundry room, why a door refused someone
last night, swapping the notice on the info screen. The alternative was an agent clicking
through a browser, which is slow (about ten seconds a page), breaks when the layout changes
and is hard to put a safety check in front of.
So we looked at how the web app talks to the controller and wrote a client for that. One
call takes about 0.3 seconds, needs no browser, and every change the agent makes through
the MCP goes through a preview first, because this system opens real doors.
## How it works
- **Login.** The client fetches a nonce, then logs in with `md5(nonce + md5(password))`, the
scheme the web app uses. Every later call carries the session cookies and the
`X-XSRF-TOKEN` header.
- **Short sessions.** Vaka allows an operator one session at a time. Every call to the
controller happens inside a short login of its own (a tool call makes one or two), so
nothing is held open between tool calls. Give the agent its own operator account: a login
from here ends any session a person has open as the same operator.
- **Reads are direct.** Tables are read through `database/<table>`. PINs, door codes,
password hashes and any field named like a password or secret are shown as `<set>` unless
the caller passes `reveal_codes`.
- **Writes are two-step.** A write tool called without `confirm_token` changes nothing: it
returns what would change and a token. Called again with the same arguments and that
token, it writes, reads the record back and logs the change. The token is random, works
for one write and for 30 minutes, and is tied to the request and to the values the preview
showed. So a write cannot skip its preview, one approval cannot be replayed, and if the
values shown have changed in between a new preview is needed. Tokens die when the server
restarts.
- **Audit.** Every write an MCP tool completes appends a line to `audit.jsonl` in the audit
directory, and so does an upload that fails. Before an update or a delete the record is
saved there as it was, codes included, because that copy is what you restore from. A PDF
that is replaced or deleted is copied there first. The files are mode 600 and the
directory is created mode 700; if you point `VAKA_AUDIT_DIR` at a directory of your own,
keep it private.
- **On https the certificate is always checked.** There is no switch to skip that.
## Tools
| Tool | Kind | What it does |
|---|---|---|
| `vaka_whoami` | read | Log in and show the operator session |
| `vaka_find_person` | read | Find persons by name, email or id |
| `vaka_get` | read | One record from any table; persons with their tags and access groups, access groups with their doors |
| `vaka_list` | read | Rows of any table, with Vaka's filters |
| `vaka_doors` | read | All doors with their time schedule |
| `vaka_accessgroups` | read | All access groups with doors, schedule and whether a door code is set |
| `vaka_events` | read | The access and event log for a period, with a text filter |
| `vaka_bookings` | read | Bookings of bookable objects (laundry room and the like) |
| `vaka_files` | read | Files of the info centre and the playlist slots that show each |
| `vaka_download_file` | read | Save a stored PDF to a local path |
| `vaka_update` | write | Change fields on one record of a table |
| `vaka_create` | write | Create a record in a table (person, booking, playlist item ...) |
| `vaka_delete` | write | Delete one record |
| `vaka_set_door_code` | write | Set the door code of an access group |
| `vaka_set_person_pin` | write | Set a person's PIN |
| `vaka_set_operator_password` | write | Set an operator's web admin password |
| `vaka_door_in_accessgroup` | write | Add a door to an access group or take it out |
| `vaka_upload_pdf` | write | Upload a PDF to the info centre; replaces one with the same name and keeps it in the same playlist slots |
| `vaka_delete_file` | write | Remove a PDF or web link and empty the playlist slots that show it |
| `vaka_raw` | both | Any call under `web_client/`. Table reads and the name lookups run at once, everything else is two-step |
### What the admin can do and how far this gets
Everything the web app stores goes through `database/<table>`. All 27 tables can be read,
and all but the event log and live person state can be changed with `vaka_update`,
`vaka_create` and `vaka_delete` (info centre files are deleted with `vaka_delete_file`).
That covers persons and tags, organisation groups, access groups, time schedules and
calendars, doors, zones, modules, entry phones, booking objects and bookings, the info
centre, fault reports and operator rights.
Some things the app does are actions, not records. They have no tool of their own yet. An
agent reaches them through `vaka_raw`, which is an MCP tool like the others and previews
them like any other write:
| Action | Call | State |
|---|---|---|
| Open, unlock or relock a door remotely | `PUT door_control?domain=&door=&method=&guid=` | call shape known, never run by us |
| Create a backup | `GET backup?notes=&flags=0` | call shape known, never run by us. Downloading the backup file has no MCP tool yet; the Python client's `fetch_file` can |
| Acknowledge alarms | `event_ack` | not looked at |
| Set the clock and time zone | `PUT set_time?vaka_time=`, `PUT set_time_zone` | call shape known, never run by us |
| Blacklists, offline doors and profiles | `blacklist`, `offline_doors`, `profiles` ... | not looked at |
| Person photos, pictures of booking objects | `image/` | not looked at; `vaka_raw` carries text, not binary data |
## Tested
Unit tests run against a stand-in server that speaks the same protocol (`tests/`). "Live"
means run against a real controller, an Axema B60 with Vaka 5.12.0001, on 2026-12-02 with
the code of version 0.1.0.
| Function | Unit tests | Live |
|---|---|---|
| Login, XSRF header, logout | yes | yes |
| No session or socket left behind after a failed login | yes | no |
| Settings and secrets files, permission check, environment override | yes | yes |
| Clear error when the box or its web backend is down | yes | no |
| `vaka_whoami` | yes | yes |
| `vaka_find_person` | yes | yes |
| `vaka_get` person, access group, file | yes | yes |
| `vaka_list` | yes | yes |
| `vaka_list` paging when the box cuts a list | yes | no: the box returned whole tables; the offsets it takes were checked with one call |
| `vaka_doors`, `vaka_accessgroups` | yes | yes |
| `vaka_events` | yes | yes |
| `vaka_bookings` | yes | yes |
| `vaka_files`, `vaka_download_file` | yes | yes |
| `vaka_upload_pdf`, new file | yes | yes, stored bytes compared with what was sent |
| `vaka_upload_pdf`, replacing a file of the same name | yes | yes |
| `vaka_upload_pdf` moving a playlist slot to the new file | yes | yes, on a playlist item no playlist uses |
| `vaka_delete_file`, emptying the slot | yes | yes, same |
| `vaka_update` | yes | yes, same |
| `vaka_create`, `vaka_delete` | yes | yes, same |
| `vaka_create` person with a login | yes | no |
| `vaka_create` booking | yes | no; the name of its domain parameter is taken from the app's code |
| `vaka_set_door_code`, `vaka_set_person_pin`, `vaka_door_in_accessgroup` | yes | no: they change who gets through a real door |
| `vaka_set_operator_password` | yes | no |
| Preview token refused when made up, used twice, expired or when the previewed values changed | yes | made up and used twice: yes |
| `vaka_raw` table read | yes | yes |
| `vaka_raw` action behind the preview | yes | preview only |
| `vaka export-events` | yes | no (the client it was ported from exported 13 months on the same box) |
| Browser helper `tools/browser/vaka-browser.mjs` | no | yes: `net` on the doors screen, certificate checked |
Run the unit tests with `python3 -m unittest discover -s tests`. They need nothing but
Python.
## Install
Standard library only. Written for Python 3.9 or newer; it has only been run on 3.14.
pipx install git+https://github.com/draca-glitch/AxemaVaka-MCP
or clone the repository and run it from there with `PYTHONPATH` pointing at the clone.
In Vaka, create an operator for the agent with the rights you want it to have, log in once
by hand as that operator and set its password (Vaka forces a change at first login, and
the client stops if that is still pending).
## Configure
Two files, because one of them is a secret.
`~/.config/axema-vaka/settings.env` (or the path in `VAKA_SETTINGS`):
VAKA_URL=https://vaka.example.com/admin
VAKA_TZ=Europe/Stockholm
VAKA_LANG=sv
`~/.config/axema-vaka/secrets.env` (or the path in `VAKA_SECRETS`), mode 600. The client
refuses to read it if anyone else can:
VAKA_USER=agent@example.com
VAKA_PASS=the operator's password
A `VAKA_*` variable in the process environment overrides both files. All settings are
listed in `settings.env.example`.
### Where the controller is
- **Same network.** It works locally: put the controller's address or local name in
`VAKA_URL`. Ours answers on https only. If yours has its own certificate rather than one
from a public authority, save that certificate and point `VAKA_CA_FILE` at it; the
certificate has to name the address or name you put in `VAKA_URL`. (We have not run it
that way ourselves; ours has a public name.)
- **From the internet.** The controller needs a domain name that points at it, its https
port reachable from outside and a certificate for that name. `VAKA_URL` is then
`https://<that name>/admin`. Think before you put a door controller on the open internet;
a VPN is the safer way in.
- **Through a VPN or tunnel.** Use the domain name in `VAKA_URL` and put the tunnel address
in `VAKA_CONNECT_IP`. The client connects to the address and still checks the certificate
against the name. This is how we run it.
Plain `http://` is refused unless `VAKA_ALLOW_HTTP=1` is set. Only a controller on the same
machine (127.0.0.1, localhost) is exempt.
## Use
As an MCP server (stdio), for example in Claude Code:
claude mcp add vaka -- vaka-mcp
or from a clone:
claude mcp add vaka --env PYTHONPATH=/path/to/AxemaVaka-MCP -- python3 -m axema_vaka.server
From a shell:
vaka whoami
vaka get 'database/door'
vaka put 'database/door' '{"id": 3, "name": "Cellar"}' --write
vaka export-events ./events 13
From Python:
from axema_vaka import Vaka
with Vaka() as v:
doors = v.get('database/door')['doors']
## Finding out how the web app does something
`tools/browser/vaka-browser.mjs` opens an admin screen in a headless browser as the same
operator and lists the API calls the screen makes (`net <route>`) or prints its text
(`page <route>`). That is how a new admin function gets added here: watch what the app
sends, then send the same. It needs Node and `playwright-core`; setup is in the file.
## Things to know
- Person records hold PINs and personal data, and the event log shows who passed where.
Decide what your agent may keep and say so in its instructions.
- The `vaka` command and the Python class are for people and scripts. Their only guard is
`--write`: no preview, no audit log.
- The two-step write makes sure a preview happened and that nothing changed since. Whether
a person really approved it is up to the agent and the client it runs in: keep the write
tools behind a permission prompt.
- The controller writes an uploaded PDF a moment after the upload call returns. The upload
tool waits until it can read the file back and compares it with what it sent before it
touches the file it replaces.
- The controller can give a new record the id of one deleted earlier. A playlist slot that
still points at a file deleted long ago will show a new file that happens to get the same
id. The upload tool reports such slots.
- An update of the Vaka software can change the API. `docs/protocol.md` has what we know
and which version it was read from.
## Licence
MIT, see `LICENSE`. "Axema" and "Vaka" are names that belong to Axema and are used here
only to say what this software works with.
TDQS
Scored across 20 tools
The specialized readers (vaka_doors, vaka_accessgroups, vaka_files, vaka_bookings, vaka_events) overlap in practice with generic vaka_list, and vaka_set_door_code/vaka_set_person_pin partly duplicate vaka_update. However, descriptions make the intended split clear (generic table access vs. curated joined views, redacted search vs. full record) and vaka_raw is explicitly framed as a last-resort escape hatch.
All names share the vaka_ prefix, but the convention is mixed: verb_noun (vaka_get, vaka_list, vaka_create, vaka_update, vaka_delete, vaka_set_door_code) alongside bare-noun readers (vaka_doors, vaka_accessgroups, vaka_events, vaka_bookings, vaka_files). It stays readable, but an agent has to learn that noun-only names are implicit 'list all' aliases alongside vaka_list.
Twenty tools is toward the heavy end, but the domain genuinely spans persons, doors, access groups, events, bookings and info-centre files, and each tool maps to a distinct operation. The count is defensible, though a couple of the read aliases could be folded into vaka_list.
Coverage is strong: generic CRUD across any table plus targeted writes (door code, PIN, operator password, access-group membership), full info-centre lifecycle (list, download, upload, delete) and read views for events/bookings. Remaining gaps are around time schedules/timegroups and playlist management, which are only reachable via defaults or the vaka_raw escape hatch.