Skip to main content
Glama
blakeyoder

TypeScript Definitions MCP Server

by blakeyoder

get_package_types

Retrieve TypeScript type definitions from a specific npm package to enable generation of type-safe mocks and test data.

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 logic: iterates over program source files filtered by package, extracts type 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 tool handler: validates args, calls typeIndexer.getPackageTypes, formats JSON response.
    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 CallToolRequestHandler switch statement.
    case "get_package_types": {
      const packageArgs = this.validateArgs<ToolArguments["get_package_types"]>(args);
      return await this.handleGetPackageTypes(packageArgs.packageName);
    }
  • Input schema and metadata registered in ListToolsRequestHandler.
      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"]
      }
    },
  • TypeScript interface definition for tool arguments.
    get_package_types: { packageName: string };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It doesn't disclose whether this is a read-only operation, what format the type definitions are returned in, if there are pagination limits, or authentication requirements. 'Get' implies a safe read, but this isn't explicitly stated.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's front-loaded with the core action and resource, making it immediately understandable. No structural issues or redundancy are present.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations and no output schema, the description is insufficient. It doesn't explain what 'type definitions' include (e.g., classes, interfaces, enums), the return format, error conditions, or how it differs from siblings. The agent lacks critical context for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the parameter 'packageName' is already documented in the schema. The description adds no additional semantic context about parameter usage, constraints, or examples. It meets the baseline for high schema coverage but doesn't enhance understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and the resource 'all type definitions from a specific package', making the purpose unambiguous. It doesn't explicitly differentiate from sibling tools like 'lookup_type' or 'check_type_compatibility', but the scope ('all type definitions') provides some implicit distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, when-not-to-use scenarios, or compare to siblings like 'lookup_type' (for single types) or 'find_interfaces' (for interface-specific queries). The agent must infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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