knip-mcp-server
Version:
MCP server for knip.dev integration to help AI agents identify and clean up unused code
41 lines • 1.55 kB
JavaScript
export function createKnipGetUnusedExportsTool(knipClient, config) {
return {
name: 'knip_get_unused_exports',
description: 'Get unused exports organized by file',
inputSchema: {
type: 'object',
properties: {
workspace: {
type: 'string',
description: 'Specific workspace to analyze (for monorepo setups)',
},
filePath: {
type: 'string',
description: 'Get unused exports for a specific file only',
},
},
},
execute: async (args) => {
try {
const unusedExports = await knipClient.getUnusedExports(args.filePath, args.workspace);
const result = args.filePath
? { [args.filePath]: unusedExports[args.filePath] || [] }
: unusedExports;
const totalCount = Object.values(result).reduce((sum, exports) => sum + exports.length, 0);
return {
success: true,
unusedExports: result,
totalCount,
fileCount: Object.keys(result).length,
};
}
catch (error) {
return {
success: false,
error: error instanceof Error ? error.message : String(error),
};
}
},
};
}
//# sourceMappingURL=knip-get-unused-exports.js.map