listConfigs
Find configuration files in your workspace by scanning for JSON, YAML, TOML, and other formats using customizable patterns to manage settings.
Instructions
List configuration files in the workspace matching specified patterns
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| include | No | Glob patterns for config files |
Implementation Reference
- src/index.ts:121-131 (handler)The handler function for the 'listConfigs' tool. It calls the searchFiles helper with an empty query and listOnly: true to list configuration files matching the provided glob patterns.async ({ include }: { include: string[] }) => { try { const items = await searchFiles("", include, { listOnly: true, maxResults: 200 }); return { content: items }; } catch (error) { return { content: [{ type: "text", text: `Error listing configs: ${error}` }], isError: true, }; } }
- src/index.ts:115-120 (schema)Input schema for the 'listConfigs' tool, defining the optional 'include' parameter with default glob patterns for common config file extensions.{ include: z .array(z.string()) .default(["**/*.{json,jsonc,yaml,yml,toml}"]) .describe("Glob patterns for config files"), },
- src/index.ts:112-132 (registration)Registration of the 'listConfigs' tool using mcp.tool(), including name, description, input schema, and inline handler function.mcp.tool( "listConfigs", "List configuration files in the workspace matching specified patterns", { include: z .array(z.string()) .default(["**/*.{json,jsonc,yaml,yml,toml}"]) .describe("Glob patterns for config files"), }, async ({ include }: { include: string[] }) => { try { const items = await searchFiles("", include, { listOnly: true, maxResults: 200 }); return { content: items }; } catch (error) { return { content: [{ type: "text", text: `Error listing configs: ${error}` }], isError: true, }; } } );
- src/lib/search.ts:15-46 (helper)The searchFiles helper function, crucial for listConfigs as it performs glob file searching and listing (when listOnly=true), filtering, and preview generation.export async function searchFiles( query: string, include: string[], options: SearchOptions = {} ): Promise<SearchResultItem[]> { const { maxResults = 100, listOnly = false } = options; const files = await fg(include, { dot: false, ignore: ["**/node_modules/**", "**/.git/**", "**/dist/**"], unique: true, }); const results: SearchResultItem[] = []; for (const file of files) { if (listOnly) { results.push({ type: "text", text: file }); if (results.length >= maxResults) break; continue; } try { const content = await fs.readFile(file, "utf8"); if (!query || content.toLowerCase().includes(query.toLowerCase())) { const preview = content.slice(0, 2000); results.push({ type: "text", text: `# ${file}\n\n${preview}` }); } if (results.length >= maxResults) break; } catch { // ignore unreadable files } } return results; }