UNPKG

knip-mcp-server

Version:

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

55 lines 2.13 kB
import { KnipGetConfigInputSchema } from '../types/index.js'; export function createKnipGetConfigTool(knipClient, config) { return { name: 'knip_get_config', description: 'Get the current knip configuration', inputSchema: { type: 'object', properties: { projectPath: { type: 'string', description: 'Path to the project (defaults to current directory)', }, configPath: { type: 'string', description: 'Specific path to knip configuration file', }, }, }, execute: async (args) => { try { const input = KnipGetConfigInputSchema.parse(args); const knipConfig = await knipClient.getConfig(); if (!knipConfig) { return { success: true, config: null, message: 'No knip configuration found. Using default settings.', searchedPaths: [ 'knip.json', 'knip.jsonc', '.knip.json', '.knip.jsonc', 'knip.config.js', 'knip.config.ts', ], }; } return { success: true, config: knipConfig, hasWorkspaces: !!(knipConfig.workspaces && Object.keys(knipConfig.workspaces).length > 0), workspaceCount: knipConfig.workspaces ? Object.keys(knipConfig.workspaces).length : 0, plugins: knipConfig.plugins || [], }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error), }; } }, }; } //# sourceMappingURL=knip-get-config.js.map