@lzimul/minecraft-mcp 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +126 -67
  3. package/SECURITY.md +38 -21
  4. package/build/config/server-info.js +5 -4
  5. package/build/config/storage.js +2 -1
  6. package/build/config/world-limits.js +6 -1
  7. package/build/data/entities.js +1581 -0
  8. package/build/enums/entity-kind.enum.js +5 -0
  9. package/build/enums/inventory-section.enum.js +5 -0
  10. package/build/enums/move-direction.enum.js +9 -0
  11. package/build/index.js +4 -3
  12. package/build/interfaces/entity-inventory.interface.js +1 -0
  13. package/build/interfaces/entity-type.interface.js +1 -0
  14. package/build/interfaces/entity.interface.js +1 -0
  15. package/build/resources/dimension-resources.js +24 -7
  16. package/build/resources/entity-resources.js +17 -0
  17. package/build/resources/index.js +2 -0
  18. package/build/schemas/coordinate-schema.js +5 -0
  19. package/build/schemas/dimension-schema.js +1 -0
  20. package/build/schemas/entity-schema.js +95 -0
  21. package/build/tools/block-tools.js +14 -23
  22. package/build/tools/entity-tools.js +638 -0
  23. package/build/tools/index.js +4 -0
  24. package/build/tools/result.js +3 -5
  25. package/build/tools/world-tools.js +526 -0
  26. package/build/utils/logger.js +53 -0
  27. package/build/world/block-spec.js +8 -6
  28. package/build/world/block-states.js +23 -4
  29. package/build/world/entity-inventory.js +101 -0
  30. package/build/world/item-spec.js +25 -0
  31. package/build/world/simulated-dimension.js +314 -14
  32. package/build/world/stores/file-world-store.js +84 -29
  33. package/build/world/stores/memory-world-store.js +18 -5
  34. package/build/world/stores/serialized-block.js +9 -14
  35. package/build/world/stores/serialized-entity.js +75 -0
  36. package/build/world/stores/serialized-snapshot.js +35 -0
  37. package/build/world/world.js +33 -1
  38. package/lib/app/server.d.ts.map +1 -1
  39. package/lib/config/dimensions.d.ts.map +1 -1
  40. package/lib/config/server-info.d.ts.map +1 -1
  41. package/lib/config/storage.d.ts.map +1 -1
  42. package/lib/config/world-limits.d.ts +5 -0
  43. package/lib/config/world-limits.d.ts.map +1 -1
  44. package/lib/data/entities.d.ts +5 -0
  45. package/lib/data/entities.d.ts.map +1 -0
  46. package/lib/enums/bounding-box.enum.d.ts.map +1 -1
  47. package/lib/enums/dimension-type.enum.d.ts.map +1 -1
  48. package/lib/enums/entity-kind.enum.d.ts +5 -0
  49. package/lib/enums/entity-kind.enum.d.ts.map +1 -0
  50. package/lib/enums/icon-theme.enum.d.ts.map +1 -1
  51. package/lib/enums/inventory-section.enum.d.ts +5 -0
  52. package/lib/enums/inventory-section.enum.d.ts.map +1 -0
  53. package/lib/enums/move-direction.enum.d.ts +9 -0
  54. package/lib/enums/move-direction.enum.d.ts.map +1 -0
  55. package/lib/interfaces/block.interface.d.ts.map +1 -1
  56. package/lib/interfaces/data-entry.interface.d.ts.map +1 -1
  57. package/lib/interfaces/dimension.interface.d.ts.map +1 -1
  58. package/lib/interfaces/entity-inventory.interface.d.ts +9 -0
  59. package/lib/interfaces/entity-inventory.interface.d.ts.map +1 -0
  60. package/lib/interfaces/entity-type.interface.d.ts +8 -0
  61. package/lib/interfaces/entity-type.interface.d.ts.map +1 -0
  62. package/lib/interfaces/entity.interface.d.ts +17 -0
  63. package/lib/interfaces/entity.interface.d.ts.map +1 -0
  64. package/lib/interfaces/item.interface.d.ts.map +1 -1
  65. package/lib/interfaces/placed-block.interface.d.ts.map +1 -1
  66. package/lib/interfaces/world-store.interface.d.ts +8 -2
  67. package/lib/interfaces/world-store.interface.d.ts.map +1 -1
  68. package/lib/resources/block-resources.d.ts.map +1 -1
  69. package/lib/resources/data-resources.d.ts.map +1 -1
  70. package/lib/resources/dimension-resources.d.ts.map +1 -1
  71. package/lib/resources/entity-resources.d.ts +3 -0
  72. package/lib/resources/entity-resources.d.ts.map +1 -0
  73. package/lib/resources/index.d.ts.map +1 -1
  74. package/lib/resources/item-resources.d.ts.map +1 -1
  75. package/lib/schemas/block-schema.d.ts.map +1 -1
  76. package/lib/schemas/coordinate-schema.d.ts +5 -0
  77. package/lib/schemas/coordinate-schema.d.ts.map +1 -1
  78. package/lib/schemas/dimension-schema.d.ts +1 -0
  79. package/lib/schemas/dimension-schema.d.ts.map +1 -1
  80. package/lib/schemas/entity-schema.d.ts +134 -0
  81. package/lib/schemas/entity-schema.d.ts.map +1 -0
  82. package/lib/schemas/item-schema.d.ts.map +1 -1
  83. package/lib/tools/block-tools.d.ts.map +1 -1
  84. package/lib/tools/entity-tools.d.ts +4 -0
  85. package/lib/tools/entity-tools.d.ts.map +1 -0
  86. package/lib/tools/index.d.ts.map +1 -1
  87. package/lib/tools/item-tools.d.ts.map +1 -1
  88. package/lib/tools/result.d.ts +2 -6
  89. package/lib/tools/result.d.ts.map +1 -1
  90. package/lib/tools/world-tools.d.ts +4 -0
  91. package/lib/tools/world-tools.d.ts.map +1 -0
  92. package/lib/utils/logger.d.ts +3 -0
  93. package/lib/utils/logger.d.ts.map +1 -0
  94. package/lib/world/block-spec.d.ts.map +1 -1
  95. package/lib/world/block-states.d.ts +2 -0
  96. package/lib/world/block-states.d.ts.map +1 -1
  97. package/lib/world/entity-inventory.d.ts +16 -0
  98. package/lib/world/entity-inventory.d.ts.map +1 -0
  99. package/lib/world/item-spec.d.ts +10 -0
  100. package/lib/world/item-spec.d.ts.map +1 -0
  101. package/lib/world/simulated-dimension.d.ts +54 -0
  102. package/lib/world/simulated-dimension.d.ts.map +1 -1
  103. package/lib/world/stores/file-world-store.d.ts +4 -4
  104. package/lib/world/stores/file-world-store.d.ts.map +1 -1
  105. package/lib/world/stores/index.d.ts.map +1 -1
  106. package/lib/world/stores/memory-world-store.d.ts +4 -4
  107. package/lib/world/stores/memory-world-store.d.ts.map +1 -1
  108. package/lib/world/stores/serialized-block.d.ts.map +1 -1
  109. package/lib/world/stores/serialized-entity.d.ts +24 -0
  110. package/lib/world/stores/serialized-entity.d.ts.map +1 -0
  111. package/lib/world/stores/serialized-snapshot.d.ts +6 -0
  112. package/lib/world/stores/serialized-snapshot.d.ts.map +1 -0
  113. package/lib/world/world.d.ts +3 -0
  114. package/lib/world/world.d.ts.map +1 -1
  115. package/package.json +16 -12
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) [2020-2030] [lZiMUl]
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) [2020-2030] [lZiMUl]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,47 +1,78 @@
1
1
  # lZiMUl Minecraft MCP
2
2
 
3
- Minecraft Model Context Protocol (MCP) server. It exposes the complete Minecraft registry (Java Edition data) as MCP resources and provides tools to read and write blocks in persisted, per-dimension worlds. Requires Node.js 22 or newer.
3
+ Minecraft Model Context Protocol (MCP) server. It exposes the complete Minecraft registry (Java Edition data) as MCP resources and provides tools to read, write, query and fill blocks, inspect dimensions, create, move and delete entities and players, set their positions, and manage inventories in persisted, per-dimension worlds. Requires Node.js 22 or newer.
4
4
 
5
5
  ## Features
6
6
 
7
- - All Minecraft blocks and items exposed as MCP resources with full properties (name, hardness, blast resistance, durability, enchantment categories, light level, collision box, and more)
8
- - Block lookup and placement tools backed by simulated dimensions (Overworld, The Nether, The End), each with its own isolated world state and height range
7
+ - All Minecraft blocks, items and entity types exposed as MCP resources with full properties (name, hardness, blast resistance, durability, enchantment categories, light level, collision box, entity dimensions, category, and more)
8
+ - Block lookup, placement, area queries and bounded fill tools backed by simulated dimensions (Overworld, The Nether, The End), each with its own isolated world state and height range
9
9
  - Block states are supported everywhere: `minecraft:oak_stairs[facing=south,half=bottom]`
10
- - World state is persisted per dimension as JSON and survives restarts
10
+ - Dimension tools for metadata, paginated block access, entity listings and raw JSON snapshots
11
+ - Entity and player tools with deletion, movement, exact position control, and a 9-slot hotbar plus 27-slot backpack per entity, managed through `getInventory`, `setInventory`, `clearInventory` and `swapInventorySlots`
12
+ - World state (blocks, entities, players and inventories) is persisted per dimension as JSON and survives restarts
13
+ - log4js logging to stderr with chalk colours (error red, warn yellow, info green); stdout stays clean for the MCP transport
11
14
  - Structured tool output (`outputSchema` / `structuredContent`) plus human readable text
12
15
  - Every failure path returns a readable message instead of an unhandled exception
13
16
  - Tool annotations for safe client automation
14
17
 
15
18
  ## Protocol
16
19
 
17
- This server implements **MCP 2026-07-28 only**. The legacy 2025-era `initialize` handshake is rejected, so clients must use the modern protocol:
18
-
19
- - Start a session with `server/discover`, or send any request carrying the per-request envelope.
20
- - Every request must include the envelope in `params._meta`:
21
- - `io.modelcontextprotocol/protocolVersion`: `"2026-07-28"`
22
- - `io.modelcontextprotocol/clientCapabilities`
23
- - `io.modelcontextprotocol/clientInfo` (optional)
24
- - Responses use the modern result shape (`resultType`, server identity under `_meta['io.modelcontextprotocol/serverInfo']`).
25
- - A legacy `initialize` is answered with `UnsupportedProtocolVersionError` naming the supported modern revision.
26
-
27
- When testing with MCP Inspector 2.12 or newer, set **Protocol Era** to `modern` (or `auto`) for this server. The Inspector's default `legacy` mode sends `initialize`, which this server intentionally rejects.
20
+ The server implements the MCP `2026-07-28` revision. Modern clients open a session with `server/discover` and carry the per-request envelope in every request's `params._meta` (`io.modelcontextprotocol/protocolVersion`, `io.modelcontextprotocol/clientCapabilities`, and optionally `io.modelcontextprotocol/clientInfo`). Responses use the modern result shape (`resultType`, server identity under `_meta['io.modelcontextprotocol/serverInfo']`). The legacy `initialize` handshake is rejected with error `-32022`; clients must use `server/discover` or send the per-request envelope.
28
21
 
29
22
  ## Tools
30
23
 
31
- | Tool | Description |
32
- | ---------- | -------------------------------------------------------------------------------------- |
33
- | `getBlock` | Get the block (and its states) at coordinates in a dimension (defaults to `overworld`) |
34
- | `setBlock` | Place a block with optional states in a dimension and return the replaced block |
35
- | `getItem` | Look up item properties by id (`minecraft:diamond_sword` or `diamond_sword`) |
24
+ | Tool | Description |
25
+ | ---------------------- | ----------------------------------------------------------------------------------------- |
26
+ | `getBlock` | Get the block (and its states) at coordinates in a dimension (defaults to `overworld`) |
27
+ | `setBlock` | Place a block with optional states in a dimension and return the replaced block |
28
+ | `getDimension` | Get dimension metadata, block count, entity count and player count |
29
+ | `getDimensionBlocks` | Page through every placed (non-air) block in a dimension, sorted by coordinates |
30
+ | `getBlocksInArea` | Page through placed blocks inside a box, with an optional block and states filter |
31
+ | `fillBlocks` | Fill a box with one block, optionally replacing existing blocks; air clears the box |
32
+ | `getDimensionEntities` | List every entity and player in a dimension with type, name and position |
33
+ | `getDimensionRawFile` | Return the raw dimension JSON snapshot, including `blocks` and `entities` |
34
+ | `getItem` | Look up item properties by id (`minecraft:diamond_sword` or `diamond_sword`) |
35
+ | `createEntity` | Create a non-player entity with an empty hotbar and backpack |
36
+ | `getEntity` | Get an entity by UUID, including position, dimension and full inventory |
37
+ | `deleteEntity` | Delete an entity or player by UUID or player name and discard its inventory |
38
+ | `moveEntity` | Move an entity one block forward, back, left, right, up or down |
39
+ | `getEntityPosition` | Get an entity UUID, type, name and exact `x`/`y`/`z` position |
40
+ | `setEntityPosition` | Set an entity UUID to an exact `x`/`y`/`z` position |
41
+ | `createPlayer` | Create a uniquely named player with an empty hotbar and backpack |
42
+ | `getPlayer` | Get a player by name (case-insensitive), including position, dimension and full inventory |
43
+ | `getInventory` | Read the 9 hotbar slots and 27 backpack slots of an entity or player |
44
+ | `clearInventory` | Remove every item from an entity or player inventory |
45
+ | `swapInventorySlots` | Swap any two hotbar or backpack slots of an entity or player |
46
+ | `setInventory` | Set or clear one hotbar/backpack slot of an entity or player |
36
47
 
37
48
  `setBlock` accepts both the full form (`minecraft:oak_stairs[facing=south,half=bottom]`) and the short form (`oak_stairs[facing=south]`). Setting `minecraft:air` removes the block; air cannot carry states.
38
49
 
50
+ `getDimensionBlocks` is paginated because a dimension can hold up to 250,000 placed blocks. `limit` defaults to 1,000 and is capped at 10,000; `offset` skips rows. Rows are sorted by `x`, `y`, `z` and include the block id, display name and states.
51
+
52
+ `getBlocksInArea` reads an inclusive box in one dimension. Its corners may be supplied in any order, and the optional `blockType` filter matches the block id; when states are included, the stored state map must match exactly. The same `limit`/`offset` pagination applies.
53
+
54
+ `fillBlocks` writes one block type into an inclusive box. By default it fills only air; set `overwrite` to `true` to replace existing blocks. Use `minecraft:air` with `overwrite` to clear a region. A single request is limited to 16,384 coordinates, and the result reports changed, placed, removed and skipped counts.
55
+
56
+ `getDimensionEntities` lists entity and player summaries, sorted by UUID; use `getEntity` or `getInventory` when you need the full inventory of one record. The former `getDimensionEntitys` spelling is no longer registered. `getDimensionRawFile` returns the same raw JSON format that is written to disk, so the result can be loaded directly by `app/minecraft_world_viewer.html`.
57
+
58
+ ### Entities, players and inventories
59
+
60
+ - Entity type ids come from the generated registry (`lzimul://minecraft/entities`), for example `minecraft:zombie` or `zombie`. `createEntity` rejects `minecraft:player`; use `createPlayer` for players.
61
+ - Players are addressed by name, case-insensitively, and names are unique across all dimensions. Entity and player UUIDs come from the creation response.
62
+ - Every entity and player has a 9-slot hotbar plus a 27-slot backpack (36 slots total). Slots are zero-based within their section.
63
+ - `getInventory`, `setInventory`, `clearInventory`, `swapInventorySlots` and `deleteEntity` accept either an entity UUID or a player name. `setInventory` requires `section` (`hotbar` or `inventory`, default `inventory`), `slot`, `item` and `count`; `swapInventorySlots` requires two section/slot pairs.
64
+ - `count` must not exceed the item's stack size. Set the item to `minecraft:air` or the count to `0` to clear a slot. Empty slots are returned as `null`. `clearInventory` removes all 36 slots at once.
65
+ - `deleteEntity` removes the entity or player and its inventory from its dimension. Deleting a player frees the name for reuse.
66
+ - `moveEntity` moves exactly one block and takes only an entity UUID and a direction: `forward` (`+Z`, south), `back` (`-Z`, north), `left` (`-X`, west), `right` (`+X`, east), `up` (`+Y`) or `down` (`-Y`). The destination must remain inside the entity's dimension.
67
+ - `getEntityPosition` returns the entity UUID, type, name and `x`/`y`/`z`; `setEntityPosition` takes an entity UUID plus a nested `{ "x": ..., "y": ..., "z": ... }` position.
68
+ - A dimension holds at most 10,000 entities and players combined. Entity names are limited to 64 characters and player names to 32 characters (`A-Z`, `a-z`, `0-9`, `_`).
69
+
39
70
  ## Persistence
40
71
 
41
72
  World snapshots are stored as one JSON document per dimension, so the dimensions never share a file:
42
73
 
43
74
  ```text
44
- world-data/
75
+ app/dimensions/
45
76
  overworld.json
46
77
  the_nether.json
47
78
  the_end.json
@@ -51,10 +82,11 @@ Each snapshot looks like this:
51
82
 
52
83
  ```json
53
84
  {
54
- "format": "lzimul-world/2",
85
+ "format": "lzimul:minecraft/dimension",
55
86
  "dimension": "minecraft:overworld",
56
87
  "updatedAt": "2026-01-01T00:00:00.000Z",
57
88
  "modifiedBlockCount": 1,
89
+ "entityCount": 1,
58
90
  "blocks": [
59
91
  {
60
92
  "x": 0,
@@ -63,28 +95,50 @@ Each snapshot looks like this:
63
95
  "block": "minecraft:oak_stairs",
64
96
  "states": { "facing": "south", "half": "bottom" }
65
97
  }
98
+ ],
99
+ "entities": [
100
+ {
101
+ "id": "0f0f2f4e-7d5a-4d8e-9a3b-2f6c1d8e4a10",
102
+ "kind": "player",
103
+ "type": "minecraft:player",
104
+ "name": "Steve",
105
+ "x": 1,
106
+ "y": 64,
107
+ "z": 0,
108
+ "createdAt": "2026-01-01T00:00:00.000Z"
109
+ }
66
110
  ]
67
111
  }
68
112
  ```
69
113
 
70
- - The whole dimension is loaded once at startup and kept in memory; mutations are written back debounced and atomically (temporary file + rename).
71
- - `setBlock` awaits the write, so a successful response means the block is durably stored. If persisting fails the tool returns an error instead of pretending success.
114
+ - The whole dimension (blocks, entities and players) is loaded once at startup and kept in memory; mutations are written back debounced and atomically (temporary file + rename).
115
+ - `setBlock`, `fillBlocks`, `createEntity`, `deleteEntity`, `createPlayer`, `setInventory`, `clearInventory`, `swapInventorySlots`, `moveEntity` and `setEntityPosition` await the write, so a successful response means the change is durably stored. If persisting fails the tool returns an error instead of pretending success.
72
116
  - Parallel tool calls share a single in-flight snapshot write instead of writing one full file per call, so building with many simultaneous `setBlock` calls stays fast.
73
117
  - Unmodified coordinates are air; only placed blocks are stored. Placing air removes the coordinate from the snapshot.
74
118
  - Empty state maps are omitted from the file to keep snapshots small.
119
+ - Entity and player inventories are omitted when they are completely empty. When present, `inventory.hotbar` has 9 entries and `inventory.inventory` has 27 entries; each entry is `{ "item": "minecraft:diamond_sword", "count": 1 }` or `null`.
120
+ - Player names are not stored in a separate index: the player name index is rebuilt from the snapshots when the world loads. If two dimension files contain the same case-insensitive name, the first dimension wins and the duplicate player is dropped with a warning.
75
121
  - Snapshots are written as compact JSON (about half the bytes of pretty-printed JSON) with a trailing newline.
76
- - Files written by format v1 (`lzimul-world/1`, no states) still load; new files use `lzimul-world/2`.
122
+ - Files written by format v1 (`lzimul-world/1`, no states) and v2 (`lzimul-world/2`, no entities) still load; new files use `lzimul:minecraft/dimension` and include an `entities` array. A missing `entities` array simply means the dimension has no entities.
123
+ - Malformed block or entity entries are skipped without discarding the rest of the dimension. An entity's dimension always comes from the file it was loaded from, so an entry cannot claim to live in another dimension.
77
124
  - A dimension file is created on its first write; untouched dimensions stay empty.
78
125
 
79
126
  ### Configuration
80
127
 
81
- | Variable | Default | Description |
82
- | ------------------- | -------------- | ------------------------------------------------------ |
83
- | `MCP_WORLD_STORAGE` | `file` | `file` for JSON snapshots, `memory` for volatile state |
84
- | `MCP_WORLD_DIR` | `./world-data` | Directory that holds the per-dimension snapshots |
128
+ | Variable | Default | Description |
129
+ | ------------------- | -------------- | ------------------------------------------------------- |
130
+ | `MCP_WORLD_STORAGE` | `file` | `file` for JSON snapshots, `memory` for volatile state |
131
+ | `MCP_WORLD_DIR` | `./app/dimensions` | Directory that holds the per-dimension snapshots |
132
+ | `MCP_LOG_LEVEL` | `info` | log4js level: `trace`, `debug`, `info`, `warn`, `error` |
85
133
 
86
134
  A corrupt or oversized snapshot is moved aside as `<dimension>.json.corrupt-<uuid>` and the dimension starts empty, so a bad file never blocks startup.
87
135
 
136
+ ### Logging
137
+
138
+ Server logs use [log4js](https://log4js-node.github.io/log4js-node/) with a chalk-based layout. `error`/`fatal` are red, `warn` yellow, `info` green, `debug` cyan and `trace` blue. Chalk disables ANSI colours automatically when the output is redirected to a non-colour terminal.
139
+
140
+ Logs are written to **stderr**, never stdout: stdout is the MCP JSON-RPC transport, so mixing log lines into it would corrupt the protocol stream. `MCP_LOG_LEVEL` controls the verbosity (default `info`). Developer scripts use a small stdout logger (`scripts/logger.mjs`) with the same colours, so test output stays readable.
141
+
88
142
  ### Storage backends
89
143
 
90
144
  State is accessed through `IWorldStore` (`src/interfaces/world-store.interface.ts`):
@@ -96,34 +150,38 @@ State is accessed through `IWorldStore` (`src/interfaces/world-store.interface.t
96
150
 
97
151
  ## Resources
98
152
 
99
- | URI | Description |
100
- | -------------------------------------- | ---------------------------------------------- |
101
- | `lzimul://minecraft/blocks` | Block index |
102
- | `lzimul://minecraft/blocks/{name}` | Single block properties |
103
- | `lzimul://minecraft/items` | Item index |
104
- | `lzimul://minecraft/items/{name}` | Single item properties |
105
- | `lzimul://minecraft/dimensions` | Persisted dimension index with world state |
106
- | `lzimul://minecraft/dimensions/{type}` | Single dimension state including placed blocks |
153
+ | URI | Description |
154
+ | -------------------------------------- | ---------------------------------------------------- |
155
+ | `lzimul://minecraft/blocks` | Block index |
156
+ | `lzimul://minecraft/blocks/{name}` | Single block properties |
157
+ | `lzimul://minecraft/items` | Item index |
158
+ | `lzimul://minecraft/items/{name}` | Single item properties |
159
+ | `lzimul://minecraft/entities` | Entity type index (157 types, including `player`) |
160
+ | `lzimul://minecraft/entities/{name}` | Single entity type properties |
161
+ | `lzimul://minecraft/dimensions` | Dimension index with block, entity and player counts |
162
+ | `lzimul://minecraft/dimensions/{type}` | Single dimension state including blocks and entities |
107
163
 
108
- Placed blocks in the dimension resources include a `states` object. If a resource read fails, the server returns a JSON document with an `error` field instead of dropping the request.
164
+ Placed blocks in the dimension resources include a `states` object. If a resource read fails, the server returns a JSON document with an `error` field instead of dropping the request. The dimensions index stays small on purpose: it reports per-dimension metadata, `modifiedBlockCount`, `entityCount` and `playerCount`, while `lzimul://minecraft/dimensions/{type}` returns the placed blocks plus the full entity/player list. In total the server registers 2,838 resources: every block, item and entity type, the indexes, and the seven dimension-related resources.
109
165
 
110
166
  ## Security
111
167
 
112
168
  - Tool input is validated with Zod: coordinates are bounded, dimensions come from an enum, and ids are limited in length.
113
- - Block ids are resolved against the generated registry; unknown blocks and namespaces are rejected.
169
+ - Block and item ids are resolved against the generated registries; unknown blocks, items and entity types and unknown namespaces are rejected.
114
170
  - State names and values are restricted to `[a-z0-9_]` / `[a-z0-9_.-]`, 64 characters each, and reserved keys (`__proto__`, `constructor`, `prototype`) are rejected to rule out prototype pollution.
115
- - Each dimension holds at most 250,000 modified blocks, and the file store refuses snapshots over 128 MiB.
116
- - Snapshot writes are atomic, corrupt files are quarantined with a UUID suffix, and malformed blocks are skipped while the rest of the world loads.
171
+ - Inventory input is validated too: the section and slot must be in range, the item must exist, and the count must fit the item's stack size. `minecraft:air` or count `0` clears a slot.
172
+ - Each dimension holds at most 250,000 modified blocks and 10,000 entities/players. Entity names are capped at 64 characters, player names at 32 characters, and player names are case-insensitively unique across all dimensions. The file store refuses to load or write a snapshot over 128 MiB, so an oversized world fails the tool call instead of producing a file that would be quarantined on restart.
173
+ - Snapshot writes are atomic, corrupt files are quarantined with a UUID suffix, and malformed block or entity entries are skipped while the rest of the world loads. Entity dimensions are taken from the snapshot file rather than trusted from the entry.
117
174
  - Run `npm audit` after dependency changes. The dependency tree currently reports no vulnerabilities; the `katex` override keeps the markdown lint toolchain patched.
118
175
 
119
176
  ## Performance
120
177
 
121
178
  Measured on Node.js 26 (results vary by hardware):
122
179
 
123
- - Startup, including registry import and 2,686 resource registrations: about 0.4 s.
180
+ - Startup, including registry import and 2,838 resource registrations: about 0.4 s.
124
181
  - 300 concurrent `setBlock` tool calls: about 70 ms end-to-end, because parallel flushes share in-flight snapshot writes instead of writing the file 300 times.
125
182
  - 20,000 persisted blocks: about 1.1 MiB of compact JSON, ~25 ms to save and ~24 ms to load.
126
- - In-memory reads and writes are O(1) map operations; only the debounced snapshot write is proportional to the number of modified blocks.
183
+ - In-memory block, entity and inventory reads/writes are O(1) map operations; only the debounced snapshot write is proportional to the number of modified blocks and entities.
184
+ - `getDimensionBlocks` pages a cached, coordinate-sorted block array instead of re-sorting the world on every call.
127
185
 
128
186
  ## Project Structure
129
187
 
@@ -132,20 +190,20 @@ src/
132
190
  index.ts Entry point
133
191
  app/ Server assembly
134
192
  config/ Server metadata, dimensions, storage, world limits
135
- data/ Generated registry data (blocks, items, version)
136
- enums/ Enumerations (EBoundingBox, EIconTheme, EDimensionType)
137
- interfaces/ Interfaces (IBlock, IItem, IDimension, IPlacedBlock, IDataEntry, IWorldStore)
138
- resources/ Resource registration and error fallbacks
139
- schemas/ Zod schemas and converters
140
- tools/ Tool registration and error handling
141
- utils/ Shared helpers (error messages)
142
- world/ Simulated dimension world state
143
- stores/ IWorldStore implementations (file, memory)
193
+ data/ Generated registry data (blocks, items, entities, version)
194
+ enums/ Enumerations (EBoundingBox, EIconTheme, EDimensionType, EEntityKind, EInventorySection, EMoveDirection)
195
+ interfaces/ Interfaces (IBlock, IItem, IEntityType, IEntity, IEntityInventory, IDimension, IPlacedBlock, IWorldSnapshot, IWorldStore)
196
+ resources/ Block, item, entity and dimension resource registration
197
+ schemas/ Zod schemas and converters (blocks, entities, inventories)
198
+ tools/ Block, dimension, entity, player and inventory tools
199
+ utils/ Shared helpers (error messages, log4js + chalk logger)
200
+ world/ Simulated dimension state, entity inventory and item specs
201
+ stores/ IWorldStore implementations (file, memory) and serializers
144
202
  scripts/
203
+ logger.mjs Coloured stdout logger for developer scripts
145
204
  generate-data.mjs Regenerates src/data from minecraft-data
146
- smoke-test.mjs End-to-end smoke test (including states)
147
- protocol-test.mjs Modern-only protocol era and envelope enforcement
148
- persistence-test.mjs Restart test for the world snapshots
205
+ smoke-test.mjs End-to-end smoke test (blocks, dimensions, entities, inventories)
206
+ persistence-test.mjs Restart test for blocks, entities and inventories
149
207
  error-test.mjs Error fallbacks, sanitizing and storage limit tests
150
208
  stress-test.mjs Parallel write, coalescing and restart stress test
151
209
  clean.mjs Removes build output
@@ -153,26 +211,27 @@ scripts/
153
211
 
154
212
  ## Scripts
155
213
 
156
- | Command | Description |
157
- | ----------------------- | --------------------------------------------------------------- |
158
- | `npm run build` | Lint, compile and generate docs |
159
- | `npm run dev` | Build then start the server |
160
- | `npm start` | Start the server (stdio) |
161
- | `npm test` | Run the smoke, protocol, persistence, security and stress tests |
162
- | `npm run test:stress` | Run only the parallel write stress test |
163
- | `npm run generate-data` | Regenerate registry data (see below) |
164
- | `npm run clean` | Remove build output |
165
- | `npm run lint` | Lint and auto-fix |
214
+ | Command | Description |
215
+ | ----------------------- | ----------------------------------------------------- |
216
+ | `npm run build` | Lint, compile and generate docs |
217
+ | `npm run dev` | Build then start the server |
218
+ | `npm start` | Start the server (stdio) |
219
+ | `npm test` | Run the smoke, persistence, security and stress tests |
220
+ | `npm run test:stress` | Run only the parallel write stress test |
221
+ | `npm run generate-data` | Regenerate registry data (see below) |
222
+ | `npm run clean` | Remove build output |
223
+ | `npm run lint` | Lint without modifying files |
224
+ | `npm run lint:fix` | Lint and auto-fix |
166
225
 
167
226
  ## Data
168
227
 
169
228
  Registry data is generated from [PrismarineJS/minecraft-data](https://github.com/PrismarineJS/minecraft-data). To regenerate for a specific version:
170
229
 
171
230
  ```bash
172
- node scripts/generate-data.mjs <version> [blocks.json] [items.json]
231
+ node scripts/generate-data.mjs <version> [blocks.json] [items.json] [entities.json]
173
232
  ```
174
233
 
175
- When local JSON files are provided they are used directly, otherwise the data is fetched from GitHub. The data version is exported as `MINECRAFT_DATA_VERSION` and used in all descriptions.
234
+ When local JSON files are provided they are used directly, otherwise the data is fetched from GitHub. The fourth argument is optional and only needed for a custom entity registry; without it the entity list is fetched from the same minecraft-data release. The data version is exported as `MINECRAFT_DATA_VERSION` and used in all descriptions.
176
235
 
177
236
  ## License
178
237
 
package/SECURITY.md CHANGED
@@ -1,21 +1,38 @@
1
- # Security Policy
2
-
3
- ## Supported Versions
4
-
5
- Use this section to tell people about which versions of your project are
6
- currently being supported with security updates.
7
-
8
- | Version | Supported |
9
- |---------|--------------------|
10
- | 5.1.x | :white_check_mark: |
11
- | 5.0.x | :x: |
12
- | 4.0.x | :white_check_mark: |
13
- | < 4.0 | :x: |
14
-
15
- ## Reporting a Vulnerability
16
-
17
- Use this section to tell people how to report a vulnerability.
18
-
19
- Tell them where to go, how often they can expect to get an update on a
20
- reported vulnerability, what to expect if the vulnerability is accepted or
21
- declined, etc.
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ Only the latest `1.x` release line receives security fixes.
6
+
7
+ | Version | Supported |
8
+ | ------- | ------------------ |
9
+ | 1.0.x | :white_check_mark: |
10
+ | < 1.0 | :x: |
11
+
12
+ ## Reporting a Vulnerability
13
+
14
+ Please do **not** open a public issue for security problems.
15
+
16
+ - Email: lZiMUl@lzimul.com
17
+ - Or use GitHub's private vulnerability reporting on
18
+ <https://github.com/lZiMUl/minecraft-mcp/security/advisories/new>
19
+
20
+ Include the affected version, a minimal reproduction (tool call, resource URI
21
+ or world snapshot), and the impact you observed. You can expect an initial
22
+ response within a few days. Please allow time for a fix and release before
23
+ disclosing the issue publicly.
24
+
25
+ ## Scope
26
+
27
+ The server is designed to run locally over stdio. Reports that are in scope
28
+ include, but are not limited to:
29
+
30
+ - Prototype pollution or code execution through block ids, block states or
31
+ snapshot files
32
+ - Path traversal or arbitrary file writes through `MCP_WORLD_DIR`
33
+ - Denial of service through oversized tool input or snapshots
34
+ - Data loss when persisting world state
35
+
36
+ The following are generally out of scope: running the server with an
37
+ untrusted `MCP_WORLD_DIR`, modifying files on disk without restarting the
38
+ server, and issues that require an already-compromised host.
@@ -1,13 +1,14 @@
1
1
  import { MINECRAFT_BLOCK_COUNT } from '../data/blocks.js';
2
+ import { MINECRAFT_ENTITY_COUNT } from '../data/entities.js';
2
3
  import { MINECRAFT_ITEM_COUNT } from '../data/items.js';
3
4
  import { MINECRAFT_DATA_VERSION } from '../data/version.js';
4
5
  import { EIconTheme } from '../enums/icon-theme.enum.js';
5
6
  export const SERVER_INFO = {
6
- name: 'lzimul',
7
+ name: '@lzimul/minecraft-mcp',
7
8
  title: 'lZiMUl Minecraft MCP',
8
- description: `Minecraft Model Context Protocol server (Java Edition ${MINECRAFT_DATA_VERSION}): exposes all ${MINECRAFT_BLOCK_COUNT} blocks and ${MINECRAFT_ITEM_COUNT} items with their properties (name, hardness, blast resistance, durability, enchantment categories, etc.) as resources, plus tools to get and place blocks and look up items.`,
9
- version: '1.0.3',
10
- websiteUrl: 'https://mcp.lzimul.com/lZiMUl',
9
+ description: `Minecraft Model Context Protocol server (Java Edition ${MINECRAFT_DATA_VERSION}): exposes all ${MINECRAFT_BLOCK_COUNT} blocks, ${MINECRAFT_ITEM_COUNT} items and ${MINECRAFT_ENTITY_COUNT} entity types with their properties as resources, plus tools to read, place, query and fill blocks, inspect dimensions, create, move and delete entities and players, set entity positions, and manage their hotbar and backpack inventories.`,
10
+ version: '1.0.5',
11
+ websiteUrl: 'https://projects.lzimul.com/minecraft-mcp',
11
12
  icons: [
12
13
  {
13
14
  src: 'https://i1.hdslb.com/bfs/face/79fbb5635ff6e50fe2699c518af82162523e5f08.jpg',
@@ -4,9 +4,10 @@ function storageKind() {
4
4
  ? 'memory'
5
5
  : 'file';
6
6
  }
7
+ const DEFAULT_WORLD_DIRECTORY = './app/dimensions';
7
8
  function storageDirectory() {
8
9
  const configured = process.env.MCP_WORLD_DIR?.trim();
9
- return path.resolve(configured && configured.length > 0 ? configured : './world-data');
10
+ return path.resolve(configured && configured.length > 0 ? configured : DEFAULT_WORLD_DIRECTORY);
10
11
  }
11
12
  export const WORLD_STORAGE = {
12
13
  kind: storageKind(),
@@ -3,5 +3,10 @@ export const WORLD_LIMITS = {
3
3
  maxHorizontal: 30000000,
4
4
  minVertical: -64,
5
5
  maxVertical: 320,
6
- maxModifiedBlocks: 250_000
6
+ maxModifiedBlocks: 250_000,
7
+ maxFillVolume: 16_384,
8
+ maxEntitiesPerDimension: 10_000,
9
+ maxEntityIdLength: 128,
10
+ maxEntityNameLength: 64,
11
+ maxPlayerNameLength: 32
7
12
  };