Skip to content

feat: add cmd support for allowing all tools #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,13 @@ const DEFAULT_ALLOW_TOOLS = [
];
const ALLOW_TOOLS_OPTIONS_TUPLE = [
"-t, --allow-tools <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;

Expand All @@ -75,7 +80,7 @@ function formatErrorForCli(error: unknown): string {
program
.command("start-server", { isDefault: true })
.description("Starts the Algolia MCP server")
.option<string[]>(...ALLOW_TOOLS_OPTIONS_TUPLE)
.option<string[] | undefined>(...ALLOW_TOOLS_OPTIONS_TUPLE)
.option(
"--credentials <applicationId:apiKey>",
"Application ID and associated API key to use. Optional: the MCP will authenticate you if unspecified, giving you access to all your applications.",
Expand Down Expand Up @@ -116,7 +121,7 @@ program
program
.command("list-tools")
.description("List available tools")
.option<string[]>(...ALLOW_TOOLS_OPTIONS_TUPLE)
.option<string[] | undefined>(...ALLOW_TOOLS_OPTIONS_TUPLE)
.option("--all", "List all tools")
.action(async (opts: ListToolsOptions) => {
const { listTools } = await import("./commands/list-tools.ts");
Expand Down
10 changes: 10 additions & 0 deletions src/commands/list-tools.ts
Original file line number Diff line number Diff line change
@@ -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;
};
Expand Down