Files
server-deploy/windows-dev-stack/godot-mcp-pro-v1.14.1/server/build/tools/tilemap-tools.js
Joywayer dd3eb24d0f refactor: 拆分 claude-dev-stack 为 windows-dev-stack 和 wsl-dev-stack
将原 claude-dev-stack 目录拆分为独立的 Windows 和 WSL 部署栈,便于分别维护和使用。

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-29 01:11:20 +08:00

88 lines
4.4 KiB
JavaScript

import { z } from "zod";
import { formatErrorForMcp } from "../utils/errors.js";
export function registerTilemapTools(server, godot) {
server.tool("tilemap_set_cell", "Set a single cell in a TileMapLayer", {
node_path: z.string().describe("Path to the TileMapLayer node"),
x: z.number().describe("Cell X coordinate"),
y: z.number().describe("Cell Y coordinate"),
source_id: z.number().optional().describe("Tile source ID (default: 0)"),
atlas_x: z.number().optional().describe("Atlas X coordinate (default: 0)"),
atlas_y: z.number().optional().describe("Atlas Y coordinate (default: 0)"),
alternative: z.number().optional().describe("Alternative tile ID (default: 0)"),
}, async (params) => {
try {
const result = await godot.sendCommand("tilemap_set_cell", params);
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
}
catch (e) {
return { content: [{ type: "text", text: formatErrorForMcp(e) }], isError: true };
}
});
server.tool("tilemap_fill_rect", "Fill a rectangular region of a TileMapLayer with tiles", {
node_path: z.string().describe("Path to the TileMapLayer node"),
x1: z.number().describe("Start X coordinate"),
y1: z.number().describe("Start Y coordinate"),
x2: z.number().describe("End X coordinate"),
y2: z.number().describe("End Y coordinate"),
source_id: z.number().optional().describe("Tile source ID (default: 0)"),
atlas_x: z.number().optional().describe("Atlas X coordinate (default: 0)"),
atlas_y: z.number().optional().describe("Atlas Y coordinate (default: 0)"),
alternative: z.number().optional().describe("Alternative tile ID (default: 0)"),
}, async (params) => {
try {
const result = await godot.sendCommand("tilemap_fill_rect", params);
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
}
catch (e) {
return { content: [{ type: "text", text: formatErrorForMcp(e) }], isError: true };
}
});
server.tool("tilemap_get_cell", "Get tile data at a specific cell in a TileMapLayer", {
node_path: z.string().describe("Path to the TileMapLayer node"),
x: z.number().describe("Cell X coordinate"),
y: z.number().describe("Cell Y coordinate"),
}, async (params) => {
try {
const result = await godot.sendCommand("tilemap_get_cell", params);
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
}
catch (e) {
return { content: [{ type: "text", text: formatErrorForMcp(e) }], isError: true };
}
});
server.tool("tilemap_clear", "Clear all cells in a TileMapLayer", {
node_path: z.string().describe("Path to the TileMapLayer node"),
}, async (params) => {
try {
const result = await godot.sendCommand("tilemap_clear", params);
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
}
catch (e) {
return { content: [{ type: "text", text: formatErrorForMcp(e) }], isError: true };
}
});
server.tool("tilemap_get_info", "Get TileMapLayer info including tile set sources and cell count", {
node_path: z.string().describe("Path to the TileMapLayer node"),
}, async (params) => {
try {
const result = await godot.sendCommand("tilemap_get_info", params);
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
}
catch (e) {
return { content: [{ type: "text", text: formatErrorForMcp(e) }], isError: true };
}
});
server.tool("tilemap_get_used_cells", "Get a list of used (non-empty) cells in a TileMapLayer", {
node_path: z.string().describe("Path to the TileMapLayer node"),
max_count: z.number().optional().describe("Maximum cells to return (default: 500)"),
}, async (params) => {
try {
const result = await godot.sendCommand("tilemap_get_used_cells", params);
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
}
catch (e) {
return { content: [{ type: "text", text: formatErrorForMcp(e) }], isError: true };
}
});
}
//# sourceMappingURL=tilemap-tools.js.map