firebase-tools-with-isolate 15.28.2 → 15.30.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.
- package/lib/api.js +4 -2
- package/lib/apphosting/config.js +10 -8
- package/lib/apphosting/localbuilds.js +8 -0
- package/lib/apphosting/yaml.js +27 -0
- package/lib/bin/cli.js +1 -1
- package/lib/bin/mcp.js +8 -3
- package/lib/commands/ext-export.js +52 -14
- package/lib/commands/ext-migrate.js +70 -4
- package/lib/commands/ext-uninstall.js +2 -28
- package/lib/commands/functions-delete.js +6 -67
- package/lib/commands/functions-kits-install.js +7 -0
- package/lib/commands/functions-kits-uninstall.js +30 -86
- package/lib/crashlytics/onboarding.js +23 -2
- package/lib/deploy/apphosting/deploy.js +2 -1
- package/lib/deploy/apphosting/prepare.js +12 -3
- package/lib/deploy/apphosting/release.js +3 -0
- package/lib/deploy/apphosting/util.js +3 -1
- package/lib/deploy/extensions/secrets.js +10 -0
- package/lib/deploy/functions/delete.js +105 -0
- package/lib/deploy/functions/release/executor.js +14 -8
- package/lib/deploy/functions/release/fabricator.js +42 -20
- package/lib/deploy/functions/release/sourceTokenScraper.js +16 -2
- package/lib/emulator/downloadableEmulatorInfo.json +24 -24
- package/lib/emulator/tasksEmulator.js +2 -2
- package/lib/emulator/types.js +3 -1
- package/lib/extensions/askUserForParam.js +9 -8
- package/lib/extensions/export.js +47 -10
- package/lib/extensions/extensionsHelper.js +29 -2
- package/lib/extensions/manifest.js +5 -4
- package/lib/extensions/migrate.js +176 -2
- package/lib/extensions/paramHelper.js +78 -25
- package/lib/extensions/secretsUtils.js +3 -0
- package/lib/extensions/updateHelper.js +3 -1
- package/lib/functions/kits/install.js +322 -70
- package/lib/gcp/apikeys.js +89 -0
- package/lib/gcp/resourceManager.js +31 -22
- package/lib/gcp/run.js +2 -2
- package/lib/gcp/storage.js +3 -2
- package/lib/logger.js +83 -9
- package/lib/mcp/onemcp/index.js +19 -0
- package/lib/mcp/onemcp/onemcp_server.js +12 -7
- package/lib/mcp/tools/apphosting/fetch_logs.js +1 -0
- package/lib/mcp/tools/apphosting/list_backends.js +1 -0
- package/lib/mcp/tools/apptesting/tests.js +2 -0
- package/lib/mcp/tools/auth/get_users.js +1 -0
- package/lib/mcp/tools/auth/set_sms_region_policy.js +1 -0
- package/lib/mcp/tools/auth/update_user.js +1 -0
- package/lib/mcp/tools/core/create_android_sha.js +1 -0
- package/lib/mcp/tools/core/create_app.js +1 -0
- package/lib/mcp/tools/core/create_project.js +1 -0
- package/lib/mcp/tools/core/deploy.js +1 -0
- package/lib/mcp/tools/core/deploy_status.js +1 -0
- package/lib/mcp/tools/core/get_environment.js +1 -0
- package/lib/mcp/tools/core/get_project.js +1 -0
- package/lib/mcp/tools/core/get_sdk_config.js +1 -0
- package/lib/mcp/tools/core/get_security_rules.js +1 -0
- package/lib/mcp/tools/core/init.js +1 -0
- package/lib/mcp/tools/core/list_apps.js +1 -0
- package/lib/mcp/tools/core/list_projects.js +1 -0
- package/lib/mcp/tools/core/login.js +1 -0
- package/lib/mcp/tools/core/logout.js +1 -0
- package/lib/mcp/tools/core/read_resources.js +1 -0
- package/lib/mcp/tools/core/update_environment.js +1 -0
- package/lib/mcp/tools/core/validate_security_rules.js +1 -0
- package/lib/mcp/tools/crashlytics/events.js +2 -0
- package/lib/mcp/tools/crashlytics/issues.js +2 -0
- package/lib/mcp/tools/crashlytics/notes.js +3 -0
- package/lib/mcp/tools/crashlytics/reports.js +1 -0
- package/lib/mcp/tools/dataconnect/compile.js +1 -0
- package/lib/mcp/tools/dataconnect/execute.js +34 -19
- package/lib/mcp/tools/dataconnect/index.js +1 -1
- package/lib/mcp/tools/dataconnect/list_services.js +1 -0
- package/lib/mcp/tools/firestore/query_collection.js +1 -0
- package/lib/mcp/tools/functions/get_logs.js +1 -0
- package/lib/mcp/tools/functions/list_functions.js +1 -0
- package/lib/mcp/tools/index.js +3 -1
- package/lib/mcp/tools/messaging/send_message.js +1 -0
- package/lib/mcp/tools/realtime_database/get_data.js +1 -0
- package/lib/mcp/tools/realtime_database/set_data.js +1 -0
- package/lib/mcp/tools/remoteconfig/get_template.js +1 -0
- package/lib/mcp/tools/remoteconfig/update_template.js +1 -0
- package/lib/mcp/tools/storage/get_download_url.js +1 -0
- package/lib/prompt.js +10 -1
- package/lib/throttler/throttler.js +2 -11
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/lib/utils.js +26 -0
- package/package.json +5 -5
- package/templates/init/functions/typescript/index-kit-migration.ts +21 -2
- package/templates/init/functions/typescript/index-kit.ts +1 -0
- package/templates/init/functions/typescript/package-kit.json +21 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateAppApiKeyRestriction = updateAppApiKeyRestriction;
|
|
4
|
+
const api_1 = require("../api");
|
|
5
|
+
const apiv2_1 = require("../apiv2");
|
|
6
|
+
const error_1 = require("../error");
|
|
7
|
+
const operation_poller_1 = require("../operation-poller");
|
|
8
|
+
const API_VERSION = "v2";
|
|
9
|
+
const CREDENTIALS_CONSOLE_URL = "https://console.cloud.google.com/apis/credentials";
|
|
10
|
+
const client = new apiv2_1.Client({
|
|
11
|
+
urlPrefix: (0, api_1.apiKeysOrigin)(),
|
|
12
|
+
auth: true,
|
|
13
|
+
apiVersion: API_VERSION,
|
|
14
|
+
});
|
|
15
|
+
async function updateAppApiKeyRestriction(options) {
|
|
16
|
+
const { apiKey, service } = options;
|
|
17
|
+
const keyResourceName = await lookupKeyResourceName(apiKey);
|
|
18
|
+
const key = await getKey(keyResourceName);
|
|
19
|
+
await ensureServiceInKeyRestrictions(key, service);
|
|
20
|
+
}
|
|
21
|
+
async function lookupKeyResourceName(apiKeyString) {
|
|
22
|
+
try {
|
|
23
|
+
const res = await client.get("/keys:lookupKey", {
|
|
24
|
+
queryParams: { keyString: apiKeyString },
|
|
25
|
+
});
|
|
26
|
+
return res.body.name;
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
if ((0, error_1.getErrStatus)(err) === 403) {
|
|
30
|
+
throw new error_1.FirebaseError(`Permission denied when looking up API key.\n\n` +
|
|
31
|
+
`To resolve this, ensure your account has the right permissions on the project in the Google Cloud Console:\n\n` +
|
|
32
|
+
` ${CREDENTIALS_CONSOLE_URL}`, { original: err instanceof Error ? err : undefined, status: 403 });
|
|
33
|
+
}
|
|
34
|
+
throw err;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async function getKey(keyResourceName) {
|
|
38
|
+
try {
|
|
39
|
+
const res = await client.get(keyResourceName);
|
|
40
|
+
return res.body;
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
if ((0, error_1.getErrStatus)(err) === 403) {
|
|
44
|
+
throw new error_1.FirebaseError(`Permission denied when retrieving API key ${keyResourceName}.\n\n` +
|
|
45
|
+
`To resolve this, ensure your account has the right permissions on the project in the Google Cloud Console:\n\n` +
|
|
46
|
+
` ${CREDENTIALS_CONSOLE_URL}`, { original: err instanceof Error ? err : undefined, status: 403 });
|
|
47
|
+
}
|
|
48
|
+
throw err;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async function ensureServiceInKeyRestrictions(key, service) {
|
|
52
|
+
if (!key.restrictions?.apiTargets || key.restrictions.apiTargets.length === 0) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const alreadyAllowed = key.restrictions.apiTargets.some((target) => target.service === service);
|
|
56
|
+
if (alreadyAllowed) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const updatedRestrictions = {
|
|
60
|
+
...key.restrictions,
|
|
61
|
+
apiTargets: [...key.restrictions.apiTargets, { service }],
|
|
62
|
+
};
|
|
63
|
+
await updateKeyRestrictions({
|
|
64
|
+
...key,
|
|
65
|
+
restrictions: updatedRestrictions,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async function updateKeyRestrictions(key) {
|
|
69
|
+
const queryParams = { updateMask: "restrictions" };
|
|
70
|
+
try {
|
|
71
|
+
const res = await client.patch(key.name, key, {
|
|
72
|
+
queryParams,
|
|
73
|
+
});
|
|
74
|
+
await (0, operation_poller_1.pollOperation)({
|
|
75
|
+
apiOrigin: (0, api_1.apiKeysOrigin)(),
|
|
76
|
+
apiVersion: API_VERSION,
|
|
77
|
+
operationResourceName: res.body.name,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
if ((0, error_1.getErrStatus)(err) === 403) {
|
|
82
|
+
const keyIdentifier = key.displayName ? `${key.displayName} (${key.name})` : key.name;
|
|
83
|
+
throw new error_1.FirebaseError(`Permission denied when updating API key ${keyIdentifier}.\n\n` +
|
|
84
|
+
`To resolve this, ensure your account has the right permissions on the project in the Google Cloud Console:\n\n` +
|
|
85
|
+
` ${CREDENTIALS_CONSOLE_URL}`, { original: err instanceof Error ? err : undefined, status: 403 });
|
|
86
|
+
}
|
|
87
|
+
throw err;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -7,9 +7,10 @@ exports.addServiceAccountToRoles = addServiceAccountToRoles;
|
|
|
7
7
|
exports.serviceAccountHasRoles = serviceAccountHasRoles;
|
|
8
8
|
exports.removeServiceAccountRoles = removeServiceAccountRoles;
|
|
9
9
|
exports.getServiceAccountRoles = getServiceAccountRoles;
|
|
10
|
-
const lodash_1 = require("lodash");
|
|
11
10
|
const api_1 = require("../api");
|
|
12
11
|
const apiv2_1 = require("../apiv2");
|
|
12
|
+
const error_1 = require("../error");
|
|
13
|
+
const utils = require("../utils");
|
|
13
14
|
const iam_1 = require("./iam");
|
|
14
15
|
const API_VERSION = "v1";
|
|
15
16
|
const apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.resourceManagerOrigin)(), apiVersion: API_VERSION });
|
|
@@ -32,30 +33,38 @@ async function setIamPolicy(projectIdOrNumber, newPolicy, updateMask = "") {
|
|
|
32
33
|
});
|
|
33
34
|
return response.body;
|
|
34
35
|
}
|
|
36
|
+
function isRetryableIamError(err) {
|
|
37
|
+
const status = (0, error_1.getErrStatus)(err);
|
|
38
|
+
if (status === 409) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
const msg = (0, error_1.getErrMsg)(err).toLowerCase();
|
|
42
|
+
const hasSa = msg.includes("service account") || msg.includes("serviceaccount");
|
|
43
|
+
if (status === 400 && hasSa && msg.includes("does not exist")) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
35
48
|
async function addServiceAccountToRoles(projectId, serviceAccountName, roles, skipAccountLookup = false) {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
: (0, iam_1.getServiceAccount)(projectId, serviceAccountName),
|
|
40
|
-
getIamPolicy(projectId),
|
|
41
|
-
]);
|
|
42
|
-
projectPolicy.bindings = projectPolicy.bindings || [];
|
|
49
|
+
const { name: fullServiceAccountName } = skipAccountLookup
|
|
50
|
+
? { name: serviceAccountName }
|
|
51
|
+
: await (0, iam_1.getServiceAccount)(projectId, serviceAccountName);
|
|
43
52
|
const newMemberName = `serviceAccount:${fullServiceAccountName.split("/").pop()}`;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
return await utils.retryWithBackoff(async () => {
|
|
54
|
+
const projectPolicy = await getIamPolicy(projectId);
|
|
55
|
+
projectPolicy.bindings = projectPolicy.bindings || [];
|
|
56
|
+
const requiredBindings = roles.map((role) => ({
|
|
57
|
+
role,
|
|
58
|
+
members: [newMemberName],
|
|
59
|
+
}));
|
|
60
|
+
(0, iam_1.mergeBindings)(projectPolicy, requiredBindings);
|
|
61
|
+
return await setIamPolicy(projectId, projectPolicy, "bindings");
|
|
62
|
+
}, {
|
|
63
|
+
retries: 6,
|
|
64
|
+
delay: 1000,
|
|
65
|
+
maxDelay: 5000,
|
|
66
|
+
retryPredicate: isRetryableIamError,
|
|
57
67
|
});
|
|
58
|
-
return setIamPolicy(projectId, projectPolicy, "bindings");
|
|
59
68
|
}
|
|
60
69
|
async function serviceAccountHasRoles(projectId, serviceAccountName, roles, skipAccountLookup = false) {
|
|
61
70
|
const [{ name: fullServiceAccountName }, projectPolicy] = await Promise.all([
|
package/lib/gcp/run.js
CHANGED
|
@@ -15,7 +15,7 @@ const apiv2_1 = require("../apiv2");
|
|
|
15
15
|
const error_1 = require("../error");
|
|
16
16
|
const api_1 = require("../api");
|
|
17
17
|
const proto = require("./proto");
|
|
18
|
-
const
|
|
18
|
+
const utils_1 = require("../utils");
|
|
19
19
|
const logger_1 = require("../logger");
|
|
20
20
|
const cloudlogging_1 = require("./cloudlogging");
|
|
21
21
|
const API_VERSION = "v1";
|
|
@@ -49,7 +49,7 @@ async function updateService(name, service) {
|
|
|
49
49
|
service = await exports.replaceService(name, service);
|
|
50
50
|
let retry = 0;
|
|
51
51
|
while (!exports.serviceIsResolved(service)) {
|
|
52
|
-
await (0,
|
|
52
|
+
await (0, utils_1.backoff)(retry, 2, 30);
|
|
53
53
|
retry = retry + 1;
|
|
54
54
|
service = await exports.getService(name);
|
|
55
55
|
}
|
package/lib/gcp/storage.js
CHANGED
|
@@ -72,7 +72,7 @@ async function upload(source, uploadUrl, extraHeaders, ignoreQuotaProject) {
|
|
|
72
72
|
generation: res.response.headers.get("x-goog-generation"),
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
async function uploadObject(source, bucketName, contentType) {
|
|
75
|
+
async function uploadObject(source, bucketName, contentType, maxSizeBytes) {
|
|
76
76
|
switch (contentType) {
|
|
77
77
|
case ContentType.TAR:
|
|
78
78
|
if (!source.file.endsWith(".tar.gz")) {
|
|
@@ -86,12 +86,13 @@ async function uploadObject(source, bucketName, contentType) {
|
|
|
86
86
|
}
|
|
87
87
|
const localAPIClient = new apiv2_1.Client({ urlPrefix: (0, api_1.storageOrigin)() });
|
|
88
88
|
const location = `/${bucketName}/${path.basename(source.file)}`;
|
|
89
|
+
const rangeHeader = maxSizeBytes !== undefined ? `0,${maxSizeBytes}` : "0,123289600";
|
|
89
90
|
const res = await localAPIClient.request({
|
|
90
91
|
method: "PUT",
|
|
91
92
|
path: location,
|
|
92
93
|
headers: {
|
|
93
94
|
"Content-Type": contentType === ContentType.TAR ? "application/octet-stream" : "application/zip",
|
|
94
|
-
"x-goog-content-length-range":
|
|
95
|
+
"x-goog-content-length-range": rangeHeader,
|
|
95
96
|
},
|
|
96
97
|
body: source.stream,
|
|
97
98
|
});
|
package/lib/logger.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.logger = exports.vsceLogEmitter = void 0;
|
|
4
|
+
exports.resolveLogTarget = resolveLogTarget;
|
|
4
5
|
exports.findAvailableLogFile = findAvailableLogFile;
|
|
5
6
|
exports.tryStringify = tryStringify;
|
|
6
7
|
exports.useFileLogger = useFileLogger;
|
|
@@ -8,6 +9,7 @@ exports.useConsoleLoggers = useConsoleLoggers;
|
|
|
8
9
|
const winston = require("winston");
|
|
9
10
|
const events_1 = require("events");
|
|
10
11
|
const path = require("path");
|
|
12
|
+
const os = require("os");
|
|
11
13
|
const fs = require("fs");
|
|
12
14
|
const triple_beam_1 = require("triple-beam");
|
|
13
15
|
const util_1 = require("util");
|
|
@@ -53,25 +55,97 @@ function maybeUseVSCodeLogger(logger) {
|
|
|
53
55
|
logger.log = vsceLogger;
|
|
54
56
|
return logger;
|
|
55
57
|
}
|
|
56
|
-
function
|
|
57
|
-
const
|
|
58
|
+
function resolveLogTarget(customPath) {
|
|
59
|
+
const debugPath = customPath ?? process.env.FIREBASE_DEBUG_PATH;
|
|
60
|
+
if (!debugPath || !debugPath.trim()) {
|
|
61
|
+
return {
|
|
62
|
+
baseDir: process.cwd(),
|
|
63
|
+
baseName: "firebase-debug",
|
|
64
|
+
ext: ".log",
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
let trimmed = debugPath.trim();
|
|
68
|
+
if (trimmed === "~" || trimmed.startsWith("~/") || trimmed.startsWith("~\\")) {
|
|
69
|
+
trimmed = path.join(os.homedir(), trimmed.slice(1));
|
|
70
|
+
}
|
|
71
|
+
const resolvedPath = path.resolve(process.cwd(), trimmed);
|
|
72
|
+
if (fs.existsSync(resolvedPath)) {
|
|
73
|
+
let isDir = false;
|
|
74
|
+
try {
|
|
75
|
+
isDir = fs.statSync(resolvedPath).isDirectory();
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
}
|
|
79
|
+
if (isDir) {
|
|
80
|
+
return {
|
|
81
|
+
baseDir: resolvedPath,
|
|
82
|
+
baseName: "firebase-debug",
|
|
83
|
+
ext: ".log",
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const ext = path.extname(resolvedPath);
|
|
87
|
+
return {
|
|
88
|
+
baseDir: path.dirname(resolvedPath),
|
|
89
|
+
baseName: path.basename(resolvedPath, ext),
|
|
90
|
+
ext,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (trimmed.endsWith(path.sep) || trimmed.endsWith("/") || trimmed.endsWith("\\")) {
|
|
94
|
+
return {
|
|
95
|
+
baseDir: resolvedPath,
|
|
96
|
+
baseName: "firebase-debug",
|
|
97
|
+
ext: ".log",
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const ext = path.extname(resolvedPath);
|
|
101
|
+
if (ext) {
|
|
102
|
+
return {
|
|
103
|
+
baseDir: path.dirname(resolvedPath),
|
|
104
|
+
baseName: path.basename(resolvedPath, ext),
|
|
105
|
+
ext,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
baseDir: resolvedPath,
|
|
110
|
+
baseName: "firebase-debug",
|
|
111
|
+
ext: ".log",
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function findAvailableLogFile(customPath) {
|
|
115
|
+
const { baseDir, baseName, ext } = resolveLogTarget(customPath);
|
|
116
|
+
if (!fs.existsSync(baseDir)) {
|
|
117
|
+
try {
|
|
118
|
+
fs.mkdirSync(baseDir, { recursive: true });
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const candidates = [`${baseName}${ext}`];
|
|
58
124
|
for (let i = 1; i < 10; i++) {
|
|
59
|
-
candidates.push(
|
|
125
|
+
candidates.push(`${baseName}.${i}${ext}`);
|
|
60
126
|
}
|
|
61
127
|
for (const c of candidates) {
|
|
62
|
-
const logFilename = path.join(
|
|
128
|
+
const logFilename = path.join(baseDir, c);
|
|
63
129
|
try {
|
|
64
130
|
const fd = fs.openSync(logFilename, "r+");
|
|
65
131
|
fs.closeSync(fd);
|
|
66
132
|
return logFilename;
|
|
67
133
|
}
|
|
68
|
-
catch (
|
|
69
|
-
if (
|
|
70
|
-
|
|
134
|
+
catch (err) {
|
|
135
|
+
if (typeof err === "object" &&
|
|
136
|
+
err !== null &&
|
|
137
|
+
"code" in err &&
|
|
138
|
+
err.code === "ENOENT") {
|
|
139
|
+
try {
|
|
140
|
+
fs.accessSync(baseDir, fs.constants.W_OK);
|
|
141
|
+
return logFilename;
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
}
|
|
71
145
|
}
|
|
72
146
|
}
|
|
73
147
|
}
|
|
74
|
-
throw new Error(
|
|
148
|
+
throw new Error(`Unable to obtain permissions for ${baseName}${ext}`);
|
|
75
149
|
}
|
|
76
150
|
function tryStringify(value) {
|
|
77
151
|
if (typeof value === "string") {
|
|
@@ -92,7 +166,7 @@ rawLogger.add(new winston.transports.Console({
|
|
|
92
166
|
rawLogger.exitOnError = false;
|
|
93
167
|
exports.logger = maybeUseVSCodeLogger(annotateDebugLines(expandErrors(rawLogger)));
|
|
94
168
|
function useFileLogger(logFile) {
|
|
95
|
-
const logFileName =
|
|
169
|
+
const logFileName = findAvailableLogFile(logFile);
|
|
96
170
|
exports.logger.add(new winston.transports.File({
|
|
97
171
|
level: "debug",
|
|
98
172
|
filename: logFileName,
|
package/lib/mcp/onemcp/index.js
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ONEMCP_SERVERS = void 0;
|
|
4
|
+
exports.dataConnectLocationHeaderInjector = dataConnectLocationHeaderInjector;
|
|
4
5
|
const api_1 = require("../../api");
|
|
5
6
|
const onemcp_server_1 = require("./onemcp_server");
|
|
7
|
+
function dataConnectLocationHeaderInjector(headers, _toolName, args) {
|
|
8
|
+
if (typeof args?.location === "string" && args.location && !headers["Mcp-Param-Region"]) {
|
|
9
|
+
return { "Mcp-Param-Region": args.location };
|
|
10
|
+
}
|
|
11
|
+
}
|
|
6
12
|
exports.ONEMCP_SERVERS = {
|
|
13
|
+
dataconnect: new onemcp_server_1.OneMcpServer("dataconnect", (0, api_1.dataconnectOrigin)(), {
|
|
14
|
+
requiresAuth: true,
|
|
15
|
+
}, {
|
|
16
|
+
allowedTools: [
|
|
17
|
+
"execute_graphql",
|
|
18
|
+
"execute_graphql_read",
|
|
19
|
+
"generate_schema",
|
|
20
|
+
"generate_query",
|
|
21
|
+
"generate_query_from_schema",
|
|
22
|
+
"list_locations",
|
|
23
|
+
],
|
|
24
|
+
headerOverride: dataConnectLocationHeaderInjector,
|
|
25
|
+
}),
|
|
7
26
|
developerknowledge: new onemcp_server_1.OneMcpServer("developerknowledge", (0, api_1.developerKnowledgeOrigin)(), {
|
|
8
27
|
requiresAuth: true,
|
|
9
28
|
}, {
|
|
@@ -88,6 +88,17 @@ class OneMcpServer {
|
|
|
88
88
|
await (0, ensureApiEnabled_1.ensure)(ctx.projectId, this.serverUrl, this.feature, true);
|
|
89
89
|
}
|
|
90
90
|
try {
|
|
91
|
+
const baseHeaders = {
|
|
92
|
+
"MCP-Protocol-Version": types_js_1.LATEST_PROTOCOL_VERSION,
|
|
93
|
+
"Mcp-Method": "tools/call",
|
|
94
|
+
"Mcp-Name": toolName,
|
|
95
|
+
...(ctx.projectId ? { "x-goog-user-project": ctx.projectId } : {}),
|
|
96
|
+
...paramHeaders,
|
|
97
|
+
};
|
|
98
|
+
const headers = {
|
|
99
|
+
...baseHeaders,
|
|
100
|
+
...(this.options.headerOverride?.(baseHeaders, toolName, args) ?? {}),
|
|
101
|
+
};
|
|
91
102
|
const res = await this.callClient.post("/mcp", {
|
|
92
103
|
method: "tools/call",
|
|
93
104
|
params: {
|
|
@@ -97,13 +108,7 @@ class OneMcpServer {
|
|
|
97
108
|
jsonrpc: "2.0",
|
|
98
109
|
id: 1,
|
|
99
110
|
}, {
|
|
100
|
-
headers
|
|
101
|
-
"MCP-Protocol-Version": types_js_1.LATEST_PROTOCOL_VERSION,
|
|
102
|
-
"Mcp-Method": "tools/call",
|
|
103
|
-
"Mcp-Name": toolName,
|
|
104
|
-
...(ctx.projectId ? { "x-goog-user-project": ctx.projectId } : {}),
|
|
105
|
-
...paramHeaders,
|
|
106
|
-
},
|
|
111
|
+
headers,
|
|
107
112
|
});
|
|
108
113
|
return types_js_1.CallToolResultSchema.parse(res.body.result);
|
|
109
114
|
}
|
|
@@ -12,6 +12,7 @@ const cloudlogging_1 = require("../../../gcp/cloudlogging");
|
|
|
12
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
|
+
humanReadableDescription: "Fetch recent service or build logs for an App Hosting backend.",
|
|
15
16
|
inputSchema: zod_1.z.object({
|
|
16
17
|
buildLogs: zod_1.z
|
|
17
18
|
.boolean()
|
|
@@ -15,6 +15,7 @@ exports.list_backends = (0, tool_1.tool)("apphosting", {
|
|
|
15
15
|
" Every backend should have a `DEFAULT` domain. " +
|
|
16
16
|
" The actual domain that a user would use to connect to the backend is the last parameter of the domain resource name. " +
|
|
17
17
|
" If a custom domain is correctly set up, it will have statuses ending in `ACTIVE`.",
|
|
18
|
+
humanReadableDescription: "List App Hosting backends, traffic configurations, and custom domains in your project.",
|
|
18
19
|
inputSchema: zod_1.z.object({
|
|
19
20
|
location: zod_1.z
|
|
20
21
|
.string()
|
|
@@ -41,6 +41,7 @@ const defaultDevices = [
|
|
|
41
41
|
exports.run_tests = (0, tool_1.tool)("apptesting", {
|
|
42
42
|
name: "run_test",
|
|
43
43
|
description: `Run a remote test.`,
|
|
44
|
+
humanReadableDescription: "Run an automated test case on a remote Android or iOS device via Firebase App Distribution.",
|
|
44
45
|
inputSchema: zod_1.z.object({
|
|
45
46
|
appId: filters_1.ApplicationIdSchema,
|
|
46
47
|
releaseBinaryFile: zod_1.z.string().describe("Path to the binary release (APK)."),
|
|
@@ -66,6 +67,7 @@ exports.run_tests = (0, tool_1.tool)("apptesting", {
|
|
|
66
67
|
exports.check_status = (0, tool_1.tool)("apptesting", {
|
|
67
68
|
name: "check_status",
|
|
68
69
|
description: "Check the status of an apptesting release test and/or get available devices that can be used for automated tests ",
|
|
70
|
+
humanReadableDescription: "Check the status of an automated release test or list available test devices.",
|
|
69
71
|
inputSchema: zod_1.z.object({
|
|
70
72
|
release_test_name: zod_1.z
|
|
71
73
|
.string()
|
|
@@ -8,6 +8,7 @@ const auth_1 = require("../../../gcp/auth");
|
|
|
8
8
|
exports.get_users = (0, tool_1.tool)("auth", {
|
|
9
9
|
name: "get_users",
|
|
10
10
|
description: "Use this to retrieve one or more Firebase Auth users based on a list of UIDs or a list of emails.",
|
|
11
|
+
humanReadableDescription: "Retrieve Firebase Auth users by UID, email, phone number, or list all users.",
|
|
11
12
|
inputSchema: zod_1.z.object({
|
|
12
13
|
uids: zod_1.z.array(zod_1.z.string()).optional().describe("A list of user UIDs to retrieve."),
|
|
13
14
|
emails: zod_1.z.array(zod_1.z.string()).optional().describe("A list of user emails to retrieve."),
|
|
@@ -8,6 +8,7 @@ const auth_1 = require("../../../gcp/auth");
|
|
|
8
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
|
+
humanReadableDescription: "Set an SMS region policy allowing or denying specific country codes for Firebase Authentication.",
|
|
11
12
|
inputSchema: zod_1.z.object({
|
|
12
13
|
policy_type: zod_1.z
|
|
13
14
|
.enum(["ALLOW", "DENY"])
|
|
@@ -8,6 +8,7 @@ const auth_1 = require("../../../gcp/auth");
|
|
|
8
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
|
+
humanReadableDescription: "Update a user's account by enabling/disabling it or setting custom claims.",
|
|
11
12
|
inputSchema: zod_1.z.object({
|
|
12
13
|
uid: zod_1.z.string().describe("the UID of the user to update"),
|
|
13
14
|
disabled: zod_1.z.boolean().optional().describe("true disables the user, false enables the user"),
|
|
@@ -17,6 +17,7 @@ function getCertHashType(shaHash) {
|
|
|
17
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
|
+
humanReadableDescription: "Add a SHA-1 or SHA-256 certificate hash to an Android app in the active Firebase project.",
|
|
20
21
|
inputSchema: zod_1.z.object({
|
|
21
22
|
app_id: zod_1.z.string().describe("The Android app ID to add the SHA certificate to."),
|
|
22
23
|
sha_hash: zod_1.z.string().describe("The SHA certificate hash to add (SHA-1 or SHA-256)."),
|
|
@@ -10,6 +10,7 @@ const CREATE_APP_OUTUT_SUFFIX = "\n\nTo fetch the SDK configuration for this app
|
|
|
10
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
|
+
humanReadableDescription: "Create a new iOS, Android, or Web app in the active Firebase project.",
|
|
13
14
|
inputSchema: zod_1.z.object({
|
|
14
15
|
display_name: zod_1.z
|
|
15
16
|
.string()
|
|
@@ -20,6 +20,7 @@ async function checkCloudProject(projectId) {
|
|
|
20
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
|
+
humanReadableDescription: "Create a new Firebase project or enable Firebase services on an existing Google Cloud project.",
|
|
23
24
|
inputSchema: zod_1.z.object({
|
|
24
25
|
project_id: zod_1.z.string().describe("The project ID to create or use."),
|
|
25
26
|
display_name: zod_1.z
|
|
@@ -21,6 +21,7 @@ const TARGETS = {
|
|
|
21
21
|
exports.deploy = (0, tool_1.tool)("core", {
|
|
22
22
|
name: "deploy",
|
|
23
23
|
description: "Deploy resources to your Firebase project, based on the contents of firebase.json.",
|
|
24
|
+
humanReadableDescription: "Deploy Firebase services and resources configured in firebase.json to your project.",
|
|
24
25
|
inputSchema: zod_1.z.object({
|
|
25
26
|
only: zod_1.z
|
|
26
27
|
.string()
|
|
@@ -8,6 +8,7 @@ const jobs_1 = require("../../util/jobs");
|
|
|
8
8
|
exports.deploy_status = (0, tool_1.tool)("core", {
|
|
9
9
|
name: "deploy_status",
|
|
10
10
|
description: "Check the status of a background deployment job using its Job ID.",
|
|
11
|
+
humanReadableDescription: "Check the status and progress of a background deployment job.",
|
|
11
12
|
inputSchema: zod_1.z.object({
|
|
12
13
|
jobId: zod_1.z.string().describe("The Job ID returned by the deploy tool"),
|
|
13
14
|
}),
|
|
@@ -56,6 +56,7 @@ Confirm with the user before taking action.`}`;
|
|
|
56
56
|
exports.get_environment = (0, tool_1.tool)("core", {
|
|
57
57
|
name: "get_environment",
|
|
58
58
|
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. All tools require the user to be authenticated, but not all information is required for all tools. Pay attention to the tool requirements for which pieces of information are required.",
|
|
59
|
+
humanReadableDescription: "Retrieve the current Firebase CLI and MCP environment configuration, active project, and authenticated user.",
|
|
59
60
|
inputSchema: zod_1.z.object({}),
|
|
60
61
|
annotations: {
|
|
61
62
|
title: "Get Firebase Environment Info",
|
|
@@ -8,6 +8,7 @@ const util_1 = require("../../util");
|
|
|
8
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
|
+
humanReadableDescription: "Retrieve metadata and configuration details for the currently active Firebase project.",
|
|
11
12
|
inputSchema: zod_1.z.object({}),
|
|
12
13
|
annotations: {
|
|
13
14
|
title: "Get Current Firebase Project",
|
|
@@ -9,6 +9,7 @@ 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.",
|
|
12
|
+
humanReadableDescription: "Retrieve SDK configuration details or config file contents for a registered Firebase app.",
|
|
12
13
|
inputSchema: zod_1.z.object({
|
|
13
14
|
platform: zod_1.z
|
|
14
15
|
.enum(["ios", "android", "web"])
|
|
@@ -12,6 +12,7 @@ exports.get_security_rules = (0, tool_1.tool)("core", {
|
|
|
12
12
|
name: "get_security_rules",
|
|
13
13
|
description: "Use this to retrieve the security rules for a specified Firebase service. " +
|
|
14
14
|
"If there are multiple instances of that service in the product, the rules for the default instance are returned.",
|
|
15
|
+
humanReadableDescription: "Retrieve the active security rules for Firestore, Storage, or Realtime Database.",
|
|
15
16
|
inputSchema: zod_1.z.object({
|
|
16
17
|
type: zod_1.z.enum(["firestore", "rtdb", "storage"]).describe("The service to get rules for."),
|
|
17
18
|
}),
|
|
@@ -16,6 +16,7 @@ exports.init = (0, tool_1.tool)("core", {
|
|
|
16
16
|
description: "Use this to initialize selected Firebase services in the workspace (Cloud Firestore database, Firebase SQL Connect, Firebase Realtime Database, Firebase AI Logic). All services are optional; specify only the products you want to set up. " +
|
|
17
17
|
"You can initialize new features into an existing project directory, but re-initializing an existing feature may overwrite configuration. " +
|
|
18
18
|
"To deploy the initialized features, run the `firebase deploy` command after `firebase_init` tool.",
|
|
19
|
+
humanReadableDescription: "Initialize and configure Firebase services in your local project workspace.",
|
|
19
20
|
inputSchema: zod_1.z.object({
|
|
20
21
|
features: zod_1.z.object({
|
|
21
22
|
database: zod_1.z
|
|
@@ -8,6 +8,7 @@ const apps_1 = require("../../../management/apps");
|
|
|
8
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
|
+
humanReadableDescription: "List all Firebase apps registered in the active project.",
|
|
11
12
|
inputSchema: zod_1.z.object({
|
|
12
13
|
platform: zod_1.z
|
|
13
14
|
.enum(["ios", "android", "web", "all"])
|
|
@@ -9,6 +9,7 @@ const PROJECT_LIST_PAGE_SIZE = 20;
|
|
|
9
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
|
+
humanReadableDescription: "List Firebase projects accessible by the authenticated user.",
|
|
12
13
|
inputSchema: zod_1.z.object({
|
|
13
14
|
page_size: zod_1.z
|
|
14
15
|
.number()
|
|
@@ -9,6 +9,7 @@ const logger_1 = require("../../../logger");
|
|
|
9
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
|
+
humanReadableDescription: "Sign the user out of the Firebase CLI and MCP server.",
|
|
12
13
|
inputSchema: zod_1.z.object({
|
|
13
14
|
email: zod_1.z
|
|
14
15
|
.string()
|
|
@@ -9,6 +9,7 @@ const track_1 = require("../../../track");
|
|
|
9
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
|
+
humanReadableDescription: "Read the contents of internal firebase:// documentation resources or list all available resources.",
|
|
12
13
|
annotations: {
|
|
13
14
|
title: "Read Firebase Resources",
|
|
14
15
|
destructiveHint: false,
|
|
@@ -10,6 +10,7 @@ const node_fs_1 = require("node:fs");
|
|
|
10
10
|
exports.update_environment = (0, tool_1.tool)("core", {
|
|
11
11
|
name: "update_environment",
|
|
12
12
|
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.",
|
|
13
|
+
humanReadableDescription: "Update environment settings such as project directory, active project, or active user account.",
|
|
13
14
|
inputSchema: zod_1.z.object({
|
|
14
15
|
project_dir: zod_1.z
|
|
15
16
|
.string()
|
|
@@ -45,6 +45,7 @@ function formatRulesetIssues(issues, rulesSource) {
|
|
|
45
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
|
+
humanReadableDescription: "Validate syntax and check for errors in Firestore, Storage, or Realtime Database security rules.",
|
|
48
49
|
inputSchema: zod_1.z.object({
|
|
49
50
|
type: zod_1.z.enum(["firestore", "storage", "rtdb"]),
|
|
50
51
|
source: zod_1.z
|
|
@@ -98,6 +98,7 @@ exports.list_events = (0, tool_1.tool)("crashlytics", {
|
|
|
98
98
|
description: `Use this to list the most recent events matching the given filters.
|
|
99
99
|
Can be used to fetch sample crashes and exceptions for an issue,
|
|
100
100
|
which will include stack traces and other data useful for debugging.`,
|
|
101
|
+
humanReadableDescription: "List recent crash and exception events matching specified filters for an issue.",
|
|
101
102
|
inputSchema: zod_1.z.object({
|
|
102
103
|
appId: filters_1.ApplicationIdSchema,
|
|
103
104
|
filter: filters_1.EventFilterSchema,
|
|
@@ -138,6 +139,7 @@ exports.batch_get_events = (0, tool_1.tool)("crashlytics", {
|
|
|
138
139
|
description: `Gets specific events by resource name.
|
|
139
140
|
Can be used to fetch sample crashes and exceptions for an issue,
|
|
140
141
|
which will include stack traces and other data useful for debugging.`,
|
|
142
|
+
humanReadableDescription: "Retrieve sample crash and exception events by resource name for debugging.",
|
|
141
143
|
inputSchema: zod_1.z.object({
|
|
142
144
|
appId: filters_1.ApplicationIdSchema,
|
|
143
145
|
names: zod_1.z
|