firebase-tools 14.20.0 → 14.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/lib/appUtils.js +2 -1
  2. package/lib/command.js +5 -9
  3. package/lib/commands/dataconnect-sdk-generate.js +66 -11
  4. package/lib/commands/firestore-databases-clone.js +99 -0
  5. package/lib/commands/functions-secrets-set.js +19 -1
  6. package/lib/commands/index.js +1 -0
  7. package/lib/commands/init.js +12 -8
  8. package/lib/commands/internaltesting-functions-discover.js +1 -3
  9. package/lib/dataconnect/provisionCloudSql.js +3 -2
  10. package/lib/deploy/extensions/prepare.js +3 -1
  11. package/lib/deploy/functions/checkIam.js +1 -1
  12. package/lib/deploy/functions/functionsDeployHelper.js +8 -7
  13. package/lib/deploy/functions/params.js +17 -3
  14. package/lib/deploy/functions/prepare.js +9 -6
  15. package/lib/detectProjectRoot.js +1 -1
  16. package/lib/emulator/downloadableEmulatorInfo.json +18 -18
  17. package/lib/emulator/hubExport.js +5 -0
  18. package/lib/experiments.js +0 -7
  19. package/lib/firestore/api.js +15 -0
  20. package/lib/firestore/util.js +22 -1
  21. package/lib/functions/projectConfig.js +5 -1
  22. package/lib/functions/secrets.js +14 -1
  23. package/lib/init/features/dataconnect/index.js +21 -20
  24. package/lib/init/features/dataconnect/sdk.js +44 -21
  25. package/lib/init/features/functions/index.js +1 -0
  26. package/lib/init/index.js +2 -2
  27. package/lib/mcp/index.js +46 -18
  28. package/lib/mcp/prompt.js +4 -1
  29. package/lib/mcp/prompts/core/consult.js +1 -1
  30. package/lib/mcp/prompts/core/deploy.js +1 -1
  31. package/lib/mcp/prompts/core/init.js +1 -1
  32. package/lib/mcp/prompts/crashlytics/connect.js +1 -1
  33. package/lib/mcp/prompts/dataconnect/schema.js +1 -1
  34. package/lib/mcp/prompts/index.js +20 -10
  35. package/lib/mcp/tool.js +17 -2
  36. package/lib/mcp/tools/apphosting/fetch_logs.js +1 -1
  37. package/lib/mcp/tools/apphosting/list_backends.js +1 -1
  38. package/lib/mcp/tools/auth/get_users.js +1 -1
  39. package/lib/mcp/tools/auth/set_sms_region_policy.js +1 -1
  40. package/lib/mcp/tools/auth/update_user.js +1 -1
  41. package/lib/mcp/tools/core/create_android_sha.js +1 -1
  42. package/lib/mcp/tools/core/create_app.js +1 -1
  43. package/lib/mcp/tools/core/create_project.js +1 -1
  44. package/lib/mcp/tools/core/get_environment.js +1 -1
  45. package/lib/mcp/tools/core/get_project.js +1 -1
  46. package/lib/mcp/tools/core/get_sdk_config.js +1 -1
  47. package/lib/mcp/tools/core/get_security_rules.js +1 -1
  48. package/lib/mcp/tools/core/init.js +3 -2
  49. package/lib/mcp/tools/core/list_apps.js +1 -1
  50. package/lib/mcp/tools/core/list_projects.js +1 -1
  51. package/lib/mcp/tools/core/login.js +1 -1
  52. package/lib/mcp/tools/core/logout.js +1 -1
  53. package/lib/mcp/tools/core/read_resources.js +1 -1
  54. package/lib/mcp/tools/core/update_environment.js +1 -1
  55. package/lib/mcp/tools/core/validate_security_rules.js +15 -1
  56. package/lib/mcp/tools/crashlytics/events.js +3 -3
  57. package/lib/mcp/tools/crashlytics/issues.js +3 -3
  58. package/lib/mcp/tools/crashlytics/notes.js +4 -4
  59. package/lib/mcp/tools/crashlytics/reports.js +6 -6
  60. package/lib/mcp/tools/dataconnect/compile.js +1 -1
  61. package/lib/mcp/tools/dataconnect/execute.js +1 -1
  62. package/lib/mcp/tools/dataconnect/generate_operation.js +1 -1
  63. package/lib/mcp/tools/dataconnect/generate_schema.js +1 -1
  64. package/lib/mcp/tools/dataconnect/list_services.js +1 -1
  65. package/lib/mcp/tools/firestore/delete_document.js +1 -1
  66. package/lib/mcp/tools/firestore/get_documents.js +1 -1
  67. package/lib/mcp/tools/firestore/list_collections.js +1 -1
  68. package/lib/mcp/tools/firestore/query_collection.js +1 -1
  69. package/lib/mcp/tools/functions/get_logs.js +1 -1
  70. package/lib/mcp/tools/index.js +14 -4
  71. package/lib/mcp/tools/messaging/send_message.js +1 -1
  72. package/lib/mcp/tools/realtime_database/get_data.js +1 -1
  73. package/lib/mcp/tools/realtime_database/set_data.js +1 -1
  74. package/lib/mcp/tools/remoteconfig/get_template.js +1 -1
  75. package/lib/mcp/tools/remoteconfig/update_template.js +1 -1
  76. package/lib/mcp/tools/storage/get_download_url.js +1 -1
  77. package/lib/mcp/util/availability.js +22 -0
  78. package/lib/mcp/util/crashlytics/availability.js +81 -0
  79. package/lib/mcp/util.js +26 -6
  80. package/package.json +1 -1
  81. package/schema/firebase-config.json +3 -0
@@ -5,15 +5,15 @@ const core_1 = require("./core");
5
5
  const dataconnect_1 = require("./dataconnect");
6
6
  const crashlytics_1 = require("./crashlytics");
7
7
  const prompts = {
8
- core: core_1.corePrompts,
8
+ core: namespacePrompts(core_1.corePrompts, "core"),
9
9
  firestore: [],
10
10
  storage: [],
11
- dataconnect: dataconnect_1.dataconnectPrompts,
11
+ dataconnect: namespacePrompts(dataconnect_1.dataconnectPrompts, "dataconnect"),
12
12
  auth: [],
13
13
  messaging: [],
14
14
  functions: [],
15
15
  remoteconfig: [],
16
- crashlytics: crashlytics_1.crashlyticsPrompts,
16
+ crashlytics: namespacePrompts(crashlytics_1.crashlyticsPrompts, "crashlytics"),
17
17
  apphosting: [],
18
18
  database: [],
19
19
  };
@@ -33,23 +33,33 @@ function namespacePrompts(promptsToNamespace, feature) {
33
33
  return newPrompt;
34
34
  });
35
35
  }
36
- function availablePrompts(activeFeatures) {
37
- const allPrompts = [];
36
+ async function availablePrompts(ctx, activeFeatures) {
37
+ const allPrompts = getAllPrompts(activeFeatures);
38
+ const availabilities = await Promise.all(allPrompts.map((p) => {
39
+ if (p.isAvailable) {
40
+ return p.isAvailable(ctx);
41
+ }
42
+ return true;
43
+ }));
44
+ return allPrompts.filter((_, i) => availabilities[i]);
45
+ }
46
+ exports.availablePrompts = availablePrompts;
47
+ function getAllPrompts(activeFeatures) {
48
+ const promptDefs = [];
38
49
  if (!(activeFeatures === null || activeFeatures === void 0 ? void 0 : activeFeatures.length)) {
39
50
  activeFeatures = Object.keys(prompts);
40
51
  }
41
52
  if (!activeFeatures.includes("core")) {
42
- activeFeatures = ["core", ...activeFeatures];
53
+ activeFeatures.unshift("core");
43
54
  }
44
55
  for (const feature of activeFeatures) {
45
- allPrompts.push(...namespacePrompts(prompts[feature], feature));
56
+ promptDefs.push(...prompts[feature]);
46
57
  }
47
- return allPrompts;
58
+ return promptDefs;
48
59
  }
49
- exports.availablePrompts = availablePrompts;
50
60
  function markdownDocsOfPrompts() {
51
61
  var _a, _b;
52
- const allPrompts = availablePrompts();
62
+ const allPrompts = getAllPrompts();
53
63
  let doc = `
54
64
  | Prompt Name | Feature Group | Description |
55
65
  | ----------- | ------------- | ----------- |`;
package/lib/mcp/tool.js CHANGED
@@ -1,12 +1,27 @@
1
1
  "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  exports.tool = void 0;
4
15
  const zod_to_json_schema_1 = require("zod-to-json-schema");
5
16
  const util_1 = require("./util");
6
- function tool(options, fn) {
17
+ const availability_1 = require("./util/availability");
18
+ function tool(feature, options, fn) {
19
+ const { isAvailable } = options, mcpOptions = __rest(options, ["isAvailable"]);
20
+ const isAvailableFunc = isAvailable || (0, availability_1.getDefaultFeatureAvailabilityCheck)(feature);
7
21
  return {
8
- mcp: Object.assign(Object.assign({}, options), { inputSchema: (0, util_1.cleanSchema)((0, zod_to_json_schema_1.zodToJsonSchema)(options.inputSchema)) }),
22
+ mcp: Object.assign(Object.assign({}, mcpOptions), { inputSchema: (0, util_1.cleanSchema)((0, zod_to_json_schema_1.zodToJsonSchema)(options.inputSchema)) }),
9
23
  fn,
24
+ isAvailable: isAvailableFunc,
10
25
  };
11
26
  }
12
27
  exports.tool = tool;
@@ -9,7 +9,7 @@ const utils_1 = require("../../../utils");
9
9
  const error_1 = require("../../../error");
10
10
  const run_1 = require("../../../gcp/run");
11
11
  const cloudlogging_1 = require("../../../gcp/cloudlogging");
12
- exports.fetch_logs = (0, tool_1.tool)({
12
+ exports.fetch_logs = (0, tool_1.tool)("apphosting", {
13
13
  name: "fetch_logs",
14
14
  description: "Use this to fetch the most recent logs for a specified App Hosting backend. If `buildLogs` is specified, the logs from the build process for the latest build are returned. The most recent logs are listed first.",
15
15
  inputSchema: zod_1.z.object({
@@ -5,7 +5,7 @@ const zod_1 = require("zod");
5
5
  const tool_1 = require("../../tool");
6
6
  const util_1 = require("../../util");
7
7
  const apphosting_1 = require("../../../gcp/apphosting");
8
- exports.list_backends = (0, tool_1.tool)({
8
+ exports.list_backends = (0, tool_1.tool)("apphosting", {
9
9
  name: "list_backends",
10
10
  description: "Use this to retrieve a list of App Hosting backends in the current project. An empty list means that there are no backends. " +
11
11
  "The `uri` is the public URL of the backend. " +
@@ -16,7 +16,7 @@ const zod_1 = require("zod");
16
16
  const tool_1 = require("../../tool");
17
17
  const util_1 = require("../../util");
18
18
  const auth_1 = require("../../../gcp/auth");
19
- exports.get_users = (0, tool_1.tool)({
19
+ exports.get_users = (0, tool_1.tool)("auth", {
20
20
  name: "get_users",
21
21
  description: "Use this to retrieve one or more Firebase Auth users based on a list of UIDs or a list of emails.",
22
22
  inputSchema: zod_1.z.object({
@@ -5,7 +5,7 @@ const zod_1 = require("zod");
5
5
  const tool_1 = require("../../tool");
6
6
  const util_1 = require("../../util");
7
7
  const auth_1 = require("../../../gcp/auth");
8
- exports.set_sms_region_policy = (0, tool_1.tool)({
8
+ exports.set_sms_region_policy = (0, tool_1.tool)("auth", {
9
9
  name: "set_sms_region_policy",
10
10
  description: "Use this to set an SMS region policy for Firebase Authentication to restrict the regions which can receive text messages based on an ALLOW or DENY list of country codes. This policy will override any existing policies when set.",
11
11
  inputSchema: zod_1.z.object({
@@ -5,7 +5,7 @@ const zod_1 = require("zod");
5
5
  const tool_1 = require("../../tool");
6
6
  const util_1 = require("../../util");
7
7
  const auth_1 = require("../../../gcp/auth");
8
- exports.update_user = (0, tool_1.tool)({
8
+ exports.update_user = (0, tool_1.tool)("auth", {
9
9
  name: "update_user",
10
10
  description: "Use this to disable, enable, or set a custom claim on a specific user's account.",
11
11
  inputSchema: zod_1.z.object({
@@ -14,7 +14,7 @@ function getCertHashType(shaHash) {
14
14
  return apps_1.ShaCertificateType.SHA_256.toString();
15
15
  return apps_1.ShaCertificateType.SHA_CERTIFICATE_TYPE_UNSPECIFIED.toString();
16
16
  }
17
- exports.create_android_sha = (0, tool_1.tool)({
17
+ exports.create_android_sha = (0, tool_1.tool)("core", {
18
18
  name: "create_android_sha",
19
19
  description: "Use this to add the specified SHA certificate hash to the specified Firebase Android App.",
20
20
  inputSchema: zod_1.z.object({
@@ -7,7 +7,7 @@ const util_1 = require("../../util");
7
7
  const apps_1 = require("../../../management/apps");
8
8
  const CREATE_APP_OUTUT_PREFIX = "Created app with the following details:\n\n";
9
9
  const CREATE_APP_OUTUT_SUFFIX = "\n\nTo fetch the SDK configuration for this app, use the firebase_get_sdk_config tool.";
10
- exports.create_app = (0, tool_1.tool)({
10
+ exports.create_app = (0, tool_1.tool)("core", {
11
11
  name: "create_app",
12
12
  description: "Use this to create a new Firebase App in the currently active Firebase Project. Firebase Apps can be iOS, Android, or Web.",
13
13
  inputSchema: zod_1.z.object({
@@ -17,7 +17,7 @@ async function checkCloudProject(projectId) {
17
17
  throw err;
18
18
  }
19
19
  }
20
- exports.create_project = (0, tool_1.tool)({
20
+ exports.create_project = (0, tool_1.tool)("core", {
21
21
  name: "create_project",
22
22
  description: "Use this to create a new Firebase Project.",
23
23
  inputSchema: zod_1.z.object({
@@ -9,7 +9,7 @@ const js_yaml_1 = require("js-yaml");
9
9
  const auth_1 = require("../../../auth");
10
10
  const configstore_1 = require("../../../configstore");
11
11
  const appUtils_1 = require("../../../appUtils");
12
- exports.get_environment = (0, tool_1.tool)({
12
+ exports.get_environment = (0, tool_1.tool)("core", {
13
13
  name: "get_environment",
14
14
  description: "Use this to retrieve the current Firebase **environment** configuration for the Firebase CLI and Firebase MCP server, including current authenticated user, project directory, active Firebase Project, and more.",
15
15
  inputSchema: zod_1.z.object({}),
@@ -5,7 +5,7 @@ const zod_1 = require("zod");
5
5
  const tool_1 = require("../../tool");
6
6
  const projects_1 = require("../../../management/projects");
7
7
  const util_1 = require("../../util");
8
- exports.get_project = (0, tool_1.tool)({
8
+ exports.get_project = (0, tool_1.tool)("core", {
9
9
  name: "get_project",
10
10
  description: "Use this to retrieve information about the currently active Firebase Project.",
11
11
  inputSchema: zod_1.z.object({}),
@@ -5,7 +5,7 @@ const zod_1 = require("zod");
5
5
  const tool_1 = require("../../tool");
6
6
  const util_1 = require("../../util");
7
7
  const apps_1 = require("../../../management/apps");
8
- exports.get_sdk_config = (0, tool_1.tool)({
8
+ exports.get_sdk_config = (0, tool_1.tool)("core", {
9
9
  name: "get_sdk_config",
10
10
  description: "Use this to retrieve the Firebase configuration information for a Firebase App. " +
11
11
  "You must specify EITHER a platform OR the Firebase App ID for a Firebase App registered in the currently active Firebase Project.",
@@ -7,7 +7,7 @@ const tool_1 = require("../../tool");
7
7
  const util_1 = require("../../util");
8
8
  const rules_1 = require("../../../gcp/rules");
9
9
  const getDefaultDatabaseInstance_1 = require("../../../getDefaultDatabaseInstance");
10
- exports.get_security_rules = (0, tool_1.tool)({
10
+ exports.get_security_rules = (0, tool_1.tool)("core", {
11
11
  name: "get_security_rules",
12
12
  description: "Use this to retrieve the security rules for a specified Firebase service. " +
13
13
  "If there are multiple instances of that service in the product, the rules for the defualt instance are returned.",
@@ -12,7 +12,7 @@ const error_1 = require("../../../error");
12
12
  const utils_1 = require("../../../init/features/ailogic/utils");
13
13
  const projects_1 = require("../../../management/projects");
14
14
  const dataconnect_1 = require("../../../init/features/dataconnect");
15
- exports.init = (0, tool_1.tool)({
15
+ exports.init = (0, tool_1.tool)("core", {
16
16
  name: "init",
17
17
  description: "Use this to initialize selected Firebase services in the workspace (Cloud Firestore database, Firebase Data Connect, Firebase Realtime Database, Firebase AI Logic). All services are optional; specify only the products you want to set up. " +
18
18
  "You can initialize new features into an existing project directory, but re-initializing an existing feature may overwrite configuration. " +
@@ -157,8 +157,9 @@ exports.init = (0, tool_1.tool)({
157
157
  return err;
158
158
  }
159
159
  featuresList.push("dataconnect");
160
+ featureInfo.dataconnectSource = "mcp_init";
160
161
  featureInfo.dataconnect = {
161
- analyticsFlow: "mcp",
162
+ flow: "",
162
163
  appDescription: features.dataconnect.app_description || "",
163
164
  serviceId: features.dataconnect.service_id || "",
164
165
  locationId: features.dataconnect.location_id || "",
@@ -5,7 +5,7 @@ const zod_1 = require("zod");
5
5
  const tool_1 = require("../../tool");
6
6
  const util_1 = require("../../util");
7
7
  const apps_1 = require("../../../management/apps");
8
- exports.list_apps = (0, tool_1.tool)({
8
+ exports.list_apps = (0, tool_1.tool)("core", {
9
9
  name: "list_apps",
10
10
  description: "Use this to retrieve a list of the Firebase Apps registered in the currently active Firebase project. Firebase Apps can be iOS, Android, or Web.",
11
11
  inputSchema: zod_1.z.object({
@@ -6,7 +6,7 @@ const tool_1 = require("../../tool");
6
6
  const util_1 = require("../../util");
7
7
  const projects_1 = require("../../../management/projects");
8
8
  const PROJECT_LIST_PAGE_SIZE = 20;
9
- exports.list_projects = (0, tool_1.tool)({
9
+ exports.list_projects = (0, tool_1.tool)("core", {
10
10
  name: "list_projects",
11
11
  description: "Use this to retrieve a list of Firebase Projects that the signed-in user has access to.",
12
12
  inputSchema: zod_1.z.object({
@@ -8,7 +8,7 @@ const util_1 = require("../../util");
8
8
  const LoginInputSchema = zod_1.z.object({
9
9
  authCode: zod_1.z.string().optional().describe("The authorization code from the login flow"),
10
10
  });
11
- exports.login = (0, tool_1.tool)({
11
+ exports.login = (0, tool_1.tool)("core", {
12
12
  name: "login",
13
13
  description: "Use this to sign the user into the Firebase CLI and Firebase MCP server. This requires a Google Account, and sign in is required to create and work with Firebase Projects.",
14
14
  inputSchema: LoginInputSchema,
@@ -6,7 +6,7 @@ const tool_1 = require("../../tool");
6
6
  const util_1 = require("../../util");
7
7
  const auth_1 = require("../../../auth");
8
8
  const logger_1 = require("../../../logger");
9
- exports.logout = (0, tool_1.tool)({
9
+ exports.logout = (0, tool_1.tool)("core", {
10
10
  name: "logout",
11
11
  description: "Use this to sign the user out of the Firebase CLI and Firebase MCP server.",
12
12
  inputSchema: zod_1.z.object({
@@ -6,7 +6,7 @@ const tool_1 = require("../../tool");
6
6
  const resources_1 = require("../../resources");
7
7
  const util_1 = require("../../util");
8
8
  const track_1 = require("../../../track");
9
- exports.read_resources = (0, tool_1.tool)({
9
+ exports.read_resources = (0, tool_1.tool)("core", {
10
10
  name: "read_resources",
11
11
  description: "Use this to read the contents of `firebase://` resources or list available resources",
12
12
  annotations: {
@@ -8,7 +8,7 @@ const use_1 = require("../../../commands/use");
8
8
  const auth_1 = require("../../../auth");
9
9
  const node_fs_1 = require("node:fs");
10
10
  const configstore_1 = require("../../../configstore");
11
- exports.update_environment = (0, tool_1.tool)({
11
+ exports.update_environment = (0, tool_1.tool)("core", {
12
12
  name: "update_environment",
13
13
  description: "Use this to update environment config for the Firebase CLI and Firebase MCP server, such as project directory, active project, active user account, accept terms of service, and more. Use `firebase_get_environment` to see the currently configured environment.",
14
14
  inputSchema: zod_1.z.object({
@@ -42,7 +42,7 @@ function formatRulesetIssues(issues, rulesSource) {
42
42
  }
43
43
  return formattedOutput.join("\n\n");
44
44
  }
45
- exports.validate_security_rules = (0, tool_1.tool)({
45
+ exports.validate_security_rules = (0, tool_1.tool)("core", {
46
46
  name: "validate_security_rules",
47
47
  description: "Use this to check Firebase Security Rules for Firestore, Storage, or Realtime Database for syntax and validation errors.",
48
48
  inputSchema: zod_1.z.object({
@@ -64,6 +64,20 @@ exports.validate_security_rules = (0, tool_1.tool)({
64
64
  requiresProject: true,
65
65
  requiresAuth: true,
66
66
  },
67
+ isAvailable: async (ctx) => {
68
+ const [rtdbActive, storageActive, firestoreActive] = await Promise.all([
69
+ (0, util_1.checkFeatureActive)("database", ctx.projectId, {
70
+ config: ctx.config,
71
+ }),
72
+ (0, util_1.checkFeatureActive)("storage", ctx.projectId, {
73
+ config: ctx.config,
74
+ }),
75
+ (0, util_1.checkFeatureActive)("firestore", ctx.projectId, {
76
+ config: ctx.config,
77
+ }),
78
+ ]);
79
+ return rtdbActive || storageActive || firestoreActive;
80
+ },
67
81
  }, async ({ type, source, source_file }, { projectId, config, host }) => {
68
82
  var _a, _b;
69
83
  let rulesSourceContent;
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.batch_get_events = exports.list_events = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const tool_1 = require("../../tool");
6
- const util_1 = require("../../util");
7
6
  const events_1 = require("../../../crashlytics/events");
8
7
  const types_1 = require("../../../crashlytics/types");
9
8
  const filters_1 = require("../../../crashlytics/filters");
9
+ const util_1 = require("../../util");
10
10
  function pruneThreads(sample) {
11
11
  var _a, _b, _c;
12
12
  if (((_a = sample.issue) === null || _a === void 0 ? void 0 : _a.errorType) === types_1.ErrorType.FATAL || ((_b = sample.issue) === null || _b === void 0 ? void 0 : _b.errorType) === types_1.ErrorType.ANR) {
@@ -14,7 +14,7 @@ function pruneThreads(sample) {
14
14
  }
15
15
  return sample;
16
16
  }
17
- exports.list_events = (0, tool_1.tool)({
17
+ exports.list_events = (0, tool_1.tool)("crashlytics", {
18
18
  name: "list_events",
19
19
  description: `Use this to list the most recent events matching the given filters.
20
20
  Can be used to fetch sample crashes and exceptions for an issue,
@@ -40,7 +40,7 @@ exports.list_events = (0, tool_1.tool)({
40
40
  response.events = response.events ? response.events.map((e) => pruneThreads(e)) : [];
41
41
  return (0, util_1.toContent)(response);
42
42
  });
43
- exports.batch_get_events = (0, tool_1.tool)({
43
+ exports.batch_get_events = (0, tool_1.tool)("crashlytics", {
44
44
  name: "batch_get_events",
45
45
  description: `Gets specific events by resource name.
46
46
  Can be used to fetch sample crashes and exceptions for an issue,
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.update_issue = exports.get_issue = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const tool_1 = require("../../tool");
6
- const util_1 = require("../../util");
7
6
  const issues_1 = require("../../../crashlytics/issues");
8
7
  const types_1 = require("../../../crashlytics/types");
9
8
  const filters_1 = require("../../../crashlytics/filters");
10
- exports.get_issue = (0, tool_1.tool)({
9
+ const util_1 = require("../../util");
10
+ exports.get_issue = (0, tool_1.tool)("crashlytics", {
11
11
  name: "get_issue",
12
12
  description: `Gets data for a Crashlytics issue, which can be used as a starting point for debugging.`,
13
13
  inputSchema: zod_1.z.object({
@@ -28,7 +28,7 @@ exports.get_issue = (0, tool_1.tool)({
28
28
  return (0, util_1.mcpError)(`Must specify 'issueId' parameter.`);
29
29
  return (0, util_1.toContent)(await (0, issues_1.getIssue)(appId, issueId));
30
30
  });
31
- exports.update_issue = (0, tool_1.tool)({
31
+ exports.update_issue = (0, tool_1.tool)("crashlytics", {
32
32
  name: "update_issue",
33
33
  description: "Use this to update the state of Crashlytics issue.",
34
34
  inputSchema: zod_1.z.object({
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.delete_note = exports.list_notes = exports.create_note = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const tool_1 = require("../../tool");
6
- const util_1 = require("../../util");
7
6
  const notes_1 = require("../../../crashlytics/notes");
8
7
  const filters_1 = require("../../../crashlytics/filters");
9
- exports.create_note = (0, tool_1.tool)({
8
+ const util_1 = require("../../util");
9
+ exports.create_note = (0, tool_1.tool)("crashlytics", {
10
10
  name: "create_note",
11
11
  description: "Add a note to an issue from crashlytics.",
12
12
  inputSchema: zod_1.z.object({
@@ -30,7 +30,7 @@ exports.create_note = (0, tool_1.tool)({
30
30
  return (0, util_1.mcpError)(`Must specify 'note' parameter.`);
31
31
  return (0, util_1.toContent)(await (0, notes_1.createNote)(appId, issueId, note));
32
32
  });
33
- exports.list_notes = (0, tool_1.tool)({
33
+ exports.list_notes = (0, tool_1.tool)("crashlytics", {
34
34
  name: "list_notes",
35
35
  description: "Use this to list all notes for an issue in Crashlytics.",
36
36
  inputSchema: zod_1.z.object({
@@ -52,7 +52,7 @@ exports.list_notes = (0, tool_1.tool)({
52
52
  return (0, util_1.mcpError)(`Must specify 'issueId' parameter.`);
53
53
  return (0, util_1.toContent)(await (0, notes_1.listNotes)(appId, issueId, pageSize));
54
54
  });
55
- exports.delete_note = (0, tool_1.tool)({
55
+ exports.delete_note = (0, tool_1.tool)("crashlytics", {
56
56
  name: "delete_note",
57
57
  description: "Delete a note from a Crashlytics issue.",
58
58
  inputSchema: zod_1.z.object({
@@ -28,7 +28,7 @@ function getReportContent(report, additionalPrompt) {
28
28
  return (0, util_1.toContent)(reportResponse);
29
29
  };
30
30
  }
31
- exports.get_top_issues = (0, tool_1.tool)({
31
+ exports.get_top_issues = (0, tool_1.tool)("crashlytics", {
32
32
  name: "get_top_issues",
33
33
  description: `Use this to count events and distinct impacted users, grouped by *issue*.
34
34
  Groups are sorted by event count, in descending order.
@@ -45,7 +45,7 @@ exports.get_top_issues = (0, tool_1.tool)({
45
45
  Pass the sampleEvent in the names field.
46
46
  The crashlytics_list_events tool can retrieve a list of events for an issue in this response.
47
47
  Pass the issue.id in the filter.issueId field.`));
48
- exports.get_top_variants = (0, tool_1.tool)({
48
+ exports.get_top_variants = (0, tool_1.tool)("crashlytics", {
49
49
  name: "get_top_variants",
50
50
  description: `Counts events and distinct impacted users, grouped by issue *variant*.
51
51
  Groups are sorted by event count, in descending order.
@@ -61,7 +61,7 @@ exports.get_top_variants = (0, tool_1.tool)({
61
61
  }, getReportContent(reports_1.CrashlyticsReport.TopVariants, `The crashlytics_get_top_issues tool can report the top issues for the variants in this response.
62
62
  Pass the variant.displayName in the filter.variantDisplayNames field.
63
63
  The crashlytics_list_events tool can retrieve a list of events for a variant in this response.`));
64
- exports.get_top_versions = (0, tool_1.tool)({
64
+ exports.get_top_versions = (0, tool_1.tool)("crashlytics", {
65
65
  name: "get_top_versions",
66
66
  description: `Counts events and distinct impacted users, grouped by *version*.
67
67
  Groups are sorted by event count, in descending order.
@@ -77,7 +77,7 @@ exports.get_top_versions = (0, tool_1.tool)({
77
77
  }, getReportContent(reports_1.CrashlyticsReport.TopVersions, `The crashlytics_get_top_issues tool can report the top issues for the versions in this response.
78
78
  Pass the version.displayName in the filter.versionDisplayNames field.
79
79
  The crashlytics_list_events tool can retrieve a list of events for a version in this response.`));
80
- exports.get_top_apple_devices = (0, tool_1.tool)({
80
+ exports.get_top_apple_devices = (0, tool_1.tool)("crashlytics", {
81
81
  name: "get_top_apple_devices",
82
82
  description: `Counts events and distinct impacted users, grouped by apple *device*.
83
83
  Groups are sorted by event count, in descending order.
@@ -94,7 +94,7 @@ exports.get_top_apple_devices = (0, tool_1.tool)({
94
94
  }, getReportContent(reports_1.CrashlyticsReport.TopAppleDevices, `The crashlytics_get_top_issues tool can report the top issues for the devices in this response.
95
95
  Pass the device.displayName in the filter.deviceDisplayNames field.
96
96
  The crashlytics_list_events tool can retrieve a list of events for a device in this response.`));
97
- exports.get_top_android_devices = (0, tool_1.tool)({
97
+ exports.get_top_android_devices = (0, tool_1.tool)("crashlytics", {
98
98
  name: "get_top_android_devices",
99
99
  description: `Counts events and distinct impacted users, grouped by android *device*.
100
100
  Groups are sorted by event count, in descending order.
@@ -111,7 +111,7 @@ exports.get_top_android_devices = (0, tool_1.tool)({
111
111
  }, getReportContent(reports_1.CrashlyticsReport.TopAndroidDevices, `The crashlytics_get_top_issues tool can report the top issues for the devices in this response.
112
112
  Pass the device.displayName in the filter.deviceDisplayNames field.
113
113
  The crashlytics_list_events tool can retrieve a list of events for a device in this response.`));
114
- exports.get_top_operating_systems = (0, tool_1.tool)({
114
+ exports.get_top_operating_systems = (0, tool_1.tool)("crashlytics", {
115
115
  name: "get_top_operating_systems",
116
116
  description: `Counts events and distinct impacted users, grouped by *operating system*.
117
117
  Groups are sorted by event count, in descending order.
@@ -5,7 +5,7 @@ const zod_1 = require("zod");
5
5
  const tool_1 = require("../../tool");
6
6
  const load_1 = require("../../../dataconnect/load");
7
7
  const compile_1 = require("../../util/dataconnect/compile");
8
- exports.compile = (0, tool_1.tool)({
8
+ exports.compile = (0, tool_1.tool)("dataconnect", {
9
9
  name: "build",
10
10
  description: "Use this to compile Firebase Data Connect schema, operations, and/or connectors and check for build errors.",
11
11
  inputSchema: zod_1.z.object({
@@ -7,7 +7,7 @@ const dataplane = require("../../../dataconnect/dataplaneClient");
7
7
  const load_1 = require("../../../dataconnect/load");
8
8
  const converter_1 = require("../../util/dataconnect/converter");
9
9
  const emulator_1 = require("../../util/dataconnect/emulator");
10
- exports.execute = (0, tool_1.tool)({
10
+ exports.execute = (0, tool_1.tool)("dataconnect", {
11
11
  name: "execute",
12
12
  description: "Use this to execute a GraphQL operation against a Data Connect service or its emulator.",
13
13
  inputSchema: zod_1.z.object({
@@ -6,7 +6,7 @@ const tool_1 = require("../../tool");
6
6
  const util_1 = require("../../util");
7
7
  const fdcExperience_1 = require("../../../gemini/fdcExperience");
8
8
  const load_1 = require("../../../dataconnect/load");
9
- exports.generate_operation = (0, tool_1.tool)({
9
+ exports.generate_operation = (0, tool_1.tool)("dataconnect", {
10
10
  name: "generate_operation",
11
11
  description: "Use this to generate a single Firebase Data Connect query or mutation based on the currently deployed schema and the provided prompt.",
12
12
  inputSchema: zod_1.z.object({
@@ -5,7 +5,7 @@ const zod_1 = require("zod");
5
5
  const tool_1 = require("../../tool");
6
6
  const util_1 = require("../../util");
7
7
  const fdcExperience_1 = require("../../../gemini/fdcExperience");
8
- exports.generate_schema = (0, tool_1.tool)({
8
+ exports.generate_schema = (0, tool_1.tool)("dataconnect", {
9
9
  name: "generate_schema",
10
10
  description: "Use this to generate a Firebase Data Connect Schema based on the users description of an app.",
11
11
  inputSchema: zod_1.z.object({
@@ -9,7 +9,7 @@ const client = require("../../../dataconnect/client");
9
9
  const load_1 = require("../../../dataconnect/load");
10
10
  const js_yaml_1 = require("js-yaml");
11
11
  const logger_1 = require("../../../logger");
12
- exports.list_services = (0, tool_1.tool)({
12
+ exports.list_services = (0, tool_1.tool)("dataconnect", {
13
13
  name: "list_services",
14
14
  description: "Use this to list existing local and backend Firebase Data Connect services",
15
15
  inputSchema: zod_1.z.object({}),
@@ -7,7 +7,7 @@ const util_1 = require("../../util");
7
7
  const firestore_1 = require("../../../gcp/firestore");
8
8
  const delete_1 = require("../../../firestore/delete");
9
9
  const types_1 = require("../../../emulator/types");
10
- exports.delete_document = (0, tool_1.tool)({
10
+ exports.delete_document = (0, tool_1.tool)("firestore", {
11
11
  name: "delete_document",
12
12
  description: "Use this to delete a Firestore documents from a database in the current project by full document paths. Use this if you know the exact path of a document.",
13
13
  inputSchema: zod_1.z.object({
@@ -7,7 +7,7 @@ const util_1 = require("../../util");
7
7
  const firestore_1 = require("../../../gcp/firestore");
8
8
  const converter_1 = require("./converter");
9
9
  const types_1 = require("../../../emulator/types");
10
- exports.get_documents = (0, tool_1.tool)({
10
+ exports.get_documents = (0, tool_1.tool)("firestore", {
11
11
  name: "get_documents",
12
12
  description: "Use this to retrieve one or more Firestore documents from a database in the current project by full document paths. Use this if you know the exact path of a document.",
13
13
  inputSchema: zod_1.z.object({
@@ -6,7 +6,7 @@ const tool_1 = require("../../tool");
6
6
  const util_1 = require("../../util");
7
7
  const firestore_1 = require("../../../gcp/firestore");
8
8
  const types_1 = require("../../../emulator/types");
9
- exports.list_collections = (0, tool_1.tool)({
9
+ exports.list_collections = (0, tool_1.tool)("firestore", {
10
10
  name: "list_collections",
11
11
  description: "Use this to retrieve a list of collections from a Firestore database in the current project.",
12
12
  inputSchema: zod_1.z.object({
@@ -7,7 +7,7 @@ const util_1 = require("../../util");
7
7
  const firestore_1 = require("../../../gcp/firestore");
8
8
  const converter_1 = require("./converter");
9
9
  const types_1 = require("../../../emulator/types");
10
- exports.query_collection = (0, tool_1.tool)({
10
+ exports.query_collection = (0, tool_1.tool)("firestore", {
11
11
  name: "query_collection",
12
12
  description: "Use this to retrieve one or more Firestore documents from a collection is a database in the current project by a collection with a full document path. Use this if you know the exact path of a collection and the filtering clause you would like for the document.",
13
13
  inputSchema: zod_1.z.object({
@@ -38,7 +38,7 @@ function validateTimestamp(label, value) {
38
38
  }
39
39
  return null;
40
40
  }
41
- exports.get_logs = (0, tool_1.tool)({
41
+ exports.get_logs = (0, tool_1.tool)("functions", {
42
42
  name: "get_logs",
43
43
  description: "Use this to retrieve a page of Cloud Functions log entries using Google Cloud Logging advanced filters.",
44
44
  inputSchema: zod_1.z.object({
@@ -12,20 +12,30 @@ const index_8 = require("./crashlytics/index");
12
12
  const index_9 = require("./apphosting/index");
13
13
  const index_10 = require("./realtime_database/index");
14
14
  const index_11 = require("./functions/index");
15
- function availableTools(activeFeatures) {
15
+ async function availableTools(ctx, activeFeatures) {
16
+ const allTools = getAllTools(activeFeatures);
17
+ const availabilities = await Promise.all(allTools.map((t) => {
18
+ if (t.isAvailable) {
19
+ return t.isAvailable(ctx);
20
+ }
21
+ return true;
22
+ }));
23
+ return allTools.filter((_, i) => availabilities[i]);
24
+ }
25
+ exports.availableTools = availableTools;
26
+ function getAllTools(activeFeatures) {
16
27
  const toolDefs = [];
17
28
  if (!(activeFeatures === null || activeFeatures === void 0 ? void 0 : activeFeatures.length)) {
18
29
  activeFeatures = Object.keys(tools);
19
30
  }
20
31
  if (!activeFeatures.includes("core")) {
21
- activeFeatures = ["core", ...activeFeatures];
32
+ activeFeatures.unshift("core");
22
33
  }
23
34
  for (const key of activeFeatures) {
24
35
  toolDefs.push(...tools[key]);
25
36
  }
26
37
  return toolDefs;
27
38
  }
28
- exports.availableTools = availableTools;
29
39
  const tools = {
30
40
  core: addFeaturePrefix("firebase", index_4.coreTools),
31
41
  firestore: addFeaturePrefix("firestore", index_3.firestoreTools),
@@ -44,7 +54,7 @@ function addFeaturePrefix(feature, tools) {
44
54
  }
45
55
  function markdownDocsOfTools() {
46
56
  var _a, _b, _c;
47
- const allTools = availableTools([]);
57
+ const allTools = getAllTools([]);
48
58
  let doc = `
49
59
  | Tool Name | Feature Group | Description |
50
60
  | --------- | ------------- | ----------- |`;
@@ -5,7 +5,7 @@ const zod_1 = require("zod");
5
5
  const tool_1 = require("../../tool");
6
6
  const util_1 = require("../../util");
7
7
  const sendMessage_1 = require("../../../messaging/sendMessage");
8
- exports.send_message = (0, tool_1.tool)({
8
+ exports.send_message = (0, tool_1.tool)("messaging", {
9
9
  name: "send_message",
10
10
  description: "Use this to send a message to a Firebase Cloud Messaging registration token or topic. ONLY ONE of `registration_token` or `topic` may be supplied in a specific call.",
11
11
  inputSchema: zod_1.z.object({