Skip to main content
Glama

get-phrase-by-name

Retrieve inspirational phrases by specifying an author's name to access their attributed quotes within the Phrases MCP Server.

Instructions

Returns a phrase by author name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesAuthor name

Implementation Reference

  • The core handler logic for the 'get-phrase-by-name' tool. It queries the mock API for phrases matching the author name and returns a formatted text response.
    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 } ] } }
  • Zod schema defining the input parameter 'name' for the tool.
    { name: z.string().max(20).describe("Author name"), },
  • src/index.ts:73-97 (registration)
    Registration of the 'get-phrase-by-name' tool using server.tool, including name, description, schema, and handler.
    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 } ] } } );
  • Supporting helper function makeMockAPIRequest used by the tool handler to fetch data from 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