The rules every MCP tool follows
You know what an MCP tool, existing or new, must respect: designate the edition, bring a business refusal back readable, declare its hints and name, say what happens to a write during a solve, respect the edition’s phase, flag an outgoing mail. Each rule is held by a structural test: a tool added later cannot escape by omission.
Designating the edition by argument
An MCP request is not a JAX-RS request: X-Edition-Id has no effect on /mcp. Each tool that works inside an edition carries an edition argument (id or name, the id being tried first: an edition name of the form E followed by a number is therefore refused at creation and renaming). It is mandatory (ADR 0072 (external site)): omitted, the call is refused (EDITION_REQUISE), and so is an unknown edition (EDITION_INCONNUE, with the list of editions), rather than writing into an edition nobody named.
@EditionArg marks the carrying argument, @EditionCiblee goes on the tool class (a tool added later inherits it), EditionCibleeInterceptor binds the edition around the call. McpEditionStructurelleTest fails on any @Tool that works in an edition without allowing it to be designated; any other tool without an edition is @InstanceOnlyTool (administrator only) or argued in the test. Solver launches capture the edition at submission, and an edition: section in an imported YAML overrides the argument.
Self-invocation trap. A write tool that calls another on
thisgoes through the second one’s interceptor again, which journals the action twice. Go through a private helper.
Only one edition is active; it alone publishes, sends mail and opens the animateur space, the ICS feed and the wall display. lister_editions flags it (none between two events), modifier_edition changes it.
Bringing back a business refusal
Untreated, a BusinessError leaves as a generic JSON-RPC error (“Internal error”): the refusal’s sentence is lost and the assistant retries identically. RefusMetierInterceptor, the MCP counterpart of api/BusinessErrorMapper, brings it back as a tool result in error (isError) carrying its sentence. Only a deliberate refusal goes through there: an unintended IllegalArgumentException or a database failure keeps its “Internal error” and its alert. It binds to tool classes through @RefusMetier (next to @EditionCiblee and @Journalise, three different questions), outside EditionCibleeInterceptor so the refusal of an unknown edition arrives too; McpRefusMetierStructurelleTest fails on a class that forgets it.
The sentence travels as is, which is safe only because no refusal names anyone: McpRefusMetierStructurelleTest fails on a BusinessError built from an animateur’s name, first name, birth date or address. Always designate an animateur by id in a refusal message.
Declaring the hints and the name
The four MCP-specification hints are declared on every tool, because their defaults (destructiveHint = true, openWorldHint = true) would announce a lister_stands as a destructive call to the outside.
| Hint | Value |
|---|---|
readOnlyHint |
true for tools that only read |
destructiveHint |
true for deletions, imports, restores and solves, which replace the saved plan |
idempotentHint |
true when calling again with the same arguments changes nothing more |
openWorldHint |
true for the only tools that send mail |
McpAnnotationsStructurelleTest derives the expected hints from the name prefix (lister_, consulter_, analyser_… read; supprimer_, importer_, lancer_calcul… destructive; creer_, modifier_… non-destructive): a read-only supprimer_stand fails, and so does a name it cannot classify. The outgoing tools are enumerated in the test, never deduced: a send is a reviewed decision.
Each tool and each prompt carries its published name in full (@Tool(name = "lister_stands", …) on the listStands method): renaming the method never renames the tool for connected clients. McpToolNamesTest fails on a @Tool or @Prompt without an explicit name.
A range of days is an argument
Reading or freezing several days is not another verb: modifier_etat_journee takes a jusqua argument and applies the requested state to every day from jour to jusqua, each by the rules of a single day. Days with a prerequisite known to be missed are passed unless inclureNonPrets. The answer gains a lot key (moved, already in that state, refused, passed, day by day); without jusqua it does not change. The journal keeps a single line for the range (ADR 0127 (external site)).
Naming a tool
A tool’s name is <verb>_<object>, the verb taken from a closed set: lister, consulter, analyser, diagnostiquer, comparer, simuler, previsualiser to read; creer, modifier, activer, desactiver, verrouiller, appliquer, arreter, publier, envoyer to write; supprimer, deverrouiller, lancer, importer, restaurer to overwrite or erase; exporter. A settings tool with sections splits into a read tool and a write tool, each with a section argument. One object has one tool per verb: what distinguished two neighbouring tools becomes an argument, except a mail send, which keeps its tool (ADR 0127 (external site)). src/main/resources/mcp-renommages.tsv gives, for each name published in 3.1.0, its current name or retiré; the 4.x still published the old names beside the new ones, the 5.0 publishes the current names only. McpRenommageTest refuses a name without a line, a current tool outside the convention (only verrouiller and deverrouiller go without an object, ADR 0109 (external site)), an old name still published, and a table of old names that no longer follows the file.
Writing while a solve holds the edition
A solve’s landing rewrites the seats and takes back its problem’s stands, timeslots and staff members: a write made in between would be undone. Each write tool therefore has an answer to “what if a solve holds the edition?”, and McpWarnsWhileSolvingStructuralTest fails the build on a tool without one (it also checks that a refused tool’s service method carries @RefusedWhileSolving). The three lists are disjoint and exhaustive.
| During a solve of the edition | Tools | What the assistant gets |
|---|---|---|
| Refused | staff members, stands, hours, timeslots (edit, delete, recurring, derived), template materialisation, consignes, modifier_affectation, modifier_demande_echange, modifier_etat_journee, restore, imports, reset |
the refusal (409 on REST) naming the job |
Accepted, warned (@WarnsWhileSolving) |
game categories, locations, ad hoc constraints, legal parameters, locks, rule activation and weights, creating a stand, animateur or timeslot | the usual answer, with RESOLUTION_EN_COURS in avertissements |
| Unrelated | solver, editions, phase, publications and sends, consigne presets, snapshots, notification and backup settings | the usual answer; each exclusion carries its reason in the test |
RESOLUTION_EN_COURS means: saved, but the running solve read the referential and the plan at its start and will not see this write; launch a solve afterwards. consulter_calcul names the job and carries feasibleAtSeconds (seconds elapsed when its plan became feasible, null otherwise): the assistant can propose stopping there, arreter_calcul keeping the best plan reached. Reading or freezing a day is refused during a solve (decision 0132 (external site)). A solve of another edition, or only queued, does not count. Never turn a refusal into a warning: it protects against the landing resurrecting data; screens lock these entries, an assistant without a screen has only the warning.
Respecting the phase of the edition
The edition’s phase decides which referential families are frozen (STANDS, CRENEAUX, TYPOLOGIES_EMPLACEMENTS, COMPETENCES, ADR 0115 (external site)); consulter_edition says so in its gel block. modifier_phase_edition changes it: phase (PREPARATION, CALCUL, PUBLIEE, TERMINEE, going back included) or structure (DEBLOQUER or REFIGER, in PUBLIEE only), never both. It replaces the two 3.x freeze tools (the table of old names points them to it); the tool is “unrelated” to a solve, a phase changing no data a solve reads.
The refusal of a frozen write sits on the services: modifier_stand changing a headcount, supprimer_creneaux, creer_typologie or modifier_animateur changing competences come back as a business refusal, with the sentence naming the frozen families and how to reopen them; modifier_stand touching only the name, or appliquer_consigne, go through. Reopen the referential only on explicit request: after a publication, any touch-up moves plans already sent.
Flagging an outgoing e-mail
Five tools send mail and are the only ones announcing openWorldHint = true: publier_planning (the whole list), envoyer_planning_animateur (one person), envoyer_relance_animateurs (the named silent ones), envoyer_message_equipe (a free message to a scope, after previsualiser_message_equipe whose count it confirms) and modifier_collecte_disponibilites when it notifies staff members. Each has its own verb: a send is never a mode of another tool, so a forgotten argument cannot write to the whole team. They are refused on an inactive edition (409 EDITION_INACTIVE), and ActiveEditionEmissionStructuralTest fails on an outgoing tool neither guarded nor argued.
publier_planning first captures the published snapshot, then writes to people: a send failing midway leaves a coherent published plan and the trace of who was missed (consulter_publication, destinataires view, by id). envoyer_relance_animateurs follows the night reminder’s rule: one reminder per person and per publication.
Where a tool differs from REST
The assistant names ids it may have invented, sees no greyed-out button and reads an empty result as a success, hence deliberate differences.
| Tool | Difference from REST | Reason |
|---|---|---|
modifier_animateur |
merges instead of replacing | the assistant does not read the identity it would have to send back |
modifier_stand, modifier_animateur, modifier_creneau, modifier_emplacement, modifier_typologie |
modifieLe optional |
the merge re-reads the record just before writing: without the argument, the concurrent-edit check says nothing; pass the value read earlier to be refused if the record moved |
modifier_affectation |
refuses an animateur the seat cannot take: scored on the saved plan, rejected if it worsens the hard score or creates a hard breach on the seat (ADR 0046 (external site)) | the screen only offers an already scored candidate |
verrouiller |
returns { verrouillage, avertissements }; VERROUILLAGE_SUR_VIOLATION_DURE says the frozen seats already break a hard rule |
the lock freezes without exempting: whoever chains on lancer_calcul must know where the negative hard score comes from |
simuler_affectation, modifier_affectation |
one tool for the three gestures of “Replace” in the seat panel, the target being a seat or a person | the server picks the gesture then refuses what would break a hard rule |
lancer_calcul |
starts from the saved plan by default; deZero asks for a cold start |
relaunching “to see” would otherwise silently destroy the quality reached |
lancer_calcul |
distant argument, and calculDistant in consulter_calcul |
with a compute machine (ADR 0086 (external site)), true sends the search there, false keeps it local, absent follows the instance. calculDistant is PREPARING then SOLVING. A failed remote solve ends FAILED with its reason: relaunch with distant=false |
lancer_calcul, lancer_correction |
during the event, seats of begun timeslots are taken from the saved plan and pinned; a job whose seats are all past ends FAILED (“Nothing to plan…”) (ADR 0044 (external site)) |
an assistant does not rewrite yesterday any more than the screen, and an empty plan at zero hard would read as a success |
consulter_calcul |
with no jobId and no active job, answers IDLE; an unknown jobId is refused |
a tool returning nothing cannot be encoded |
Solves launched by lancer_calcul and lancer_correction go through SolverJobService's replayable submissions, like the screens: the problem is built when the job starts, not at the call, hence queueing (enFile, otherwise a busy solver refuses) and the freshness of a write made while waiting; the queue is in memory, a restart loses it. The budget follows the solve: without secondes, the instance sets the duration and the plateau stop (consulter_parametres, calcul section, read-only); above its ceiling, a secondes is refused by a sentence citing it.
A mistake, an omission? Fix this page on GitHub. (external site)