register_resource
Register reusable resources like templates, assets, and data to streamline RPG Maker MZ project development and maintain consistency across your game.
Instructions
Register a resource (template, asset, data) for reuse across the project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | Resource content (any JSON data) | |
| description | No | Resource description | |
| name | Yes | Resource name | |
| project_path | Yes | Project path | |
| resource_id | Yes | Unique resource ID | |
| resource_type | Yes | Resource type | |
| tags | No | Tags for categorization |
Implementation Reference
- src/resource-manager.ts:107-139 (handler)The core handler function `registerResource` that performs input validation, loads the resource registry, adds the new resource, persists it to disk, and returns success/error status.export async function registerResource( projectPath: string, resource: Omit<Resource, "metadata"> & { metadata?: Partial<Resource["metadata"]> } ): Promise<{ success: boolean; resourceId?: string; error?: string }> { try { Validator.requireString(resource.id, "resource_id"); Validator.requireString(resource.name, "resource_name"); await Logger.info("Registering resource", { projectPath, resourceId: resource.id }); const registry = await loadResourceRegistry(projectPath); const fullResource: Resource = { ...resource, metadata: { ...resource.metadata, createdAt: resource.metadata?.createdAt || new Date().toISOString(), updatedAt: new Date().toISOString() } }; registry.resources.set(resource.id, fullResource); await saveResourceRegistry(registry); return { success: true, resourceId: resource.id }; } catch (error) { await Logger.error("Failed to register resource", { projectPath, error }); return { success: false, error: error instanceof Error ? error.message : String(error) }; } }
- src/index.ts:731-750 (schema)The JSON schema defining the input parameters and structure for the 'register_resource' tool in the MCP server's tool list.name: "register_resource", description: "Register a resource (template, asset, data) for reuse across the project", inputSchema: { type: "object", properties: { project_path: { type: "string", description: "Project path" }, resource_id: { type: "string", description: "Unique resource ID" }, resource_type: { type: "string", enum: ["template", "asset", "scenario", "data", "custom"], description: "Resource type" }, name: { type: "string", description: "Resource name" }, description: { type: "string", description: "Resource description" }, content: { type: "object", description: "Resource content (any JSON data)" }, tags: { type: "array", items: { type: "string" }, description: "Tags for categorization" }, }, required: ["project_path", "resource_id", "resource_type", "name", "content"], }, },
- src/index.ts:1396-1410 (registration)The registration and dispatch logic in the MCP server's CallToolRequestHandler that maps tool arguments to the registerResource function call and formats the response.case "register_resource": { const result = await registerResource(args.project_path as string, { id: args.resource_id as string, type: args.resource_type as any, name: args.name as string, description: args.description as string, content: args.content as any, metadata: { tags: args.tags as string[] } }); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }
- src/resource-manager.ts:10-24 (schema)TypeScript interface defining the structure of a Resource object used by the register_resource tool.export interface Resource { id: string; type: "template" | "asset" | "scenario" | "data" | "custom"; name: string; description?: string; content: any; metadata?: { tags?: string[]; category?: string; author?: string; version?: string; createdAt?: string; updatedAt?: string; }; }