find_interfaces
Search for TypeScript interfaces by name pattern using wildcards to discover available type definitions for generating type-safe mocks and test data.
Instructions
Find interfaces matching a pattern
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pattern | Yes | Pattern to match interface names (supports wildcards with *) |
Implementation Reference
- src/type-indexer.ts:384-401 (handler)Core handler function that implements the logic to find interfaces matching the pattern by iterating over program source files, extracting definitions, and filtering interfaces using regex.async findInterfaces(pattern: string): Promise<TypeDefinition[]> { if (!this.program) { throw new Error("TypeIndexer not initialized. Call initialize() first."); } const results: TypeDefinition[] = []; const regex = new RegExp(pattern.replace(/\*/g, ".*")); for (const sourceFile of this.program.getSourceFiles()) { const definitions = this.extractTypeDefinitions(sourceFile); const matching = definitions.filter(def => def.kind === "interface" && regex.test(def.name) ); results.push(...matching); } return results; }
- src/mcp-server.ts:305-319 (handler)MCP server-specific handler wrapper that invokes the type indexer's findInterfaces and formats the response as JSON.private async handleFindInterfaces(pattern: string) { const results = await this.typeIndexer.findInterfaces(pattern); return { content: [ { type: "text", text: JSON.stringify({ pattern, results, count: results.length }, null, 2) } ] };
- src/mcp-server.ts:112-125 (registration)Tool registration in the MCP server's listTools response, defining name, description, and input schema for 'find_interfaces'.{ name: "find_interfaces", description: "Find interfaces matching a pattern", inputSchema: { type: "object", properties: { pattern: { type: "string", description: "Pattern to match interface names (supports wildcards with *)" } }, required: ["pattern"] } },
- src/mcp-server.ts:222-225 (handler)Dispatch handler case in MCP callToolRequest that routes 'find_interfaces' calls to the specific handler after argument validation.case "find_interfaces": { const interfaceArgs = this.validateArgs<ToolArguments["find_interfaces"]>(args); return await this.handleFindInterfaces(interfaceArgs.pattern); }
- src/mcp-server.ts:18-18 (schema)TypeScript type definition for 'find_interfaces' tool arguments used in validation.find_interfaces: { pattern: string };