Skip to main content
Glama
SpringMT
by SpringMT

GetMicroCMSContent

Retrieve specific content from microCMS by providing the endpoint and content ID. Use this tool to fetch structured data with optional field selection and reference expansion.

Instructions

Get specific content from MicroCMS by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endpointYesAPI endpoint (e.g., 'blogs')
contentIdYesContent ID to retrieve
fieldsNoComma-separated list of fields to return
depthNoDepth for expanding references

Implementation Reference

  • The asynchronous handler function that fetches specific content from MicroCMS by ID using the client.get method. It constructs queries for optional fields and depth, stringifies the response as formatted JSON, and returns it as text content. Includes error handling to return an error message if the request fails.
    async ({ endpoint, contentId, fields, depth }) => { try { const queries: Record<string, any> = {}; if (fields) queries.fields = fields; if (depth) queries.depth = depth; const response = await client.get({ endpoint, contentId, queries, }); // 結果をJSON文字列に変換 const resultJson = JSON.stringify(response, null, 2); return { content: [ { type: "text", text: resultJson } ] }; } catch (error: unknown) { console.error("Error getting MicroCMS content:", error); const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get MicroCMS content: ${errorMessage}` } ] }; } } );
  • Zod input schema defining required parameters 'endpoint' and 'contentId', with optional 'fields' and 'depth' for customizing the content retrieval.
    { endpoint: z.string().describe("API endpoint (e.g., 'blogs')"), contentId: z.string().describe("Content ID to retrieve"), fields: z.string().optional().describe("Comma-separated list of fields to return"), depth: z.number().optional().describe("Depth for expanding references"), },
  • src/index.ts:93-139 (registration)
    The server.tool registration call that defines the 'GetMicroCMSContent' tool, including its name, description, input schema, and handler function.
    server.tool( "GetMicroCMSContent", "Get specific content from MicroCMS by ID", { endpoint: z.string().describe("API endpoint (e.g., 'blogs')"), contentId: z.string().describe("Content ID to retrieve"), fields: z.string().optional().describe("Comma-separated list of fields to return"), depth: z.number().optional().describe("Depth for expanding references"), }, async ({ endpoint, contentId, fields, depth }) => { try { const queries: Record<string, any> = {}; if (fields) queries.fields = fields; if (depth) queries.depth = depth; const response = await client.get({ endpoint, contentId, queries, }); // 結果をJSON文字列に変換 const resultJson = JSON.stringify(response, null, 2); return { content: [ { type: "text", text: resultJson } ] }; } catch (error: unknown) { console.error("Error getting MicroCMS content:", error); const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get MicroCMS content: ${errorMessage}` } ] }; } } );

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/SpringMT/microcms-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server