firebase-tools 14.3.0 → 14.3.1
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/apphosting/githubConnections.js +13 -19
- package/lib/dataconnect/dataplaneClient.js +16 -1
- package/lib/dataconnect/types.js +5 -1
- package/lib/ensureApiEnabled.js +11 -1
- package/lib/gcp/storage.js +19 -1
- package/lib/init/features/emulators.js +1 -1
- package/lib/init/features/firestore/indexes.js +1 -0
- package/lib/init/features/firestore/rules.js +1 -0
- package/lib/management/projects.js +1 -1
- package/lib/mcp/index.js +1 -10
- package/lib/mcp/tools/auth/{disable_auth_user.js → disable_user.js} +3 -3
- package/lib/mcp/tools/auth/{get_auth_user.js → get_user.js} +4 -4
- package/lib/mcp/tools/auth/index.js +4 -9
- package/lib/mcp/tools/auth/{set_auth_claims.js → set_claims.js} +3 -3
- package/lib/mcp/tools/core/{consult_firebase_assistant.js → consult_assistant.js} +3 -3
- package/lib/mcp/tools/core/index.js +5 -8
- package/lib/mcp/tools/dataconnect/converter.js +18 -1
- package/lib/mcp/tools/dataconnect/execute_graphql.js +32 -0
- package/lib/mcp/tools/dataconnect/execute_graphql_read.js +32 -0
- package/lib/mcp/tools/dataconnect/execute_mutation.js +50 -0
- package/lib/mcp/tools/dataconnect/execute_query.js +50 -0
- package/lib/mcp/tools/dataconnect/{generate_dataconnect_operation.js → generate_operation.js} +3 -3
- package/lib/mcp/tools/dataconnect/{generate_dataconnect_schema.js → generate_schema.js} +3 -3
- package/lib/mcp/tools/dataconnect/{get_dataconnect_connector.js → get_connector.js} +5 -5
- package/lib/mcp/tools/dataconnect/{get_dataconnect_schema.js → get_schema.js} +5 -5
- package/lib/mcp/tools/dataconnect/index.js +18 -10
- package/lib/mcp/tools/dataconnect/{list_dataconnect_services.js → list_services.js} +4 -4
- package/lib/mcp/tools/{core/get_firebase_directory.js → directory/get_project_directory.js} +5 -5
- package/lib/mcp/tools/directory/index.js +6 -0
- package/lib/mcp/tools/{core/set_firebase_directory.js → directory/set_project_directory.js} +3 -3
- package/lib/mcp/tools/firestore/{get_firestore_documents.js → get_documents.js} +3 -3
- package/lib/mcp/tools/firestore/{get_firestore_rules.js → get_rules.js} +6 -6
- package/lib/mcp/tools/firestore/index.js +4 -8
- package/lib/mcp/tools/firestore/{list_firestore_collections.js → list_collections.js} +3 -3
- package/lib/mcp/tools/index.js +26 -9
- package/lib/mcp/tools/storage/get_download_url.js +31 -0
- package/lib/mcp/tools/storage/{get_storage_rules.js → get_rules.js} +6 -6
- package/lib/mcp/tools/storage/index.js +3 -2
- package/lib/mcp/types.js +1 -1
- package/package.json +1 -1
- package/lib/mcp/tools/project/index.js +0 -7
- /package/lib/mcp/tools/{project → core}/get_project.js +0 -0
- /package/lib/mcp/tools/{project → core}/get_sdk_config.js +0 -0
- /package/lib/mcp/tools/{project → core}/list_apps.js +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getGitHubCommit = exports.getGitHubBranch = exports.fetchRepositoryCloneUris = exports.listAppHostingConnections = exports.getOrCreateRepository = exports.getOrCreateConnection = exports.createConnection = exports.ensureSecretManagerAdminGrant = exports.promptGitHubBranch = exports.getOrCreateOauthConnection = exports.listValidInstallations = exports.promptGitHubInstallation = exports.getConnectionForInstallation = exports.linkGitHubRepository = exports.
|
|
3
|
+
exports.getGitHubCommit = exports.getGitHubBranch = exports.fetchRepositoryCloneUris = exports.listAppHostingConnections = exports.getOrCreateRepository = exports.getOrCreateConnection = exports.createConnection = exports.ensureSecretManagerAdminGrant = exports.promptGitHubBranch = exports.getOrCreateOauthConnection = exports.listValidInstallations = exports.promptGitHubInstallation = exports.getConnectionForInstallation = exports.linkGitHubRepository = exports.getOrCreateFullyInstalledGithubConnection = exports.generateConnectionId = exports.generateRepositoryId = exports.extractRepoSlugFromUri = exports.parseConnectionName = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
5
|
const devConnect = require("../gcp/devConnect");
|
|
6
6
|
const rm = require("../gcp/resourceManager");
|
|
@@ -14,7 +14,6 @@ const fuzzy = require("fuzzy");
|
|
|
14
14
|
const apiv2_1 = require("../apiv2");
|
|
15
15
|
const githubApiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.githubApiOrigin)(), auth: false });
|
|
16
16
|
const APPHOSTING_CONN_PATTERN = /.+\/apphosting-github-conn-.+$/;
|
|
17
|
-
const APPHOSTING_OAUTH_CONN_NAME = "firebase-app-hosting-github-oauth";
|
|
18
17
|
const CONNECTION_NAME_REGEX = /^projects\/(?<projectId>[^\/]+)\/locations\/(?<location>[^\/]+)\/connections\/(?<id>[^\/]+)$/;
|
|
19
18
|
function parseConnectionName(name) {
|
|
20
19
|
const match = CONNECTION_NAME_REGEX.exec(name);
|
|
@@ -48,13 +47,14 @@ function generateRepositoryId(remoteUri) {
|
|
|
48
47
|
return (_a = extractRepoSlugFromUri(remoteUri)) === null || _a === void 0 ? void 0 : _a.replaceAll("/", "-");
|
|
49
48
|
}
|
|
50
49
|
exports.generateRepositoryId = generateRepositoryId;
|
|
51
|
-
|
|
50
|
+
const generateConnectionId = () => {
|
|
52
51
|
const randomHash = Math.random().toString(36).slice(6);
|
|
53
52
|
return `apphosting-github-conn-${randomHash}`;
|
|
54
|
-
}
|
|
53
|
+
};
|
|
54
|
+
exports.generateConnectionId = generateConnectionId;
|
|
55
55
|
const ADD_ACCOUNT_CHOICE = "@ADD_ACCOUNT";
|
|
56
56
|
const MANAGE_INSTALLATION_CHOICE = "@MANAGE_INSTALLATION";
|
|
57
|
-
async function
|
|
57
|
+
async function getOrCreateFullyInstalledGithubConnection(projectId, location, createConnectionId) {
|
|
58
58
|
utils.logBullet(clc.bold(`${clc.yellow("===")} Import a GitHub repository`));
|
|
59
59
|
if (createConnectionId) {
|
|
60
60
|
try {
|
|
@@ -87,15 +87,15 @@ async function getOrCreateGithubConnectionWithSentinel(projectId, location, crea
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
if (!createConnectionId) {
|
|
90
|
-
createConnectionId = generateConnectionId();
|
|
90
|
+
createConnectionId = (0, exports.generateConnectionId)();
|
|
91
91
|
}
|
|
92
92
|
const connection = await createFullyInstalledConnection(projectId, location, createConnectionId, oauthConn, installationId);
|
|
93
93
|
return connection;
|
|
94
94
|
}
|
|
95
|
-
exports.
|
|
95
|
+
exports.getOrCreateFullyInstalledGithubConnection = getOrCreateFullyInstalledGithubConnection;
|
|
96
96
|
async function linkGitHubRepository(projectId, location, createConnectionId) {
|
|
97
97
|
var _a, _b;
|
|
98
|
-
const connection = await
|
|
98
|
+
const connection = await getOrCreateFullyInstalledGithubConnection(projectId, location, createConnectionId);
|
|
99
99
|
let repoCloneUri;
|
|
100
100
|
do {
|
|
101
101
|
if (repoCloneUri === MANAGE_INSTALLATION_CHOICE) {
|
|
@@ -192,18 +192,12 @@ async function listValidInstallations(projectId, location, connection) {
|
|
|
192
192
|
exports.listValidInstallations = listValidInstallations;
|
|
193
193
|
async function getOrCreateOauthConnection(projectId, location) {
|
|
194
194
|
let conn;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
catch (err) {
|
|
199
|
-
if (err.status === 404) {
|
|
200
|
-
await ensureSecretManagerAdminGrant(projectId);
|
|
201
|
-
conn = await createConnection(projectId, location, APPHOSTING_OAUTH_CONN_NAME);
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
throw err;
|
|
205
|
-
}
|
|
195
|
+
const completedConnections = await listAppHostingConnections(projectId, location);
|
|
196
|
+
if (completedConnections.length > 0) {
|
|
197
|
+
return completedConnections[0];
|
|
206
198
|
}
|
|
199
|
+
await ensureSecretManagerAdminGrant(projectId);
|
|
200
|
+
conn = await createConnection(projectId, location, (0, exports.generateConnectionId)());
|
|
207
201
|
while (conn.installationState.stage === "PENDING_USER_OAUTH") {
|
|
208
202
|
utils.logBullet("Please authorize the Firebase GitHub app by visiting this url:");
|
|
209
203
|
const { url, cleanup } = await utils.openInBrowserPopup(conn.installationState.actionUri, "Authorize the GitHub app");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.executeGraphQL = exports.dataconnectDataplaneClient = exports.DATACONNECT_API_VERSION = exports.dataconnectOrigin = void 0;
|
|
3
|
+
exports.executeGraphQLMutation = exports.executeGraphQLQuery = exports.executeGraphQLRead = exports.executeGraphQL = exports.dataconnectDataplaneClient = exports.DATACONNECT_API_VERSION = exports.dataconnectOrigin = void 0;
|
|
4
4
|
const api_1 = require("../api");
|
|
5
5
|
var api_2 = require("../api");
|
|
6
6
|
Object.defineProperty(exports, "dataconnectOrigin", { enumerable: true, get: function () { return api_2.dataconnectOrigin; } });
|
|
@@ -19,3 +19,18 @@ async function executeGraphQL(client, servicePath, body) {
|
|
|
19
19
|
return res;
|
|
20
20
|
}
|
|
21
21
|
exports.executeGraphQL = executeGraphQL;
|
|
22
|
+
async function executeGraphQLRead(client, servicePath, body) {
|
|
23
|
+
const res = await client.post(`${servicePath}:executeGraphqlRead`, body, { resolveOnHTTPError: true });
|
|
24
|
+
return res;
|
|
25
|
+
}
|
|
26
|
+
exports.executeGraphQLRead = executeGraphQLRead;
|
|
27
|
+
async function executeGraphQLQuery(client, connectorPath, body) {
|
|
28
|
+
const res = await client.post(`${connectorPath}:executeQuery`, body, { resolveOnHTTPError: true });
|
|
29
|
+
return res;
|
|
30
|
+
}
|
|
31
|
+
exports.executeGraphQLQuery = executeGraphQLQuery;
|
|
32
|
+
async function executeGraphQLMutation(client, connectorPath, body) {
|
|
33
|
+
const res = await client.post(`${connectorPath}:executeMutation`, body, { resolveOnHTTPError: true });
|
|
34
|
+
return res;
|
|
35
|
+
}
|
|
36
|
+
exports.executeGraphQLMutation = executeGraphQLMutation;
|
package/lib/dataconnect/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toDatasource = exports.Platform = exports.requiresVector = exports.SCHEMA_ID = void 0;
|
|
3
|
+
exports.isGraphQLResponseError = exports.isGraphQLResponse = exports.toDatasource = exports.Platform = exports.requiresVector = exports.SCHEMA_ID = void 0;
|
|
4
4
|
exports.SCHEMA_ID = "main";
|
|
5
5
|
function requiresVector(dm) {
|
|
6
6
|
var _a, _b, _c, _d;
|
|
@@ -31,3 +31,7 @@ function toDatasource(projectId, locationId, ds) {
|
|
|
31
31
|
return {};
|
|
32
32
|
}
|
|
33
33
|
exports.toDatasource = toDatasource;
|
|
34
|
+
const isGraphQLResponse = (g) => !!g.data || !!g.errors;
|
|
35
|
+
exports.isGraphQLResponse = isGraphQLResponse;
|
|
36
|
+
const isGraphQLResponseError = (g) => !!g.error;
|
|
37
|
+
exports.isGraphQLResponseError = isGraphQLResponseError;
|
package/lib/ensureApiEnabled.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.enableApiURI = exports.ensure = exports.check = exports.POLL_SETTINGS = void 0;
|
|
3
|
+
exports.enableApiURI = exports.bestEffortEnsure = exports.ensure = exports.check = exports.POLL_SETTINGS = void 0;
|
|
4
4
|
const colorette_1 = require("colorette");
|
|
5
5
|
const track_1 = require("./track");
|
|
6
6
|
const api_1 = require("./api");
|
|
7
7
|
const apiv2_1 = require("./apiv2");
|
|
8
8
|
const utils = require("./utils");
|
|
9
9
|
const error_1 = require("./error");
|
|
10
|
+
const logger_1 = require("./logger");
|
|
10
11
|
exports.POLL_SETTINGS = {
|
|
11
12
|
pollInterval: 10000,
|
|
12
13
|
pollsBeforeRetry: 12,
|
|
@@ -106,6 +107,15 @@ async function ensure(projectId, apiUri, prefix, silent = false) {
|
|
|
106
107
|
return enableApiWithRetries(projectId, hostname, prefix, silent);
|
|
107
108
|
}
|
|
108
109
|
exports.ensure = ensure;
|
|
110
|
+
async function bestEffortEnsure(projectId, apiUri, prefix, silent = false) {
|
|
111
|
+
try {
|
|
112
|
+
await ensure(projectId, apiUri, prefix, silent);
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
logger_1.logger.debug(`Unable to check that ${apiUri} is enabled on ${projectId}. Calls to it will fail if it is not enabled`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
exports.bestEffortEnsure = bestEffortEnsure;
|
|
109
119
|
function enableApiURI(projectId, apiName) {
|
|
110
120
|
return `https://console.cloud.google.com/apis/library/${apiName}?project=${projectId}`;
|
|
111
121
|
}
|
package/lib/gcp/storage.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getServiceAccount = exports.listBuckets = exports.getBucket = exports.deleteObject = exports.uploadObject = exports.upload = exports.getDefaultBucket = void 0;
|
|
3
|
+
exports.getDownloadUrl = exports.getServiceAccount = exports.listBuckets = exports.getBucket = exports.deleteObject = exports.uploadObject = exports.upload = exports.getDefaultBucket = void 0;
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const clc = require("colorette");
|
|
6
6
|
const api_1 = require("../api");
|
|
@@ -119,3 +119,21 @@ async function getServiceAccount(projectId) {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
exports.getServiceAccount = getServiceAccount;
|
|
122
|
+
async function getDownloadUrl(bucketName, objectPath) {
|
|
123
|
+
try {
|
|
124
|
+
const localAPIClient = new apiv2_1.Client({ urlPrefix: (0, api_1.firebaseStorageOrigin)() });
|
|
125
|
+
const response = await localAPIClient.get(`/v0/b/${bucketName}/o/${encodeURIComponent(objectPath)}`);
|
|
126
|
+
if (!response.body.downloadTokens) {
|
|
127
|
+
throw new Error("no download tokens exist for ${objectPath}, please visit the Firebase console to make one");
|
|
128
|
+
}
|
|
129
|
+
const [token] = response.body.downloadTokens.split(",");
|
|
130
|
+
return `${(0, api_1.firebaseStorageOrigin)()}/v0/b/${bucketName}/o/${encodeURIComponent(objectPath)}?alt=media&token=${token}`;
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
logger_1.logger.error(err);
|
|
134
|
+
throw new error_1.FirebaseError(`${err} Check that you have permission in the Firebase console to generate a download token`, {
|
|
135
|
+
original: err,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.getDownloadUrl = getDownloadUrl;
|
|
@@ -56,7 +56,7 @@ async function doSetup(setup, config) {
|
|
|
56
56
|
else {
|
|
57
57
|
const ui = setup.config.emulators.ui || {};
|
|
58
58
|
setup.config.emulators.ui = ui;
|
|
59
|
-
ui.
|
|
59
|
+
ui.enabled = await (0, prompt_1.confirm)({
|
|
60
60
|
message: `Would you like to enable the ${uiDesc}?`,
|
|
61
61
|
default: true,
|
|
62
62
|
});
|
|
@@ -22,6 +22,7 @@ async function initIndexes(setup, config) {
|
|
|
22
22
|
message: "What file should be used for Firestore indexes?",
|
|
23
23
|
default: "firestore.indexes.json",
|
|
24
24
|
}));
|
|
25
|
+
setup.config.firestore.indexes = filename;
|
|
25
26
|
if (fsutils.fileExistsSync(filename)) {
|
|
26
27
|
const msg = "File " +
|
|
27
28
|
clc.bold(filename) +
|
|
@@ -21,6 +21,7 @@ async function initRules(setup, config) {
|
|
|
21
21
|
message: "What file should be used for Firestore Rules?",
|
|
22
22
|
default: DEFAULT_RULES_FILE,
|
|
23
23
|
}));
|
|
24
|
+
setup.config.firestore.rules = filename;
|
|
24
25
|
if (fsutils.fileExistsSync(filename)) {
|
|
25
26
|
const msg = "File " +
|
|
26
27
|
clc.bold(filename) +
|
|
@@ -336,7 +336,7 @@ async function getFirebaseProject(projectId) {
|
|
|
336
336
|
}
|
|
337
337
|
exports.getFirebaseProject = getFirebaseProject;
|
|
338
338
|
async function getProject(projectId) {
|
|
339
|
-
await (0, ensureApiEnabled_1.
|
|
339
|
+
await (0, ensureApiEnabled_1.bestEffortEnsure)(projectId, api.resourceManagerOrigin(), "firebase", true);
|
|
340
340
|
const response = await resourceManagerClient.get(`/projects/${projectId}`);
|
|
341
341
|
return response.body;
|
|
342
342
|
}
|
package/lib/mcp/index.js
CHANGED
|
@@ -7,7 +7,6 @@ const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
|
7
7
|
const util_js_1 = require("./util.js");
|
|
8
8
|
const index_js_2 = require("./tools/index.js");
|
|
9
9
|
const configstore_js_1 = require("../configstore.js");
|
|
10
|
-
const index_js_3 = require("./tools/core/index.js");
|
|
11
10
|
const command_js_1 = require("../command.js");
|
|
12
11
|
const requireAuth_js_1 = require("../requireAuth.js");
|
|
13
12
|
const projectUtils_js_1 = require("../projectUtils.js");
|
|
@@ -31,15 +30,7 @@ class FirebaseMcpServer {
|
|
|
31
30
|
this.fixedRoot = true;
|
|
32
31
|
}
|
|
33
32
|
get availableTools() {
|
|
34
|
-
|
|
35
|
-
const toolDefs = this.fixedRoot ? [] : [...index_js_3.coreTools];
|
|
36
|
-
const activeFeatures = ((_a = this.activeFeatures) === null || _a === void 0 ? void 0 : _a.length)
|
|
37
|
-
? this.activeFeatures
|
|
38
|
-
: Object.keys(index_js_2.tools);
|
|
39
|
-
for (const key of activeFeatures || []) {
|
|
40
|
-
toolDefs.push(...index_js_2.tools[key]);
|
|
41
|
-
}
|
|
42
|
-
return toolDefs;
|
|
33
|
+
return (0, index_js_2.availableTools)(!!this.fixedRoot, this.activeFeatures);
|
|
43
34
|
}
|
|
44
35
|
getTool(name) {
|
|
45
36
|
return this.availableTools.find((t) => t.mcp.name === name) || null;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.disable_user = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const tool_js_1 = require("../../tool.js");
|
|
6
6
|
const util_js_1 = require("../../util.js");
|
|
7
7
|
const auth_js_1 = require("../../../gcp/auth.js");
|
|
8
|
-
exports.
|
|
9
|
-
name: "
|
|
8
|
+
exports.disable_user = (0, tool_js_1.tool)({
|
|
9
|
+
name: "disable_user",
|
|
10
10
|
description: "Disables or enables a user based on a UID.",
|
|
11
11
|
inputSchema: zod_1.z.object({
|
|
12
12
|
uid: zod_1.z.string().describe("The localId or UID of the user to disable or enable"),
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.get_user = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const tool_js_1 = require("../../tool.js");
|
|
6
6
|
const util_js_1 = require("../../util.js");
|
|
7
7
|
const auth_js_1 = require("../../../gcp/auth.js");
|
|
8
|
-
exports.
|
|
9
|
-
name: "
|
|
8
|
+
exports.get_user = (0, tool_js_1.tool)({
|
|
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({
|
|
12
12
|
email: zod_1.z.string().optional(),
|
|
@@ -23,7 +23,7 @@ exports.get_auth_user = (0, tool_js_1.tool)({
|
|
|
23
23
|
},
|
|
24
24
|
}, async ({ email, phoneNumber, uid }, { projectId }) => {
|
|
25
25
|
if (email === undefined && phoneNumber === undefined && uid === undefined) {
|
|
26
|
-
return (0, util_js_1.mcpError)(`No user identifier supplied in
|
|
26
|
+
return (0, util_js_1.mcpError)(`No user identifier supplied in auth_get_user tool`);
|
|
27
27
|
}
|
|
28
28
|
return (0, util_js_1.toContent)(await (0, auth_js_1.findUser)(projectId, email, phoneNumber, uid));
|
|
29
29
|
});
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.authTools = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
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
7
|
const set_sms_region_policy_js_1 = require("./set_sms_region_policy.js");
|
|
8
|
-
exports.authTools = [
|
|
9
|
-
get_auth_user_js_1.get_auth_user,
|
|
10
|
-
disable_auth_user_js_1.disable_auth_user,
|
|
11
|
-
set_auth_claims_js_1.set_auth_claim,
|
|
12
|
-
set_sms_region_policy_js_1.set_sms_region_policy,
|
|
13
|
-
];
|
|
8
|
+
exports.authTools = [get_user_js_1.get_user, disable_user_js_1.disable_user, set_claims_js_1.set_claim, set_sms_region_policy_js_1.set_sms_region_policy];
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.set_claim = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const tool_js_1 = require("../../tool.js");
|
|
6
6
|
const util_js_1 = require("../../util.js");
|
|
7
7
|
const auth_js_1 = require("../../../gcp/auth.js");
|
|
8
|
-
exports.
|
|
9
|
-
name: "
|
|
8
|
+
exports.set_claim = (0, tool_js_1.tool)({
|
|
9
|
+
name: "set_claims",
|
|
10
10
|
description: "Sets custom claims 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.",
|
|
11
11
|
inputSchema: zod_1.z.object({
|
|
12
12
|
uid: zod_1.z.string().describe("the UID of the user to update"),
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.consult_assistant = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const tool_js_1 = require("../../tool.js");
|
|
6
6
|
const util_js_1 = require("../../util.js");
|
|
7
7
|
const fdcExperience_js_1 = require("../../../gif/fdcExperience.js");
|
|
8
|
-
exports.
|
|
9
|
-
name: "
|
|
8
|
+
exports.consult_assistant = (0, tool_js_1.tool)({
|
|
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({
|
|
12
12
|
prompt: zod_1.z
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.coreTools = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
set_firebase_directory_1.set_firebase_directory,
|
|
10
|
-
consult_firebase_assistant_1.consult_firebase_assistant,
|
|
11
|
-
];
|
|
4
|
+
const consult_assistant_js_1 = require("./consult_assistant.js");
|
|
5
|
+
const get_project_js_1 = require("./get_project.js");
|
|
6
|
+
const get_sdk_config_js_1 = require("./get_sdk_config.js");
|
|
7
|
+
const list_apps_js_1 = require("./list_apps.js");
|
|
8
|
+
exports.coreTools = [get_project_js_1.get_project, list_apps_js_1.list_apps, get_sdk_config_js_1.get_sdk_config, consult_assistant_js_1.consult_assistant];
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sourceToText = exports.connectorToText = exports.schemaToText = void 0;
|
|
3
|
+
exports.graphqlResponseToToolResponse = exports.sourceToText = exports.connectorToText = exports.schemaToText = void 0;
|
|
4
4
|
const js_yaml_1 = require("js-yaml");
|
|
5
|
+
const types_1 = require("../../../dataconnect/types");
|
|
6
|
+
const util_1 = require("../../util");
|
|
5
7
|
function schemaToText(s) {
|
|
6
8
|
return ((0, js_yaml_1.dump)({
|
|
7
9
|
name: s.name,
|
|
@@ -31,3 +33,18 @@ function sourceToText(s) {
|
|
|
31
33
|
return output;
|
|
32
34
|
}
|
|
33
35
|
exports.sourceToText = sourceToText;
|
|
36
|
+
function graphqlResponseToToolResponse(g) {
|
|
37
|
+
var _a;
|
|
38
|
+
if ((0, types_1.isGraphQLResponse)(g)) {
|
|
39
|
+
const isError = ((_a = g.errors) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
40
|
+
const contentString = `${isError ? "A GraphQL error occurred while executing the operation:" : ""}${JSON.stringify(g, null, 2)}`;
|
|
41
|
+
return {
|
|
42
|
+
isError,
|
|
43
|
+
content: [{ type: "text", text: contentString }],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return (0, util_1.mcpError)(JSON.stringify(g, null, 2));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.graphqlResponseToToolResponse = graphqlResponseToToolResponse;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.execute_graphql = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const tool_js_1 = require("../../tool.js");
|
|
6
|
+
const client = require("../../../dataconnect/dataplaneClient.js");
|
|
7
|
+
const fileUtils_js_1 = require("../../../dataconnect/fileUtils.js");
|
|
8
|
+
const converter_js_1 = require("./converter.js");
|
|
9
|
+
exports.execute_graphql = (0, tool_js_1.tool)({
|
|
10
|
+
name: "execute_graphql",
|
|
11
|
+
description: "Executes an arbitrary GraphQL against a Data Connect service",
|
|
12
|
+
inputSchema: zod_1.z.object({
|
|
13
|
+
query: zod_1.z.string().describe("A GraphQL query or mutation to execute against the service"),
|
|
14
|
+
serviceId: zod_1.z
|
|
15
|
+
.string()
|
|
16
|
+
.nullable()
|
|
17
|
+
.describe("The Firebase Data Connect service ID to look for. If there is only one service defined in firebase.json, this can be omitted and that will be used."),
|
|
18
|
+
variables: zod_1.z.record(zod_1.z.string()).optional().describe("Variables for this operation."),
|
|
19
|
+
}),
|
|
20
|
+
annotations: {
|
|
21
|
+
title: "Executes a arbitrary GraphQL query or mutation against a Data Connect service",
|
|
22
|
+
readOnlyHint: false,
|
|
23
|
+
},
|
|
24
|
+
_meta: {
|
|
25
|
+
requiresProject: true,
|
|
26
|
+
requiresAuth: true,
|
|
27
|
+
},
|
|
28
|
+
}, async ({ query, serviceId, variables }, { projectId, config }) => {
|
|
29
|
+
const serviceInfo = await (0, fileUtils_js_1.pickService)(projectId, config, serviceId || undefined);
|
|
30
|
+
const response = await client.executeGraphQL(client.dataconnectDataplaneClient(), serviceInfo.serviceName, { name: "", query, variables });
|
|
31
|
+
return (0, converter_js_1.graphqlResponseToToolResponse)(response.body);
|
|
32
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.execute_graphql_read = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const tool_js_1 = require("../../tool.js");
|
|
6
|
+
const client = require("../../../dataconnect/dataplaneClient.js");
|
|
7
|
+
const fileUtils_js_1 = require("../../../dataconnect/fileUtils.js");
|
|
8
|
+
const converter_js_1 = require("./converter.js");
|
|
9
|
+
exports.execute_graphql_read = (0, tool_js_1.tool)({
|
|
10
|
+
name: "execute_graphql_read",
|
|
11
|
+
description: "Executes an arbitrary GraphQL against a Data Connect service. Cannot write data.",
|
|
12
|
+
inputSchema: zod_1.z.object({
|
|
13
|
+
query: zod_1.z.string().describe("A GraphQL query to execute against the service"),
|
|
14
|
+
serviceId: zod_1.z
|
|
15
|
+
.string()
|
|
16
|
+
.nullable()
|
|
17
|
+
.describe("The Firebase Data Connect service ID to look for. If there is only one service defined in firebase.json, this can be omitted and that will be used."),
|
|
18
|
+
variables: zod_1.z.record(zod_1.z.string()).optional().describe("Variables for this operation."),
|
|
19
|
+
}),
|
|
20
|
+
annotations: {
|
|
21
|
+
title: "Executes a arbitrary GraphQL query against a Data Connect service",
|
|
22
|
+
readOnlyHint: true,
|
|
23
|
+
},
|
|
24
|
+
_meta: {
|
|
25
|
+
requiresProject: true,
|
|
26
|
+
requiresAuth: true,
|
|
27
|
+
},
|
|
28
|
+
}, async ({ query, serviceId, variables }, { projectId, config }) => {
|
|
29
|
+
const serviceInfo = await (0, fileUtils_js_1.pickService)(projectId, config, serviceId || undefined);
|
|
30
|
+
const response = await client.executeGraphQLRead(client.dataconnectDataplaneClient(), serviceInfo.serviceName, { name: "", query, variables });
|
|
31
|
+
return (0, converter_js_1.graphqlResponseToToolResponse)(response.body);
|
|
32
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.execute_mutation = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const tool_js_1 = require("../../tool.js");
|
|
6
|
+
const util_js_1 = require("../../util.js");
|
|
7
|
+
const client = require("../../../dataconnect/dataplaneClient.js");
|
|
8
|
+
const fileUtils_js_1 = require("../../../dataconnect/fileUtils.js");
|
|
9
|
+
const converter_js_1 = require("./converter.js");
|
|
10
|
+
exports.execute_mutation = (0, tool_js_1.tool)({
|
|
11
|
+
name: "execute_mutation",
|
|
12
|
+
description: "Executes a deployed Data Connect mutation. Can read and write data.",
|
|
13
|
+
inputSchema: zod_1.z.object({
|
|
14
|
+
operationName: zod_1.z.string().describe("The name of the deployed operation you want to execute"),
|
|
15
|
+
serviceId: zod_1.z
|
|
16
|
+
.string()
|
|
17
|
+
.nullable()
|
|
18
|
+
.describe("The Firebase Data Connect service ID to look for. If there is only one service defined in firebase.json, this can be omitted and that will be used."),
|
|
19
|
+
connectorId: zod_1.z
|
|
20
|
+
.string()
|
|
21
|
+
.nullable()
|
|
22
|
+
.describe("The Firebase Data Connect connector ID to look for. If there is only one connector defined in dataconnect.yaml, this can be omitted and that will be used."),
|
|
23
|
+
variables: zod_1.z
|
|
24
|
+
.record(zod_1.z.string())
|
|
25
|
+
.optional()
|
|
26
|
+
.describe("Variables for this operation. Use dataconnect_get_connector to find the expected variables for this query"),
|
|
27
|
+
}),
|
|
28
|
+
annotations: {
|
|
29
|
+
title: "Executes a deployed Data Connect query or mutation",
|
|
30
|
+
readOnlyHint: false,
|
|
31
|
+
},
|
|
32
|
+
_meta: {
|
|
33
|
+
requiresProject: true,
|
|
34
|
+
requiresAuth: true,
|
|
35
|
+
},
|
|
36
|
+
}, async ({ operationName, serviceId, connectorId, variables }, { projectId, config }) => {
|
|
37
|
+
const serviceInfo = await (0, fileUtils_js_1.pickService)(projectId, config, serviceId || undefined);
|
|
38
|
+
if (!connectorId) {
|
|
39
|
+
if (serviceInfo.connectorInfo.length === 0) {
|
|
40
|
+
return (0, util_js_1.mcpError)(`Service ${serviceInfo.serviceName} has no connectors`);
|
|
41
|
+
}
|
|
42
|
+
if (serviceInfo.connectorInfo.length > 1) {
|
|
43
|
+
return (0, util_js_1.mcpError)(`Service ${serviceInfo.serviceName} has more than one connector. Please use the connectorId argument to specifiy which connector this operation is part of.`);
|
|
44
|
+
}
|
|
45
|
+
connectorId = serviceInfo.connectorInfo[0].connectorYaml.connectorId;
|
|
46
|
+
}
|
|
47
|
+
const connectorPath = `${serviceInfo.serviceName}/connectors/${connectorId}`;
|
|
48
|
+
const response = await client.executeGraphQLMutation(client.dataconnectDataplaneClient(), connectorPath, { operationName, variables });
|
|
49
|
+
return (0, converter_js_1.graphqlResponseToToolResponse)(response.body);
|
|
50
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.execute_query = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const tool_js_1 = require("../../tool.js");
|
|
6
|
+
const util_js_1 = require("../../util.js");
|
|
7
|
+
const client = require("../../../dataconnect/dataplaneClient.js");
|
|
8
|
+
const fileUtils_js_1 = require("../../../dataconnect/fileUtils.js");
|
|
9
|
+
const converter_js_1 = require("./converter.js");
|
|
10
|
+
exports.execute_query = (0, tool_js_1.tool)({
|
|
11
|
+
name: "execute_query",
|
|
12
|
+
description: "Executes a deployed Data Connect query. Cannot write any data.",
|
|
13
|
+
inputSchema: zod_1.z.object({
|
|
14
|
+
operationName: zod_1.z.string().describe("The name of the deployed operation you want to execute"),
|
|
15
|
+
serviceId: zod_1.z
|
|
16
|
+
.string()
|
|
17
|
+
.nullable()
|
|
18
|
+
.describe("The Firebase Data Connect service ID to look for. If there is only one service defined in firebase.json, this can be omitted and that will be used."),
|
|
19
|
+
connectorId: zod_1.z
|
|
20
|
+
.string()
|
|
21
|
+
.nullable()
|
|
22
|
+
.describe("The Firebase Data Connect connector ID to look for. If there is only one connector defined in dataconnect.yaml, this can be omitted and that will be used."),
|
|
23
|
+
variables: zod_1.z
|
|
24
|
+
.record(zod_1.z.string())
|
|
25
|
+
.optional()
|
|
26
|
+
.describe("Variables for this operation. Use dataconnect_get_connector to find the expected variables for this query"),
|
|
27
|
+
}),
|
|
28
|
+
annotations: {
|
|
29
|
+
title: "Executes a deployed Data Connect query.",
|
|
30
|
+
readOnlyHint: true,
|
|
31
|
+
},
|
|
32
|
+
_meta: {
|
|
33
|
+
requiresProject: true,
|
|
34
|
+
requiresAuth: true,
|
|
35
|
+
},
|
|
36
|
+
}, async ({ operationName, serviceId, connectorId, variables }, { projectId, config }) => {
|
|
37
|
+
const serviceInfo = await (0, fileUtils_js_1.pickService)(projectId, config, serviceId || undefined);
|
|
38
|
+
if (!connectorId) {
|
|
39
|
+
if (serviceInfo.connectorInfo.length === 0) {
|
|
40
|
+
return (0, util_js_1.mcpError)(`Service ${serviceInfo.serviceName} has no connectors`);
|
|
41
|
+
}
|
|
42
|
+
if (serviceInfo.connectorInfo.length > 1) {
|
|
43
|
+
return (0, util_js_1.mcpError)(`Service ${serviceInfo.serviceName} has more than one connector. Please use the connectorId argument to specifiy which connector this operation is part of.`);
|
|
44
|
+
}
|
|
45
|
+
connectorId = serviceInfo.connectorInfo[0].connectorYaml.connectorId;
|
|
46
|
+
}
|
|
47
|
+
const connectorPath = `${serviceInfo.serviceName}/connectors/${connectorId}`;
|
|
48
|
+
const response = await client.executeGraphQLQuery(client.dataconnectDataplaneClient(), connectorPath, { operationName, variables });
|
|
49
|
+
return (0, converter_js_1.graphqlResponseToToolResponse)(response.body);
|
|
50
|
+
});
|
package/lib/mcp/tools/dataconnect/{generate_dataconnect_operation.js → generate_operation.js}
RENAMED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.generate_operation = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const tool_js_1 = require("../../tool.js");
|
|
6
6
|
const util_js_1 = require("../../util.js");
|
|
7
7
|
const fdcExperience_js_1 = require("../../../gif/fdcExperience.js");
|
|
8
8
|
const fileUtils_js_1 = require("../../../dataconnect/fileUtils.js");
|
|
9
|
-
exports.
|
|
10
|
-
name: "
|
|
9
|
+
exports.generate_operation = (0, tool_js_1.tool)({
|
|
10
|
+
name: "generate_operation",
|
|
11
11
|
description: "Generates 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({
|
|
13
13
|
prompt: zod_1.z
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.generate_schema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const tool_js_1 = require("../../tool.js");
|
|
6
6
|
const util_js_1 = require("../../util.js");
|
|
7
7
|
const fdcExperience_js_1 = require("../../../gif/fdcExperience.js");
|
|
8
|
-
exports.
|
|
9
|
-
name: "
|
|
8
|
+
exports.generate_schema = (0, tool_js_1.tool)({
|
|
9
|
+
name: "generate_schema",
|
|
10
10
|
description: "Generates a Firebase Data Connect Schema based on the users description of an app.",
|
|
11
11
|
inputSchema: zod_1.z.object({
|
|
12
12
|
prompt: zod_1.z.string().describe("A description of an app that you are interested in building"),
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.get_connector = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const tool_js_1 = require("../../tool.js");
|
|
6
6
|
const util_js_1 = require("../../util.js");
|
|
7
|
-
const client = require("../../../dataconnect/client");
|
|
7
|
+
const client = require("../../../dataconnect/client.js");
|
|
8
8
|
const fileUtils_js_1 = require("../../../dataconnect/fileUtils.js");
|
|
9
9
|
const converter_js_1 = require("./converter.js");
|
|
10
|
-
exports.
|
|
11
|
-
name: "
|
|
10
|
+
exports.get_connector = (0, tool_js_1.tool)({
|
|
11
|
+
name: "get_connector",
|
|
12
12
|
description: "Get the Firebase Data Connect Connectors in the project, which includes the pre-defined GraphQL queries accessible to client SDKs.",
|
|
13
13
|
inputSchema: zod_1.z.object({
|
|
14
14
|
serviceId: zod_1.z
|
|
15
15
|
.string()
|
|
16
16
|
.nullable()
|
|
17
|
-
.describe("The Firebase Data Connect service ID to look for.
|
|
17
|
+
.describe("The Firebase Data Connect service ID to look for. If there is only one service defined in firebase.json, this can be omitted and that will be used."),
|
|
18
18
|
}),
|
|
19
19
|
annotations: {
|
|
20
20
|
title: "Obtain the Firebase Data Connect Connectors that's available in the backend",
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.get_schema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const tool_js_1 = require("../../tool.js");
|
|
6
6
|
const util_js_1 = require("../../util.js");
|
|
7
|
-
const client = require("../../../dataconnect/client");
|
|
7
|
+
const client = require("../../../dataconnect/client.js");
|
|
8
8
|
const fileUtils_js_1 = require("../../../dataconnect/fileUtils.js");
|
|
9
9
|
const converter_js_1 = require("./converter.js");
|
|
10
|
-
exports.
|
|
11
|
-
name: "
|
|
10
|
+
exports.get_schema = (0, tool_js_1.tool)({
|
|
11
|
+
name: "get_schema",
|
|
12
12
|
description: "List the Firebase Data Connect Schema in the project, which includes Cloud SQL data sources and the GraphQL Schema describing what tables are available.",
|
|
13
13
|
inputSchema: zod_1.z.object({
|
|
14
14
|
serviceId: zod_1.z
|
|
15
15
|
.string()
|
|
16
16
|
.nullable()
|
|
17
|
-
.describe("The Firebase Data Connect service ID to look for.
|
|
17
|
+
.describe("The Firebase Data Connect service ID to look for. If there is only one service defined in firebase.json, this can be omitted and that will be used."),
|
|
18
18
|
}),
|
|
19
19
|
annotations: {
|
|
20
20
|
title: "Obtain the Firebase Data Connect Schemas that's available in the backend",
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.dataconnectTools = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
4
|
+
const generate_operation_js_1 = require("./generate_operation.js");
|
|
5
|
+
const generate_schema_js_1 = require("./generate_schema.js");
|
|
6
|
+
const list_services_js_1 = require("./list_services.js");
|
|
7
|
+
const get_schema_js_1 = require("./get_schema.js");
|
|
8
|
+
const get_connector_js_1 = require("./get_connector.js");
|
|
9
|
+
const execute_graphql_js_1 = require("./execute_graphql.js");
|
|
10
|
+
const execute_graphql_read_js_1 = require("./execute_graphql_read.js");
|
|
11
|
+
const execute_query_js_1 = require("./execute_query.js");
|
|
12
|
+
const execute_mutation_js_1 = require("./execute_mutation.js");
|
|
9
13
|
exports.dataconnectTools = [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
list_services_js_1.list_services,
|
|
15
|
+
generate_schema_js_1.generate_schema,
|
|
16
|
+
generate_operation_js_1.generate_operation,
|
|
17
|
+
get_schema_js_1.get_schema,
|
|
18
|
+
get_connector_js_1.get_connector,
|
|
19
|
+
execute_graphql_js_1.execute_graphql,
|
|
20
|
+
execute_graphql_read_js_1.execute_graphql_read,
|
|
21
|
+
execute_mutation_js_1.execute_mutation,
|
|
22
|
+
execute_query_js_1.execute_query,
|
|
15
23
|
];
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.list_services = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const tool_js_1 = require("../../tool.js");
|
|
6
6
|
const util_js_1 = require("../../util.js");
|
|
7
|
-
const client = require("../../../dataconnect/client");
|
|
8
|
-
exports.
|
|
9
|
-
name: "
|
|
7
|
+
const client = require("../../../dataconnect/client.js");
|
|
8
|
+
exports.list_services = (0, tool_js_1.tool)({
|
|
9
|
+
name: "list_services",
|
|
10
10
|
description: "List the Firebase Data Connect services available in the current project.",
|
|
11
11
|
inputSchema: zod_1.z.object({}),
|
|
12
12
|
annotations: {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.get_project_directory = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const tool_js_1 = require("../../tool.js");
|
|
6
6
|
const util_js_1 = require("../../util.js");
|
|
7
7
|
const detectProjectRoot_js_1 = require("../../../detectProjectRoot.js");
|
|
8
|
-
exports.
|
|
9
|
-
name: "
|
|
10
|
-
description: "Gets the current Firebase project directory. If this has been set using the `
|
|
8
|
+
exports.get_project_directory = (0, tool_js_1.tool)({
|
|
9
|
+
name: "get_project_directory",
|
|
10
|
+
description: "Gets the current Firebase project directory. If this has been set using the `set_project_directory` tool it will return that, otherwise it will look for a PROJECT_ROOT environment variable or the current working directory of the running Firebase MCP server.",
|
|
11
11
|
inputSchema: zod_1.z.object({}),
|
|
12
12
|
annotations: {
|
|
13
13
|
title: "Get Firebase Project Directory",
|
|
@@ -15,6 +15,6 @@ exports.get_firebase_directory = (0, tool_js_1.tool)({
|
|
|
15
15
|
},
|
|
16
16
|
}, (_, { host }) => {
|
|
17
17
|
if (!(0, detectProjectRoot_js_1.detectProjectRoot)({ cwd: host.projectRoot }))
|
|
18
|
-
return Promise.resolve((0, util_js_1.mcpError)(`There is no detected 'firebase.json' in directory '${host.projectRoot}'. Please use the '
|
|
18
|
+
return Promise.resolve((0, util_js_1.mcpError)(`There is no detected 'firebase.json' in directory '${host.projectRoot}'. Please use the 'set_project_directory' tool to activate a Firebase project directory.`));
|
|
19
19
|
return Promise.resolve((0, util_js_1.toContent)(`The current Firebase project directory is '${host.projectRoot}'.`));
|
|
20
20
|
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.directoryTools = void 0;
|
|
4
|
+
const get_project_directory_1 = require("./get_project_directory");
|
|
5
|
+
const set_project_directory_1 = require("./set_project_directory");
|
|
6
|
+
exports.directoryTools = [get_project_directory_1.get_project_directory, set_project_directory_1.set_project_directory];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.set_project_directory = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const tool_js_1 = require("../../tool.js");
|
|
6
6
|
const util_js_1 = require("../../util.js");
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const path_1 = require("path");
|
|
9
|
-
exports.
|
|
10
|
-
name: "
|
|
9
|
+
exports.set_project_directory = (0, tool_js_1.tool)({
|
|
10
|
+
name: "set_project_directory",
|
|
11
11
|
description: "Sets the project directory for the Firebase MCP server to utilize for project detection and authentication. This should be a directory with a `firebase.json` file in it. This information is persisted between sessions.",
|
|
12
12
|
inputSchema: zod_1.z.object({
|
|
13
13
|
dir: zod_1.z
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.get_documents = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const tool_js_1 = require("../../tool.js");
|
|
6
6
|
const util_js_1 = require("../../util.js");
|
|
7
7
|
const firestore_js_1 = require("../../../gcp/firestore.js");
|
|
8
8
|
const converter_js_1 = require("./converter.js");
|
|
9
|
-
exports.
|
|
10
|
-
name: "
|
|
9
|
+
exports.get_documents = (0, tool_js_1.tool)({
|
|
10
|
+
name: "get_documents",
|
|
11
11
|
description: "Retrieves 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.",
|
|
12
12
|
inputSchema: zod_1.z.object({
|
|
13
13
|
paths: zod_1.z
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.get_rules = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const tool_js_1 = require("../../tool.js");
|
|
6
6
|
const util_js_1 = require("../../util.js");
|
|
7
|
-
const
|
|
8
|
-
exports.
|
|
9
|
-
name: "
|
|
7
|
+
const rules_js_1 = require("../../../gcp/rules.js");
|
|
8
|
+
exports.get_rules = (0, tool_js_1.tool)({
|
|
9
|
+
name: "get_rules",
|
|
10
10
|
description: "Retrieves the active Firestore security rules for the current project.",
|
|
11
11
|
inputSchema: zod_1.z.object({}),
|
|
12
12
|
annotations: {
|
|
@@ -18,9 +18,9 @@ exports.get_firestore_rules = (0, tool_js_1.tool)({
|
|
|
18
18
|
requiresAuth: true,
|
|
19
19
|
},
|
|
20
20
|
}, async (_, { projectId }) => {
|
|
21
|
-
const rulesetName = await (0,
|
|
21
|
+
const rulesetName = await (0, rules_js_1.getLatestRulesetName)(projectId, "cloud.firestore");
|
|
22
22
|
if (!rulesetName)
|
|
23
23
|
return (0, util_js_1.mcpError)(`No active Firestore rules were found in project '${projectId}'`);
|
|
24
|
-
const rules = await (0,
|
|
24
|
+
const rules = await (0, rules_js_1.getRulesetContent)(rulesetName);
|
|
25
25
|
return (0, util_js_1.toContent)(rules[0].content);
|
|
26
26
|
});
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.firestoreTools = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
exports.firestoreTools = [
|
|
8
|
-
list_firestore_collections_1.list_firestore_collections,
|
|
9
|
-
get_firestore_documents_1.get_firestore_documents,
|
|
10
|
-
get_firestore_rules_1.get_firestore_rules,
|
|
11
|
-
];
|
|
4
|
+
const get_documents_1 = require("./get_documents");
|
|
5
|
+
const get_rules_1 = require("./get_rules");
|
|
6
|
+
const list_collections_1 = require("./list_collections");
|
|
7
|
+
exports.firestoreTools = [list_collections_1.list_collections, get_documents_1.get_documents, get_rules_1.get_rules];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.list_collections = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const tool_js_1 = require("../../tool.js");
|
|
6
6
|
const util_js_1 = require("../../util.js");
|
|
7
7
|
const firestore_js_1 = require("../../../gcp/firestore.js");
|
|
8
8
|
const errors_js_1 = require("../../errors.js");
|
|
9
|
-
exports.
|
|
10
|
-
name: "
|
|
9
|
+
exports.list_collections = (0, tool_js_1.tool)({
|
|
10
|
+
name: "list_collections",
|
|
11
11
|
description: "Retrieves a list of collections from a Firestore database in the current project.",
|
|
12
12
|
inputSchema: zod_1.z.object({
|
|
13
13
|
document_path: zod_1.z
|
package/lib/mcp/tools/index.js
CHANGED
|
@@ -1,15 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.availableTools = void 0;
|
|
4
4
|
const index_js_1 = require("./auth/index.js");
|
|
5
5
|
const index_js_2 = require("./dataconnect/index.js");
|
|
6
6
|
const index_js_3 = require("./firestore/index.js");
|
|
7
|
-
const index_js_4 = require("./
|
|
8
|
-
const index_js_5 = require("./
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
const index_js_4 = require("./directory/index.js");
|
|
8
|
+
const index_js_5 = require("./core/index.js");
|
|
9
|
+
const index_js_6 = require("./storage/index.js");
|
|
10
|
+
function availableTools(fixedRoot, activeFeatures) {
|
|
11
|
+
const toolDefs = addPrefixToToolName("firebase_", index_js_5.coreTools);
|
|
12
|
+
if (!fixedRoot) {
|
|
13
|
+
toolDefs.push(...index_js_4.directoryTools);
|
|
14
|
+
}
|
|
15
|
+
if (!activeFeatures || !activeFeatures.length) {
|
|
16
|
+
activeFeatures = Object.keys(tools);
|
|
17
|
+
}
|
|
18
|
+
for (const key of activeFeatures) {
|
|
19
|
+
toolDefs.push(...tools[key]);
|
|
20
|
+
}
|
|
21
|
+
return toolDefs;
|
|
22
|
+
}
|
|
23
|
+
exports.availableTools = availableTools;
|
|
24
|
+
const tools = {
|
|
25
|
+
firestore: addPrefixToToolName("firestore_", index_js_3.firestoreTools),
|
|
26
|
+
auth: addPrefixToToolName("auth_", index_js_1.authTools),
|
|
27
|
+
dataconnect: addPrefixToToolName("dataconnect_", index_js_2.dataconnectTools),
|
|
28
|
+
storage: addPrefixToToolName("storage_", index_js_6.storageTools),
|
|
15
29
|
};
|
|
30
|
+
function addPrefixToToolName(prefix, tools) {
|
|
31
|
+
return tools.map((tool) => (Object.assign(Object.assign({}, tool), { mcp: Object.assign(Object.assign({}, tool.mcp), { name: `${prefix}${tool.mcp.name}` }) })));
|
|
32
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.get_object_download_url = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const tool_js_1 = require("../../tool.js");
|
|
6
|
+
const util_js_1 = require("../../util.js");
|
|
7
|
+
const storage_js_1 = require("../../../gcp/storage.js");
|
|
8
|
+
exports.get_object_download_url = (0, tool_js_1.tool)({
|
|
9
|
+
name: "get_object_download_url",
|
|
10
|
+
description: "Retrieves the download URL for an object in Firebase Storage.",
|
|
11
|
+
inputSchema: zod_1.z.object({
|
|
12
|
+
bucket: zod_1.z.string().nullish().describe("The bucket name in Firebase Storage."),
|
|
13
|
+
objectPath: zod_1.z
|
|
14
|
+
.string()
|
|
15
|
+
.describe("The path to the object in Firebase storage without the bucket name attached"),
|
|
16
|
+
}),
|
|
17
|
+
annotations: {
|
|
18
|
+
title: "Get the download url for an obejct in Firebase Storage.",
|
|
19
|
+
readOnlyHint: true,
|
|
20
|
+
},
|
|
21
|
+
_meta: {
|
|
22
|
+
requiresProject: true,
|
|
23
|
+
requiresAuth: true,
|
|
24
|
+
},
|
|
25
|
+
}, async ({ bucket, objectPath }, { projectId }) => {
|
|
26
|
+
if (!bucket) {
|
|
27
|
+
bucket = `${projectId}.firebasestorage.app`;
|
|
28
|
+
}
|
|
29
|
+
const downloadUrl = await (0, storage_js_1.getDownloadUrl)(bucket, objectPath);
|
|
30
|
+
return (0, util_js_1.toContent)(downloadUrl);
|
|
31
|
+
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.get_rules = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const tool_js_1 = require("../../tool.js");
|
|
6
6
|
const util_js_1 = require("../../util.js");
|
|
7
|
-
const
|
|
8
|
-
exports.
|
|
9
|
-
name: "
|
|
7
|
+
const rules_js_1 = require("../../../gcp/rules.js");
|
|
8
|
+
exports.get_rules = (0, tool_js_1.tool)({
|
|
9
|
+
name: "get_rules",
|
|
10
10
|
description: "Retrieves the Firebase Cloud Storage Rules for the default bucket.",
|
|
11
11
|
inputSchema: zod_1.z.object({}),
|
|
12
12
|
annotations: {
|
|
@@ -18,9 +18,9 @@ exports.get_storage_rules = (0, tool_js_1.tool)({
|
|
|
18
18
|
requiresAuth: true,
|
|
19
19
|
},
|
|
20
20
|
}, async (_, { projectId }) => {
|
|
21
|
-
const rulesetName = await (0,
|
|
21
|
+
const rulesetName = await (0, rules_js_1.getLatestRulesetName)(projectId, "firebase.storage");
|
|
22
22
|
if (!rulesetName)
|
|
23
23
|
return (0, util_js_1.mcpError)(`No active Firebase Storage rules were found in project '${projectId}'`);
|
|
24
|
-
const rules = await (0,
|
|
24
|
+
const rules = await (0, rules_js_1.getRulesetContent)(rulesetName);
|
|
25
25
|
return (0, util_js_1.toContent)(rules[0].content);
|
|
26
26
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.storageTools = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const get_download_url_1 = require("./get_download_url");
|
|
5
|
+
const get_rules_1 = require("./get_rules");
|
|
6
|
+
exports.storageTools = [get_rules_1.get_rules, get_download_url_1.get_object_download_url];
|
package/lib/mcp/types.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SERVER_FEATURES = void 0;
|
|
4
|
-
exports.SERVER_FEATURES = ["
|
|
4
|
+
exports.SERVER_FEATURES = ["firestore", "storage", "dataconnect", "auth"];
|
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.projectTools = void 0;
|
|
4
|
-
const get_project_js_1 = require("./get_project.js");
|
|
5
|
-
const get_sdk_config_js_1 = require("./get_sdk_config.js");
|
|
6
|
-
const list_apps_js_1 = require("./list_apps.js");
|
|
7
|
-
exports.projectTools = [get_project_js_1.get_project, list_apps_js_1.list_apps, get_sdk_config_js_1.get_sdk_config];
|
|
File without changes
|
|
File without changes
|
|
File without changes
|