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,
      });
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It describes the scanning and parsing behavior but lacks critical details: whether it's read-only or modifies files, what permissions are needed, how errors are handled, output format (though no output schema exists), or performance considerations like rate limits. The description covers basic operation but misses behavioral traits essential for safe invocation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two concise sentences with zero waste. The first sentence states the core purpose, and the second explains the implementation method. It's front-loaded with essential information and appropriately sized for the tool's complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete. It explains what the tool does but omits behavioral context (e.g., safety, errors, output), which is critical for a tool that interacts with source code. For a 3-parameter tool with full schema coverage but no other structured data, the description should compensate more with usage and behavioral details.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents parameters. The description adds no parameter-specific information beyond what's in the schema (e.g., it doesn't explain glob pattern syntax or rootDir expectations). Baseline 3 is appropriate as the schema handles parameter documentation adequately.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Extract MCP tool definitions'), identifies the resource ('ProducerSchemas from server source code'), and explains the method ('Scans for server.tool() calls and parses their Zod schemas'). It distinguishes itself from siblings like 'extract_file' or 'trace_file' by focusing on tool definitions rather than general file operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing source code access), exclusions (e.g., not for runtime extraction), or comparisons to siblings like 'scaffold_producer' or 'trace_usage' that might relate to tool definitions. Usage context is implied but not explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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