Skip to main content
Glama

execute_prompt

Execute prompt templates with custom variables to generate RPG Maker MZ game content, enabling automated creation of maps, events, characters, and database elements from provided parameters.

Instructions

Execute a prompt template with provided variables and resource references

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_pathYesProject path
prompt_idYesPrompt template ID
variablesYesVariables to fill in the template

Implementation Reference

  • The core handler function that loads the prompt template, expands variables and resource references, and returns the fully rendered prompt or an error.
    export async function executePrompt( projectPath: string, promptId: string, variables: Record<string, any> ): Promise<{ success: boolean; prompt?: string; error?: string }> { try { const registry = await loadResourceRegistry(projectPath); const promptTemplate = registry.prompts.get(promptId); if (!promptTemplate) { return { success: false, error: `Prompt template not found: ${promptId}` }; } let prompt = promptTemplate.template; // 変数展開 for (const [key, value] of Object.entries(variables)) { const placeholder = `{{${key}}}`; prompt = prompt.replace(new RegExp(placeholder, "g"), String(value)); } // リソース参照を展開 if (promptTemplate.resourceRefs) { for (const resourceId of promptTemplate.resourceRefs) { const resource = registry.resources.get(resourceId); if (resource) { const placeholder = `{{resource:${resourceId}}}`; prompt = prompt.replace( new RegExp(placeholder, "g"), JSON.stringify(resource.content) ); } } } await Logger.info("Prompt executed", { promptId, variablesCount: Object.keys(variables).length }); return { success: true, prompt }; } catch (error) { await Logger.error("Failed to execute prompt", { projectPath, promptId, error }); return { success: false, error: error instanceof Error ? error.message : String(error) }; } }
  • The input schema defining parameters for the execute_prompt tool: project_path, prompt_id, and variables.
    { name: "execute_prompt", description: "Execute a prompt template with provided variables and resource references", inputSchema: { type: "object", properties: { project_path: { type: "string", description: "Project path" }, prompt_id: { type: "string", description: "Prompt template ID" }, variables: { type: "object", description: "Variables to fill in the template" }, }, required: ["project_path", "prompt_id", "variables"], }, },
  • src/index.ts:1426-1435 (registration)
    The tool dispatch handler in the MCP server's CallToolRequestSchema that invokes the executePrompt function with parsed arguments and formats the response.
    case "execute_prompt": { const result = await executePrompt( args.project_path as string, args.prompt_id as string, args.variables as Record<string, any> ); return { content: [{ type: "text", text: result.success ? result.prompt! : `Error: ${result.error}` }], }; }
  • src/index.ts:49-57 (registration)
    Import of the executePrompt function used by the MCP tool handler.
    registerResource, registerPromptTemplate, getResource, listResources, listPromptTemplates, executePrompt, generatePromptFromResources, initializeDefaultPrompts } from "./resource-manager.js";

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