-
Notifications
You must be signed in to change notification settings - Fork 19
Write Tools
The server is read-only by default. One optional write tool exists, and it is off unless you turn it on.
Setting ENABLE_CHARGING_WRITES=true registers:
set_charging_cost(charging_process_id, cost) — sets the total cost of one charging session. This is the same field TeslaMate's own UI lets you edit. Find the session id with search_charging_sessions first.
It also registers a backfill_costs_from_receipts prompt that walks through matching receipts to sessions.
Do not rely on the application flag alone. Give the role write access to that single column and nothing else:
GRANT UPDATE (cost) ON charging_processes TO teslamate_ro;With that grant in place, PostgreSQL itself refuses any other write, regardless of what the application does. The write path is a single hand-written parameterized UPDATE … WHERE id = … — the declarative .sql/.toml query registry stays read-only by design and never routes through it.
run_sql remains read-only no matter what: it runs in a READ ONLY transaction with a forced rollback.
On clients that support MCP form elicitation, the user is shown a confirmation dialog before each write, quoting the session id and the new cost.
Clients without form elicitation proceed without a confirmation step. This is deliberate — portal-fronted connectors have no back channel to ask through — but it means the elicitation dialog is a convenience, not a security control. The grant is the control.
Unset ENABLE_CHARGING_WRITES (or set it to false) and the tool disappears from tools/list. Revoking the grant is the belt-and-braces version:
REVOKE UPDATE (cost) ON charging_processes FROM teslamate_ro;