@aaswe/codebase-ai
Version:
AI-Assisted Software Engineering (AASWE) - Rich codebase context for IDE LLMs
206 lines • 4.55 kB
TypeScript
/**
* MCP Server Implementation
*
* Model Context Protocol server that provides rich codebase context
* to IDE LLMs using TTL files and knowledge graphs.
*/
import { EventEmitter } from 'events';
import { Layer3AIService } from '../layer3/index';
import { HybridStorageManager } from '../layer2/hybrid-storage/HybridStorageManager';
import { MCPServerConfig, MCPServerStatus, MCPServerMetrics } from './types';
/**
* MCP Server for IDE Integration
*/
export declare class MCPServer extends EventEmitter {
private config;
private server;
private wsServer;
private layer3Service;
private clients;
private connections;
private ttlFiles;
private contextCache;
private fileWatcher;
private status;
private startTime;
private metrics;
private cacheCleanupInterval?;
constructor(config: MCPServerConfig, layer3Service: Layer3AIService, hybridStorage: HybridStorageManager);
/**
* Initialize metrics
*/
private initializeMetrics;
/**
* Setup WebSocket handlers
*/
private setupWebSocketHandlers;
/**
* Handle incoming MCP message
*/
private handleMessage;
/**
* Handle initialize request
*/
private handleInitialize;
/**
* Handle tools list request
*/
private handleToolsList;
/**
* Handle tool call
*/
private handleToolCall;
/**
* Handle get context tool call
*/
private handleGetContext;
/**
* Handle query knowledge tool call
*/
private handleQueryKnowledge;
/**
* Handle analyze code tool call
*/
private handleAnalyzeCode;
/**
* Handle resources list request
*/
private handleResourcesList;
/**
* Handle resource read request
*/
private handleResourceRead;
/**
* Handle context request
*/
private handleContextRequest;
/**
* Generate context for a request
*/
private generateContext;
/**
* Select relevant context based on request
*/
private selectRelevantContext;
/**
* Format TTL file content for LLM consumption
*/
private formatTTLForLLM;
/**
* Build context string from sources
*/
private buildContextString;
/**
* Generate follow-up queries
*/
private generateFollowUpQueries;
/**
* Generate improvement suggestions
*/
private generateImprovements;
/**
* Start the MCP server
*/
start(): Promise<void>;
/**
* Stop the MCP server
*/
stop(): Promise<void>;
/**
* Initialize TTL file watcher
*/
private initializeTTLWatcher;
/**
* Handle file system events
*/
private handleFileEvent;
/**
* Load all TTL files
*/
private loadTTLFiles;
/**
* Load a single TTL file
*/
private loadTTLFile;
/**
* Parse TTL content (simplified)
*/
private parseTTLContent;
/**
* Extract metadata from TTL content
*/
private extractTTLMetadata;
/**
* Extract module name from path
*/
private extractModuleName;
/**
* Extract language from path/content
*/
private extractLanguage;
/**
* Extract dependencies from content
*/
private extractDependencies;
/**
* Send response to client
*/
private sendResponse;
/**
* Send error to client
*/
private sendError;
/**
* Send notification to client
*/
private sendNotification;
/**
* Broadcast notification to all clients
*/
private broadcastNotification;
/**
* Send message to client
*/
private sendMessage;
/**
* Get error code for MCP error
*/
private getErrorCode;
/**
* Update response time metrics
*/
private updateResponseTimeMetrics;
/**
* Generate cache key for context request
*/
private generateCacheKey;
/**
* Get cached context
*/
private getCachedContext;
/**
* Cache context response
*/
private cacheContext;
/**
* Clear cache related to a file
*/
private clearRelatedCache;
/**
* Estimate tokens in text
*/
private estimateTokens;
/**
* Start cache cleanup interval
*/
private startCacheCleanup;
/**
* Get server status
*/
getStatus(): MCPServerStatus;
/**
* Get server metrics
*/
getMetrics(): MCPServerMetrics;
}
//# sourceMappingURL=MCPServer.d.ts.map