Skip to main content
Glama

extract_schemas

Extract MCP tool definitions from server source code by scanning for server.tool() calls and parsing Zod schemas to detect schema mismatches.

Instructions

Extract MCP tool definitions (ProducerSchemas) from server source code. Scans for server.tool() calls and parses their Zod schemas.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
rootDirYesRoot directory of MCP server source code
includeNoGlob patterns to include
excludeNoGlob patterns to exclude

Implementation Reference

  • Executes the extract_schemas tool by parsing input with Zod schema, calling extractProducerSchemas, logging progress, and returning formatted JSON result.
    case 'extract_schemas': { const input = ExtractSchemasInput.parse(args); log(`Extracting schemas from: ${input.rootDir}`); const schemas = await extractProducerSchemas({ rootDir: input.rootDir, include: input.include, exclude: input.exclude, }); log(`Found ${schemas.length} tool definitions`); return { content: [ { type: 'text', text: JSON.stringify({ success: true, count: schemas.length, schemas, }, null, 2), }, ], }; }
  • Zod schema for validating the input parameters (rootDir, include, exclude) to the extract_schemas tool.
    const ExtractSchemasInput = z.object({ rootDir: z.string().describe('Root directory of MCP server source code'), include: z.array(z.string()).optional().describe('Glob patterns to include (default: **/*.ts)'), exclude: z.array(z.string()).optional().describe('Glob patterns to exclude (default: node_modules, dist)'), });
  • src/index.ts:130-142 (registration)
    MCP tool registration in the listTools handler, defining name, description, and JSON inputSchema.
    { name: 'extract_schemas', description: 'Extract MCP tool definitions (ProducerSchemas) from server source code. Scans for server.tool() calls and parses their Zod schemas.', inputSchema: { type: 'object', properties: { rootDir: { type: 'string', description: 'Root directory of MCP server source code' }, include: { type: 'array', items: { type: 'string' }, description: 'Glob patterns to include' }, exclude: { type: 'array', items: { type: 'string' }, description: 'Glob patterns to exclude' }, }, required: ['rootDir'], }, },
  • Helper function invoked by the tool handler; selects language parser and delegates schema extraction from source files.
    export async function extractProducerSchemas( options: ExtractorOptions ): Promise<ProducerSchema[]> { // For backward compatibility, default to TypeScript const language = options.language || 'typescript'; // Get parser from registry if (!hasParser(language)) { throw new Error( `No parser available for language: ${language}. Make sure to call bootstrapLanguageParsers() at startup.` ); } const parser = getParser(language); return parser.extractSchemas({ rootDir: options.rootDir, include: options.include, exclude: options.exclude, }); }

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/Mnehmos/mnehmos.trace.mcp'

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