Skip to main content
Glama
blakeyoder

TypeScript Definitions MCP Server

by blakeyoder

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
NameRequiredDescriptionDefault
patternYesPattern to match interface names (supports wildcards with *)

Implementation Reference

  • 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; }
  • 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) } ] };
  • 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"] } },
  • 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); }
  • TypeScript type definition for 'find_interfaces' tool arguments used in validation.
    find_interfaces: { pattern: string };

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/blakeyoder/typescript-definitions-mcp'

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