get_prompt
Retrieve prompt templates by name using a structured protocol, enabling efficient access and management of markdown-based prompts with YAML metadata.
Instructions
Retrieve a prompt by name
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the prompt to retrieve |
Implementation Reference
- src/tools.ts:216-230 (handler)The primary handler function for the 'get_prompt' MCP tool. Validates the 'name' parameter and retrieves the full prompt content from the file system via file operations.private async handleGetPrompt(args: ToolArguments): Promise<CallToolResult> { if (!args.name) { throw new Error('Name is required for get_prompt'); } const content = await this.fileOps.readPrompt(args.name); return { content: [ { type: 'text', text: content, } as TextContent, ], }; }
- src/tools.ts:48-57 (schema)Input schema definition for the 'get_prompt' tool, specifying that a 'name' string is required.inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name of the prompt to retrieve', }, }, required: ['name'], },
- src/tools.ts:45-58 (registration)Registration of the 'get_prompt' tool within the MCP tool definitions returned by getToolDefinitions().{ name: 'get_prompt', description: 'Retrieve a prompt by name', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name of the prompt to retrieve', }, }, required: ['name'], }, },
- src/fileOperations.ts:50-58 (helper)Helper function in file operations that reads the full content of the prompt file corresponding to the given name.async readPrompt(name: string): Promise<string> { const fileName = this.sanitizeFileName(name) + '.md'; const filePath = path.join(this.promptsDir, fileName); try { return await fs.readFile(filePath, 'utf-8'); } catch (error) { throw new Error(`Prompt "${name}" not found`); } }