create_api_schema
Create an API schema by providing the API ID, schema type, and schema files. Supports various schema formats like Proto, GraphQL, OpenAPI, RAML, WSDL, and AsyncAPI.
Instructions
Create a schema for an API
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apiId | Yes | API ID | |
| type | Yes | Schema type | |
| files | Yes | Schema files |
Implementation Reference
- src/tools/api/apis/index.ts:189-200 (handler)The createApiSchema handler method in the ApiTools class. Validates that apiId, type, and files are provided, then makes a POST request to /apis/{apiId}/schemas.
/** * Create a schema for an API * @param args Parameters including apiId (required), type (required), files (required) */ async createApiSchema(args: any): Promise<ToolCallResponse> { if (!args.apiId || !args.type || !args.files) { throw new McpError(ErrorCode.InvalidParams, 'apiId, type, and files are required'); } const { apiId, ...data } = args; const response = await this.client.post(`/apis/${apiId}/schemas`, data); return this.createResponse(response.data); } - src/types/apis.ts:74-77 (schema)The CreateApiSchemaRequest interface defining the request schema: type (ApiSchemaType enum) and files (array of SchemaFile objects).
export interface CreateApiSchemaRequest { type: ApiSchemaType; files: SchemaFile[]; } - The tool definition for 'create_api_schema' registered in TOOL_DEFINITIONS, specifying inputSchema with apiId, type (enum from ApiSchemaType), and files (array of path/content/root objects).
{ name: 'create_api_schema', description: 'Create a schema for an API', inputSchema: { type: 'object', properties: { apiId: { type: 'string', description: 'API ID', }, type: { type: 'string', enum: Object.values(ApiSchemaType), description: 'Schema type', }, files: { type: 'array', description: 'Schema files', items: { type: 'object', properties: { path: { type: 'string', description: 'File path', }, content: { type: 'string', description: 'File content', }, root: { type: 'object', properties: { enabled: { type: 'boolean', description: 'Tag as root file (protobuf only)', }, }, }, }, required: ['path', 'content'], }, }, }, required: ['apiId', 'type', 'files'], }, }, - src/tools/api/apis/index.ts:53-54 (registration)The switch-case registration in handleToolCall that routes 'create_api_schema' to the createApiSchema method.
case 'create_api_schema': return await this.createApiSchema(args); - src/types/apis.ts:7-11 (helper)The ApiSchemaType enum listing all supported schema types (PROTO2, PROTO3, GRAPHQL, OPENAPI_3_1, etc.) used as validation for the 'type' field.
export enum ApiSchemaType { PROTO2 = 'proto:2', PROTO3 = 'proto:3', GRAPHQL = 'graphql', OPENAPI_3_1 = 'openapi:3_1',