Skip to main content
Glama

strapi_get_components

Retrieve all components from Strapi CMS with paginated results, including component data and pagination metadata for efficient content management.

Instructions

Get all components from Strapi with pagination support. Returns both component data and pagination metadata (page, pageSize, total, pageCount).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serverYesThe name of the server to connect to
pageYesPage number (starts at 1)
pageSizeYesNumber of items per page

Implementation Reference

  • Handler for 'strapi_get_components' tool: validates input, fetches components from Strapi API endpoint '/api/content-type-builder/components' with pagination parameters, adds pagination metadata, and returns formatted JSON response.
    // Validate input using Zod (with defaults applied) const validatedArgs = validateToolInput("strapi_get_components", args, requestId); const { server, page, pageSize } = validatedArgs; logger.startRequest(requestId, name, server); const params = { 'pagination[page]': page.toString(), 'pagination[pageSize]': pageSize.toString(), }; const data = await makeStrapiRequest(server, "/api/content-type-builder/components", params, requestId); // Add pagination metadata to the response const response = { data: data, pagination: { page, pageSize, total: data.length, pageCount: Math.ceil(data.length / pageSize), }, }; result = { content: [ { type: "text", text: JSON.stringify(response, null, 2), }, ], }; } else if (name === "strapi_rest") {
  • Zod schema for input validation of 'strapi_get_components' tool, defining server (required), page (default 1), and pageSize (default 25).
    // Schema for strapi_get_components tool const GetComponentsSchema = z.object({ server: z.string().min(1, "Server name is required and cannot be empty"), page: z.union([ z.number().int().min(1, "Page must be a positive integer"), z.string().transform((str, ctx) => { const num = parseInt(str); if (isNaN(num) || num < 1) { ctx.addIssue({ code: z.ZodIssueCode.custom, message: "Page must be a positive integer" }); return z.NEVER; } return num; }) ]).optional().default(1), pageSize: z.union([ z.number().int().min(1, "Page size must be a positive integer"), z.string().transform((str, ctx) => { const num = parseInt(str); if (isNaN(num) || num < 1) { ctx.addIssue({ code: z.ZodIssueCode.custom, message: "Page size must be a positive integer" }); return z.NEVER; } return num; }) ]).optional().default(25) }).strict();
  • src/index.ts:1263-1286 (registration)
    Tool registration in ListToolsRequestSchema handler: defines name, description, and inputSchema for discovery by MCP clients.
    { name: "strapi_get_components", description: "Get all components from Strapi with pagination support. Returns both component data and pagination metadata (page, pageSize, total, pageCount).", inputSchema: { ...zodToJsonSchema(ToolSchemas.strapi_get_components), properties: { ...zodToJsonSchema(ToolSchemas.strapi_get_components).properties, server: { ...zodToJsonSchema(ToolSchemas.strapi_get_components).properties.server, description: "The name of the server to connect to" }, page: { ...zodToJsonSchema(ToolSchemas.strapi_get_components).properties.page, description: "Page number (starts at 1)", default: 1 }, pageSize: { ...zodToJsonSchema(ToolSchemas.strapi_get_components).properties.pageSize, description: "Number of items per page", default: 25 } } }, },
  • src/index.ts:621-627 (registration)
    Central registry of tool schemas including GetComponentsSchema for 'strapi_get_components', used for validation and JSON schema conversion.
    const ToolSchemas = { strapi_list_servers: ListServersSchema, strapi_get_content_types: GetContentTypesSchema, strapi_get_components: GetComponentsSchema, strapi_rest: RestSchema, strapi_upload_media: UploadMediaSchema } as const;

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/misterboe/strapi-mcp-server'

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