Skip to main content
Glama
ronniemh
by ronniemh

delete-phrase

Remove a specific inspirational phrase from the Phrases MCP Server by providing its unique ID number.

Instructions

Deletes a phrase by its ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesPhrase ID to delete

Implementation Reference

  • src/index.ts:157-181 (registration)
    Registration of the 'delete-phrase' MCP tool, including description, input schema, and execution handler.
    server.tool(
        "delete-phrase",
        "Deletes a phrase by its ID.",
        {
            id: z.number().min(0).describe("Phrase ID to delete")
        },
        async ({id}) => {
            const result = await makeMockAPIRequest<null>("DELETE", {
                path: `/${id}`,
            });
    
            const resultText = result === null
                ? `Phrase with ID ${id} was successfully deleted.`
                : `Failed to delete phrase with ID ${id}.`;
    
            return {
                content: [
                    {
                        type: "text",
                        text: resultText
                    }
                ]
            }
        }
    );
  • Handler function that executes the delete-phrase tool: calls mock API DELETE, formats success/failure message.
    async ({id}) => {
        const result = await makeMockAPIRequest<null>("DELETE", {
            path: `/${id}`,
        });
    
        const resultText = result === null
            ? `Phrase with ID ${id} was successfully deleted.`
            : `Failed to delete phrase with ID ${id}.`;
    
        return {
            content: [
                {
                    type: "text",
                    text: resultText
                }
            ]
        }
    }
  • Zod input schema for the tool requiring a positive integer Phrase ID.
    {
        id: z.number().min(0).describe("Phrase ID to delete")
    },
  • Shared helper function that performs the actual HTTP DELETE request to the mock API, used by the delete-phrase handler.
    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 DeletePhraseParams.
    export type DeletePhraseParams = { id: number };

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