Skip to main content
Glama

get-all-phrases

Retrieve a comprehensive list of all phrases managed by the Phrases MCP Server, enabling easy access to inspirational quotes with author attribution.

Instructions

Returns a list of all phrases.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that fetches all phrases from the mock API using makeMockAPIRequest, formats them into a readable text list, and returns a structured text response.
    async () => { const phrases = await makeMockAPIRequest<Phrase[]>("GET"); let resultText = ""; if (!phrases || phrases.length === 0) { resultText = "No phrases found."; } else { const formatted = phrases.map( (p) => `${p.phrase}: "${p.name}"` ).join("\n"); resultText = `Here are all the phrases:\n\n${formatted}`; } return { content: [ { type: "text", text: resultText } ] } }
  • src/index.ts:17-43 (registration)
    Registers the 'get-all-phrases' tool with server.tool, providing the tool name, description, empty input schema, and the inline handler function.
    server.tool( "get-all-phrases", "Returns a list of all phrases.", {}, async () => { const phrases = await makeMockAPIRequest<Phrase[]>("GET"); let resultText = ""; if (!phrases || phrases.length === 0) { resultText = "No phrases found."; } else { const formatted = phrases.map( (p) => `${p.phrase}: "${p.name}"` ).join("\n"); resultText = `Here are all the phrases:\n\n${formatted}`; } return { content: [ { type: "text", text: resultText } ] } } );
  • Supporting utility function that performs HTTP requests to the mock API endpoint. Used in the get-all-phrases handler with 'GET' method and no options to retrieve the list of all phrases.
    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; } }
  • Type definition for Phrase used in the response of get-all-phrases tool.
    export interface Phrase { id: number; name: string; phrase: string; }

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