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 ); }

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