Skip to main content
Glama
cremich

promptz.dev MCP Server

by cremich

get_prompt

Retrieve specific prompts by ID or name from promptz.dev to reduce context switching in development workflows.

Instructions

Get a specific prompt by ID or name

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameNoName of the prompt to retrieve

Implementation Reference

  • The primary handler function for the 'get_prompt' tool. It validates the input name, fetches the prompt using getPromptByName, constructs a response object, and serializes it to JSON for the tool result.
    export async function getPromptToolHandler(request: CallToolRequest): Promise<CallToolResult> {
      const name = request.params.arguments?.name as string | undefined;
    
      if (!name) {
        throw new Error("Prompt name is required");
      }
      const prompt = await getPromptByName(name);
      if (!prompt) {
        throw new Error(`Prompt not found: ${name}`);
      }
    
      const promptData = {
        name: prompt.name,
        description: prompt.description,
        tags: prompt.tags || [],
        author: prompt.author?.displayName,
        instruction: prompt.instruction,
        howto: prompt.howto || "",
      };
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(promptData, null, 2),
          },
        ],
      };
    }
  • src/index.ts:51-63 (registration)
    Tool registration in the ListToolsRequestHandler response. Defines the name, description, and input schema for 'get_prompt'.
    {
      name: "get_prompt",
      description: "Get a specific prompt by ID or name",
      inputSchema: {
        type: "object",
        properties: {
          name: {
            type: "string",
            description: "Name of the prompt to retrieve",
          },
        },
      },
    },
  • src/index.ts:111-113 (registration)
    Dispatch logic in the CallToolRequestHandler switch statement that routes 'get_prompt' calls to the getPromptToolHandler.
    case "get_prompt": {
      return await getPromptToolHandler(request);
    }
  • TypeScript interface defining the structure of a Prompt object, used in the tool's response formatting and GraphQL responses.
    export interface Prompt {
      id?: string;
      name: string;
      description: string;
      tags?: string[];
      instruction: string;
      sourceURL?: string;
      howto?: string;
      public?: boolean;
      author?: {
        displayName: string;
      };
      createdAt?: string;
      updatedAt?: string;
    }
  • Helper function that performs the GraphQL query to fetch a prompt by its name, handling errors and returning the Prompt object or null.
    export async function getPromptByName(name: string): Promise<Prompt | null> {
      try {
        logger.info(`[API] Getting prompt by name: ${name}`);
    
        // Search for prompts with the exact name
        const { data, error } = await client.query(
          gql`
            ${GET_PROMPT_BY_NAME}
          `,
          { name },
        );
    
        if (error) {
          throw error;
        }
    
        const prompts = data.listByName.items;
        if (prompts.length === 0) {
          return null;
        }
    
        let prompt = prompts[0];
    
        return prompt;
      } catch (error) {
        logger.error(`[Error] Failed to get prompt by name: ${error instanceof Error ? error.message : String(error)}`);
        throw new Error(`Failed to get prompt by name: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
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/cremich/promptz-mcp'

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