diff --git a/src/app.ts b/src/app.ts index 25541f3..4a8b48b 100644 --- a/src/app.ts +++ b/src/app.ts @@ -53,8 +53,13 @@ const DEFAULT_ALLOW_TOOLS = [ ]; const ALLOW_TOOLS_OPTIONS_TUPLE = [ "-t, --allow-tools ", - "Comma separated list of tool ids", - (val: string) => val.split(",").map((s) => s.trim()), + "Comma separated list of tool ids (or all)", + (val: string) => { + if (val.trim().toLowerCase() === "all") { + return undefined; + } + return val.split(",").map((tool) => tool.trim()); + }, DEFAULT_ALLOW_TOOLS, ] as const; @@ -75,7 +80,7 @@ function formatErrorForCli(error: unknown): string { program .command("start-server", { isDefault: true }) .description("Starts the Algolia MCP server") - .option(...ALLOW_TOOLS_OPTIONS_TUPLE) + .option(...ALLOW_TOOLS_OPTIONS_TUPLE) .option( "--credentials ", "Application ID and associated API key to use. Optional: the MCP will authenticate you if unspecified, giving you access to all your applications.", @@ -116,7 +121,7 @@ program program .command("list-tools") .description("List available tools") - .option(...ALLOW_TOOLS_OPTIONS_TUPLE) + .option(...ALLOW_TOOLS_OPTIONS_TUPLE) .option("--all", "List all tools") .action(async (opts: ListToolsOptions) => { const { listTools } = await import("./commands/list-tools.ts"); diff --git a/src/commands/list-tools.ts b/src/commands/list-tools.ts index d2ea312..70d8d84 100644 --- a/src/commands/list-tools.ts +++ b/src/commands/list-tools.ts @@ -1,8 +1,18 @@ import { operationId as GetUserInfoOperationId } from "../tools/registerGetUserInfo.ts"; import { operationId as GetApplicationsOperationId } from "../tools/registerGetApplications.ts"; import { ALL_SPECS, type OpenApiSpec } from "../openApi.ts"; +import type { ToolFilter } from "../toolFilters.ts"; import { type CliFilteringOptions, getToolFilter, isToolAllowed } from "../toolFilters.ts"; +export function getToolIds(toolFilter?: ToolFilter): string[] { + const results = []; + for (const spec of ALL_SPECS) { + const toolIds = extractToolIds(spec).filter((id) => isToolAllowed(id, toolFilter)); + results.push(...toolIds); + } + return results; +} + export type ListToolsOptions = CliFilteringOptions & { all: boolean; };