get_prompt
Retrieve specific prompts by name or ID from promptz.dev to reduce context switching in development workflows.
Instructions
Get a specific prompt by ID or name
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | Name of the prompt to retrieve |
Implementation Reference
- src/tools.ts:30-58 (handler)The primary handler function that implements the execution logic for the 'get_prompt' tool. It validates input, fetches the prompt data using GraphQL client, formats it, and returns as JSON response.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:111-113 (registration)Registers the 'get_prompt' tool by dispatching CallToolRequest to the specific handler function within the MCP server's tool execution handler.case "get_prompt": { return await getPromptToolHandler(request); }
- src/index.ts:54-62 (schema)Defines the input schema for the 'get_prompt' tool, specifying the required 'name' parameter as a string.inputSchema: { type: "object", properties: { name: { type: "string", description: "Name of the prompt to retrieve", }, }, },
- src/index.ts:51-63 (registration)Tool specification for 'get_prompt' including name, description, and input schema, returned by the list tools endpoint.{ 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/graphql-client.ts:60-88 (helper)Supporting helper function that performs the GraphQL query to retrieve a prompt by its name from the promptz.dev API.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)}`); } }