UNPKG

knip-mcp-server

Version:

MCP server for knip.dev integration to help AI agents identify and clean up unused code

269 lines 10.1 kB
import { z } from 'zod'; export interface KnipAnalysisResult { files: string[]; exports: Record<string, string[]>; imports: Record<string, string[]>; dependencies: string[]; devDependencies: string[]; issues: KnipIssue[]; } export interface KnipIssue { type: 'file' | 'export' | 'import' | 'dependency' | 'devDependency'; filePath: string; name?: string; line?: number; column?: number; severity: 'error' | 'warning' | 'info'; message: string; } export interface KnipConfig { include?: string[]; exclude?: string[]; ignore?: string[]; ignoreDependencies?: string[]; ignoreExports?: string[]; workspaces?: Record<string, KnipWorkspaceConfig>; plugins?: string[]; compilerOptions?: Record<string, unknown>; } export interface KnipWorkspaceConfig { include?: string[]; exclude?: string[]; ignore?: string[]; ignoreDependencies?: string[]; ignoreExports?: string[]; } export declare const KnipScanInputSchema: z.ZodObject<{ projectPath: z.ZodOptional<z.ZodString>; configPath: z.ZodOptional<z.ZodString>; includePaths: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; excludePaths: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; dryRun: z.ZodDefault<z.ZodBoolean>; workspace: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { dryRun: boolean; projectPath?: string | undefined; configPath?: string | undefined; includePaths?: string[] | undefined; excludePaths?: string[] | undefined; workspace?: string | undefined; }, { projectPath?: string | undefined; configPath?: string | undefined; includePaths?: string[] | undefined; excludePaths?: string[] | undefined; dryRun?: boolean | undefined; workspace?: string | undefined; }>; export declare const KnipScanOutputSchema: z.ZodObject<{ success: z.ZodBoolean; result: z.ZodOptional<z.ZodObject<{ unusedFiles: z.ZodArray<z.ZodString, "many">; unusedExports: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>; unusedImports: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>; unusedDependencies: z.ZodArray<z.ZodString, "many">; unusedDevDependencies: z.ZodArray<z.ZodString, "many">; issues: z.ZodArray<z.ZodObject<{ type: z.ZodEnum<["file", "export", "import", "dependency", "devDependency"]>; filePath: z.ZodString; name: z.ZodOptional<z.ZodString>; line: z.ZodOptional<z.ZodNumber>; column: z.ZodOptional<z.ZodNumber>; severity: z.ZodEnum<["error", "warning", "info"]>; message: z.ZodString; }, "strip", z.ZodTypeAny, { message: string; type: "file" | "export" | "import" | "dependency" | "devDependency"; filePath: string; severity: "error" | "warning" | "info"; name?: string | undefined; line?: number | undefined; column?: number | undefined; }, { message: string; type: "file" | "export" | "import" | "dependency" | "devDependency"; filePath: string; severity: "error" | "warning" | "info"; name?: string | undefined; line?: number | undefined; column?: number | undefined; }>, "many">; }, "strip", z.ZodTypeAny, { issues: { message: string; type: "file" | "export" | "import" | "dependency" | "devDependency"; filePath: string; severity: "error" | "warning" | "info"; name?: string | undefined; line?: number | undefined; column?: number | undefined; }[]; unusedFiles: string[]; unusedExports: Record<string, string[]>; unusedImports: Record<string, string[]>; unusedDependencies: string[]; unusedDevDependencies: string[]; }, { issues: { message: string; type: "file" | "export" | "import" | "dependency" | "devDependency"; filePath: string; severity: "error" | "warning" | "info"; name?: string | undefined; line?: number | undefined; column?: number | undefined; }[]; unusedFiles: string[]; unusedExports: Record<string, string[]>; unusedImports: Record<string, string[]>; unusedDependencies: string[]; unusedDevDependencies: string[]; }>>; error: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { success: boolean; error?: string | undefined; result?: { issues: { message: string; type: "file" | "export" | "import" | "dependency" | "devDependency"; filePath: string; severity: "error" | "warning" | "info"; name?: string | undefined; line?: number | undefined; column?: number | undefined; }[]; unusedFiles: string[]; unusedExports: Record<string, string[]>; unusedImports: Record<string, string[]>; unusedDependencies: string[]; unusedDevDependencies: string[]; } | undefined; }, { success: boolean; error?: string | undefined; result?: { issues: { message: string; type: "file" | "export" | "import" | "dependency" | "devDependency"; filePath: string; severity: "error" | "warning" | "info"; name?: string | undefined; line?: number | undefined; column?: number | undefined; }[]; unusedFiles: string[]; unusedExports: Record<string, string[]>; unusedImports: Record<string, string[]>; unusedDependencies: string[]; unusedDevDependencies: string[]; } | undefined; }>; export declare const KnipRemoveUnusedFilesInputSchema: z.ZodObject<{ files: z.ZodArray<z.ZodString, "many">; dryRun: z.ZodDefault<z.ZodBoolean>; createBackup: z.ZodDefault<z.ZodBoolean>; backupDir: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { dryRun: boolean; files: string[]; createBackup: boolean; backupDir?: string | undefined; }, { files: string[]; dryRun?: boolean | undefined; createBackup?: boolean | undefined; backupDir?: string | undefined; }>; export declare const KnipRemoveUnusedImportsInputSchema: z.ZodObject<{ filePath: z.ZodString; imports: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; dryRun: z.ZodDefault<z.ZodBoolean>; createBackup: z.ZodDefault<z.ZodBoolean>; }, "strip", z.ZodTypeAny, { dryRun: boolean; filePath: string; createBackup: boolean; imports?: string[] | undefined; }, { filePath: string; dryRun?: boolean | undefined; createBackup?: boolean | undefined; imports?: string[] | undefined; }>; export declare const KnipFixIssuesInputSchema: z.ZodObject<{ projectPath: z.ZodOptional<z.ZodString>; issueTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["files", "imports", "exports", "dependencies"]>, "many">>; dryRun: z.ZodDefault<z.ZodBoolean>; createBackup: z.ZodDefault<z.ZodBoolean>; interactive: z.ZodDefault<z.ZodBoolean>; maxFiles: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { dryRun: boolean; createBackup: boolean; interactive: boolean; projectPath?: string | undefined; issueTypes?: ("files" | "imports" | "exports" | "dependencies")[] | undefined; maxFiles?: number | undefined; }, { projectPath?: string | undefined; dryRun?: boolean | undefined; createBackup?: boolean | undefined; issueTypes?: ("files" | "imports" | "exports" | "dependencies")[] | undefined; interactive?: boolean | undefined; maxFiles?: number | undefined; }>; export declare const KnipGetConfigInputSchema: z.ZodObject<{ projectPath: z.ZodOptional<z.ZodString>; configPath: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { projectPath?: string | undefined; configPath?: string | undefined; }, { projectPath?: string | undefined; configPath?: string | undefined; }>; export declare const KnipValidateConfigInputSchema: z.ZodObject<{ projectPath: z.ZodOptional<z.ZodString>; configPath: z.ZodOptional<z.ZodString>; config: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>; }, "strip", z.ZodTypeAny, { projectPath?: string | undefined; configPath?: string | undefined; config?: {} | undefined; }, { projectPath?: string | undefined; configPath?: string | undefined; config?: {} | undefined; }>; export type KnipScanInput = z.infer<typeof KnipScanInputSchema>; export type KnipScanOutput = z.infer<typeof KnipScanOutputSchema>; export type KnipRemoveUnusedFilesInput = z.infer<typeof KnipRemoveUnusedFilesInputSchema>; export type KnipRemoveUnusedImportsInput = z.infer<typeof KnipRemoveUnusedImportsInputSchema>; export type KnipFixIssuesInput = z.infer<typeof KnipFixIssuesInputSchema>; export type KnipGetConfigInput = z.infer<typeof KnipGetConfigInputSchema>; export type KnipValidateConfigInput = z.infer<typeof KnipValidateConfigInputSchema>; export interface KnipMcpServerConfig { projectRoot?: string; knipConfigPath?: string; backupDir?: string; logLevel?: 'debug' | 'info' | 'warn' | 'error'; enableSafeMode?: boolean; maxFileSize?: number; maxFilesPerOperation?: number; } export declare class KnipMcpError extends Error { code: string; details?: Record<string, unknown> | undefined; constructor(message: string, code: string, details?: Record<string, unknown> | undefined); } export declare class KnipAnalysisError extends KnipMcpError { constructor(message: string, details?: Record<string, unknown>); } export declare class KnipConfigError extends KnipMcpError { constructor(message: string, details?: Record<string, unknown>); } export declare class KnipFileSystemError extends KnipMcpError { constructor(message: string, details?: Record<string, unknown>); } //# sourceMappingURL=index.d.ts.map