Skip to main content
Glama

create-phrase

Add new inspirational phrases with author attribution to manage and organize motivational content within the Phrases MCP Server.

Instructions

Creates a new phrase for an author.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesAuthor name
phraseYesPhrase text

Implementation Reference

  • Handler function that executes the create-phrase tool logic by sending a POST request to the mock API with the provided name and phrase, then formats and returns the result.
    async ({name, phrase}) => { const created = await makeMockAPIRequest<Phrase>("POST", { body: { name, phrase }, }); const resultText = created ? `Created phrase for ${created.name}: "${created.phrase}" (ID: ${created.id})` : "Failed to create the phrase."; return { content: [ { type: "text", text: resultText } ] } }
  • Input schema using Zod for validating the 'name' and 'phrase' parameters of the create-phrase tool.
    { name: z.string().max(50).describe("Author name"), phrase: z.string().max(200).describe("Phrase text") },
  • src/index.ts:100-125 (registration)
    Registration of the 'create-phrase' tool using server.tool, including name, description, schema, and inline handler.
    server.tool( "create-phrase", "Creates a new phrase for an author.", { name: z.string().max(50).describe("Author name"), phrase: z.string().max(200).describe("Phrase text") }, async ({name, phrase}) => { const created = await makeMockAPIRequest<Phrase>("POST", { body: { name, phrase }, }); const resultText = created ? `Created phrase for ${created.name}: "${created.phrase}" (ID: ${created.id})` : "Failed to create the phrase."; return { content: [ { type: "text", text: resultText } ] } } );
  • Helper function makeMockAPIRequest used by the create-phrase handler to perform the actual HTTP POST request to the mock API.
    export async function makeMockAPIRequest<T>( method: HTTPMethod, options: RequestOptions = {} ): Promise<T | null> { const { path, queryParams, body } = options; let url = BASE_URL; if (path) url += path; if (method === "GET" && queryParams) { const query = new URLSearchParams(queryParams).toString(); url += `?${query}`; } const headers: HeadersInit = { "Content-Type": "application/json", }; const fetchOptions: RequestInit = { method, headers, body: body && method !== "GET" && method !== "DELETE" ? JSON.stringify(body) : undefined, }; try { const response = await fetch(url, fetchOptions); if (!response.ok) throw new Error(`HTTP error: ${response.status}`); if (method === "DELETE" || response.status === 204) return null; return await response.json(); } catch (err) { console.error(`Error on ${method} ${url}:`, err); return null; } }

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/ronniemh/phrases-MCP-server'

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