tree-ast-grep-mcp
Version:
Simple, direct ast-grep wrapper for AI coding agents. Zero abstractions, maximum performance.
50 lines • 1.9 kB
TypeScript
import { PathResolver, ResolvedPaths } from './path-resolver.js';
import { ParameterValidator } from './validator.js';
import { WorkspaceManager } from './workspace-manager.js';
import { AstGrepBinaryManager } from './binary-manager.js';
/**
* Provides shared validation and path handling utilities for MCP tools.
*/
export declare abstract class BaseTool {
protected workspaceManager: WorkspaceManager;
protected binaryManager: AstGrepBinaryManager;
protected pathResolver: PathResolver;
protected validator: ParameterValidator;
/**
* Create a tool with workspace context and binary access.
*/
constructor(workspaceManager: WorkspaceManager, binaryManager: AstGrepBinaryManager);
/**
* Resolve provided paths and ensure they are accessible within the workspace.
*/
protected resolveAndValidatePaths(paths?: string[]): Promise<ResolvedPaths>;
/**
* Resolve paths synchronously when asynchronous access is unnecessary.
*/
protected resolveAndValidatePathsSync(paths?: string[]): ResolvedPaths;
/**
* Construct ast-grep arguments that apply to all tool executions.
*/
protected buildCommonArgs(params: any): string[];
/**
* Add language hint flags when one is provided by the caller.
*/
protected buildLanguageArgs(language?: string): string[];
/**
* Request JSON output in the format expected by downstream parsers.
*/
protected buildJsonArgs(jsonStyle?: string): string[];
/**
* Normalize file paths for consistent display
*/
protected normalizePath(filePath: string, relativePaths?: boolean): string;
/**
* Get workspace root for context
*/
protected getWorkspaceRoot(): string;
/**
* Abstract method that each tool must implement
*/
abstract execute(params: any): Promise<any>;
}
//# sourceMappingURL=tool-base.d.ts.map