Skip to main content
Glama

get-phrase-by-name

Retrieve inspirational phrases by specifying the author's name using the Phrases MCP Server tool. Ideal for accessing curated quotes with attribution.

Instructions

Returns a phrase by author name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesAuthor name

Implementation Reference

  • The asynchronous handler function that executes the core logic of the 'get-phrase-by-name' tool. It calls makeMockAPIRequest to fetch phrases by author name, formats the result into a text response, and returns it in the MCP format.
    async ({name}) => { const result = await makeMockAPIRequest<Phrase[]>("GET", { queryParams: { name }, }); const resultText = result && result[0] ? `Phrase from ${name}: "${result[0].phrase}" (ID: ${result[0].id})` : `No phrase found for ${name}.`; return { content: [ { type: "text", text: resultText } ] } }
  • The Zod schema defining the input parameters for the tool, specifically the 'name' field as a string up to 20 characters.
    { name: z.string().max(20).describe("Author name"), },
  • src/index.ts:73-97 (registration)
    The server.tool registration call that defines and registers the 'get-phrase-by-name' tool, including its name, description, input schema, and handler function.
    server.tool( "get-phrase-by-name", "Returns a phrase by author name.", { name: z.string().max(20).describe("Author name"), }, async ({name}) => { const result = await makeMockAPIRequest<Phrase[]>("GET", { queryParams: { name }, }); const resultText = result && result[0] ? `Phrase from ${name}: "${result[0].phrase}" (ID: ${result[0].id})` : `No phrase found for ${name}.`; return { content: [ { type: "text", text: resultText } ] } } );
  • The makeMockAPIRequest helper function used by the tool handler to perform the HTTP GET request to the mock API with query parameters for the author name.
    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; } }

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

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