Skip to main content
Glama
blakeyoder

TypeScript Definitions MCP Server

by blakeyoder

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
NameRequiredDescriptionDefault
packageNameYesName of the package to get types from

Implementation Reference

  • 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; }
  • 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) } ] }; }
  • 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"] } },
  • 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); }
  • TypeScript type definition for the tool's input arguments used in validation.
    get_package_types: { packageName: 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