lookup_type
Find TypeScript type definitions by name and optional package to understand interface structures and generate type-safe code.
Instructions
Look up TypeScript type definitions by name and optional package
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| typeName | Yes | The name of the type to look up | |
| packageName | No | Optional package name to filter results |
Implementation Reference
- src/mcp-server.ts:275-290 (handler)The primary handler function for the 'lookup_type' tool. It invokes the TypeIndexer to find the type definition matching the given typeName and optional packageName, then formats and returns the results as a JSON string in the MCP response format.private async handleLookupType(typeName: string, packageName?: string) { const results = await this.typeIndexer.findType(typeName, packageName); return { content: [ { type: "text", text: JSON.stringify({ query: { typeName, packageName }, results, count: results.length }, null, 2) } ] }; }
- src/mcp-server.ts:76-93 (registration)Tool registration in the ListToolsRequestSchema handler. Defines the tool name, description, and input schema for lookup_type.{ name: "lookup_type", description: "Look up TypeScript type definitions by name and optional package", inputSchema: { type: "object", properties: { typeName: { type: "string", description: "The name of the type to look up" }, packageName: { type: "string", description: "Optional package name to filter results" } }, required: ["typeName"] } },
- src/mcp-server.ts:212-215 (registration)Dispatcher in the CallToolRequestSchema handler that validates arguments and routes to the lookup_type handler function.case "lookup_type": { const lookupArgs = this.validateArgs<ToolArguments["lookup_type"]>(args); return await this.handleLookupType(lookupArgs.typeName, lookupArgs.packageName); }
- src/mcp-server.ts:15-27 (schema)Internal TypeScript interface defining the argument types for all tools, including lookup_type, used for type-safe validation.interface ToolArguments { lookup_type: { typeName: string; packageName?: string }; validate_type_usage: { code: string; expectedType?: string }; find_interfaces: { pattern: string }; get_package_types: { packageName: string }; validate_interface_implementation: { implementation: string; interfaceName: string; interfaceDefinition: string; }; check_type_compatibility: { sourceType: string; targetType: string }; reinitialize_indexer: { workingDir?: string }; }