porymap-mcp

v1.0.1
porymap-mcp Checked 3 days ago Published 1 month ago

MCP server that lets AI agents author Porymap-compatible Pokémon Gen-3 decompilation maps.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

get_project_info Get Project Info

Return a one-shot snapshot of a pokeemerald-family project. Use this as the FIRST call when you start working on an unfamiliar project — it tells you which decomp base the project targets, how many maps and tilesets it contains, and the absolute paths to the three index files you may want to inspect with other tools.

ParameterTypeDescription
project_path *stringFilesystem path to the project root (the directory that contains porymap.project.cfg). Accepts absolute paths, ~-prefixed paths, and paths relative to the server's cwd.

list_maps List Maps

List every map registered in data/maps/map_groups.json. Use this to translate a fuzzy user request like "edit Littleroot" into a canonical MAP_LITTLEROOT_TOWN identifier before calling map-specific tools. Maps are returned in the project's canonical group order (matching what Porymap shows in its sidebar).

ParameterTypeDescription
project_path *stringproject root.

get_map_info Get Map Info

Return full metadata for a single map. Call this immediately before any map-mutation tool. It gives the map's dimensions (needed to validate (x, y) for paint_*), its tilesets (needed to decide which metatile ids are valid), and counts of every event class. Coordinates inside the map are (x, y) with origin top-left and 0 <= x < width, 0 <= y < height.

ParameterTypeDescription
map_name *stringmap constant, e.g. "MAP_LITTLEROOT_TOWN". Get the valid set with list_maps.
project_path *stringproject root.

list_tilesets List Tilesets

List every tileset discovered on disk (primary + secondary). The agent uses this to pick a primary_tileset / secondary_tileset pair when calling create_map, or to look up a tileset's metatile count before list_metatiles. Treat c_label_unverified=true as "probably right, but cross-check with layouts.json".

ParameterTypeDescription
project_path *stringproject root.

list_metatiles List Metatiles

List the metatiles in a single tileset. Returns one entry per metatile id with its decoded attributes. Does NOT return rendered images; that's a Phase 4 (L3) capability. In v0.1.0 prerelease ``metatiles`` is empty and ``metatile_count`` is file-size-derived; per-metatile attributes land with parsers/metatiles.py.

ParameterTypeDescription
project_path *stringproject root.
tileset_name *stringdirectory basename (NOT C label). Example: "general", not "gTileset_General". Get the valid set with list_tilesets.

list_prefabs List Prefabs

List named metatile-stamp prefabs available to paint_prefab. In v0.1.0 no prefabs ship; this tool returns ``{"prefabs": []}`` so paint_prefab has a discovery pair from day one.

ParameterTypeDescription
project_path *stringproject root.

list_events List Events

List every event on a map, grouped by class. Returns object_events, warp_events, coord_events, and bg_events. Each event carries a synthesized "_event_id" of the form "<class>:<index>" usable with remove_event. IDs shift across mutations — call list_events again after any change.

ParameterTypeDescription
map_name *stringmap constant. Get from list_maps.
project_path *stringproject root.

paint_metatile Paint Metatile

Set a single tile on a map's layout. The atomic paint primitive. Idempotent: re-running with identical args does NOT rewrite the file (mtime stable). Coordinates are (x, y), origin top-left.

ParameterTypeDescription
map_name *stringMAP_* constant. Get from list_maps.
metatile_id *integer0..1023. Use list_metatiles for valid ids.
project_path *stringproject root.
x *integer
y *integer
collision0..3, or None to preserve.
elevation0..15, or None to preserve.
return_renderbooleanif True, the response also carries a PNG render of the post-mutation map (default False to keep the response small).

paint_rectangle Paint Rectangle

Fill an axis-aligned inclusive rectangle with one metatile id. Both corners painted. Strict order: x1<=x2 and y1<=y2 (reversed raises rather than auto-swapping). Idempotent.

ParameterTypeDescription
map_name *stringMAP_* constant.
metatile_id *integer0..1023.
project_path *stringproject root.
x1 *integer
x2 *integer
y1 *integer
y2 *integer
collision0..3, or None to preserve each tile's value.
elevation0..15, or None to preserve.
return_renderbooleanif True, attach a PNG render of the post-mutation map to the response.

flood_fill Flood Fill

Replace a 4-connected region of identical metatiles with a new id. Matches against metatile_id only (collision/elevation not consulted for matching). 4-connected (N/S/E/W), iterative BFS.

ParameterTypeDescription
map_name *stringMAP_* constant.
metatile_id *integerreplacement value.
project_path *stringproject root.
x *integer
y *integer
collision0..3, or None to preserve per-tile.
elevation0..15, or None to preserve.
return_renderbooleanif True, attach a PNG render of the post-mutation map to the response.

set_border Set Border

Replace a map's repeating border tiles. metatile_ids is a 2-D list [row][col] of size border_height x border_width (read via get_map_info). Idempotent.

ParameterTypeDescription
map_name *stringMAP_* constant.
metatile_ids *array2-D grid of metatile ids matching the layout's declared border dimensions.
project_path *stringproject root.
collision_idsoptional 2-D grid of 0..3, or None to preserve.
elevation_idsoptional 2-D grid of 0..15, or None to preserve.
return_renderbooleanif True, attach a PNG render of the post-mutation map to the response.

create_map Create Map

Create a new map: writes 5 files and registers it everywhere. Naming is derived from `name` (bare PascalCase, e.g. "LittlerootTown"): MAP_LITTLEROOT_TOWN, LAYOUT_LITTLEROOT_TOWN, data/maps/LittlerootTown/, data/layouts/LittlerootTown/. DO NOT pass MAP_* or LAYOUT_* directly. Group is created if missing. Duplicate names raise. include/constants/map_groups.h is NOT touched (pret build scripts regenerate it).

ParameterTypeDescription
group *stringC symbol, e.g. "gMapGroup_TownsAndRoutes".
height *integer
name *stringbare PascalCase.
primary_tileset *string
project_path *stringproject root.
secondary_tileset *string
width *integer
border_metatile_idsoptional 2-D border grid (default 2x2).
fill_metatile_idintegerinitial fill for layout + border (collision=0, elevation=0). Default 0.
header_overridesdict of map.json header keys to override on top of the minimal defaults (MUS_NONE, WEATHER_NONE, etc.).
return_renderboolean

resize_map Resize Map

Resize a map's layout, preserving overlapping content. Existing content anchored at (0, 0); new cells filled with fill_metatile_id. Shrinking that would orphan any event is REFUSED with an error listing the events — call remove_event first. Only anchor="top-left" supported in v0.1.0.

ParameterTypeDescription
map_name *stringMAP_* constant.
new_height *integer
new_width *integer
project_path *stringproject root.
anchorstring"top-left" only for now.
fill_metatile_idinteger0..1023; value for newly-exposed cells.
return_renderboolean

paint_prefab Paint Prefab

Stamp a named prefab at (x, y) (top-left anchor). Lists available prefabs via list_prefabs. Tileset compatibility is enforced: if the prefab declares required primary/secondary tilesets, the target map's layout must match. No auto-import.

ParameterTypeDescription
map_name *stringMAP_* constant.
prefab_name *stringbuilt-in prefab name (e.g. "house_small").
project_path *stringproject root.
x *integer
y *integer
return_renderboolean

register_map Register Map

Register an existing on-disk map directory in map_groups.json. Repair tool. Use when a map's files exist on disk (data/maps/<bare>/map.json + data/layouts/<bare>/) but it is not listed in any group. Scans every map.json on disk to locate the map (does NOT require it to already be registered).

ParameterTypeDescription
group *stringC symbol for the map group.
map_name *stringMAP_* constant.
project_path *stringproject root.

unregister_map Unregister Map

Remove a map from map_groups.json. Does NOT delete files. The map's data/maps/<bare>/ and data/layouts/<bare>/ directories are left in place. Idempotent: a map already absent from every group is a no-op success. If unregistering empties the group, the group itself is also removed.

ParameterTypeDescription
map_name *stringMAP_* constant.
project_path *stringproject root.

add_warp Add Warp

Append a warp event to a map. A warp teleports the player to dest_map's dest_warp_id (the destination warp's index, 0-based, in its own warp_events array).

ParameterTypeDescription
dest_map *stringMAP_* constant of the DESTINATION map.
dest_warp_id *integer0-based index into dest_map's warp_events array.
map_name *stringMAP_* constant of the SOURCE map (where the warp lives).
project_path *stringproject root.
x *integer
y *integer
elevationinteger0..15. Default 0.
return_renderbooleanif True, attach a PNG render of the post-mutation map to the response.

add_object_event Add Object Event

Append an object event (NPC, item ball, static) to a map. Does NOT generate a script stub — too varied for boilerplate. The caller is responsible for authoring the referenced script symbol elsewhere (or leaving script="" for a non-interactive NPC).

ParameterTypeDescription
graphics_id *stringOBJ_EVENT_GFX_* constant (e.g. "OBJ_EVENT_GFX_MOM").
map_name *stringMAP_* constant.
project_path *stringproject root.
x *integer
y *integer
elevationinteger0..15. Default 3.
flagstringflag controlling visibility (e.g. "FLAG_HIDE_X"), "0" for none.
movement_range_xinteger
movement_range_yinteger
movement_typestringMOVEMENT_TYPE_* constant. Default static.
return_renderboolean
scriptstringscript symbol name (e.g. "LittlerootTown_EventScript_Mom"), or "" for none.
trainer_sight_or_berry_tree_idstring
trainer_typestring

add_sign Add Sign

Append a sign with inline text. Generates a script stub. Writes a poryscript stub by default (use_poryscript=1) or a legacy .inc stub. Script symbol: <bare>_EventScript_Sign_<N> where <N> is the next free index for this map. The script file is created if missing; the stub is appended.

ParameterTypeDescription
map_name *stringMAP_* constant.
project_path *stringproject root.
text *stringthe message displayed when the sign is read.
x *integer
y *integer
elevationinteger0..15. Default 0.
player_facing_dirstringBG_EVENT_PLAYER_FACING_* constant.
return_renderbooleanif True, attach a PNG render of the post-mutation map to the response.

add_trigger Add Trigger

Append a coord-based script trigger. Fires the script when the player steps on (x, y) AND var equals value. Does NOT generate a script stub; the caller authors the referenced symbol elsewhere.

ParameterTypeDescription
map_name *stringMAP_* constant.
project_path *stringproject root.
script *stringscript symbol to run.
value *integerinteger compared against var.
var *stringVAR_* constant controlling fire condition.
x *integer
y *integer
elevationinteger0..15. Default 0.
return_renderbooleanif True, attach a PNG render of the post-mutation map to the response.

remove_event Remove Event

Remove any event by its synthesized _event_id. Get the id from list_events. Format: "<class>:<index>" (e.g. "warp_events:1"). Ids shift across mutations — call list_events again after any add_*/remove_event. Idempotent: removing an already-absent id is a no-op success. Script files are NOT deleted; if you removed a sign, its stub stays in data/maps/<bare>/scripts.pory (or .inc).

ParameterTypeDescription
event_id *stringe.g. "warp_events:1".
map_name *stringMAP_* constant.
project_path *stringproject root.
return_renderboolean

render_map Render Map

Render a map's full layout as a PNG image. Returns the rendered PNG as an MCP image content block plus a structured metadata dict (dimensions, encoding, byte size). Use this as the canonical "let me see what I just painted" tool after any layout mutation.

ParameterTypeDescription
map_name *stringMAP_* constant. Get from list_maps.
project_path *stringproject root.
include_borderbooleanrender the wrap-around border frame (7 metatiles per side, Porymap default). Default False.
overlayssubset of {"collision", "elevation", "grid", "events"}. Drawn alpha-blended on top of the base render, in order. Forces RGBA PNG output. Default [] (none).
scaleintegerinteger up-scale factor (1..8), nearest-neighbor. Default 1.

render_map_region Render Map Region

Render a half-open rectangular slice of a map to PNG. Coordinates are in metatile units with the top-left origin Porymap uses; the rectangle is half-open [x1, x2) x [y1, y2). Useful for inspecting a single town inside a large region map, or the patch you just edited inside a 60x120 layout without spending the full render.

ParameterTypeDescription
map_name *stringMAP_* constant.
project_path *stringproject root.
x1 *integer
x2 *integer
y1 *integer
y2 *integer
overlayssubset of {"collision", "elevation", "grid", "events"}. Same semantics as render_map; clipped to the region. Events outside the region are silently dropped. Forces RGBA output.
scaleintegerinteger up-scale factor (1..8).

render_metatile Render Metatile

Render a single metatile from a tileset as a PNG. The metatile is composed using the requested tileset paired with the first opposite-kind tileset in the project (primary <-> secondary). This matters only for metatiles that reference the companion's tiles or palettes; same-tileset references render identically regardless of pairing.

ParameterTypeDescription
metatile_id *integer0..1023.
project_path *stringproject root.
tileset_name *stringdirectory basename (NOT C label). Get from list_tilesets.
scaleintegerinteger up-scale factor (1..8). Default 4 (yields a 64x64 preview, comfortable to inspect visually).