Skip to main content
Glama

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
NameRequiredDescriptionDefault
contentYesResource content (any JSON data)
descriptionNoResource description
nameYesResource name
project_pathYesProject path
resource_idYesUnique resource ID
resource_typeYesResource type
tagsNoTags for categorization

Implementation Reference

  • 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)
        };
      }
    }
  • 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) }],
      };
    }
  • 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;
      };
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ShunsukeHayashi/rpgmaker-mz-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server