Skip to main content
Glama

update-phrase

Modify the text of a specific phrase by its ID using the Phrases MCP Server. Ensure accurate phrase updates with structured input for ID and new text.

Instructions

Updates the text of a phrase by its ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesPhrase ID
phraseYesNew phrase text

Implementation Reference

  • src/index.ts:128-154 (registration)
    Registers the 'update-phrase' MCP tool with input schema (Zod validation for id and phrase parameters) and the complete handler implementation that performs a PATCH request to the mock API endpoint to update the phrase text by ID, then formats and returns a text response.
    server.tool( "update-phrase", "Updates the text of a phrase by its ID.", { id: z.number().min(0).describe("Phrase ID"), phrase: z.string().max(200).describe("New phrase text") }, async ({id, phrase}) => { const result = await makeMockAPIRequest<Phrase>("PATCH", { path: `/${id}`, body: { phrase }, }); const resultText = result ? `Updated phrase for ${result.name}: "${result.phrase}"` : `Failed to update phrase with ID ${id}.`; return { content: [ { type: "text", text: resultText } ] } } );
  • Zod schema defining the input parameters for the update-phrase tool: id (positive number) and new phrase text (string up to 200 chars).
    { id: z.number().min(0).describe("Phrase ID"), phrase: z.string().max(200).describe("New phrase text") },
  • The async handler function for update-phrase: calls makeMockAPIRequest with PATCH method, path /${id}, body {phrase}, formats success or failure message using the result, returns MCP text content.
    async ({id, phrase}) => { const result = await makeMockAPIRequest<Phrase>("PATCH", { path: `/${id}`, body: { phrase }, }); const resultText = result ? `Updated phrase for ${result.name}: "${result.phrase}"` : `Failed to update phrase with ID ${id}.`; return { content: [ { type: "text", text: resultText } ] } }
  • Shared helper utility function that performs HTTP requests (including PATCH for updates) to the mock API at BASE_URL, used by the update-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; } }

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