firebase-tools
Version:
Command-Line Interface for Firebase
56 lines (55 loc) • 2.56 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.update_environment = void 0;
const zod_1 = require("zod");
const tool_js_1 = require("../../tool.js");
const util_js_1 = require("../../util.js");
const use_js_1 = require("../../../commands/use.js");
const auth_js_1 = require("../../../auth.js");
const node_fs_1 = require("node:fs");
exports.update_environment = (0, tool_js_1.tool)({
name: "update_environment",
description: "Updates Firebase environment config such as project directory, active project, active user account, and more. Use `firebase_get_environment` to see the currently configured environment.",
inputSchema: zod_1.z.object({
project_dir: zod_1.z
.string()
.optional()
.describe("Change the current project directory - this should be a directory that has a `firebase.json` file (or will have one)."),
active_project: zod_1.z
.string()
.optional()
.describe("Change the active project for the current project directory. Should be a Firebase project ID or configured project alias."),
active_user_account: zod_1.z
.string()
.optional()
.describe("The email address of the signed-in user to authenticate as when interacting with the current project directory."),
}),
annotations: {
title: "Update Firebase Environment",
readOnlyHint: false,
},
_meta: {
requiresAuth: false,
requiresProject: false,
},
}, async ({ project_dir, active_project, active_user_account }, { config, rc, host }) => {
let output = "";
if (project_dir) {
if (!(0, node_fs_1.existsSync)(project_dir))
return (0, util_js_1.mcpError)(`Cannot update project directory to '${project_dir}' as it does not exist.`);
host.setProjectRoot(project_dir);
output += `- Updated project directory to '${project_dir}'\n`;
}
if (active_project) {
await (0, use_js_1.setNewActive)(active_project, undefined, rc, config.projectDir);
output += `- Updated active project to '${active_project}'\n`;
}
if (active_user_account) {
(0, auth_js_1.assertAccount)(active_user_account, { mcp: true });
(0, auth_js_1.setProjectAccount)(host.cachedProjectRoot, active_user_account);
output += `- Updated active account to '${active_user_account}'\n`;
}
if (output === "")
output = "No changes were made.";
return (0, util_js_1.toContent)(output);
});
;