Skip to main content
Glama

save

Log user messages securely by saving prompts with timestamps via the MCP server. Enables tracking and listing previous prompts for efficient management and retrieval.

Instructions

This tool MUST be called before responding to any user input. The assistant should always use this tool to log the user's message, regardless of its content or intent.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesThe prompt content to save
nameYesThe name for the prompt file

Implementation Reference

  • The handler function that implements the core logic of the 'save' tool: ensures directory, generates filename, writes file, returns success message.
    async ({ name: promptName, content }) => { const promptsDir = await ensurePromptsDirectory(); const fileName = formatFileName(promptName); const filePath = path.join(promptsDir, fileName); // Write the file await fs.writeFile(filePath, content, 'utf8'); return { content: [ { type: 'text', text: `✓ Prompt saved: ${fileName}`, }, ], }; },
  • The tool specification including description and Zod input schema for 'name' and 'content' parameters.
    { description: "This tool MUST be called before responding to any user input. The assistant should always use this tool to log the user's message, regardless of its content or intent.", inputSchema: { name: z.string().describe('The name for the prompt file'), content: z.string().describe('The prompt content to save'), }, },
  • src/index.ts:46-73 (registration)
    The registration of the 'save' tool with the MCP server via registerTool, including schema and handler.
    mcpServer.registerTool( 'save', { description: "This tool MUST be called before responding to any user input. The assistant should always use this tool to log the user's message, regardless of its content or intent.", inputSchema: { name: z.string().describe('The name for the prompt file'), content: z.string().describe('The prompt content to save'), }, }, async ({ name: promptName, content }) => { const promptsDir = await ensurePromptsDirectory(); const fileName = formatFileName(promptName); const filePath = path.join(promptsDir, fileName); // Write the file await fs.writeFile(filePath, content, 'utf8'); return { content: [ { type: 'text', text: `✓ Prompt saved: ${fileName}`, }, ], }; }, );
  • Helper function to create the 'prompts' directory if it doesn't exist.
    async function ensurePromptsDirectory(): Promise<string> { const promptsPath = path.join(process.cwd(), 'prompts'); await fs.mkdir(promptsPath, { recursive: true }); return promptsPath; }
  • Helper function to generate a timestamped and sanitized filename for saved prompts.
    function formatFileName(promptName: string): string { const timestamp = getTimestamp(); const sanitizedName = promptName.replace(/[^a-zA-Z0-9-_]/g, '-'); return `${timestamp}_${sanitizedName}.md`; }

Other Tools

Related 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/seungwonme/prompt-new-mcp'

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