server_update_file
Modify configuration files on a Minecraft server managed by crafty-mcp, such as server.properties or whitelist.json, to adjust server settings or permissions.
Instructions
Write or update a file on the Minecraft server (e.g., server.properties, ops.json, whitelist.json)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| server_id | Yes | Server ID or UUID | |
| path | Yes | Relative file path | |
| contents | Yes | New file contents | |
| overwrite | No | Overwrite even if file was modified externally |
Implementation Reference
- src/tools/server-files.ts:42-67 (handler)Implementation of the server_update_file tool, which uses the client.patch method to update file contents on the Minecraft server.
server.tool( "server_update_file", "Write or update a file on the Minecraft server (e.g., server.properties, ops.json, whitelist.json)", { server_id: z.string().describe("Server ID or UUID"), path: z.string().describe("Relative file path"), contents: z.string().describe("New file contents"), overwrite: z .boolean() .default(false) .describe("Overwrite even if file was modified externally"), }, async ({ server_id, path, contents, overwrite }) => { try { const data = await client.patch(`/servers/${server_id}/files`, { path, contents, overwrite, }); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } catch (error) { const msg = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Error: ${msg}` }], isError: true }; } } );