generate_schema
Generate an OpenAPI schema component by specifying fields in 'name:type' format. Create structured API documentation components quickly.
Instructions
Generate an OpenAPI schema component. Fields format: 'name:type,name2:type2' (types: string,integer,number,boolean,array).
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: name (str): The name to analyze or process. fields (str): The fields 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
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| fields | Yes | ||
| api_key | No |
Implementation Reference
- server.py:122-179 (handler)The `generate_schema` tool handler function. It parses a comma-separated list of 'name:type' fields, builds an OpenAPI schema object with properties and required fields, checks access and rate limits, and returns the schema.
def generate_schema(name: str, fields: str, api_key: str = "") -> dict: """Generate an OpenAPI schema component. Fields format: 'name:type,name2:type2' (types: string,integer,number,boolean,array). 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: name (str): The name to analyze or process. fields (str): The fields 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)"} properties = {} required = [] for field in fields.split(","): parts = field.strip().split(":") fname = parts[0].strip() ftype = parts[1].strip() if len(parts) > 1 else "string" if not fname: continue if ftype == "array": properties[fname] = {"type": "array", "items": {"type": "string"}} else: properties[fname] = {"type": ftype} required.append(fname) schema = {"type": "object", "properties": properties, "required": required} return {"schema_name": name, "schema": schema} - server.py:121-122 (registration)The `generate_schema` function is registered as an MCP tool via the `@mcp.tool()` decorator on line 121.
@mcp.tool() def generate_schema(name: str, fields: str, api_key: str = "") -> dict: - server.py:23-29 (helper)The `_check_rate()` helper function used by generate_schema to enforce a daily rate limit of 50 calls.
def _check_rate() -> bool: now = time.time() _calls[:] = [t for t in _calls if now - t < 86400] if len(_calls) >= DAILY_LIMIT: return False _calls.append(now) return True