diff --git a/desktop/README.md b/desktop/README.md index 6c941b5..cddd3ac 100644 --- a/desktop/README.md +++ b/desktop/README.md @@ -46,6 +46,8 @@ Available tools: - `quantlab_outputs_list` - `quantlab_artifact_read` +`quantlab_outputs_list` accepts optional `relative_path` and `entry_kind` filters (`all`, `directory`, `file`). + The server entrypoint is `mcp-server.mjs`, and the `mcp` npm script runs it directly. ## Current Tabs diff --git a/desktop/mcp-server.mjs b/desktop/mcp-server.mjs index 814e8fe..155f22d 100644 --- a/desktop/mcp-server.mjs +++ b/desktop/mcp-server.mjs @@ -113,7 +113,7 @@ async function runPythonCli(args, timeoutMs = 120000) { }); } -async function listOutputs(relativePath = "") { +async function listOutputs(relativePath = "", entryKind = "all") { const targetPath = resolveOutputsPath(relativePath); const stat = await fs.stat(targetPath); if (!stat.isDirectory()) { @@ -142,12 +142,20 @@ async function listOutputs(relativePath = "") { return left.name.localeCompare(right.name); }); + let filtered = detailed; + if (entryKind === "directory") { + filtered = detailed.filter((item) => item.kind === "directory"); + } else if (entryKind === "file") { + filtered = detailed.filter((item) => item.kind === "file"); + } + return { root: "outputs", requested_path: relativePath || ".", absolute_path: targetPath, - entry_count: detailed.length, - entries: detailed, + entry_kind: entryKind, + entry_count: filtered.length, + entries: filtered, }; } @@ -286,13 +294,19 @@ async function main() { }); server.registerTool("quantlab_outputs_list", { - description: "List artifacts and directories under outputs/.", + description: + "List artifacts and directories under outputs/. Optional entry_kind filters to files or directories only (default all).", inputSchema: { relative_path: z.string().optional().default("").describe("Path relative to outputs/"), + entry_kind: z + .enum(["all", "directory", "file"]) + .optional() + .default("all") + .describe('List "all" entries, or only "directory" or "file"'), }, - }, async ({ relative_path }) => { + }, async ({ relative_path, entry_kind }) => { try { - const payload = await listOutputs(relative_path); + const payload = await listOutputs(relative_path, entry_kind); return { content: [ {