Skip to main content
Glama

extract_schemas

Extracts MCP tool definitions from server source code by scanning for tool calls and parsing their Zod schemas to identify 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

  • MCP CallToolRequest handler case for 'extract_schemas' tool: validates input with Zod schema, invokes extractProducerSchemas, logs progress, and returns JSON result with extracted schemas.
    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 input schema validation for the 'extract_schemas' tool parameters.
    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)
    Tool registration in ListToolsResponse: defines name, description, and inputSchema for 'extract_schemas'.
    { 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'], }, },
  • Core extraction logic: selects language parser (defaults to TypeScript) and delegates schema extraction to parser.extractSchemas.
    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