Skip to main content
Glama
blakeyoder

TypeScript Definitions MCP Server

by blakeyoder

check_type_compatibility

Verify if a source type can be assigned to a target type in TypeScript. This tool helps developers validate type compatibility for safer code and better type safety.

Instructions

Check if two types are compatible/assignable

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceTypeYesThe source type
targetTypeYesThe target type

Implementation Reference

  • Core handler function that implements the type compatibility check by generating test TypeScript code with an assignment from sourceType to targetType and validating it using the TypeScript compiler diagnostics.
    checkTypeCompatibility(sourceType: string, targetType: string): ValidationResult {
      const errors: ValidationError[] = [];
      const warnings: ValidationWarning[] = [];
    
      try {
        // Create a test assignment to check compatibility
        const testCode = `
          let source: ${sourceType};
          let target: ${targetType};
          target = source; // This will fail if types are incompatible
        `;
    
        const result = this.validateTypeUsage(testCode);
        
        // Filter out assignment-specific errors and focus on type compatibility
        const compatibilityErrors = result.errors.filter(error => 
          error.message.includes("not assignable") || 
          error.message.includes("incompatible")
        );
    
        errors.push(...compatibilityErrors);
        warnings.push(...result.warnings);
    
      } catch (error) {
        errors.push({
          message: `Type compatibility check failed: ${error instanceof Error ? error.message : String(error)}`,
          code: "COMPATIBILITY_ERROR"
        });
      }
    
      return {
        valid: errors.length === 0,
        errors,
        warnings
      };
    }
  • MCP server wrapper handler that invokes the core type validator's checkTypeCompatibility and formats the response as MCP content.
    private async handleCheckTypeCompatibility(sourceType: string, targetType: string) {
      const result = this.typeValidator.checkTypeCompatibility(sourceType, targetType);
      
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify({
              sourceType,
              targetType,
              ...result
            }, null, 2)
          }
        ]
      };
    }
  • Tool registration in the listTools response, defining the tool name, description, and input schema.
    {
      name: "check_type_compatibility",
      description: "Check if two types are compatible/assignable",
      inputSchema: {
        type: "object",
        properties: {
          sourceType: {
            type: "string",
            description: "The source type"
          },
          targetType: {
            type: "string",
            description: "The target type"
          }
        },
        required: ["sourceType", "targetType"]
      }
    },
  • TypeScript type definition for the tool arguments used in validateArgs.
    check_type_compatibility: { sourceType: string; targetType: string };
  • Dispatch case in CallToolRequestSchema handler that routes the tool call to the appropriate handler method.
    case "check_type_compatibility": {
      const compatArgs = this.validateArgs<ToolArguments["check_type_compatibility"]>(args);
      return await this.handleCheckTypeCompatibility(
        compatArgs.sourceType,
        compatArgs.targetType
      );
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. The description only states what the tool does ('check if two types are compatible/assignable') but doesn't reveal any behavioral traits such as whether it's a read-only operation, what the output format might be, error conditions, or performance characteristics. This is inadequate for a tool with no annotation coverage.

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 extremely concise—a single sentence that directly states the tool's purpose without any fluff. It's front-loaded with the core functionality and wastes no words. Every word earns its place in this minimal description.

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?

Given that there are no annotations and no output schema, the description is incomplete. It doesn't explain what 'compatible/assignable' means in this context, what the return value might be (e.g., boolean, detailed report), or any error handling. For a tool that performs type checking—which can be complex—this description lacks necessary context for effective use by an AI agent.

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?

The input schema has 100% description coverage, with both parameters ('sourceType' and 'targetType') documented as 'The source type' and 'The target type' respectively. The description adds no additional parameter semantics beyond what the schema already provides. According to the scoring rules, when schema_description_coverage is high (>80%), the baseline is 3 even with no param info in the description.

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 tool's purpose: 'Check if two types are compatible/assignable'. It specifies the verb ('check') and the resource/operation (type compatibility). However, it doesn't differentiate this tool from its siblings like 'validate_interface_implementation' or 'validate_type_usage', which might involve similar type-checking operations.

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 any prerequisites, context for usage, or how it differs from sibling tools like 'validate_type_usage' or 'lookup_type'. The agent must infer usage based solely on the tool name and description.

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