mcp-adr-analysis-server
Version:
MCP server for analyzing Architectural Decision Records and project architecture
184 lines • 4.85 kB
TypeScript
/**
* Tree-Sitter Code Analysis Tools
*
* Provides deterministic code structure analysis tools for MCP.
* These tools replace non-deterministic ripgrep-based search with
* AST-based structural analysis.
*
* Design Philosophy (per ADR-016):
* - Tools provide deterministic data
* - LLM handles reasoning and semantic matching
* - Same input always produces same output
*
* @see docs/adrs/adr-016-replace-ripgrep-with-tree-sitter.md
*/
import { CodeAnalysisResult, type ImportAnalysis, type FunctionAnalysis } from '../utils/tree-sitter-analyzer.js';
/**
* File structure entry
*/
export interface FileEntry {
path: string;
relativePath: string;
type: 'file' | 'directory';
extension?: string;
language?: string;
size?: number;
}
/**
* Project structure result
*/
export interface ProjectStructureResult {
root: string;
totalFiles: number;
totalDirectories: number;
filesByLanguage: Record<string, number>;
entries: FileEntry[];
}
/**
* Import extraction result
*/
export interface ImportExtractionResult {
file: string;
language: string;
imports: ImportAnalysis[];
externalDependencies: string[];
internalDependencies: string[];
}
/**
* Function extraction result
*/
export interface FunctionExtractionResult {
file: string;
language: string;
functions: FunctionAnalysis[];
totalFunctions: number;
securitySensitiveFunctions: string[];
}
/**
* Class/Module definition
*/
export interface ClassDefinition {
name: string;
type: 'class' | 'interface' | 'type' | 'enum';
methods: string[];
properties: string[];
location: {
line: number;
column: number;
};
exported: boolean;
}
/**
* Class extraction result
*/
export interface ClassExtractionResult {
file: string;
language: string;
classes: ClassDefinition[];
interfaces: ClassDefinition[];
types: ClassDefinition[];
}
/**
* Dependency from package.json or requirements.txt
*/
export interface DependencyInfo {
name: string;
version: string;
type: 'production' | 'development' | 'peer' | 'optional';
source: string;
}
/**
* Project dependencies result
*/
export interface DependenciesResult {
projectPath: string;
dependencies: DependencyInfo[];
totalCount: number;
byType: Record<string, number>;
}
/**
* Export definition
*/
export interface ExportDefinition {
name: string;
type: 'function' | 'class' | 'const' | 'type' | 'interface' | 'default' | 'variable';
location: {
line: number;
column: number;
};
isDefault: boolean;
}
/**
* Export extraction result
*/
export interface ExportExtractionResult {
file: string;
language: string;
exports: ExportDefinition[];
hasDefaultExport: boolean;
namedExports: string[];
}
/**
* Get deterministic file structure of a project
*
* Returns a complete file tree without any search or filtering.
* The LLM can then decide which files are relevant.
*/
export declare function getFileStructure(projectPath: string, options?: {
maxDepth?: number;
includeHidden?: boolean;
excludePatterns?: string[];
}): Promise<ProjectStructureResult>;
/**
* Get AST-extracted imports from a file
*
* Returns deterministic list of all imports/requires in a file.
*/
export declare function getImports(filePath: string): Promise<ImportExtractionResult>;
/**
* Get AST-extracted exports from a file
*
* Returns deterministic list of all exports in a file.
*/
export declare function getExports(filePath: string): Promise<ExportExtractionResult>;
/**
* Get AST-extracted functions from a file
*
* Returns deterministic list of all functions with signatures.
*/
export declare function getFunctions(filePath: string): Promise<FunctionExtractionResult>;
/**
* Get classes, interfaces, and types from a file
*
* Returns deterministic list of class/interface/type definitions.
*/
export declare function getClasses(filePath: string): Promise<ClassExtractionResult>;
/**
* Get project dependencies from manifest files
*
* Parses package.json, requirements.txt, etc. for dependencies.
*/
export declare function getDependencies(projectPath: string): Promise<DependenciesResult>;
/**
* Perform full tree-sitter analysis on a file
*
* Returns complete AST analysis result.
*/
export declare function analyzeFile(filePath: string): Promise<CodeAnalysisResult>;
/**
* Analyze multiple files in a directory
*
* Returns analysis results for all code files.
*/
export declare function analyzeDirectory(dirPath: string, options?: {
extensions?: string[];
maxFiles?: number;
recursive?: boolean;
}): Promise<{
files: Array<{
path: string;
analysis: CodeAnalysisResult;
}>;
errors: string[];
}>;
//# sourceMappingURL=tree-sitter-code-tools.d.ts.map