Skip to main content
Glama
blakeyoder

TypeScript Definitions MCP Server

by blakeyoder

validate_interface_implementation

Check if code correctly implements a TypeScript interface by comparing implementation against the interface definition.

Instructions

Validate if code correctly implements an interface

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
implementationYesThe implementation code to validate
interfaceNameYesName of the interface being implemented
interfaceDefinitionYesThe interface definition

Implementation Reference

  • Core handler function that validates interface implementation by combining interface definition and implementation code, compiling with TypeScript, and reporting semantic diagnostics.
    validateInterfaceImplementation(implementation: string, interfaceName: string, interfaceDefinition: string): ValidationResult {
      const errors: ValidationError[] = [];
      const warnings: ValidationWarning[] = [];
    
      try {
        // Combine interface definition with implementation
        const combinedCode = `${interfaceDefinition}\n\n${implementation}`;
        
        const sourceFile = ts.createSourceFile(
          "temp.ts",
          combinedCode,
          ts.ScriptTarget.Latest,
          true
        );
    
        const defaultCompilerHost = ts.createCompilerHost(this.compilerOptions);
        const compilerHost = {
          ...defaultCompilerHost,
          getSourceFile: (fileName: string, languageVersion: ts.ScriptTarget) => {
            if (fileName === "temp.ts") {
              return sourceFile;
            }
            return defaultCompilerHost.getSourceFile(fileName, languageVersion);
          }
        };
    
        const program = ts.createProgram(["temp.ts"], this.compilerOptions, compilerHost);
        const diagnostics = program.getSemanticDiagnostics(sourceFile);
        
        for (const diagnostic of diagnostics) {
          const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
          const position = diagnostic.start ? sourceFile.getLineAndCharacterOfPosition(diagnostic.start) : undefined;
    
          errors.push({
            message,
            line: position ? position.line + 1 : undefined,
            column: position ? position.character + 1 : undefined,
            code: diagnostic.code?.toString()
          });
        }
    
      } catch (error) {
        errors.push({
          message: `Interface validation failed: ${error instanceof Error ? error.message : String(error)}`,
          code: "INTERFACE_VALIDATION_ERROR"
        });
      }
    
      return {
        valid: errors.length === 0,
        errors,
        warnings
      };
    }
  • JSON Schema defining the input parameters for the validate_interface_implementation tool.
    inputSchema: {
      type: "object",
      properties: {
        implementation: {
          type: "string",
          description: "The implementation code to validate"
        },
        interfaceName: {
          type: "string",
          description: "Name of the interface being implemented"
        },
        interfaceDefinition: {
          type: "string",
          description: "The interface definition"
        }
      },
      required: ["implementation", "interfaceName", "interfaceDefinition"]
    }
  • Tool registration in the ListTools response, including name, description, and input schema.
    {
      name: "validate_interface_implementation",
      description: "Validate if code correctly implements an interface",
      inputSchema: {
        type: "object",
        properties: {
          implementation: {
            type: "string",
            description: "The implementation code to validate"
          },
          interfaceName: {
            type: "string",
            description: "Name of the interface being implemented"
          },
          interfaceDefinition: {
            type: "string",
            description: "The interface definition"
          }
        },
        required: ["implementation", "interfaceName", "interfaceDefinition"]
      }
    },
  • MCP server wrapper handler that delegates to TypeValidator and formats the response.
    private async handleValidateInterfaceImplementation(
      implementation: string,
      interfaceName: string,
      interfaceDefinition: string
    ) {
      const result = this.typeValidator.validateInterfaceImplementation(
        implementation,
        interfaceName,
        interfaceDefinition
      );
      
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(result, null, 2)
          }
        ]
      };
    }
  • Tool dispatcher case in the CallToolRequest handler switch statement.
    case "validate_interface_implementation": {
      const implArgs = this.validateArgs<ToolArguments["validate_interface_implementation"]>(args);
      return await this.handleValidateInterfaceImplementation(
        implArgs.implementation,
        implArgs.interfaceName,
        implArgs.interfaceDefinition
      );
    }
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. It states the tool validates code against an interface but does not explain how validation works (e.g., static analysis, runtime checks), what constitutes success/failure, error handling, or any side effects. For a validation tool with zero annotation coverage, this is a significant gap in transparency.

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, direct sentence: 'Validate if code correctly implements an interface.' It is front-loaded, with no unnecessary words, making it highly efficient and easy to understand. Every part of the sentence earns its place by clearly stating the tool's function.

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 the complexity of code validation and the lack of annotations and output schema, the description is insufficient. It does not cover behavioral aspects like validation methods, result formats, or error conditions. For a tool with three parameters and no structured output information, more context is needed to guide 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?

The input schema has 100% description coverage, with clear parameter descriptions (e.g., 'The implementation code to validate'). The description adds no additional meaning beyond what the schema provides, as it does not elaborate on parameter interactions or usage nuances. Given the high schema coverage, a baseline score of 3 is appropriate.

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: 'Validate if code correctly implements an interface.' It specifies the verb (validate) and the resource (code implementing an interface), making the function unambiguous. However, it does not explicitly differentiate from sibling tools like 'check_type_compatibility' or 'validate_type_usage,' which might have overlapping purposes, so it falls short of a perfect score.

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. With siblings such as 'check_type_compatibility' and 'validate_type_usage,' there is no indication of specific contexts, prerequisites, or exclusions for using this tool. This lack of differentiation leaves the agent without clear usage instructions.

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