Skip to main content
Glama

strapi_get_content_types

Retrieve all content type schemas from Strapi CMS to understand available data structures and their configurations.

Instructions

Get all content types from Strapi. Returns the complete schema of all content types.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serverYesThe name of the server to connect to

Implementation Reference

  • Handler function for 'strapi_get_content_types' tool. Validates input with Zod schema, makes authenticated GET request to Strapi's /api/content-type-builder/content-types endpoint using makeStrapiRequest helper, and returns formatted response with schema data and usage guide.
        // Validate input using Zod
        const validatedArgs = validateToolInput("strapi_get_content_types", args, requestId);
        const { server } = validatedArgs;
        logger.startRequest(requestId, name, server);
        const data = await makeStrapiRequest(server, "/api/content-type-builder/content-types", undefined, requestId);
    
        // Add helpful usage information to the response
        const response = {
            data: data,
            usage_guide: {
                naming_conventions: {
                    rest_api: "Use pluralName for REST API endpoints (e.g., 'api/articles' for pluralName: 'articles')",
                    graphql: {
                        collections: "Use pluralName for collections (e.g., 'query { articles { data { id } } }')",
                        single_items: "Use singularName for single items (e.g., 'query { article(id: 1) { data { id } } }')"
                    }
                },
                examples: {
                    rest: {
                        collection: "GET /api/{pluralName}",
                        single: "GET /api/{pluralName}/{id}",
                        create: "POST /api/{pluralName}",
                        update: "PUT /api/{pluralName}/{id}",
                        delete: "DELETE /api/{pluralName}/{id}"
                    },
                    graphql: {
                        collection: "query { pluralName(pagination: { page: 1, pageSize: 100 }) { data { id attributes } } }",
                        single: "query { singularName(id: 1) { data { id attributes } } }",
                        create: "mutation { createPluralName(data: { field: value }) { data { id } } }",
                        update: "mutation { updatePluralName(id: 1, data: { field: value }) { data { id } } }"
                    }
                },
                important_notes: [
                    "Always check singularName and pluralName in the schema for correct endpoint/query names",
                    "REST endpoints always start with 'api/'",
                    "Include pagination in GraphQL collection queries",
                    "For updates, always fetch current data first and include ALL fields in the update"
                ]
            }
        };
    
        result = {
            content: [
                {
                    type: "text",
                    text: JSON.stringify(response, null, 2),
                },
            ],
        };
    } else if (name === "strapi_get_components") {
  • Zod schema for input validation of 'strapi_get_content_types' tool. Requires a 'server' string parameter.
    const GetContentTypesSchema = z.object({
        server: z.string().min(1, "Server name is required and cannot be empty")
    }).strict();
  • src/index.ts:1250-1261 (registration)
    Tool registration in the ListTools response. Defines name, description, and JSON schema derived from Zod schema.
    name: "strapi_get_content_types",
    description: "Get all content types from Strapi. Returns the complete schema of all content types.",
    inputSchema: {
        ...zodToJsonSchema(ToolSchemas.strapi_get_content_types),
        properties: {
            ...zodToJsonSchema(ToolSchemas.strapi_get_content_types).properties,
            server: {
                ...zodToJsonSchema(ToolSchemas.strapi_get_content_types).properties.server,
                description: "The name of the server to connect to"
            }
        }
    },
  • Helper function used by the tool handler to make authenticated GET requests to Strapi API endpoints, handles logging, error processing, and query params.
    async function makeStrapiRequest(
        serverName: string, 
        endpoint: string, 
        params?: Record<string, string>, 
        requestId?: string
    ): Promise<any> {
        const serverConfig = getServerConfig(serverName);
        let url = `${serverConfig.API_URL}${endpoint}`;
        if (params) {
            const queryString = new URLSearchParams(params).toString();
            url = `${url}?${queryString}`;
        }
    
        const headers = {
            'Authorization': `Bearer ${serverConfig.JWT}`,
            'Content-Type': 'application/json',
        };
    
        const startTime = Date.now();
        
        logger.debug(`Making API request to Strapi`, {
            requestId,
            server: serverName,
            endpoint,
            method: 'GET',
            hasParams: !!params,
            url: url.replace(serverConfig.JWT, '[REDACTED]')
        });
    
        try {
            const response = await fetch(url, { headers });
            const duration = Date.now() - startTime;
            
            logger.logApiCall(
                requestId || 'unknown',
                'GET',
                endpoint,
                duration,
                response.status,
                serverName
            );
            
            return await handleStrapiError(response, `Request to ${endpoint}`, requestId);
        } catch (error) {
            const duration = Date.now() - startTime;
            
            logger.error("Error making Strapi request", {
                requestId,
                server: serverName,
                endpoint,
                method: 'GET',
                duration,
                errorType: error instanceof Error ? error.constructor.name : typeof error
            }, error instanceof Error ? error : undefined);
            
            throw error;
        }
    }

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