Skip to main content
Glama

render_prompt

Render prompt templates with provided parameters to generate structured inputs for AI tasks within the Open MCP Server's automation workflows.

Instructions

Render a prompt template with the given parameters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
templateIdYesThe ID of the template to render
parametersYesParameters for the template

Implementation Reference

  • Registration of the 'render_prompt' MCP tool, including inline handler function that renders the prompt using registry.prompts.render and returns formatted JSON response.
      "render_prompt",
      "Render a prompt template with the given parameters",
      {
        templateId: z.string().describe("The ID of the template to render"),
        parameters: z.record(z.any()).describe("Parameters for the template"),
      },
      async (args) => {
        try {
          const rendered = registry.prompts.render(args.templateId, args.parameters);
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(
                  {
                    templateId: rendered.templateId,
                    content: rendered.content,
                    parameters: rendered.parameters,
                  },
                  null,
                  2
                ),
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error rendering prompt: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
            isError: true,
          };
        }
      }
    );
  • Helper function renderPrompt in Registry class that implements PromptExecutor interface by calling this.prompts.render and returning the rendered content.
    async renderPrompt(
      promptId: string,
      parameters: Record<string, unknown>
    ): Promise<string> {
      const rendered = this.prompts.render(promptId, parameters);
      return rendered.content;
    }
  • Zod schema for input parameters of the 'render_prompt' tool: templateId (string) and parameters (record).
      templateId: z.string().describe("The ID of the template to render"),
      parameters: z.record(z.any()).describe("Parameters for the template"),
    },

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/ishuru/open-mcp'

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