Skip to main content
Glama
tanker327

Prompts MCP Server

by tanker327

add_prompt

Add new prompt templates to a collection by providing name, filename, and markdown content for easy management and retrieval.

Instructions

Add a new prompt to the collection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName of the prompt
filenameYesEnglish filename for the prompt file (without .md extension)
contentYesContent of the prompt in markdown format

Implementation Reference

  • The handler function that implements the core logic for the 'add_prompt' tool: validates required arguments (name, filename, content), ensures metadata is present, saves the prompt using fileOps, and returns a success message.
    private async handleAddPrompt(args: ToolArguments): Promise<CallToolResult> { if (!args.name || !args.filename || !args.content) { throw new Error('Name, filename, and content are required for add_prompt'); } // Validate and enhance content with metadata if needed const processedContent = this.ensureMetadata(args.content, args.name); const fileName = await this.fileOps.savePromptWithFilename(args.filename, processedContent); return { content: [ { type: 'text', text: `Prompt "${args.name}" saved as ${fileName}`, } as TextContent, ], }; }
  • Input schema defining the expected parameters for the add_prompt tool: name (string), filename (string), content (string), all required.
    inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name of the prompt', }, filename: { type: 'string', description: 'English filename for the prompt file (without .md extension)', }, content: { type: 'string', description: 'Content of the prompt in markdown format', }, }, required: ['name', 'filename', 'content'], },
  • src/tools.ts:23-44 (registration)
    Registration of the 'add_prompt' tool in the getToolDefinitions() method, including name, description, and full input schema.
    { name: 'add_prompt', description: 'Add a new prompt to the collection', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name of the prompt', }, filename: { type: 'string', description: 'English filename for the prompt file (without .md extension)', }, content: { type: 'string', description: 'Content of the prompt in markdown format', }, }, required: ['name', 'filename', 'content'], }, },
  • Supporting helper function used by add_prompt handler to ensure the prompt content includes YAML frontmatter metadata, adding defaults if absent.
    private ensureMetadata(content: string, promptName: string): string { // Check if content already has frontmatter if (content.trim().startsWith('---')) { return content; // Already has frontmatter, keep as-is } // Add default frontmatter if missing const defaultMetadata = `--- title: "${promptName.replace(/-/g, ' ').replace(/\b\w/g, l => l.toUpperCase())}" description: "A prompt for ${promptName.replace(/-/g, ' ')}" category: "general" tags: ["general"] difficulty: "beginner" author: "User" version: "1.0" created: "${new Date().toISOString().split('T')[0]}" --- `; return defaultMetadata + content; }
  • src/tools.ts:138-139 (registration)
    Dispatch/registration case in handleToolCall switch statement that routes 'add_prompt' calls to the handler.
    case 'add_prompt': return await this.handleAddPrompt(toolArgs);

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/tanker327/prompts-mcp-server'

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