Skip to main content
Glama
ronniemh
by ronniemh

get-phrase-by-id

Retrieve a specific inspirational phrase by its unique ID from the Phrases MCP Server database for reference or editing.

Instructions

Returns a phrase by its ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesPhrase ID

Implementation Reference

  • The handler function for the 'get-phrase-by-id' tool. It fetches the phrase using makeMockAPIRequest with the given ID, formats a text response, and returns it in the MCP content format.
    async ({id}) => {
        const result = await makeMockAPIRequest<Phrase>("GET", {
            path: `/${id}`,
        });
    
        const resultText = result
            ? `Phrase from ${result.name}: "${result.phrase}"`
            : `No phrase found with ID ${id}.`;
    
        return {
            content: [
                {
                    type: "text",
                    text: resultText
                }
            ]
        }
    }
  • Zod input schema for the tool, defining the 'id' parameter as a non-negative number.
    {
        id: z.number().min(0).describe("Phrase ID"),
    },
  • src/index.ts:46-70 (registration)
    Registration of the 'get-phrase-by-id' tool on the MCP server, specifying name, description, input schema, and handler function.
    server.tool(
        "get-phrase-by-id",
        "Returns a phrase by its ID.",
        {
            id: z.number().min(0).describe("Phrase ID"),
        },
        async ({id}) => {
            const result = await makeMockAPIRequest<Phrase>("GET", {
                path: `/${id}`,
            });
    
            const resultText = result
                ? `Phrase from ${result.name}: "${result.phrase}"`
                : `No phrase found with ID ${id}.`;
    
            return {
                content: [
                    {
                        type: "text",
                        text: resultText
                    }
                ]
            }
        }
    );
  • Generic helper function used by the tool handler to perform the actual HTTP GET request to the mock API endpoint for fetching the phrase by ID.
    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;
        }
    }
  • TypeScript type definition for GetPhraseByIdParams, imported but not directly used in the tool schema (inline Zod is used instead).
    export type GetPhraseByIdParams = { id: number };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It only states the basic action ('Returns a phrase') without addressing critical aspects like error handling (e.g., what happens if the ID doesn't exist), permissions, rate limits, or return format. This leaves significant gaps for a read operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's front-loaded with the core action and resource, making it easy to parse quickly without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what a 'phrase' entails (e.g., text, metadata), how results are structured, or error scenarios. For a tool with no structured behavioral data, this minimal description leaves too much undefined.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, clearly documenting the 'id' parameter as a number with a minimum value. The description adds no additional meaning beyond what the schema provides (e.g., no context about ID sources or uniqueness), so it meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Returns') and resource ('a phrase by its ID'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'get-phrase-by-name' or 'get-all-phrases' beyond the ID parameter, which is a minor gap.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'get-phrase-by-name' or 'get-all-phrases'. It lacks context about prerequisites (e.g., needing a valid ID) or exclusions, leaving the agent to infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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