Skip to main content
Glama
CSOAI-ORG

API Docs Generator AI MCP

generate_endpoint

Create an OpenAPI endpoint definition from a path, method, summary, and optional request body and response description.

Instructions

Generate an OpenAPI endpoint definition from a description.

Behavior: This tool generates structured output without modifying external systems. Output is deterministic for identical inputs. No side effects. Free tier: 10/day rate limit. Pro tier: unlimited. No authentication required for basic usage.

When to use: Use this tool when you need structured analysis or classification of inputs against established frameworks or standards.

When NOT to use: Not suitable for real-time production decision-making without human review of results.

Args: path (str): The path to analyze or process. method (str): The method to analyze or process. summary (str): The summary to analyze or process. request_body (Optional[str]): The request body to analyze or process. response_description (str): The response description to analyze or process. api_key (str): The api key to analyze or process.

Behavioral Transparency: - Side Effects: This tool is read-only and produces no side effects. It does not modify any external state, databases, or files. All output is computed in-memory and returned directly to the caller. - Authentication: No authentication required for basic usage. Pro/Enterprise tiers require a valid MEOK API key passed via the MEOK_API_KEY environment variable. - Rate Limits: Free tier: 10 calls/day. Pro tier: unlimited. Rate limit headers are included in responses (X-RateLimit-Remaining, X-RateLimit-Reset). - Error Handling: Returns structured error objects with 'error' key on failure. Never raises unhandled exceptions. Invalid inputs return descriptive validation errors. - Idempotency: Fully idempotent — calling with the same inputs always produces the same output. Safe to retry on timeout or transient failure. - Data Privacy: No input data is stored, logged, or transmitted to external services. All processing happens locally within the MCP server process.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
methodYes
summaryYes
request_bodyNo
response_descriptionNoSuccessful response
api_keyNo

Implementation Reference

  • The main handler function for the 'generate_endpoint' MCP tool. It is decorated with @mcp.tool() (line 32), accepts path, method, summary, request_body, response_description, and api_key parameters, performs access check and rate limiting, constructs an OpenAPI endpoint definition dictionary with operationId, responses, optional requestBody (from comma-separated fields), and path parameters extracted via regex, and returns a dict with path, method, and definition.
    def generate_endpoint(
        path: str, method: str, summary: str, request_body: Optional[str] = None, response_description: str = "Successful response"
    , api_key: str = "") -> dict:
        """Generate an OpenAPI endpoint definition from a description.
    
        Behavior:
            This tool generates structured output without modifying external systems.
            Output is deterministic for identical inputs. No side effects.
            Free tier: 10/day rate limit. Pro tier: unlimited.
            No authentication required for basic usage.
    
        When to use:
            Use this tool when you need structured analysis or classification
            of inputs against established frameworks or standards.
    
        When NOT to use:
            Not suitable for real-time production decision-making without
            human review of results.
    
        Args:
            path (str): The path to analyze or process.
            method (str): The method to analyze or process.
            summary (str): The summary to analyze or process.
            request_body (Optional[str]): The request body to analyze or process.
            response_description (str): The response description to analyze or process.
            api_key (str): The api key to analyze or process.
    
        Behavioral Transparency:
            - Side Effects: This tool is read-only and produces no side effects. It does not modify
              any external state, databases, or files. All output is computed in-memory and returned
              directly to the caller.
            - Authentication: No authentication required for basic usage. Pro/Enterprise tiers
              require a valid MEOK API key passed via the MEOK_API_KEY environment variable.
            - Rate Limits: Free tier: 10 calls/day. Pro tier: unlimited. Rate limit headers are
              included in responses (X-RateLimit-Remaining, X-RateLimit-Reset).
            - Error Handling: Returns structured error objects with 'error' key on failure.
              Never raises unhandled exceptions. Invalid inputs return descriptive validation errors.
            - Idempotency: Fully idempotent — calling with the same inputs always produces the
              same output. Safe to retry on timeout or transient failure.
            - Data Privacy: No input data is stored, logged, or transmitted to external services.
              All processing happens locally within the MCP server process.
        """
        allowed, msg, tier = check_access(api_key)
        if not allowed:
            return {"error": msg, "upgrade_url": "https://meok.ai/pricing"}
    
        if not _check_rate():
            return {"error": "Rate limit exceeded (50/day)"}
        method = method.lower()
        if method not in ("get", "post", "put", "patch", "delete", "head", "options"):
            return {"error": f"Invalid HTTP method: {method}"}
        endpoint: dict = {
            "summary": summary,
            "operationId": path.strip("/").replace("/", "_").replace("{", "").replace("}", "") + f"_{method}",
            "responses": {
                "200": {
                    "description": response_description,
                    "content": {"application/json": {"schema": {"type": "object"}}},
                },
                "400": {"description": "Bad request"},
                "500": {"description": "Internal server error"},
            },
        }
        if request_body and method in ("post", "put", "patch"):
            fields = [f.strip() for f in request_body.split(",")]
            properties = {}
            for field in fields:
                parts = field.split(":")
                fname = parts[0].strip()
                ftype = parts[1].strip() if len(parts) > 1 else "string"
                properties[fname] = {"type": ftype}
            endpoint["requestBody"] = {
                "required": True,
                "content": {
                    "application/json": {
                        "schema": {"type": "object", "properties": properties, "required": list(properties.keys())},
                    }
                },
            }
        params = []
        import re
        for match in re.finditer(r"\{(\w+)\}", path):
            params.append({"name": match.group(1), "in": "path", "required": True, "schema": {"type": "string"}})
        if params:
            endpoint["parameters"] = params
        return {"path": path, "method": method, "definition": endpoint}
  • server.py:32-33 (registration)
    The tool is registered with MCP via the @mcp.tool() decorator on line 32, which registers 'generate_endpoint' as a callable tool on the FastMCP instance.
    @mcp.tool()
    def generate_endpoint(
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Despite no annotations, the description comprehensively covers all behavioral aspects: side effects (read-only), authentication (none for basic, pro key), rate limits (10/day free, unlimited pro), error handling (structured errors), idempotency, and data privacy. This fully compensates for missing annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-organized with clear sections (Behavior, When to use, etc.) and front-loads the main purpose. While lengthy, every section adds relevant detail. Some parameter descriptions are repetitive, but overall structure is efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity and lack of output schema, the description provides good coverage of inputs, behaviors, and return format (structured errors). It could benefit from briefly describing the output shape (e.g., structure of the generated endpoint definition), but it's largely complete for an agent to invoke correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%. The description lists parameters but uses generic phrases like 'The path to analyze or process' that add minimal context beyond the parameter name. For example, 'path' and 'method' are not explained in terms of format, allowed values, or how they affect the generated endpoint definition.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it generates an OpenAPI endpoint definition. While it doesn't explicitly differentiate from sibling tools like 'generate_schema' or 'generate_full_spec', the specific verb 'endpoint definition' combined with the tool name makes the purpose reasonably clear.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit 'When to use' and 'When NOT to use' sections provide clear guidance. States it's for structured analysis/classification and explicitly warns against using for real-time production without human review, helping the agent choose appropriately.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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/CSOAI-ORG/api-docs-generator-ai-mcp'

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