Skip to main content
Glama

load-api-schema-by-schemaName

Load a specific API schema by its name and specification ID using the MCP OpenAPI Server, enabling AI-powered IDE integrations to work directly with API definitions in development tools.

Instructions

Load a schema by schemaName

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
schemaNameYes
specIdYes

Implementation Reference

  • Core handler logic: retrieves the OpenAPI schema from the cached spec document's components.schemas using the schemaName, constructs and returns a LoadSchemaResult object.
    async findSchemaByName( specId: string, schemaName: string ): Promise<LoadSchemaResult | null> { const spec = this.specs[specId]; if (!spec) { return null; } const schema = spec.components?.schemas?.[schemaName]; if (!schema) { return null; } // all references must have been dereferenced return { name: schemaName, description: schema["description"], schema: schema as OpenAPIV3.SchemaObject, uri: `apis://${specId}/schemas/${schemaName}`, }; }
  • Registers the MCP tool including input schema validation with Zod, the wrapper handler function that calls the core implementation and formats the YAML response, and tool metadata.
    server.tool( "load-api-schema-by-schemaName", "Load a schema by schemaName", { specId: z.string(), schemaName: z.string(), }, async (args, extra) => { try { this.logger.debug('Loading API schema', { specId: args.specId, schemaName: args.schemaName }); const schema = await this.specExplorer.findSchemaByName( args.specId, args.schemaName ); if (!schema) { this.logger.warn('Schema not found', { specId: args.specId, schemaName: args.schemaName }); } return { content: [{ type: "text", text: stringify(schema, { indent: 2 }) }], }; } catch (error) { this.logger.error('Failed to load API schema', { error, specId: args.specId, schemaName: args.schemaName }); throw error; } } );
  • TypeScript interface defining the structure of the schema result returned by the tool handler.
    export interface LoadSchemaResult { /** Name of the schema */ name: string; /** Description of the schema */ description: string; /** The actual schema object */ schema: OpenAPIV3.SchemaObject; /** URI identifying the schema */ uri: string; }

Other Tools

Related 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/ReAPI-com/mcp-openapi'

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