Skip to main content
Glama
f

prompts.chat MCP Server

by f

Get Prompt

get_prompt

Retrieve AI prompts by ID from prompts.chat, with support for template variables that can be customized for specific use cases.

Instructions

Get a prompt by ID. If the prompt contains template variables (like ${variable} or ${variable:default}), you may need to provide values for them.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe ID of the prompt to retrieve

Implementation Reference

  • The handler function that implements the core logic of the 'get_prompt' tool. It forwards the prompt ID to the upstream prompts.chat MCP server using the 'tools/call' method, handles errors, and returns the prompt content.
    async ({ id }) => {
      try {
        const response = await callPromptsChatMcp("tools/call", {
          name: "get_prompt",
          arguments: { id },
        });
    
        if (response.error) {
          return {
            content: [{ type: "text" as const, text: JSON.stringify({ error: response.error.message }) }],
            isError: true,
          };
        }
    
        const result = response.result as { content: Array<{ type: string; text: string }> };
        return {
          content: [{ type: "text" as const, text: result.content[0].text }],
        };
      } catch (error) {
        const message = error instanceof Error ? error.message : String(error);
        return {
          content: [{ type: "text" as const, text: JSON.stringify({ error: message }) }],
          isError: true,
        };
      }
    }
  • The input schema for the 'get_prompt' tool, defining the required 'id' parameter using Zod.
    inputSchema: {
      id: z.string().describe("The ID of the prompt to retrieve"),
    },
  • src/index.ts:177-213 (registration)
    The registration of the 'get_prompt' tool using server.registerTool, including title, description, input schema, and handler reference.
    server.registerTool(
      "get_prompt",
      {
        title: "Get Prompt",
        description:
          "Get a prompt by ID. If the prompt contains template variables (like ${variable} or ${variable:default}), you may need to provide values for them.",
        inputSchema: {
          id: z.string().describe("The ID of the prompt to retrieve"),
        },
      },
      async ({ id }) => {
        try {
          const response = await callPromptsChatMcp("tools/call", {
            name: "get_prompt",
            arguments: { id },
          });
    
          if (response.error) {
            return {
              content: [{ type: "text" as const, text: JSON.stringify({ error: response.error.message }) }],
              isError: true,
            };
          }
    
          const result = response.result as { content: Array<{ type: string; text: string }> };
          return {
            content: [{ type: "text" as const, text: result.content[0].text }],
          };
        } catch (error) {
          const message = error instanceof Error ? error.message : String(error);
          return {
            content: [{ type: "text" as const, text: JSON.stringify({ error: message }) }],
            isError: true,
          };
        }
      }
    );
  • Helper utility function used by the get_prompt handler to communicate with the upstream prompts.chat MCP server.
    async function callPromptsChatMcp(
      method: string,
      params?: Record<string, unknown>
    ): Promise<McpResponse> {
      const response = await fetch(PROMPTS_CHAT_API, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Accept: "application/json, text/event-stream",
          "User-Agent": USER_AGENT,
          ...(PROMPTS_API_KEY && { "PROMPTS-API-KEY": PROMPTS_API_KEY }),
        },
        body: JSON.stringify({
          jsonrpc: "2.0",
          id: Date.now(),
          method,
          params,
        }),
      });
    
      if (!response.ok) {
        throw new Error(`HTTP error! status: ${response.status}`);
      }
    
      const contentType = response.headers.get("content-type") || "";
    
      // Handle SSE response format
      if (contentType.includes("text/event-stream")) {
        const text = await response.text();
        const lines = text.split("\n");
    
        for (const line of lines) {
          if (line.startsWith("data: ")) {
            const jsonStr = line.slice(6);
            if (jsonStr.trim()) {
              return JSON.parse(jsonStr) as McpResponse;
            }
          }
        }
    
        throw new Error("No valid JSON data found in SSE response");
      }
    
      return (await response.json()) as McpResponse;
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that prompts may contain template variables requiring values, which adds useful context about potential input needs. However, it lacks details on permissions, error handling, or response format, leaving gaps in behavioral understanding.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and front-loaded, stating the core purpose in the first sentence. The second sentence adds relevant context about template variables without unnecessary elaboration, making it efficient and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simple tool with one parameter and no output schema or annotations, the description is adequate but incomplete. It covers the basic operation and hints at template variables, but lacks details on return values, error cases, or integration with sibling tools, leaving room for improvement in context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the 'id' parameter clearly documented. The description adds no additional parameter semantics beyond what the schema provides, such as format examples or constraints, so it meets the baseline for high schema coverage without adding value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Get') and resource ('prompt by ID'), making it easy to understand what it does. However, it doesn't explicitly differentiate from its sibling 'search_prompts', which likely searches for prompts rather than retrieving a specific one by ID.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'search_prompts'. It mentions template variables but doesn't clarify if this is a prerequisite or when to choose this over searching, leaving the agent without explicit usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/f/prompts.chat-mcp'

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