firebase-mcp 0.2.0 → 0.3.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/README.md +6 -11
- package/dist/cli/index.js +9 -9
- package/dist/cli/index.js.map +1 -1
- package/dist/config/index.d.ts +39 -47
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +46 -37
- package/dist/config/index.js.map +1 -1
- package/dist/firebase/index.d.ts +9 -18
- package/dist/firebase/index.d.ts.map +1 -1
- package/dist/firebase/index.js +28 -30
- package/dist/firebase/index.js.map +1 -1
- package/dist/project/index.d.ts +17 -0
- package/dist/project/index.d.ts.map +1 -0
- package/dist/project/index.js +38 -0
- package/dist/project/index.js.map +1 -0
- package/dist/server/index.d.ts +11 -19
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +96 -46
- package/dist/server/index.js.map +1 -1
- package/dist/task/index.d.ts +53 -0
- package/dist/task/index.d.ts.map +1 -0
- package/dist/task/index.js +177 -0
- package/dist/task/index.js.map +1 -0
- package/dist/tools/auth/get_user.d.ts +9 -15
- package/dist/tools/auth/get_user.d.ts.map +1 -1
- package/dist/tools/auth/get_user.js +29 -20
- package/dist/tools/auth/get_user.js.map +1 -1
- package/dist/tools/auth/index.d.ts +1 -0
- package/dist/tools/auth/index.d.ts.map +1 -1
- package/dist/tools/auth/index.js +1 -0
- package/dist/tools/auth/index.js.map +1 -1
- package/dist/tools/auth/list_users.d.ts +7 -11
- package/dist/tools/auth/list_users.d.ts.map +1 -1
- package/dist/tools/auth/list_users.js +19 -11
- package/dist/tools/auth/list_users.js.map +1 -1
- package/dist/tools/auth/read.d.ts +15 -0
- package/dist/tools/auth/read.d.ts.map +1 -0
- package/dist/tools/auth/read.js +72 -0
- package/dist/tools/auth/read.js.map +1 -0
- package/dist/tools/config/get_config.d.ts +6 -0
- package/dist/tools/config/get_config.d.ts.map +1 -0
- package/dist/tools/config/get_config.js +31 -0
- package/dist/tools/config/get_config.js.map +1 -0
- package/dist/tools/config/index.d.ts +3 -0
- package/dist/tools/config/index.d.ts.map +1 -0
- package/dist/tools/config/index.js +19 -0
- package/dist/tools/config/index.js.map +1 -0
- package/dist/tools/config/reload_config.d.ts +8 -0
- package/dist/tools/config/reload_config.d.ts.map +1 -0
- package/dist/tools/config/reload_config.js +44 -0
- package/dist/tools/config/reload_config.js.map +1 -0
- package/dist/tools/firestore/aggregate_collection.d.ts +7 -12
- package/dist/tools/firestore/aggregate_collection.d.ts.map +1 -1
- package/dist/tools/firestore/aggregate_collection.js +21 -15
- package/dist/tools/firestore/aggregate_collection.js.map +1 -1
- package/dist/tools/firestore/count_documents.d.ts +7 -12
- package/dist/tools/firestore/count_documents.d.ts.map +1 -1
- package/dist/tools/firestore/count_documents.js +21 -15
- package/dist/tools/firestore/count_documents.js.map +1 -1
- package/dist/tools/firestore/get_collection_schema.d.ts +8 -13
- package/dist/tools/firestore/get_collection_schema.d.ts.map +1 -1
- package/dist/tools/firestore/get_collection_schema.js +23 -19
- package/dist/tools/firestore/get_collection_schema.js.map +1 -1
- package/dist/tools/firestore/get_document.d.ts +10 -17
- package/dist/tools/firestore/get_document.d.ts.map +1 -1
- package/dist/tools/firestore/get_document.js +32 -23
- package/dist/tools/firestore/get_document.js.map +1 -1
- package/dist/tools/firestore/get_many_documents.d.ts +7 -13
- package/dist/tools/firestore/get_many_documents.d.ts.map +1 -1
- package/dist/tools/firestore/get_many_documents.js +25 -26
- package/dist/tools/firestore/get_many_documents.js.map +1 -1
- package/dist/tools/firestore/index.d.ts +1 -0
- package/dist/tools/firestore/index.d.ts.map +1 -1
- package/dist/tools/firestore/index.js +1 -0
- package/dist/tools/firestore/index.js.map +1 -1
- package/dist/tools/firestore/list_collections.d.ts +7 -12
- package/dist/tools/firestore/list_collections.d.ts.map +1 -1
- package/dist/tools/firestore/list_collections.js +25 -22
- package/dist/tools/firestore/list_collections.js.map +1 -1
- package/dist/tools/firestore/list_documents.d.ts +7 -12
- package/dist/tools/firestore/list_documents.d.ts.map +1 -1
- package/dist/tools/firestore/list_documents.js +22 -20
- package/dist/tools/firestore/list_documents.js.map +1 -1
- package/dist/tools/firestore/list_indexes.d.ts +7 -11
- package/dist/tools/firestore/list_indexes.d.ts.map +1 -1
- package/dist/tools/firestore/list_indexes.js +22 -22
- package/dist/tools/firestore/list_indexes.js.map +1 -1
- package/dist/tools/firestore/query_collection.d.ts +7 -13
- package/dist/tools/firestore/query_collection.d.ts.map +1 -1
- package/dist/tools/firestore/query_collection.js +24 -27
- package/dist/tools/firestore/query_collection.js.map +1 -1
- package/dist/tools/firestore/query_collection_group.d.ts +7 -13
- package/dist/tools/firestore/query_collection_group.d.ts.map +1 -1
- package/dist/tools/firestore/query_collection_group.js +24 -24
- package/dist/tools/firestore/query_collection_group.js.map +1 -1
- package/dist/tools/firestore/read.d.ts +65 -0
- package/dist/tools/firestore/read.d.ts.map +1 -0
- package/dist/tools/firestore/read.js +197 -0
- package/dist/tools/firestore/read.js.map +1 -0
- package/dist/tools/firestore/read_collections.d.ts +7 -13
- package/dist/tools/firestore/read_collections.d.ts.map +1 -1
- package/dist/tools/firestore/read_collections.js +27 -33
- package/dist/tools/firestore/read_collections.js.map +1 -1
- package/dist/tools/index.d.ts +9 -103
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +76 -79
- package/dist/tools/index.js.map +1 -1
- package/package.json +3 -5
- package/dist/access/index.d.ts +0 -23
- package/dist/access/index.d.ts.map +0 -1
- package/dist/access/index.js +0 -35
- package/dist/access/index.js.map +0 -1
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.listUsers = exports.listUsersDefinition = exports.LIST_USERS = exports.AuthListUsersError = void 0;
|
|
4
|
-
const
|
|
5
|
-
const firebase_1 = require("../../firebase");
|
|
4
|
+
const task_1 = require("../../task");
|
|
6
5
|
const normalize_1 = require("../normalize");
|
|
7
|
-
class AuthListUsersError extends
|
|
6
|
+
class AuthListUsersError extends Error {
|
|
7
|
+
cause;
|
|
8
|
+
_tag = 'AuthListUsersError';
|
|
9
|
+
constructor(message, cause) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.cause = cause;
|
|
12
|
+
this.name = 'AuthListUsersError';
|
|
13
|
+
}
|
|
8
14
|
}
|
|
9
15
|
exports.AuthListUsersError = AuthListUsersError;
|
|
10
16
|
exports.LIST_USERS = 'list_users';
|
|
@@ -22,17 +28,19 @@ exports.listUsersDefinition = {
|
|
|
22
28
|
type: 'string',
|
|
23
29
|
description: 'Page token from a previous list_users response to fetch the next page.',
|
|
24
30
|
},
|
|
31
|
+
projectId: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
description: 'Project key as defined in firebase-mcp.json',
|
|
34
|
+
},
|
|
25
35
|
},
|
|
36
|
+
required: ['projectId'],
|
|
26
37
|
},
|
|
27
38
|
};
|
|
28
|
-
const listUsers = (input) =>
|
|
29
|
-
const
|
|
30
|
-
const result = yield*
|
|
31
|
-
try: () => auth
|
|
32
|
-
catch: (cause) => new AuthListUsersError(
|
|
33
|
-
message: 'Failed to list users',
|
|
34
|
-
cause,
|
|
35
|
-
}),
|
|
39
|
+
const listUsers = (ctx, input) => task_1.Task.gen(function* () {
|
|
40
|
+
const auth = ctx.auth();
|
|
41
|
+
const result = yield* task_1.Task.attempt({
|
|
42
|
+
try: () => auth.listUsers(input.maxResults ?? 100, input.pageToken),
|
|
43
|
+
catch: (cause) => new AuthListUsersError('Failed to list users', cause),
|
|
36
44
|
});
|
|
37
45
|
return {
|
|
38
46
|
users: result.users.map((u) => (0, normalize_1.normalizeValue)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list_users.js","sourceRoot":"","sources":["../../../src/tools/auth/list_users.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"list_users.js","sourceRoot":"","sources":["../../../src/tools/auth/list_users.ts"],"names":[],"mappings":";;;AAGA,qCAAkC;AACl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AAC,CAAC,CAAC,EAAE,EAAE,CAC5B,IAAA,0BAAc,EAAC;YACb,GAAG,CAAC,CAAC,MAAM,EAAE;YACb,YAAY,EAAE,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;SAC7D,CAAC,CACH;QACD,aAAa,EAAE,MAAM,CAAC,SAAS,IAAI,IAAI;KACxC,CAAC;AACJ,CAAC,CAAC,CAAC;AAnBQ,QAAA,SAAS,aAmBjB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import type { ProjectContext } from '../../project';
|
|
3
|
+
import { Task } from '../../task';
|
|
4
|
+
declare const READ_OPERATIONS: readonly ["get_user", "list_users"];
|
|
5
|
+
type ReadOperations = (typeof READ_OPERATIONS)[number];
|
|
6
|
+
export declare class UnknownAuthOperationError extends Error {
|
|
7
|
+
readonly operation: string;
|
|
8
|
+
readonly _tag: "UnknownAuthOperationError";
|
|
9
|
+
constructor(operation: string);
|
|
10
|
+
}
|
|
11
|
+
export declare const AUTH_READ: "auth_read";
|
|
12
|
+
export declare const authReadDefinition: Tool;
|
|
13
|
+
export declare const dispatchAuthRead: (ctx: ProjectContext, operation: ReadOperations | (string & {}), args: unknown) => Task<unknown, import("./get_user").AuthGetUserError | import("./get_user").AuthUserNotFoundError | import("./list_users").AuthListUsersError | UnknownAuthOperationError>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../src/tools/auth/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAIlC,QAAA,MAAM,eAAe,qCAAkC,CAAC;AAExD,KAAK,cAAc,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,qBAAa,yBAA0B,SAAQ,KAAK;IAEtC,QAAQ,CAAC,SAAS,EAAE,MAAM;IADtC,QAAQ,CAAC,IAAI,EAAG,2BAA2B,CAAU;gBAChC,SAAS,EAAE,MAAM;CAIvC;AAED,eAAO,MAAM,SAAS,EAAG,WAAoB,CAAC;AAE9C,eAAO,MAAM,kBAAkB,EAAE,IAwChC,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,KAAK,cAAc,EACnB,WAAW,cAAc,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,EACzC,MAAM,OAAO,8KAed,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dispatchAuthRead = exports.authReadDefinition = exports.AUTH_READ = exports.UnknownAuthOperationError = void 0;
|
|
4
|
+
const task_1 = require("../../task");
|
|
5
|
+
const get_user_1 = require("./get_user");
|
|
6
|
+
const list_users_1 = require("./list_users");
|
|
7
|
+
const READ_OPERATIONS = [get_user_1.GET_USER, list_users_1.LIST_USERS];
|
|
8
|
+
class UnknownAuthOperationError extends Error {
|
|
9
|
+
operation;
|
|
10
|
+
_tag = 'UnknownAuthOperationError';
|
|
11
|
+
constructor(operation) {
|
|
12
|
+
super(`Unknown auth_read operation: ${operation}`);
|
|
13
|
+
this.operation = operation;
|
|
14
|
+
this.name = 'UnknownAuthOperationError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.UnknownAuthOperationError = UnknownAuthOperationError;
|
|
18
|
+
exports.AUTH_READ = 'auth_read';
|
|
19
|
+
exports.authReadDefinition = {
|
|
20
|
+
name: exports.AUTH_READ,
|
|
21
|
+
description: 'Read from Firebase Authentication.',
|
|
22
|
+
inputSchema: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
required: ['operation', 'projectId'],
|
|
25
|
+
properties: {
|
|
26
|
+
operation: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
enum: [...READ_OPERATIONS],
|
|
29
|
+
description: [
|
|
30
|
+
'The Auth operation to perform:',
|
|
31
|
+
'- get_user: Fetch a user by uid or email. Args: uid? OR email?',
|
|
32
|
+
'- list_users: List users with pagination. Args: maxResults?(1-1000, default 100), pageToken?',
|
|
33
|
+
].join('\n'),
|
|
34
|
+
},
|
|
35
|
+
projectId: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
description: 'Project key as defined in firebase-mcp.json',
|
|
38
|
+
},
|
|
39
|
+
uid: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
description: 'Firebase Auth UID (get_user)',
|
|
42
|
+
},
|
|
43
|
+
email: {
|
|
44
|
+
type: 'string',
|
|
45
|
+
description: 'User email address (get_user)',
|
|
46
|
+
},
|
|
47
|
+
maxResults: {
|
|
48
|
+
type: 'number',
|
|
49
|
+
description: 'Maximum number of users to return, 1–1000 (list_users, default 100)',
|
|
50
|
+
},
|
|
51
|
+
pageToken: {
|
|
52
|
+
type: 'string',
|
|
53
|
+
description: 'Page token from a previous list_users response (list_users)',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
const dispatchAuthRead = (ctx, operation, args) => {
|
|
59
|
+
const a = args;
|
|
60
|
+
return task_1.Task.gen(function* () {
|
|
61
|
+
switch (operation) {
|
|
62
|
+
case get_user_1.GET_USER:
|
|
63
|
+
return yield* (0, get_user_1.getUser)(ctx, a);
|
|
64
|
+
case list_users_1.LIST_USERS:
|
|
65
|
+
return yield* (0, list_users_1.listUsers)(ctx, a);
|
|
66
|
+
default:
|
|
67
|
+
return yield* task_1.Task.fail(new UnknownAuthOperationError(String(operation)));
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
exports.dispatchAuthRead = dispatchAuthRead;
|
|
72
|
+
//# sourceMappingURL=read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../../src/tools/auth/read.ts"],"names":[],"mappings":";;;AAGA,qCAAkC;AAClC,yCAA4D;AAC5D,6CAAoE;AAEpE,MAAM,eAAe,GAAG,CAAC,mBAAQ,EAAE,uBAAU,CAAU,CAAC;AAIxD,MAAa,yBAA0B,SAAQ,KAAK;IAE7B;IADZ,IAAI,GAAG,2BAAoC,CAAC;IACrD,YAAqB,SAAiB;QACpC,KAAK,CAAC,gCAAgC,SAAS,EAAE,CAAC,CAAC;QADhC,cAAS,GAAT,SAAS,CAAQ;QAEpC,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;IAC1C,CAAC;CACF;AAND,8DAMC;AAEY,QAAA,SAAS,GAAG,WAAoB,CAAC;AAEjC,QAAA,kBAAkB,GAAS;IACtC,IAAI,EAAE,iBAAS;IACf,WAAW,EAAE,oCAAoC;IACjD,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC;QACpC,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,GAAG,eAAe,CAAC;gBAC1B,WAAW,EAAE;oBACX,gCAAgC;oBAChC,gEAAgE;oBAChE,8FAA8F;iBAC/F,CAAC,IAAI,CAAC,IAAI,CAAC;aACb;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,6CAA6C;aAC3D;YACD,GAAG,EAAE;gBACH,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,8BAA8B;aAC5C;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,+BAA+B;aAC7C;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,qEAAqE;aACxE;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,6DAA6D;aAChE;SACF;KACF;CACF,CAAC;AAEK,MAAM,gBAAgB,GAAG,CAC9B,GAAmB,EACnB,SAAyC,EACzC,IAAa,EACb,EAAE;IACF,MAAM,CAAC,GAAG,IAAI,CAAC;IACf,OAAO,WAAI,CAAC,GAAG,CAAC,QAAQ,CAAC;QACvB,QAAQ,SAAS,EAAE,CAAC;YAClB,KAAK,mBAAQ;gBACX,OAAO,KAAK,CAAC,CAAC,IAAA,kBAAO,EAAC,GAAG,EAAE,CAAgB,CAAC,CAAC;YAC/C,KAAK,uBAAU;gBACb,OAAO,KAAK,CAAC,CAAC,IAAA,sBAAS,EAAC,GAAG,EAAE,CAAkB,CAAC,CAAC;YACnD;gBACE,OAAO,KAAK,CAAC,CAAC,WAAI,CAAC,IAAI,CACrB,IAAI,yBAAyB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CACjD,CAAC;QACN,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAlBW,QAAA,gBAAgB,oBAkB3B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CallToolResult, Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { AppConfig } from '../../config';
|
|
3
|
+
export declare const GET_CONFIG: "get_config";
|
|
4
|
+
export declare const getConfigDefinition: Tool;
|
|
5
|
+
export declare const getConfig: (appConfig: AppConfig) => CallToolResult;
|
|
6
|
+
//# sourceMappingURL=get_config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_config.d.ts","sourceRoot":"","sources":["../../../src/tools/config/get_config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,eAAO,MAAM,UAAU,EAAG,YAAqB,CAAC;AAEhD,eAAO,MAAM,mBAAmB,EAAE,IAKjC,CAAC;AAiBF,eAAO,MAAM,SAAS,GAAI,WAAW,SAAS,KAAG,cAO/C,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getConfig = exports.getConfigDefinition = exports.GET_CONFIG = void 0;
|
|
4
|
+
exports.GET_CONFIG = 'get_config';
|
|
5
|
+
exports.getConfigDefinition = {
|
|
6
|
+
name: exports.GET_CONFIG,
|
|
7
|
+
description: 'Returns the current in-memory config, listing all available projects and their settings. Sensitive fields (e.g. serviceAccountPath) are omitted. Call this first to discover which projectId values are available for use with other tools.',
|
|
8
|
+
inputSchema: { type: 'object', properties: {} },
|
|
9
|
+
};
|
|
10
|
+
const sanitize = (config) => ({
|
|
11
|
+
projects: Object.fromEntries(Object.entries(config.projects).map(([key, project]) => [
|
|
12
|
+
key,
|
|
13
|
+
{
|
|
14
|
+
firebase: {
|
|
15
|
+
projectId: project.firebase.projectId,
|
|
16
|
+
serviceAccountPath: '[omitted]',
|
|
17
|
+
},
|
|
18
|
+
firestore: project.firestore,
|
|
19
|
+
},
|
|
20
|
+
])),
|
|
21
|
+
});
|
|
22
|
+
const getConfig = (appConfig) => ({
|
|
23
|
+
content: [
|
|
24
|
+
{
|
|
25
|
+
type: 'text',
|
|
26
|
+
text: JSON.stringify({ success: true, data: sanitize(appConfig) }),
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
});
|
|
30
|
+
exports.getConfig = getConfig;
|
|
31
|
+
//# sourceMappingURL=get_config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_config.js","sourceRoot":"","sources":["../../../src/tools/config/get_config.ts"],"names":[],"mappings":";;;AAGa,QAAA,UAAU,GAAG,YAAqB,CAAC;AAEnC,QAAA,mBAAmB,GAAS;IACvC,IAAI,EAAE,kBAAU;IAChB,WAAW,EACT,6OAA6O;IAC/O,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE;CAChD,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,MAAiB,EAAW,EAAE,CAAC,CAAC;IAChD,QAAQ,EAAE,MAAM,CAAC,WAAW,CAC1B,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC;QACtD,GAAG;QACH;YACE,QAAQ,EAAE;gBACR,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,SAAS;gBACrC,kBAAkB,EAAE,WAAW;aAChC;YACD,SAAS,EAAE,OAAO,CAAC,SAAS;SAC7B;KACF,CAAC,CACH;CACF,CAAC,CAAC;AAEI,MAAM,SAAS,GAAG,CAAC,SAAoB,EAAkB,EAAE,CAAC,CAAC;IAClE,OAAO,EAAE;QACP;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;SACnE;KACF;CACF,CAAC,CAAC;AAPU,QAAA,SAAS,aAOnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./get_config"), exports);
|
|
18
|
+
__exportStar(require("./reload_config"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,kDAAgC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CallToolResult, Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
export declare const RELOAD_CONFIG: "reload_config";
|
|
3
|
+
export declare const reloadConfigDefinition: Tool;
|
|
4
|
+
export interface ReloadResult {
|
|
5
|
+
projects: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare const reloadConfig: (onReload: () => Promise<ReloadResult>) => Promise<CallToolResult>;
|
|
8
|
+
//# sourceMappingURL=reload_config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reload_config.d.ts","sourceRoot":"","sources":["../../../src/tools/config/reload_config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAE1E,eAAO,MAAM,aAAa,EAAG,eAAwB,CAAC;AAEtD,eAAO,MAAM,sBAAsB,EAAE,IAKpC,CAAC;AAEF,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,eAAO,MAAM,YAAY,GACvB,UAAU,MAAM,OAAO,CAAC,YAAY,CAAC,KACpC,OAAO,CAAC,cAAc,CA+BxB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reloadConfig = exports.reloadConfigDefinition = exports.RELOAD_CONFIG = void 0;
|
|
4
|
+
exports.RELOAD_CONFIG = 'reload_config';
|
|
5
|
+
exports.reloadConfigDefinition = {
|
|
6
|
+
name: exports.RELOAD_CONFIG,
|
|
7
|
+
description: 'Re-reads the config file from disk and evicts all cached project runtimes. Use this after the user says they have changed their firebase-mcp.json config.',
|
|
8
|
+
inputSchema: { type: 'object', properties: {} },
|
|
9
|
+
};
|
|
10
|
+
const reloadConfig = async (onReload) => {
|
|
11
|
+
try {
|
|
12
|
+
const data = await onReload();
|
|
13
|
+
return {
|
|
14
|
+
content: [
|
|
15
|
+
{
|
|
16
|
+
type: 'text',
|
|
17
|
+
text: JSON.stringify({
|
|
18
|
+
success: true,
|
|
19
|
+
data: { message: 'Config reloaded successfully', ...data },
|
|
20
|
+
}),
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
catch (cause) {
|
|
26
|
+
return {
|
|
27
|
+
content: [
|
|
28
|
+
{
|
|
29
|
+
type: 'text',
|
|
30
|
+
text: JSON.stringify({
|
|
31
|
+
success: false,
|
|
32
|
+
error: {
|
|
33
|
+
code: 'RELOAD_FAILED',
|
|
34
|
+
message: `Failed to reload config: ${String(cause)}`,
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
isError: true,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.reloadConfig = reloadConfig;
|
|
44
|
+
//# sourceMappingURL=reload_config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reload_config.js","sourceRoot":"","sources":["../../../src/tools/config/reload_config.ts"],"names":[],"mappings":";;;AAEa,QAAA,aAAa,GAAG,eAAwB,CAAC;AAEzC,QAAA,sBAAsB,GAAS;IAC1C,IAAI,EAAE,qBAAa;IACnB,WAAW,EACT,2JAA2J;IAC7J,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE;CAChD,CAAC;AAMK,MAAM,YAAY,GAAG,KAAK,EAC/B,QAAqC,EACZ,EAAE;IAC3B,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,QAAQ,EAAE,CAAC;QAC9B,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;wBACnB,OAAO,EAAE,IAAI;wBACb,IAAI,EAAE,EAAE,OAAO,EAAE,8BAA8B,EAAE,GAAG,IAAI,EAAE;qBAC3D,CAAC;iBACH;aACF;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;wBACnB,OAAO,EAAE,KAAK;wBACd,KAAK,EAAE;4BACL,IAAI,EAAE,eAAe;4BACrB,OAAO,EAAE,4BAA4B,MAAM,CAAC,KAAK,CAAC,EAAE;yBACrD;qBACF,CAAC;iBACH;aACF;YACD,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAjCW,QAAA,YAAY,gBAiCvB"}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
-
import { Effect } from 'effect';
|
|
3
2
|
import { AggregateField } from 'firebase-admin/firestore';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import type { ProjectContext } from '../../project';
|
|
4
|
+
import { Task } from '../../task';
|
|
6
5
|
import { QueryFilter } from './types';
|
|
7
|
-
declare
|
|
6
|
+
export declare class FirestoreAggregateError extends Error {
|
|
7
|
+
readonly cause?: unknown | undefined;
|
|
8
8
|
readonly _tag: "FirestoreAggregateError";
|
|
9
|
-
|
|
10
|
-
export declare class FirestoreAggregateError extends FirestoreAggregateError_base<{
|
|
11
|
-
readonly message: string;
|
|
12
|
-
readonly cause?: unknown;
|
|
13
|
-
}> {
|
|
9
|
+
constructor(message: string, cause?: unknown | undefined);
|
|
14
10
|
}
|
|
15
11
|
export declare const AGGREGATE_COLLECTION: "aggregate_collection";
|
|
16
12
|
export interface AggregationSpec {
|
|
@@ -24,11 +20,10 @@ export interface AggregateCollectionArgs {
|
|
|
24
20
|
filters?: QueryFilter[];
|
|
25
21
|
}
|
|
26
22
|
export declare const aggregateCollectionDefinition: Tool;
|
|
27
|
-
export declare const aggregateCollection: (input: AggregateCollectionArgs) =>
|
|
23
|
+
export declare const aggregateCollection: (ctx: ProjectContext, input: AggregateCollectionArgs) => Task<{
|
|
28
24
|
collection: string;
|
|
29
25
|
result: FirebaseFirestore.AggregateSpecData<{
|
|
30
26
|
[k: string]: AggregateField<number>;
|
|
31
27
|
}>;
|
|
32
|
-
}, import("../../
|
|
33
|
-
export {};
|
|
28
|
+
}, import("../../project").AccessDeniedError | FirestoreAggregateError>;
|
|
34
29
|
//# sourceMappingURL=aggregate_collection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregate_collection.d.ts","sourceRoot":"","sources":["../../../src/tools/firestore/aggregate_collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,
|
|
1
|
+
{"version":3,"file":"aggregate_collection.d.ts","sourceRoot":"","sources":["../../../src/tools/firestore/aggregate_collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAsB,WAAW,EAAE,MAAM,SAAS,CAAC;AAE1D,qBAAa,uBAAwB,SAAQ,KAAK;IAEnB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO;IADrD,QAAQ,CAAC,IAAI,EAAG,yBAAyB,CAAU;gBACvC,OAAO,EAAE,MAAM,EAAW,KAAK,CAAC,EAAE,OAAO,YAAA;CAItD;AAED,eAAO,MAAM,oBAAoB,EAAG,sBAA+B,CAAC;AAEpE,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,KAAK,GAAG,KAAK,GAAG,OAAO,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;CACzB;AAED,eAAO,MAAM,6BAA6B,EAAE,IAiD3C,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,KAAK,cAAc,EACnB,OAAO,uBAAuB;;;;;uEAqC5B,CAAC"}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.aggregateCollection = exports.aggregateCollectionDefinition = exports.AGGREGATE_COLLECTION = exports.FirestoreAggregateError = void 0;
|
|
4
|
-
const effect_1 = require("effect");
|
|
5
4
|
const firestore_1 = require("firebase-admin/firestore");
|
|
6
|
-
const
|
|
7
|
-
const firebase_1 = require("../../firebase");
|
|
5
|
+
const task_1 = require("../../task");
|
|
8
6
|
const types_1 = require("./types");
|
|
9
|
-
class FirestoreAggregateError extends
|
|
7
|
+
class FirestoreAggregateError extends Error {
|
|
8
|
+
cause;
|
|
9
|
+
_tag = 'FirestoreAggregateError';
|
|
10
|
+
constructor(message, cause) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.cause = cause;
|
|
13
|
+
this.name = 'FirestoreAggregateError';
|
|
14
|
+
}
|
|
10
15
|
}
|
|
11
16
|
exports.FirestoreAggregateError = FirestoreAggregateError;
|
|
12
17
|
exports.AGGREGATE_COLLECTION = 'aggregate_collection';
|
|
@@ -49,17 +54,21 @@ exports.aggregateCollectionDefinition = {
|
|
|
49
54
|
description: 'Optional where-clause filters to narrow the aggregation',
|
|
50
55
|
items: types_1.FILTER_SCHEMA_ITEM,
|
|
51
56
|
},
|
|
57
|
+
projectId: {
|
|
58
|
+
type: 'string',
|
|
59
|
+
description: 'Project key as defined in firebase-mcp.json',
|
|
60
|
+
},
|
|
52
61
|
},
|
|
53
|
-
required: ['collection', 'aggregations'],
|
|
62
|
+
required: ['collection', 'aggregations', 'projectId'],
|
|
54
63
|
},
|
|
55
64
|
};
|
|
56
|
-
const aggregateCollection = (input) =>
|
|
57
|
-
|
|
58
|
-
yield*
|
|
59
|
-
const { firestore } = yield* firebase_1.FirebaseService;
|
|
60
|
-
const result = yield* effect_1.Effect.tryPromise({
|
|
65
|
+
const aggregateCollection = (ctx, input) => task_1.Task.gen(function* () {
|
|
66
|
+
yield* ctx.checkAccess(input.collection);
|
|
67
|
+
const result = yield* task_1.Task.attempt({
|
|
61
68
|
try: () => {
|
|
62
|
-
let query =
|
|
69
|
+
let query = ctx
|
|
70
|
+
.firestore()
|
|
71
|
+
.collection(input.collection);
|
|
63
72
|
for (const filter of input.filters ?? []) {
|
|
64
73
|
query = query.where(filter.field, filter.operator, filter.value);
|
|
65
74
|
}
|
|
@@ -75,10 +84,7 @@ const aggregateCollection = (input) => effect_1.Effect.gen(function* () {
|
|
|
75
84
|
.get()
|
|
76
85
|
.then((snap) => snap.data());
|
|
77
86
|
},
|
|
78
|
-
catch: (cause) => new FirestoreAggregateError({
|
|
79
|
-
message: `Failed to aggregate collection: ${input.collection}`,
|
|
80
|
-
cause,
|
|
81
|
-
}),
|
|
87
|
+
catch: (cause) => new FirestoreAggregateError(`Failed to aggregate collection: ${input.collection}`, cause),
|
|
82
88
|
});
|
|
83
89
|
return { collection: input.collection, result };
|
|
84
90
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregate_collection.js","sourceRoot":"","sources":["../../../src/tools/firestore/aggregate_collection.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"aggregate_collection.js","sourceRoot":"","sources":["../../../src/tools/firestore/aggregate_collection.ts"],"names":[],"mappings":";;;AACA,wDAA0D;AAG1D,qCAAkC;AAClC,mCAA0D;AAE1D,MAAa,uBAAwB,SAAQ,KAAK;IAEV;IAD7B,IAAI,GAAG,yBAAkC,CAAC;IACnD,YAAY,OAAe,EAAW,KAAe;QACnD,KAAK,CAAC,OAAO,CAAC,CAAC;QADqB,UAAK,GAAL,KAAK,CAAU;QAEnD,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF;AAND,0DAMC;AAEY,QAAA,oBAAoB,GAAG,sBAA+B,CAAC;AAcvD,QAAA,6BAA6B,GAAS;IACjD,IAAI,EAAE,4BAAoB;IAC1B,WAAW,EACT,+JAA+J;IACjK,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,uDAAuD;aACrE;YACD,YAAY,EAAE;gBACZ,IAAI,EAAE,OAAO;gBACb,WAAW,EACT,4DAA4D;gBAC9D,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,KAAK,EAAE;4BACL,IAAI,EAAE,QAAQ;4BACd,WAAW,EACT,+DAA+D;yBAClE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AC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;gBAC7B,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO;oBAAE,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,0BAAc,CAAC,KAAK,EAAE,CAAC,CAAC;gBACrE,IAAI,GAAG,CAAC,IAAI,KAAK,KAAK;oBACpB,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,0BAAc,CAAC,GAAG,CAAC,GAAG,CAAC,KAAM,CAAC,CAAC,CAAC;gBACrD,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,0BAAc,CAAC,OAAO,CAAC,GAAG,CAAC,KAAM,CAAC,CAAC,CAAC;YACzD,CAAC,CAAC,CACH,CAAC;YAEF,OAAO,KAAK;iBACT,SAAS,CAAC,IAAI,CAAC;iBACf,GAAG,EAAE;iBACL,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACjC,CAAC;QACD,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CACf,IAAI,uBAAuB,CACzB,mCAAmC,KAAK,CAAC,UAAU,EAAE,EACrD,KAAK,CACN;KACJ,CAAC,CAAC;IAEH,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC;AAClD,CAAC,CAAC,CAAC;AAvCQ,QAAA,mBAAmB,uBAuC3B"}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { FirebaseService } from '../../firebase';
|
|
2
|
+
import type { ProjectContext } from '../../project';
|
|
3
|
+
import { Task } from '../../task';
|
|
5
4
|
import { QueryFilter } from './types';
|
|
6
|
-
declare
|
|
5
|
+
export declare class FirestoreCountError extends Error {
|
|
6
|
+
readonly cause?: unknown | undefined;
|
|
7
7
|
readonly _tag: "FirestoreCountError";
|
|
8
|
-
|
|
9
|
-
export declare class FirestoreCountError extends FirestoreCountError_base<{
|
|
10
|
-
readonly message: string;
|
|
11
|
-
readonly cause?: unknown;
|
|
12
|
-
}> {
|
|
8
|
+
constructor(message: string, cause?: unknown | undefined);
|
|
13
9
|
}
|
|
14
10
|
export declare const COUNT_DOCUMENTS: "count_documents";
|
|
15
11
|
export interface CountDocumentsArgs {
|
|
@@ -17,9 +13,8 @@ export interface CountDocumentsArgs {
|
|
|
17
13
|
filters?: QueryFilter[];
|
|
18
14
|
}
|
|
19
15
|
export declare const countDocumentsDefinition: Tool;
|
|
20
|
-
export declare const countDocuments: (input: CountDocumentsArgs) =>
|
|
16
|
+
export declare const countDocuments: (ctx: ProjectContext, input: CountDocumentsArgs) => Task<{
|
|
21
17
|
collection: string;
|
|
22
18
|
count: number;
|
|
23
|
-
}, import("../../
|
|
24
|
-
export {};
|
|
19
|
+
}, import("../../project").AccessDeniedError | FirestoreCountError>;
|
|
25
20
|
//# sourceMappingURL=count_documents.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"count_documents.d.ts","sourceRoot":"","sources":["../../../src/tools/firestore/count_documents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"count_documents.d.ts","sourceRoot":"","sources":["../../../src/tools/firestore/count_documents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAsB,WAAW,EAAE,MAAM,SAAS,CAAC;AAE1D,qBAAa,mBAAoB,SAAQ,KAAK;IAEf,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO;IADrD,QAAQ,CAAC,IAAI,EAAG,qBAAqB,CAAU;gBACnC,OAAO,EAAE,MAAM,EAAW,KAAK,CAAC,EAAE,OAAO,YAAA;CAItD;AAED,eAAO,MAAM,eAAe,EAAG,iBAA0B,CAAC;AAE1D,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;CACzB;AAED,eAAO,MAAM,wBAAwB,EAAE,IAuBtC,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,KAAK,cAAc,EAAE,OAAO,kBAAkB;;;mEA2BzE,CAAC"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.countDocuments = exports.countDocumentsDefinition = exports.COUNT_DOCUMENTS = exports.FirestoreCountError = void 0;
|
|
4
|
-
const
|
|
5
|
-
const access_1 = require("../../access");
|
|
6
|
-
const firebase_1 = require("../../firebase");
|
|
4
|
+
const task_1 = require("../../task");
|
|
7
5
|
const types_1 = require("./types");
|
|
8
|
-
class FirestoreCountError extends
|
|
6
|
+
class FirestoreCountError extends Error {
|
|
7
|
+
cause;
|
|
8
|
+
_tag = 'FirestoreCountError';
|
|
9
|
+
constructor(message, cause) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.cause = cause;
|
|
12
|
+
this.name = 'FirestoreCountError';
|
|
13
|
+
}
|
|
9
14
|
}
|
|
10
15
|
exports.FirestoreCountError = FirestoreCountError;
|
|
11
16
|
exports.COUNT_DOCUMENTS = 'count_documents';
|
|
@@ -24,17 +29,21 @@ exports.countDocumentsDefinition = {
|
|
|
24
29
|
description: 'Optional where-clause filters to narrow the count',
|
|
25
30
|
items: types_1.FILTER_SCHEMA_ITEM,
|
|
26
31
|
},
|
|
32
|
+
projectId: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
description: 'Project key as defined in firebase-mcp.json',
|
|
35
|
+
},
|
|
27
36
|
},
|
|
28
|
-
required: ['collection'],
|
|
37
|
+
required: ['collection', 'projectId'],
|
|
29
38
|
},
|
|
30
39
|
};
|
|
31
|
-
const countDocuments = (input) =>
|
|
32
|
-
|
|
33
|
-
yield*
|
|
34
|
-
const { firestore } = yield* firebase_1.FirebaseService;
|
|
35
|
-
const count = yield* effect_1.Effect.tryPromise({
|
|
40
|
+
const countDocuments = (ctx, input) => task_1.Task.gen(function* () {
|
|
41
|
+
yield* ctx.checkAccess(input.collection);
|
|
42
|
+
const count = yield* task_1.Task.attempt({
|
|
36
43
|
try: () => {
|
|
37
|
-
let query =
|
|
44
|
+
let query = ctx
|
|
45
|
+
.firestore()
|
|
46
|
+
.collection(input.collection);
|
|
38
47
|
for (const filter of input.filters ?? []) {
|
|
39
48
|
query = query.where(filter.field, filter.operator, filter.value);
|
|
40
49
|
}
|
|
@@ -43,10 +52,7 @@ const countDocuments = (input) => effect_1.Effect.gen(function* () {
|
|
|
43
52
|
.get()
|
|
44
53
|
.then((snap) => snap.data().count);
|
|
45
54
|
},
|
|
46
|
-
catch: (cause) => new FirestoreCountError({
|
|
47
|
-
message: `Failed to count documents in: ${input.collection}`,
|
|
48
|
-
cause,
|
|
49
|
-
}),
|
|
55
|
+
catch: (cause) => new FirestoreCountError(`Failed to count documents in: ${input.collection}`, cause),
|
|
50
56
|
});
|
|
51
57
|
return { collection: input.collection, count };
|
|
52
58
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"count_documents.js","sourceRoot":"","sources":["../../../src/tools/firestore/count_documents.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"count_documents.js","sourceRoot":"","sources":["../../../src/tools/firestore/count_documents.ts"],"names":[],"mappings":";;;AAGA,qCAAkC;AAClC,mCAA0D;AAE1D,MAAa,mBAAoB,SAAQ,KAAK;IAEN;IAD7B,IAAI,GAAG,qBAA8B,CAAC;IAC/C,YAAY,OAAe,EAAW,KAAe;QACnD,KAAK,CAAC,OAAO,CAAC,CAAC;QADqB,UAAK,GAAL,KAAK,CAAU;QAEnD,IAAI,CAAC,IAAI,GAAG,q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IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC;QACD,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CACf,IAAI,mBAAmB,CACrB,iCAAiC,KAAK,CAAC,UAAU,EAAE,EACnD,KAAK,CACN;KACJ,CAAC,CAAC;IAEH,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC;AACjD,CAAC,CAAC,CAAC;AA3BQ,QAAA,cAAc,kBA2BtB"}
|
|
@@ -1,30 +1,25 @@
|
|
|
1
1
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import type { ProjectContext } from '../../project';
|
|
3
|
+
import { Task } from '../../task';
|
|
4
|
+
export declare class FirestoreSchemaError extends Error {
|
|
5
|
+
readonly cause?: unknown | undefined;
|
|
6
6
|
readonly _tag: "FirestoreSchemaError";
|
|
7
|
-
|
|
8
|
-
export declare class FirestoreSchemaError extends FirestoreSchemaError_base<{
|
|
9
|
-
readonly message: string;
|
|
10
|
-
readonly cause?: unknown;
|
|
11
|
-
}> {
|
|
7
|
+
constructor(message: string, cause?: unknown | undefined);
|
|
12
8
|
}
|
|
13
9
|
export declare const GET_COLLECTION_SCHEMA: "get_collection_schema";
|
|
14
10
|
export interface GetCollectionSchemaArgs {
|
|
15
11
|
collection: string;
|
|
16
12
|
sampleSize?: number;
|
|
17
13
|
}
|
|
18
|
-
interface FieldSchema {
|
|
14
|
+
export interface FieldSchema {
|
|
19
15
|
types: string[];
|
|
20
16
|
coverage: string;
|
|
21
17
|
}
|
|
22
18
|
export declare const getCollectionSchemaDefinition: Tool;
|
|
23
|
-
export declare const getCollectionSchema: (input: GetCollectionSchemaArgs) =>
|
|
19
|
+
export declare const getCollectionSchema: (ctx: ProjectContext, input: GetCollectionSchemaArgs) => Task<{
|
|
24
20
|
collection: string;
|
|
25
21
|
totalSampled: number;
|
|
26
22
|
sampleStrategy: string;
|
|
27
23
|
fields: Record<string, FieldSchema>;
|
|
28
|
-
}, import("../../
|
|
29
|
-
export {};
|
|
24
|
+
}, import("../../project").AccessDeniedError | FirestoreSchemaError>;
|
|
30
25
|
//# sourceMappingURL=get_collection_schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_collection_schema.d.ts","sourceRoot":"","sources":["../../../src/tools/firestore/get_collection_schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"get_collection_schema.d.ts","sourceRoot":"","sources":["../../../src/tools/firestore/get_collection_schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAG1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,qBAAa,oBAAqB,SAAQ,KAAK;IAI3C,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO;IAH1B,QAAQ,CAAC,IAAI,EAAG,sBAAsB,CAAU;gBAE9C,OAAO,EAAE,MAAM,EACN,KAAK,CAAC,EAAE,OAAO,YAAA;CAK3B;AAED,eAAO,MAAM,qBAAqB,EAAG,uBAAgC,CAAC;AAEtE,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAqBD,eAAO,MAAM,6BAA6B,EAAE,IAwB3C,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,KAAK,cAAc,EACnB,OAAO,uBAAuB;;;;;oEAmF5B,CAAC"}
|