register_prompt_template
Create reusable prompt templates with variable placeholders and resource references for RPG Maker MZ game development, enabling consistent AI-generated content creation across projects.
Instructions
Register a reusable prompt template with variable placeholders and resource references
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | No | Prompt description | |
| name | Yes | Prompt name | |
| project_path | Yes | Project path | |
| prompt_id | Yes | Unique prompt ID | |
| resource_refs | No | Referenced resource IDs | |
| template | Yes | Prompt template with {{variable}} placeholders | |
| variables | Yes | List of variable names |
Implementation Reference
- src/resource-manager.ts:144-167 (handler)Core handler function that validates the prompt template, loads the project's resource registry, registers the new prompt, saves the registry, and returns success/error response.export async function registerPromptTemplate( projectPath: string, prompt: PromptTemplate ): Promise<{ success: boolean; promptId?: string; error?: string }> { try { Validator.requireString(prompt.id, "prompt_id"); Validator.requireString(prompt.name, "prompt_name"); Validator.requireString(prompt.template, "prompt_template"); await Logger.info("Registering prompt template", { projectPath, promptId: prompt.id }); const registry = await loadResourceRegistry(projectPath); registry.prompts.set(prompt.id, prompt); await saveResourceRegistry(registry); return { success: true, promptId: prompt.id }; } catch (error) { await Logger.error("Failed to register prompt", { projectPath, error }); return { success: false, error: error instanceof Error ? error.message : String(error) }; } }
- src/index.ts:754-766 (schema)MCP tool input JSON schema defining parameters: project_path (required), prompt_id (required), name (required), description (optional), template (required), variables (required array of strings), resource_refs (optional array of resource IDs).inputSchema: { type: "object", properties: { project_path: { type: "string", description: "Project path" }, prompt_id: { type: "string", description: "Unique prompt ID" }, name: { type: "string", description: "Prompt name" }, description: { type: "string", description: "Prompt description" }, template: { type: "string", description: "Prompt template with {{variable}} placeholders" }, variables: { type: "array", items: { type: "string" }, description: "List of variable names" }, resource_refs: { type: "array", items: { type: "string" }, description: "Referenced resource IDs" }, }, required: ["project_path", "prompt_id", "name", "template", "variables"], },
- src/index.ts:1412-1424 (registration)MCP server switch case that maps the tool call to the registerPromptTemplate handler function, constructs the PromptTemplate object from args, calls the handler, and formats the response as MCP content.case "register_prompt_template": { const result = await registerPromptTemplate(args.project_path as string, { id: args.prompt_id as string, name: args.name as string, description: args.description as string, template: args.template as string, variables: args.variables as string[], resourceRefs: args.resource_refs as string[] }); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }
- src/resource-manager.ts:26-37 (schema)TypeScript interface defining the structure of a PromptTemplate used by the handler function.export interface PromptTemplate { id: string; name: string; description?: string; template: string; variables: string[]; resourceRefs?: string[]; // 参照するリソースID examples?: { input: Record<string, any>; output: string; }[]; }
- src/index.ts:49-57 (registration)Import statement that brings the registerPromptTemplate handler into the MCP server's main index file.registerResource, registerPromptTemplate, getResource, listResources, listPromptTemplates, executePrompt, generatePromptFromResources, initializeDefaultPrompts } from "./resource-manager.js";