get_package_types
Retrieve all TypeScript type definitions from a specified npm package to enable type-safe code generation and testing.
Instructions
Get all type definitions from a specific package
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| packageName | Yes | Name of the package to get types from |
Implementation Reference
- src/type-indexer.ts:403-418 (handler)Core handler function that retrieves all TypeDefinition objects from source files belonging to the specified package by filtering program source files and extracting definitions using extractTypeDefinitions.async getPackageTypes(packageName: string): Promise<TypeDefinition[]> { if (!this.program) { throw new Error("TypeIndexer not initialized. Call initialize() first."); } const results: TypeDefinition[] = []; for (const sourceFile of this.program.getSourceFiles()) { if (this.isFromPackage(sourceFile.fileName, packageName)) { const definitions = this.extractTypeDefinitions(sourceFile); results.push(...definitions); } } return results; }
- src/mcp-server.ts:322-337 (handler)MCP server wrapper handler that delegates to TypeIndexer.getPackageTypes and formats the JSON response for the MCP protocol.private async handleGetPackageTypes(packageName: string) { const results = await this.typeIndexer.getPackageTypes(packageName); return { content: [ { type: "text", text: JSON.stringify({ packageName, results, count: results.length }, null, 2) } ] }; }
- src/mcp-server.ts:127-139 (registration)Tool registration in the ListTools response, defining the tool name, description, and input schema.name: "get_package_types", description: "Get all type definitions from a specific package", inputSchema: { type: "object", properties: { packageName: { type: "string", description: "Name of the package to get types from" } }, required: ["packageName"] } },
- src/mcp-server.ts:227-230 (handler)Dispatch handler in CallToolRequest that validates arguments and calls the package types handler.case "get_package_types": { const packageArgs = this.validateArgs<ToolArguments["get_package_types"]>(args); return await this.handleGetPackageTypes(packageArgs.packageName); }
- src/mcp-server.ts:19-19 (schema)TypeScript type definition for the tool's input arguments used in validation.get_package_types: { packageName: string };