firebase-tools 14.11.0 → 14.11.2

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 (84) hide show
  1. package/lib/apptesting/ensureProjectConfigured.js +56 -0
  2. package/lib/commands/ext-export.js +1 -1
  3. package/lib/commands/functions-config-clone.js +2 -0
  4. package/lib/commands/functions-config-get.js +2 -0
  5. package/lib/commands/functions-config-set.js +2 -0
  6. package/lib/commands/functions-config-unset.js +2 -0
  7. package/lib/commands/init.js +1 -1
  8. package/lib/commands/login.js +2 -2
  9. package/lib/deploy/functions/params.js +4 -0
  10. package/lib/deploy/functions/prepare.js +3 -1
  11. package/lib/deploy/functions/prepareFunctionsUpload.js +2 -0
  12. package/lib/deploy/functions/release/reporter.js +1 -0
  13. package/lib/emulator/downloadableEmulatorInfo.json +18 -18
  14. package/lib/env.js +18 -0
  15. package/lib/experiments.js +7 -0
  16. package/lib/firestore/api.js +15 -1
  17. package/lib/functions/deprecationWarnings.js +21 -0
  18. package/lib/init/features/aitools/promptUpdater.js +4 -1
  19. package/lib/init/features/apptesting/index.js +4 -0
  20. package/lib/mcp/errors.js +7 -1
  21. package/lib/mcp/index.js +78 -60
  22. package/lib/mcp/logging-transport.js +23 -0
  23. package/lib/mcp/tools/apphosting/fetch_logs.js +22 -22
  24. package/lib/mcp/tools/apphosting/list_backends.js +10 -10
  25. package/lib/mcp/tools/auth/disable_user.js +7 -7
  26. package/lib/mcp/tools/auth/get_user.js +6 -6
  27. package/lib/mcp/tools/auth/index.js +10 -10
  28. package/lib/mcp/tools/auth/list_users.js +6 -6
  29. package/lib/mcp/tools/auth/set_claims.js +7 -7
  30. package/lib/mcp/tools/auth/set_sms_region_policy.js +6 -6
  31. package/lib/mcp/tools/core/consult_assistant.js +6 -6
  32. package/lib/mcp/tools/core/create_android_sha.js +9 -9
  33. package/lib/mcp/tools/core/create_app.js +7 -7
  34. package/lib/mcp/tools/core/create_project.js +13 -13
  35. package/lib/mcp/tools/core/get_admin_sdk_config.js +7 -7
  36. package/lib/mcp/tools/core/get_environment.js +8 -8
  37. package/lib/mcp/tools/core/get_project.js +5 -5
  38. package/lib/mcp/tools/core/get_sdk_config.js +9 -9
  39. package/lib/mcp/tools/core/index.js +24 -24
  40. package/lib/mcp/tools/core/init.js +8 -8
  41. package/lib/mcp/tools/core/list_apps.js +6 -6
  42. package/lib/mcp/tools/core/list_projects.js +6 -6
  43. package/lib/mcp/tools/core/update_environment.js +10 -10
  44. package/lib/mcp/tools/crashlytics/index.js +2 -2
  45. package/lib/mcp/tools/crashlytics/list_top_issues.js +6 -6
  46. package/lib/mcp/tools/dataconnect/emulator.js +6 -6
  47. package/lib/mcp/tools/dataconnect/execute_graphql.js +10 -10
  48. package/lib/mcp/tools/dataconnect/execute_graphql_read.js +10 -10
  49. package/lib/mcp/tools/dataconnect/execute_mutation.js +13 -13
  50. package/lib/mcp/tools/dataconnect/execute_query.js +13 -13
  51. package/lib/mcp/tools/dataconnect/generate_operation.js +8 -8
  52. package/lib/mcp/tools/dataconnect/generate_schema.js +6 -6
  53. package/lib/mcp/tools/dataconnect/get_connector.js +8 -8
  54. package/lib/mcp/tools/dataconnect/get_schema.js +8 -8
  55. package/lib/mcp/tools/dataconnect/index.js +18 -18
  56. package/lib/mcp/tools/dataconnect/list_services.js +5 -5
  57. package/lib/mcp/tools/firestore/delete_document.js +13 -13
  58. package/lib/mcp/tools/firestore/get_documents.js +13 -13
  59. package/lib/mcp/tools/firestore/list_collections.js +9 -9
  60. package/lib/mcp/tools/firestore/query_collection.js +13 -13
  61. package/lib/mcp/tools/index.js +18 -18
  62. package/lib/mcp/tools/messaging/index.js +2 -2
  63. package/lib/mcp/tools/messaging/send_message.js +7 -7
  64. package/lib/mcp/tools/remoteconfig/get_template.js +5 -5
  65. package/lib/mcp/tools/remoteconfig/index.js +4 -4
  66. package/lib/mcp/tools/remoteconfig/publish_template.js +7 -7
  67. package/lib/mcp/tools/remoteconfig/rollback_template.js +6 -6
  68. package/lib/mcp/tools/rules/get_rules.js +8 -8
  69. package/lib/mcp/tools/rules/validate_rules.js +10 -10
  70. package/lib/mcp/tools/storage/get_download_url.js +8 -8
  71. package/lib/mcp/tools/storage/get_rules.js +8 -8
  72. package/lib/mcp/util.js +2 -1
  73. package/lib/requireAuth.js +9 -3
  74. package/lib/timeout.js +21 -0
  75. package/lib/track.js +2 -2
  76. package/lib/utils.js +7 -2
  77. package/package.json +1 -1
  78. package/templates/init/dataconnect/mutations.gql +1 -1
  79. package/templates/init/dataconnect/queries.gql +3 -3
  80. package/lib/emulator/adminSdkConfig.test.js +0 -16
  81. package/lib/firestore/api-sort.test.js +0 -74
  82. package/lib/firestore/backupUtils.test.js +0 -18
  83. package/lib/firestore/pretty-print.test.js +0 -61
  84. package/lib/firestore/util.test.js +0 -42
package/lib/mcp/index.js CHANGED
@@ -4,23 +4,26 @@ exports.FirebaseMcpServer = void 0;
4
4
  const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
5
5
  const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
6
6
  const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
7
- const util_js_1 = require("./util.js");
8
- const types_js_2 = require("./types.js");
9
- const index_js_2 = require("./tools/index.js");
10
- const configstore_js_1 = require("../configstore.js");
11
- const command_js_1 = require("../command.js");
12
- const requireAuth_js_1 = require("../requireAuth.js");
13
- const projectUtils_js_1 = require("../projectUtils.js");
14
- const errors_js_1 = require("./errors.js");
15
- const track_js_1 = require("../track.js");
16
- const config_js_1 = require("../config.js");
17
- const rc_js_1 = require("../rc.js");
18
- const hubClient_js_1 = require("../emulator/hubClient.js");
7
+ const util_1 = require("./util");
8
+ const types_1 = require("./types");
9
+ const index_1 = require("./tools/index");
10
+ const configstore_1 = require("../configstore");
11
+ const command_1 = require("../command");
12
+ const requireAuth_1 = require("../requireAuth");
13
+ const projectUtils_1 = require("../projectUtils");
14
+ const errors_1 = require("./errors");
15
+ const track_1 = require("../track");
16
+ const config_1 = require("../config");
17
+ const rc_1 = require("../rc");
18
+ const hubClient_1 = require("../emulator/hubClient");
19
19
  const node_fs_1 = require("node:fs");
20
- const ensureApiEnabled_js_1 = require("../ensureApiEnabled.js");
21
- const api = require("../api.js");
22
- const SERVER_VERSION = "0.1.0";
23
- const cmd = new command_js_1.Command("experimental:mcp").before(requireAuth_js_1.requireAuth);
20
+ const ensureApiEnabled_1 = require("../ensureApiEnabled");
21
+ const api = require("../api");
22
+ const logging_transport_1 = require("./logging-transport");
23
+ const env_1 = require("../env");
24
+ const timeout_1 = require("../timeout");
25
+ const SERVER_VERSION = "0.2.0";
26
+ const cmd = new command_1.Command("experimental:mcp");
24
27
  const orderedLogLevels = [
25
28
  "debug",
26
29
  "info",
@@ -32,9 +35,20 @@ const orderedLogLevels = [
32
35
  "emergency",
33
36
  ];
34
37
  class FirebaseMcpServer {
38
+ async trackGA4(event, params = {}) {
39
+ var _a, _b;
40
+ if (!this.clientInfo)
41
+ await (0, timeout_1.timeoutFallback)(this.ready(), null, 2000);
42
+ const clientInfoParams = {
43
+ mcp_client_name: ((_a = this.clientInfo) === null || _a === void 0 ? void 0 : _a.name) || "<unknown-client>",
44
+ mcp_client_version: ((_b = this.clientInfo) === null || _b === void 0 ? void 0 : _b.version) || "<unknown-version>",
45
+ };
46
+ (0, track_1.trackGA4)(event, Object.assign(Object.assign({}, params), clientInfoParams));
47
+ }
35
48
  constructor(options) {
36
49
  this._ready = false;
37
50
  this._readyPromises = [];
51
+ this.currentLogLevel = process.env.FIREBASE_MCP_DEBUG_LOG ? "debug" : undefined;
38
52
  this.logger = Object.fromEntries(orderedLogLevels.map((logLevel) => [
39
53
  logLevel,
40
54
  (message) => this.log(logLevel, message),
@@ -50,10 +64,7 @@ class FirebaseMcpServer {
50
64
  const clientInfo = this.server.getClientVersion();
51
65
  this.clientInfo = clientInfo;
52
66
  if (clientInfo === null || clientInfo === void 0 ? void 0 : clientInfo.name) {
53
- (0, track_js_1.trackGA4)("mcp_client_connected", {
54
- mcp_client_name: clientInfo.name,
55
- mcp_client_version: clientInfo.version,
56
- });
67
+ this.trackGA4("mcp_client_connected");
57
68
  }
58
69
  if (!((_a = this.clientInfo) === null || _a === void 0 ? void 0 : _a.name))
59
70
  this.clientInfo = { name: "<unknown-client>" };
@@ -76,39 +87,45 @@ class FirebaseMcpServer {
76
87
  this._readyPromises.push({ resolve: resolve, reject });
77
88
  });
78
89
  }
90
+ get clientName() {
91
+ var _a, _b;
92
+ return (_b = (_a = this.clientInfo) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : ((0, env_1.isFirebaseStudio)() ? "Firebase Studio" : "<unknown-client>");
93
+ }
79
94
  get clientConfigKey() {
80
- var _a;
81
- return `mcp.clientConfigs.${((_a = this.clientInfo) === null || _a === void 0 ? void 0 : _a.name) || "<unknown-client>"}:${this.startupRoot || process.cwd()}`;
95
+ return `mcp.clientConfigs.${this.clientName}:${this.startupRoot || process.cwd()}`;
82
96
  }
83
97
  getStoredClientConfig() {
84
- return configstore_js_1.configstore.get(this.clientConfigKey) || {};
98
+ return configstore_1.configstore.get(this.clientConfigKey) || {};
85
99
  }
86
100
  updateStoredClientConfig(update) {
87
- const config = configstore_js_1.configstore.get(this.clientConfigKey) || {};
101
+ const config = configstore_1.configstore.get(this.clientConfigKey) || {};
88
102
  const newConfig = Object.assign(Object.assign({}, config), update);
89
- configstore_js_1.configstore.set(this.clientConfigKey, newConfig);
103
+ configstore_1.configstore.set(this.clientConfigKey, newConfig);
90
104
  return newConfig;
91
105
  }
92
106
  async detectProjectRoot() {
93
- await this.ready();
107
+ await (0, timeout_1.timeoutFallback)(this.ready(), null, 2000);
94
108
  if (this.cachedProjectRoot)
95
109
  return this.cachedProjectRoot;
96
110
  const storedRoot = this.getStoredClientConfig().projectRoot;
97
111
  this.cachedProjectRoot = storedRoot || this.startupRoot || process.cwd();
112
+ this.log("debug", "detected and cached project root: " + this.cachedProjectRoot);
98
113
  return this.cachedProjectRoot;
99
114
  }
100
115
  async detectActiveFeatures() {
101
116
  var _a;
102
117
  if ((_a = this.detectedFeatures) === null || _a === void 0 ? void 0 : _a.length)
103
118
  return this.detectedFeatures;
119
+ this.log("debug", "detecting active features of Firebase MCP server...");
104
120
  const options = await this.resolveOptions();
105
121
  const projectId = await this.getProjectId();
106
- const detected = await Promise.all(types_js_2.SERVER_FEATURES.map(async (f) => {
107
- if (await (0, util_js_1.checkFeatureActive)(f, projectId, options))
122
+ const detected = await Promise.all(types_1.SERVER_FEATURES.map(async (f) => {
123
+ if (await (0, util_1.checkFeatureActive)(f, projectId, options))
108
124
  return f;
109
125
  return null;
110
126
  }));
111
127
  this.detectedFeatures = detected.filter((f) => !!f);
128
+ this.log("debug", "detected features of Firebase MCP server: " + (this.detectedFeatures.join(", ") || "<none>"));
112
129
  return this.detectedFeatures;
113
130
  }
114
131
  async getEmulatorHubClient() {
@@ -119,7 +136,7 @@ class FirebaseMcpServer {
119
136
  if (!projectId) {
120
137
  return;
121
138
  }
122
- this.emulatorHubClient = new hubClient_js_1.EmulatorHubClient(projectId);
139
+ this.emulatorHubClient = new hubClient_1.EmulatorHubClient(projectId);
123
140
  return this.emulatorHubClient;
124
141
  }
125
142
  async getEmulatorUrl(emulatorType) {
@@ -137,7 +154,7 @@ class FirebaseMcpServer {
137
154
  }
138
155
  get availableTools() {
139
156
  var _a;
140
- return (0, index_js_2.availableTools)(((_a = this.activeFeatures) === null || _a === void 0 ? void 0 : _a.length) ? this.activeFeatures : this.detectedFeatures);
157
+ return (0, index_1.availableTools)(((_a = this.activeFeatures) === null || _a === void 0 ? void 0 : _a.length) ? this.activeFeatures : this.detectedFeatures);
141
158
  }
142
159
  getTool(name) {
143
160
  return this.availableTools.find((t) => t.mcp.name === name) || null;
@@ -154,38 +171,39 @@ class FirebaseMcpServer {
154
171
  return options;
155
172
  }
156
173
  async getProjectId() {
157
- return (0, projectUtils_js_1.getProjectId)(await this.resolveOptions());
174
+ return (0, projectUtils_1.getProjectId)(await this.resolveOptions());
158
175
  }
159
- async getAuthenticatedUser() {
176
+ async getAuthenticatedUser(skipAutoAuth = false) {
160
177
  try {
161
- const email = await (0, requireAuth_js_1.requireAuth)(await this.resolveOptions());
162
- return email !== null && email !== void 0 ? email : "Application Default Credentials";
178
+ this.log("debug", `calling requireAuth`);
179
+ const email = await (0, requireAuth_1.requireAuth)(await this.resolveOptions(), skipAutoAuth);
180
+ this.log("debug", `detected authenticated account: ${email || "<none>"}`);
181
+ return email !== null && email !== void 0 ? email : (skipAutoAuth ? null : "Application Default Credentials");
163
182
  }
164
183
  catch (e) {
184
+ this.log("debug", `error in requireAuth: ${e}`);
165
185
  return null;
166
186
  }
167
187
  }
168
188
  async mcpListTools() {
169
- var _a, _b;
170
189
  await Promise.all([this.detectActiveFeatures(), this.detectProjectRoot()]);
171
190
  const hasActiveProject = !!(await this.getProjectId());
172
- await (0, track_js_1.trackGA4)("mcp_list_tools", {
173
- mcp_client_name: (_a = this.clientInfo) === null || _a === void 0 ? void 0 : _a.name,
174
- mcp_client_version: (_b = this.clientInfo) === null || _b === void 0 ? void 0 : _b.version,
175
- });
191
+ await this.trackGA4("mcp_list_tools");
192
+ const skipAutoAuthForStudio = (0, env_1.isFirebaseStudio)();
193
+ this.log("debug", `skip auto-auth in studio environment: ${skipAutoAuthForStudio}`);
176
194
  return {
177
195
  tools: this.availableTools.map((t) => t.mcp),
178
196
  _meta: {
179
197
  projectRoot: this.cachedProjectRoot,
180
198
  projectDetected: hasActiveProject,
181
- authenticatedUser: await this.getAuthenticatedUser(),
199
+ authenticatedUser: await this.getAuthenticatedUser(skipAutoAuthForStudio),
182
200
  activeFeatures: this.activeFeatures,
183
201
  detectedFeatures: this.detectedFeatures,
184
202
  },
185
203
  };
186
204
  }
187
205
  async mcpCallTool(request) {
188
- var _a, _b, _c, _d, _e, _f, _g;
206
+ var _a, _b, _c;
189
207
  await this.detectProjectRoot();
190
208
  const toolName = request.params.name;
191
209
  const toolArgs = request.params.arguments;
@@ -194,24 +212,25 @@ class FirebaseMcpServer {
194
212
  throw new Error(`Tool '${toolName}' could not be found.`);
195
213
  if (tool.mcp.name !== "firebase_update_environment" &&
196
214
  (!this.cachedProjectRoot || !(0, node_fs_1.existsSync)(this.cachedProjectRoot))) {
197
- return (0, util_js_1.mcpError)(`The current project directory '${this.cachedProjectRoot || "<NO PROJECT DIRECTORY FOUND>"}' does not exist. Please use the 'update_firebase_environment' tool to target a different project directory.`);
215
+ return (0, util_1.mcpError)(`The current project directory '${this.cachedProjectRoot || "<NO PROJECT DIRECTORY FOUND>"}' does not exist. Please use the 'update_firebase_environment' tool to target a different project directory.`);
198
216
  }
199
217
  let projectId = await this.getProjectId();
200
218
  if (((_a = tool.mcp._meta) === null || _a === void 0 ? void 0 : _a.requiresProject) && !projectId) {
201
- return errors_js_1.NO_PROJECT_ERROR;
219
+ return errors_1.NO_PROJECT_ERROR;
202
220
  }
203
221
  projectId = projectId || "";
204
- const accountEmail = await this.getAuthenticatedUser();
222
+ const skipAutoAuthForStudio = (0, env_1.isFirebaseStudio)();
223
+ const accountEmail = await this.getAuthenticatedUser(skipAutoAuthForStudio);
205
224
  if (((_b = tool.mcp._meta) === null || _b === void 0 ? void 0 : _b.requiresAuth) && !accountEmail) {
206
- return (0, errors_js_1.mcpAuthError)();
225
+ return (0, errors_1.mcpAuthError)(skipAutoAuthForStudio);
207
226
  }
208
227
  if ((_c = tool.mcp._meta) === null || _c === void 0 ? void 0 : _c.requiresGemini) {
209
- if (configstore_js_1.configstore.get("gemini")) {
210
- await (0, ensureApiEnabled_js_1.ensure)(projectId, api.cloudAiCompanionOrigin(), "");
228
+ if (configstore_1.configstore.get("gemini")) {
229
+ await (0, ensureApiEnabled_1.ensure)(projectId, api.cloudAiCompanionOrigin(), "");
211
230
  }
212
231
  else {
213
- if (!(await (0, ensureApiEnabled_js_1.check)(projectId, api.cloudAiCompanionOrigin(), ""))) {
214
- return (0, errors_js_1.mcpGeminiError)(projectId);
232
+ if (!(await (0, ensureApiEnabled_1.check)(projectId, api.cloudAiCompanionOrigin(), ""))) {
233
+ return (0, errors_1.mcpGeminiError)(projectId);
215
234
  }
216
235
  }
217
236
  }
@@ -219,32 +238,30 @@ class FirebaseMcpServer {
219
238
  const toolsCtx = {
220
239
  projectId: projectId,
221
240
  host: this,
222
- config: config_js_1.Config.load(options, true) || new config_js_1.Config({}, options),
223
- rc: (0, rc_js_1.loadRC)(options),
241
+ config: config_1.Config.load(options, true) || new config_1.Config({}, options),
242
+ rc: (0, rc_1.loadRC)(options),
224
243
  accountEmail,
225
244
  };
226
245
  try {
227
246
  const res = await tool.fn(toolArgs, toolsCtx);
228
- await (0, track_js_1.trackGA4)("mcp_tool_call", {
247
+ await this.trackGA4("mcp_tool_call", {
229
248
  tool_name: toolName,
230
249
  error: res.isError ? 1 : 0,
231
- mcp_client_name: (_d = this.clientInfo) === null || _d === void 0 ? void 0 : _d.name,
232
- mcp_client_version: (_e = this.clientInfo) === null || _e === void 0 ? void 0 : _e.version,
233
250
  });
234
251
  return res;
235
252
  }
236
253
  catch (err) {
237
- await (0, track_js_1.trackGA4)("mcp_tool_call", {
254
+ await this.trackGA4("mcp_tool_call", {
238
255
  tool_name: toolName,
239
256
  error: 1,
240
- mcp_client_name: (_f = this.clientInfo) === null || _f === void 0 ? void 0 : _f.name,
241
- mcp_client_version: (_g = this.clientInfo) === null || _g === void 0 ? void 0 : _g.version,
242
257
  });
243
- return (0, util_js_1.mcpError)(err);
258
+ return (0, util_1.mcpError)(err);
244
259
  }
245
260
  }
246
261
  async start() {
247
- const transport = new stdio_js_1.StdioServerTransport();
262
+ const transport = process.env.FIREBASE_MCP_DEBUG_LOG
263
+ ? new logging_transport_1.LoggingStdioServerTransport(process.env.FIREBASE_MCP_DEBUG_LOG)
264
+ : new stdio_js_1.StdioServerTransport();
248
265
  await this.server.connect(transport);
249
266
  }
250
267
  async log(level, message) {
@@ -258,7 +275,8 @@ class FirebaseMcpServer {
258
275
  if (orderedLogLevels.indexOf(this.currentLogLevel) > orderedLogLevels.indexOf(level)) {
259
276
  return;
260
277
  }
261
- await this.server.sendLoggingMessage({ level, data });
278
+ if (this._ready)
279
+ await this.server.sendLoggingMessage({ level, data });
262
280
  }
263
281
  }
264
282
  exports.FirebaseMcpServer = FirebaseMcpServer;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LoggingStdioServerTransport = void 0;
4
+ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
5
+ const fs_1 = require("fs");
6
+ const promises_1 = require("fs/promises");
7
+ class LoggingStdioServerTransport extends stdio_js_1.StdioServerTransport {
8
+ constructor(path) {
9
+ super();
10
+ this.path = path;
11
+ (0, fs_1.appendFileSync)(path, "--- new process start ---\n");
12
+ const origOnData = this._ondata;
13
+ this._ondata = (chunk) => {
14
+ origOnData(chunk);
15
+ (0, fs_1.appendFileSync)(path, chunk.toString(), { encoding: "utf8" });
16
+ };
17
+ }
18
+ async send(message) {
19
+ await super.send(message);
20
+ await (0, promises_1.appendFile)(this.path, JSON.stringify(message) + "\n");
21
+ }
22
+ }
23
+ exports.LoggingStdioServerTransport = LoggingStdioServerTransport;
@@ -2,14 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fetch_logs = void 0;
4
4
  const zod_1 = require("zod");
5
- const tool_js_1 = require("../../tool.js");
6
- const util_js_1 = require("../../util.js");
7
- const apphosting_js_1 = require("../../../gcp/apphosting.js");
8
- const utils_js_1 = require("../../../utils.js");
9
- const error_js_1 = require("../../../error.js");
10
- const run_js_1 = require("../../../gcp/run.js");
11
- const cloudlogging_js_1 = require("../../../gcp/cloudlogging.js");
12
- exports.fetch_logs = (0, tool_js_1.tool)({
5
+ const tool_1 = require("../../tool");
6
+ const util_1 = require("../../util");
7
+ const apphosting_1 = require("../../../gcp/apphosting");
8
+ const utils_1 = require("../../../utils");
9
+ const error_1 = require("../../../error");
10
+ const run_1 = require("../../../gcp/run");
11
+ const cloudlogging_1 = require("../../../gcp/cloudlogging");
12
+ exports.fetch_logs = (0, tool_1.tool)({
13
13
  name: "fetch_logs",
14
14
  description: "Fetches 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({
@@ -34,36 +34,36 @@ exports.fetch_logs = (0, tool_js_1.tool)({
34
34
  var _a, _b;
35
35
  location || (location = "");
36
36
  if (!backendId) {
37
- return (0, util_js_1.toContent)(`backendId must be specified.`);
37
+ return (0, util_1.toContent)(`backendId must be specified.`);
38
38
  }
39
- const backend = await (0, apphosting_js_1.getBackend)(projectId, location, backendId);
40
- const traffic = await (0, apphosting_js_1.getTraffic)(projectId, location, backendId);
39
+ const backend = await (0, apphosting_1.getBackend)(projectId, location, backendId);
40
+ const traffic = await (0, apphosting_1.getTraffic)(projectId, location, backendId);
41
41
  const data = Object.assign(Object.assign({}, backend), { traffic });
42
42
  if (buildLogs) {
43
- const builds = await (0, apphosting_js_1.listBuilds)(projectId, location, backendId);
43
+ const builds = await (0, apphosting_1.listBuilds)(projectId, location, backendId);
44
44
  builds.builds.sort((a, b) => new Date(a.createTime).getTime() - new Date(b.createTime).getTime());
45
- const build = (0, utils_js_1.last)(builds.builds);
45
+ const build = (0, utils_1.last)(builds.builds);
46
46
  const r = new RegExp(`region=${location}/([0-9a-f-]+)?`);
47
47
  const match = r.exec((_a = build.buildLogsUri) !== null && _a !== void 0 ? _a : "");
48
48
  if (!match) {
49
- throw new error_js_1.FirebaseError("Unable to determine the build ID.");
49
+ throw new error_1.FirebaseError("Unable to determine the build ID.");
50
50
  }
51
51
  const buildId = match[1];
52
52
  const thirtyDaysAgo = new Date();
53
53
  thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30);
54
54
  const timestampFilter = `timestamp >= "${thirtyDaysAgo.toISOString()}"`;
55
55
  const filter = `resource.type="build" resource.labels.build_id="${buildId}" ${timestampFilter}`;
56
- const entries = await (0, cloudlogging_js_1.listEntries)(projectId, filter, 100, "asc");
56
+ const entries = await (0, cloudlogging_1.listEntries)(projectId, filter, 100, "asc");
57
57
  if (!Array.isArray(entries) || !entries.length) {
58
- return (0, util_js_1.toContent)("No logs found.");
58
+ return (0, util_1.toContent)("No logs found.");
59
59
  }
60
- return (0, util_js_1.toContent)(entries);
60
+ return (0, util_1.toContent)(entries);
61
61
  }
62
- const serviceName = (_b = (0, utils_js_1.last)(data.managedResources)) === null || _b === void 0 ? void 0 : _b.runService.service;
62
+ const serviceName = (_b = (0, utils_1.last)(data.managedResources)) === null || _b === void 0 ? void 0 : _b.runService.service;
63
63
  if (!serviceName) {
64
- throw new error_js_1.FirebaseError("Unable to get service name from managedResources.");
64
+ throw new error_1.FirebaseError("Unable to get service name from managedResources.");
65
65
  }
66
- const serviceId = (0, utils_js_1.last)(serviceName.split("/"));
67
- const logs = await (0, run_js_1.fetchServiceLogs)(projectId, serviceId);
68
- return (0, util_js_1.toContent)(logs);
66
+ const serviceId = (0, utils_1.last)(serviceName.split("/"));
67
+ const logs = await (0, run_1.fetchServiceLogs)(projectId, serviceId);
68
+ return (0, util_1.toContent)(logs);
69
69
  });
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.list_backends = void 0;
4
4
  const zod_1 = require("zod");
5
- const tool_js_1 = require("../../tool.js");
6
- const util_js_1 = require("../../util.js");
7
- const apphosting_js_1 = require("../../../gcp/apphosting.js");
8
- exports.list_backends = (0, tool_js_1.tool)({
5
+ const tool_1 = require("../../tool");
6
+ const util_1 = require("../../util");
7
+ const apphosting_1 = require("../../../gcp/apphosting");
8
+ exports.list_backends = (0, tool_1.tool)({
9
9
  name: "list_backends",
10
10
  description: "Retrieves 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. " +
@@ -34,18 +34,18 @@ exports.list_backends = (0, tool_js_1.tool)({
34
34
  projectId = projectId || "";
35
35
  if (!location)
36
36
  location = "-";
37
- const backends = await (0, apphosting_js_1.listBackends)(projectId, location);
37
+ const backends = await (0, apphosting_1.listBackends)(projectId, location);
38
38
  if (!backends.backends.length) {
39
- return (0, util_js_1.toContent)(`No backends exist for project ${projectId}${location !== "-" ? ` in ${location}` : ""}.`);
39
+ return (0, util_1.toContent)(`No backends exist for project ${projectId}${location !== "-" ? ` in ${location}` : ""}.`);
40
40
  }
41
41
  const promises = backends.backends.map(async (backend) => {
42
- const { location, id } = (0, apphosting_js_1.parseBackendName)(backend.name);
42
+ const { location, id } = (0, apphosting_1.parseBackendName)(backend.name);
43
43
  const [traffic, domains] = await Promise.all([
44
- (0, apphosting_js_1.getTraffic)(projectId, location, id),
45
- (0, apphosting_js_1.listDomains)(projectId, location, id),
44
+ (0, apphosting_1.getTraffic)(projectId, location, id),
45
+ (0, apphosting_1.listDomains)(projectId, location, id),
46
46
  ]);
47
47
  return Object.assign(Object.assign({}, backend), { traffic: traffic, domains: domains });
48
48
  });
49
49
  const data = await Promise.all(promises);
50
- return (0, util_js_1.toContent)(data);
50
+ return (0, util_1.toContent)(data);
51
51
  });
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.disable_user = void 0;
4
4
  const zod_1 = require("zod");
5
- const tool_js_1 = require("../../tool.js");
6
- const util_js_1 = require("../../util.js");
7
- const auth_js_1 = require("../../../gcp/auth.js");
8
- exports.disable_user = (0, tool_js_1.tool)({
5
+ const tool_1 = require("../../tool");
6
+ const util_1 = require("../../util");
7
+ const auth_1 = require("../../../gcp/auth");
8
+ exports.disable_user = (0, tool_1.tool)({
9
9
  name: "disable_user",
10
10
  description: "Disables or enables a user based on a UID.",
11
11
  inputSchema: zod_1.z.object({
@@ -22,9 +22,9 @@ exports.disable_user = (0, tool_js_1.tool)({
22
22
  requiresProject: true,
23
23
  },
24
24
  }, async ({ uid, disabled }, { projectId }) => {
25
- const res = await (0, auth_js_1.disableUser)(projectId, uid, disabled);
25
+ const res = await (0, auth_1.disableUser)(projectId, uid, disabled);
26
26
  if (res) {
27
- return (0, util_js_1.toContent)(`User ${uid} as been ${disabled ? "disabled" : "enabled"}`);
27
+ return (0, util_1.toContent)(`User ${uid} as been ${disabled ? "disabled" : "enabled"}`);
28
28
  }
29
- return (0, util_js_1.toContent)(`Failed to ${disabled ? "disable" : "enable"} user ${uid}`);
29
+ return (0, util_1.toContent)(`Failed to ${disabled ? "disable" : "enable"} user ${uid}`);
30
30
  });
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.get_user = void 0;
4
4
  const zod_1 = require("zod");
5
- const tool_js_1 = require("../../tool.js");
6
- const util_js_1 = require("../../util.js");
7
- const auth_js_1 = require("../../../gcp/auth.js");
8
- exports.get_user = (0, tool_js_1.tool)({
5
+ const tool_1 = require("../../tool");
6
+ const util_1 = require("../../util");
7
+ const auth_1 = require("../../../gcp/auth");
8
+ exports.get_user = (0, tool_1.tool)({
9
9
  name: "get_user",
10
10
  description: "Retrieves a user based on an email address, phone number, or UID.",
11
11
  inputSchema: zod_1.z.object({
@@ -32,7 +32,7 @@ exports.get_user = (0, tool_js_1.tool)({
32
32
  },
33
33
  }, async ({ email, phone_number, uid }, { projectId }) => {
34
34
  if (email === undefined && phone_number === undefined && uid === undefined) {
35
- return (0, util_js_1.mcpError)(`No user identifier supplied in auth_get_user tool`);
35
+ return (0, util_1.mcpError)(`No user identifier supplied in auth_get_user tool`);
36
36
  }
37
- return (0, util_js_1.toContent)(await (0, auth_js_1.findUser)(projectId, email, phone_number, uid));
37
+ return (0, util_1.toContent)(await (0, auth_1.findUser)(projectId, email, phone_number, uid));
38
38
  });
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.authTools = void 0;
4
- const get_user_js_1 = require("./get_user.js");
5
- const disable_user_js_1 = require("./disable_user.js");
6
- const set_claims_js_1 = require("./set_claims.js");
7
- const set_sms_region_policy_js_1 = require("./set_sms_region_policy.js");
8
- const list_users_js_1 = require("./list_users.js");
4
+ const get_user_1 = require("./get_user");
5
+ const disable_user_1 = require("./disable_user");
6
+ const set_claims_1 = require("./set_claims");
7
+ const set_sms_region_policy_1 = require("./set_sms_region_policy");
8
+ const list_users_1 = require("./list_users");
9
9
  exports.authTools = [
10
- get_user_js_1.get_user,
11
- disable_user_js_1.disable_user,
12
- list_users_js_1.list_users,
13
- set_claims_js_1.set_claim,
14
- set_sms_region_policy_js_1.set_sms_region_policy,
10
+ get_user_1.get_user,
11
+ disable_user_1.disable_user,
12
+ list_users_1.list_users,
13
+ set_claims_1.set_claim,
14
+ set_sms_region_policy_1.set_sms_region_policy,
15
15
  ];
@@ -13,10 +13,10 @@ var __rest = (this && this.__rest) || function (s, e) {
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.list_users = void 0;
15
15
  const zod_1 = require("zod");
16
- const tool_js_1 = require("../../tool.js");
17
- const util_js_1 = require("../../util.js");
18
- const auth_js_1 = require("../../../gcp/auth.js");
19
- exports.list_users = (0, tool_js_1.tool)({
16
+ const tool_1 = require("../../tool");
17
+ const util_1 = require("../../util");
18
+ const auth_1 = require("../../../gcp/auth");
19
+ exports.list_users = (0, tool_1.tool)({
20
20
  name: "list_users",
21
21
  description: "Retrieves all users in the project up to the specified limit.",
22
22
  inputSchema: zod_1.z.object({
@@ -38,10 +38,10 @@ exports.list_users = (0, tool_js_1.tool)({
38
38
  if (!limit) {
39
39
  limit = 100;
40
40
  }
41
- const users = await (0, auth_js_1.listUsers)(projectId, limit);
41
+ const users = await (0, auth_1.listUsers)(projectId, limit);
42
42
  const usersPruned = users.map((user) => {
43
43
  const { passwordHash, salt } = user, prunedUser = __rest(user, ["passwordHash", "salt"]);
44
44
  return prunedUser;
45
45
  });
46
- return (0, util_js_1.toContent)(usersPruned);
46
+ return (0, util_1.toContent)(usersPruned);
47
47
  });
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.set_claim = void 0;
4
4
  const zod_1 = require("zod");
5
- const tool_js_1 = require("../../tool.js");
6
- const util_js_1 = require("../../util.js");
7
- const auth_js_1 = require("../../../gcp/auth.js");
8
- exports.set_claim = (0, tool_js_1.tool)({
5
+ const tool_1 = require("../../tool");
6
+ const util_1 = require("../../util");
7
+ const auth_1 = require("../../../gcp/auth");
8
+ exports.set_claim = (0, tool_1.tool)({
9
9
  name: "set_claim",
10
10
  description: "Sets a custom claim on a specific user's account. Use to create trusted values associated with a user e.g. marking them as an admin. Claims are limited in size and should be succinct in name and value. Specify ONLY ONE OF `value` or `json_value` parameters.",
11
11
  inputSchema: zod_1.z.object({
@@ -30,14 +30,14 @@ exports.set_claim = (0, tool_js_1.tool)({
30
30
  },
31
31
  }, async ({ uid, claim, value, json_value }, { projectId }) => {
32
32
  if (value && json_value)
33
- return (0, util_js_1.mcpError)("Must supply only `value` or `json_value`, not both.");
33
+ return (0, util_1.mcpError)("Must supply only `value` or `json_value`, not both.");
34
34
  if (json_value) {
35
35
  try {
36
36
  value = JSON.parse(json_value);
37
37
  }
38
38
  catch (e) {
39
- return (0, util_js_1.mcpError)(`Provided \`json_value\` was not valid JSON: ${json_value}`);
39
+ return (0, util_1.mcpError)(`Provided \`json_value\` was not valid JSON: ${json_value}`);
40
40
  }
41
41
  }
42
- return (0, util_js_1.toContent)(await (0, auth_js_1.setCustomClaim)(projectId, uid, { [claim]: value }, { merge: true }));
42
+ return (0, util_1.toContent)(await (0, auth_1.setCustomClaim)(projectId, uid, { [claim]: value }, { merge: true }));
43
43
  });
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.set_sms_region_policy = void 0;
4
4
  const zod_1 = require("zod");
5
- const tool_js_1 = require("../../tool.js");
6
- const util_js_1 = require("../../util.js");
7
- const auth_js_1 = require("../../../gcp/auth.js");
8
- exports.set_sms_region_policy = (0, tool_js_1.tool)({
5
+ const tool_1 = require("../../tool");
6
+ const util_1 = require("../../util");
7
+ const auth_1 = require("../../../gcp/auth");
8
+ exports.set_sms_region_policy = (0, tool_1.tool)({
9
9
  name: "set_sms_region_policy",
10
10
  description: "Sets an SMS Region Policy for Firebase Auth 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({
@@ -30,7 +30,7 @@ exports.set_sms_region_policy = (0, tool_js_1.tool)({
30
30
  return code.toUpperCase();
31
31
  });
32
32
  if (policy_type === "ALLOW") {
33
- return (0, util_js_1.toContent)(await (0, auth_js_1.setAllowSmsRegionPolicy)(projectId, country_codes));
33
+ return (0, util_1.toContent)(await (0, auth_1.setAllowSmsRegionPolicy)(projectId, country_codes));
34
34
  }
35
- return (0, util_js_1.toContent)(await (0, auth_js_1.setDenySmsRegionPolicy)(projectId, country_codes));
35
+ return (0, util_1.toContent)(await (0, auth_1.setDenySmsRegionPolicy)(projectId, country_codes));
36
36
  });
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.consult_assistant = void 0;
4
4
  const zod_1 = require("zod");
5
- const tool_js_1 = require("../../tool.js");
6
- const util_js_1 = require("../../util.js");
7
- const fdcExperience_js_1 = require("../../../gemini/fdcExperience.js");
8
- exports.consult_assistant = (0, tool_js_1.tool)({
5
+ const tool_1 = require("../../tool");
6
+ const util_1 = require("../../util");
7
+ const fdcExperience_1 = require("../../../gemini/fdcExperience");
8
+ exports.consult_assistant = (0, tool_1.tool)({
9
9
  name: "consult_assistant",
10
10
  description: "Send a question to an AI assistant specifically enhanced to answer Firebase questions.",
11
11
  inputSchema: zod_1.z.object({
@@ -23,6 +23,6 @@ exports.consult_assistant = (0, tool_js_1.tool)({
23
23
  requiresGemini: true,
24
24
  },
25
25
  }, async ({ prompt }, { projectId }) => {
26
- const schema = await (0, fdcExperience_js_1.chatWithFirebase)(prompt, projectId);
27
- return (0, util_js_1.toContent)(schema);
26
+ const schema = await (0, fdcExperience_1.chatWithFirebase)(prompt, projectId);
27
+ return (0, util_1.toContent)(schema);
28
28
  });