Skip to main content
Glama

Create or replace objects (XML)

write_object
Destructive

Write or patch Mount & Blade II Bannerlord module XML objects like items, NPCs, or factions, then validate them against the game's XSD schema.

Instructions

Writes one or more objects (e.g. , , , , , , , ) into a writable module. Replaces an object with the same tag+id in that module, otherwise appends it to the module's file for that data type (creating ModuleData/_.xml and registering it in SubModule.xml). Runs the game's XSD check afterwards.

Input Schema

NameRequiredDescriptionDefault
xmlYesOne or more object elements (a wrapping container like <Items>…</Items> is accepted). Use {=stringId}Text for names.
fileNoOptional target file under ModuleData, e.g. mymod_weapons.xml (created and registered if needed).
modeNoupsert (default), create (fail if exists), replace (fail if missing).
moduleYesWritable module id.
xml_idNoOptional XmlName id when it cannot be inferred from the tag (e.g. Items, NPCCharacters).
validateNoRun XSD validation after writing (default true).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.3.0

TDQS

A4.1/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already flag destructiveHint=true, but the description goes well beyond them: it discloses that a matching tag+id is replaced while non-matches are appended, that a new ModuleData/<mod>_<type>.xml file may be created and registered in SubModule.xml, and that an XSD check runs afterward. These are exactly the side effects and hidden registrations an agent needs before invoking a mutation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences, front-loaded with the core action and examples before the replacement/append mechanics and validation note. Dense but every clause carries information; the long parenthetical example list borders on verbose, keeping it just under a 5.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive mutation with no output schema, the description covers write semantics, file creation/registration, and post-write validation. It omits permission or auth requirements for 'writable' modules and does not describe failure behavior beyond mode semantics, which are the only minor gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents every parameter including the mode enum and validate default. The description adds the object-identity semantics (replace on matching tag+id) and the accepted container/wrapping form, but does not elaborate on mode or validate beyond what the schema says, so the baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb (writes/creates or replaces) and resource (XML objects in a writable module), naming concrete element types like <Item>, <NPCCharacter>, and <Culture>. This clearly distinguishes it from siblings such as set_attributes, clone_object, and delete_object, which the description implicitly contrasts with by covering the full create/replace path.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explains the internal upsert-vs-append behavior and the implied prerequisite of a 'writable module', which gives useful context for when this tool applies. However, it never explicitly routes the agent against alternatives (e.g. use set_attributes for partial field edits, clone_object to duplicate, edit_submodule to change file registration), so usage is implied rather than stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.