@dereekb/firebase-server 13.17.0 → 13.18.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/mailgun/package.json +9 -9
- package/mcp/index.cjs.js +411 -133
- package/mcp/index.esm.js +403 -134
- package/mcp/package.json +11 -11
- package/mcp/src/lib/mcp.config.d.ts +71 -0
- package/mcp/src/lib/service/analytics/mcp.analytics.handler.d.ts +8 -1
- package/mcp/src/lib/service/index.d.ts +1 -0
- package/mcp/src/lib/service/mcp.reason.d.ts +80 -0
- package/mcp/src/lib/service/mcp.server.factory.d.ts +14 -1
- package/mcp/src/lib/service/mcp.tool-generator.d.ts +37 -1
- package/model/package.json +9 -9
- package/oidc/package.json +10 -10
- package/package.json +10 -10
- package/test/package.json +11 -11
- package/twilio/package.json +8 -8
- package/zoho/package.json +9 -9
package/mcp/index.cjs.js
CHANGED
|
@@ -17,7 +17,7 @@ function _class_call_check$5(instance, Constructor) {
|
|
|
17
17
|
throw new TypeError("Cannot call a class as a function");
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
function _define_property$
|
|
20
|
+
function _define_property$9(obj, key, value) {
|
|
21
21
|
if (key in obj) {
|
|
22
22
|
Object.defineProperty(obj, key, {
|
|
23
23
|
value: value,
|
|
@@ -47,6 +47,23 @@ function _define_property$8(obj, key, value) {
|
|
|
47
47
|
* Default `instructions` string advertised by the MCP server on the JSON-RPC `initialize`
|
|
48
48
|
* handshake. Apps may override this via {@link McpModuleConfig.serverInstructions}.
|
|
49
49
|
*/ var DEFAULT_MCP_SERVER_INSTRUCTIONS = 'A set of call-model tools generated automatically.';
|
|
50
|
+
/**
|
|
51
|
+
* Default name of the auto-injected reason parameter added to every advertised MCP tool's input
|
|
52
|
+
* schema. See {@link McpReasonParameterConfig.parameterName}.
|
|
53
|
+
*/ var DEFAULT_MCP_REASON_PARAMETER_NAME = 'reason';
|
|
54
|
+
/**
|
|
55
|
+
* Default maximum length (in characters) of the auto-injected reason parameter. Values longer than
|
|
56
|
+
* this are clamped server-side before being forwarded to analytics. See
|
|
57
|
+
* {@link McpReasonParameterConfig.maxLength}.
|
|
58
|
+
*/ var DEFAULT_MCP_REASON_PARAMETER_MAX_LENGTH = 250;
|
|
59
|
+
/**
|
|
60
|
+
* Default required-ness of the auto-injected reason parameter. See
|
|
61
|
+
* {@link McpReasonParameterConfig.required}.
|
|
62
|
+
*/ var DEFAULT_MCP_REASON_PARAMETER_REQUIRED = true;
|
|
63
|
+
/**
|
|
64
|
+
* Default description advertised for the auto-injected reason parameter on every tool's input schema.
|
|
65
|
+
* See {@link McpReasonParameterConfig.description}.
|
|
66
|
+
*/ var DEFAULT_MCP_REASON_PARAMETER_DESCRIPTION = 'A brief human-readable reason (≤250 chars) explaining why this tool is being called. Recorded for analytics/audit only; not part of the operation.';
|
|
50
67
|
/**
|
|
51
68
|
* Configuration for the firebase-server/mcp module.
|
|
52
69
|
*
|
|
@@ -71,7 +88,7 @@ function _define_property$8(obj, key, value) {
|
|
|
71
88
|
* discovery document. Claude custom-connector reads this to discover the OIDC issuer.
|
|
72
89
|
*
|
|
73
90
|
* @example 'https://api.example.com/oidc'
|
|
74
|
-
*/ _define_property$
|
|
91
|
+
*/ _define_property$9(this, "oidcIssuer", void 0);
|
|
75
92
|
/**
|
|
76
93
|
* The canonical resource URL of the MCP endpoint.
|
|
77
94
|
*
|
|
@@ -79,19 +96,19 @@ function _define_property$8(obj, key, value) {
|
|
|
79
96
|
* and used as the audience the access token's `aud` claim should match.
|
|
80
97
|
*
|
|
81
98
|
* @example 'https://api.example.com/mcp'
|
|
82
|
-
*/ _define_property$
|
|
99
|
+
*/ _define_property$9(this, "mcpUrl", void 0);
|
|
83
100
|
/**
|
|
84
101
|
* Optional name advertised on the MCP `initialize` handshake. Defaults to
|
|
85
102
|
* {@link DEFAULT_MCP_SERVER_NAME}.
|
|
86
|
-
*/ _define_property$
|
|
103
|
+
*/ _define_property$9(this, "serverName", void 0);
|
|
87
104
|
/**
|
|
88
105
|
* Optional version advertised on the MCP `initialize` handshake.
|
|
89
|
-
*/ _define_property$
|
|
106
|
+
*/ _define_property$9(this, "serverVersion", void 0);
|
|
90
107
|
/**
|
|
91
108
|
* Optional override for the `instructions` string passed to `new McpServer(...)` and
|
|
92
109
|
* advertised on the JSON-RPC `initialize` handshake. Defaults to
|
|
93
110
|
* {@link DEFAULT_MCP_SERVER_INSTRUCTIONS}.
|
|
94
|
-
*/ _define_property$
|
|
111
|
+
*/ _define_property$9(this, "serverInstructions", void 0);
|
|
95
112
|
/**
|
|
96
113
|
* Absolute path to a pre-rendered MCP manifest JSON file produced by
|
|
97
114
|
* `dbx-cli-generate-mcp-manifest`. When set, the runtime reads it once at
|
|
@@ -101,7 +118,7 @@ function _define_property$8(obj, key, value) {
|
|
|
101
118
|
* Optional. When unset or the file is missing, the runtime falls back to
|
|
102
119
|
* today's behavior (auto-generated descriptions, ArkType-derived input
|
|
103
120
|
* schemas, no output schemas) and emits a single boot warning.
|
|
104
|
-
*/ _define_property$
|
|
121
|
+
*/ _define_property$9(this, "mcpManifestPath", void 0);
|
|
105
122
|
/**
|
|
106
123
|
* Absolute path to a pre-rendered route manifest JSON file produced by
|
|
107
124
|
* `dbx-cli-generate-route-manifest`. When set, the runtime reads it once at
|
|
@@ -111,7 +128,7 @@ function _define_property$8(obj, key, value) {
|
|
|
111
128
|
* Optional. When unset or the file is missing, the runtime skips registering
|
|
112
129
|
* `url-models` and emits a single boot warning when the path was set but
|
|
113
130
|
* unreadable.
|
|
114
|
-
*/ _define_property$
|
|
131
|
+
*/ _define_property$9(this, "mcpRouteManifestPath", void 0);
|
|
115
132
|
/**
|
|
116
133
|
* When `true`, the MCP server only advertises tools whose effective read-only classification is `true`.
|
|
117
134
|
*
|
|
@@ -121,19 +138,29 @@ function _define_property$8(obj, key, value) {
|
|
|
121
138
|
*
|
|
122
139
|
* The advertised `serverName` on the JSON-RPC `initialize` handshake is suffixed with
|
|
123
140
|
* ` (read-only)` so the client surface reflects the mode.
|
|
124
|
-
*/ _define_property$
|
|
141
|
+
*/ _define_property$9(this, "readOnly", void 0);
|
|
142
|
+
/**
|
|
143
|
+
* Controls the auto-injected `reason` parameter added to every advertised tool's input schema.
|
|
144
|
+
*
|
|
145
|
+
* Enabled by default (unset / `true` = defaults on). Pass a {@link McpReasonParameterConfig} object
|
|
146
|
+
* to tune `required`, `maxLength`, `description`, or `parameterName`, or `false` to disable it.
|
|
147
|
+
*
|
|
148
|
+
* When enabled, every advertised tool's `inputSchema` carries a required `reason` string the model
|
|
149
|
+
* fills with a short justification for the call. The value is forwarded to analytics and stripped
|
|
150
|
+
* from the dispatched handler body. See {@link McpReasonParameterConfig}.
|
|
151
|
+
*/ _define_property$9(this, "reasonParameter", void 0);
|
|
125
152
|
};
|
|
126
153
|
/**
|
|
127
154
|
* NestJS injection token for the optional {@link McpAuthRoleReader} provider.
|
|
128
155
|
*/ var MCP_AUTH_ROLE_READER = 'MCP_AUTH_ROLE_READER';
|
|
129
156
|
|
|
130
|
-
function _type_of$
|
|
157
|
+
function _type_of$5(obj) {
|
|
131
158
|
"@swc/helpers - typeof";
|
|
132
159
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
133
160
|
}
|
|
134
161
|
function __decorate(decorators, target, key, desc) {
|
|
135
162
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
136
|
-
if ((typeof Reflect === "undefined" ? "undefined" : _type_of$
|
|
163
|
+
if ((typeof Reflect === "undefined" ? "undefined" : _type_of$5(Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
137
164
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
138
165
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
139
166
|
}
|
|
@@ -147,6 +174,206 @@ typeof SuppressedError === "function" ? SuppressedError : function(error, suppre
|
|
|
147
174
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
148
175
|
};
|
|
149
176
|
|
|
177
|
+
function _array_like_to_array$a(arr, len) {
|
|
178
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
179
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
180
|
+
return arr2;
|
|
181
|
+
}
|
|
182
|
+
function _array_without_holes$7(arr) {
|
|
183
|
+
if (Array.isArray(arr)) return _array_like_to_array$a(arr);
|
|
184
|
+
}
|
|
185
|
+
function _define_property$8(obj, key, value) {
|
|
186
|
+
if (key in obj) {
|
|
187
|
+
Object.defineProperty(obj, key, {
|
|
188
|
+
value: value,
|
|
189
|
+
enumerable: true,
|
|
190
|
+
configurable: true,
|
|
191
|
+
writable: true
|
|
192
|
+
});
|
|
193
|
+
} else {
|
|
194
|
+
obj[key] = value;
|
|
195
|
+
}
|
|
196
|
+
return obj;
|
|
197
|
+
}
|
|
198
|
+
function _iterable_to_array$7(iter) {
|
|
199
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
200
|
+
}
|
|
201
|
+
function _non_iterable_spread$7() {
|
|
202
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
203
|
+
}
|
|
204
|
+
function _object_spread$5(target) {
|
|
205
|
+
for(var i = 1; i < arguments.length; i++){
|
|
206
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
207
|
+
var ownKeys = Object.keys(source);
|
|
208
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
209
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
210
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
211
|
+
}));
|
|
212
|
+
}
|
|
213
|
+
ownKeys.forEach(function(key) {
|
|
214
|
+
_define_property$8(target, key, source[key]);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
return target;
|
|
218
|
+
}
|
|
219
|
+
function ownKeys$3(object, enumerableOnly) {
|
|
220
|
+
var keys = Object.keys(object);
|
|
221
|
+
if (Object.getOwnPropertySymbols) {
|
|
222
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
223
|
+
keys.push.apply(keys, symbols);
|
|
224
|
+
}
|
|
225
|
+
return keys;
|
|
226
|
+
}
|
|
227
|
+
function _object_spread_props$3(target, source) {
|
|
228
|
+
source = source != null ? source : {};
|
|
229
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
230
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
231
|
+
} else {
|
|
232
|
+
ownKeys$3(Object(source)).forEach(function(key) {
|
|
233
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
return target;
|
|
237
|
+
}
|
|
238
|
+
function _to_consumable_array$7(arr) {
|
|
239
|
+
return _array_without_holes$7(arr) || _iterable_to_array$7(arr) || _unsupported_iterable_to_array$a(arr) || _non_iterable_spread$7();
|
|
240
|
+
}
|
|
241
|
+
function _type_of$4(obj) {
|
|
242
|
+
"@swc/helpers - typeof";
|
|
243
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
244
|
+
}
|
|
245
|
+
function _unsupported_iterable_to_array$a(o, minLen) {
|
|
246
|
+
if (!o) return;
|
|
247
|
+
if (typeof o === "string") return _array_like_to_array$a(o, minLen);
|
|
248
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
249
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
250
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
251
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$a(o, minLen);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Normalizes the app-supplied {@link McpModuleConfig.reasonParameter} value (object / boolean /
|
|
255
|
+
* undefined) into a fully-resolved {@link ResolvedMcpReasonParameterConfig} with the package defaults
|
|
256
|
+
* applied.
|
|
257
|
+
*
|
|
258
|
+
* - `undefined` / `true` → defaults, enabled.
|
|
259
|
+
* - `false` → defaults, but `enabled: false`.
|
|
260
|
+
* - object → per-field overrides on top of the defaults (`enabled` defaults to `true`).
|
|
261
|
+
*
|
|
262
|
+
* @param config - The raw config from {@link McpModuleConfig.reasonParameter}.
|
|
263
|
+
* @returns The resolved config with all defaults applied.
|
|
264
|
+
*/ function resolveMcpReasonParameterConfig(config) {
|
|
265
|
+
var result;
|
|
266
|
+
if (config === false) {
|
|
267
|
+
result = {
|
|
268
|
+
enabled: false,
|
|
269
|
+
required: DEFAULT_MCP_REASON_PARAMETER_REQUIRED,
|
|
270
|
+
maxLength: DEFAULT_MCP_REASON_PARAMETER_MAX_LENGTH,
|
|
271
|
+
description: DEFAULT_MCP_REASON_PARAMETER_DESCRIPTION,
|
|
272
|
+
parameterName: DEFAULT_MCP_REASON_PARAMETER_NAME
|
|
273
|
+
};
|
|
274
|
+
} else if (config == null || config === true) {
|
|
275
|
+
result = {
|
|
276
|
+
enabled: true,
|
|
277
|
+
required: DEFAULT_MCP_REASON_PARAMETER_REQUIRED,
|
|
278
|
+
maxLength: DEFAULT_MCP_REASON_PARAMETER_MAX_LENGTH,
|
|
279
|
+
description: DEFAULT_MCP_REASON_PARAMETER_DESCRIPTION,
|
|
280
|
+
parameterName: DEFAULT_MCP_REASON_PARAMETER_NAME
|
|
281
|
+
};
|
|
282
|
+
} else {
|
|
283
|
+
var _config_enabled, _config_required, _config_maxLength, _config_description, _config_parameterName;
|
|
284
|
+
result = {
|
|
285
|
+
enabled: (_config_enabled = config.enabled) !== null && _config_enabled !== void 0 ? _config_enabled : true,
|
|
286
|
+
required: (_config_required = config.required) !== null && _config_required !== void 0 ? _config_required : DEFAULT_MCP_REASON_PARAMETER_REQUIRED,
|
|
287
|
+
maxLength: (_config_maxLength = config.maxLength) !== null && _config_maxLength !== void 0 ? _config_maxLength : DEFAULT_MCP_REASON_PARAMETER_MAX_LENGTH,
|
|
288
|
+
description: (_config_description = config.description) !== null && _config_description !== void 0 ? _config_description : DEFAULT_MCP_REASON_PARAMETER_DESCRIPTION,
|
|
289
|
+
parameterName: (_config_parameterName = config.parameterName) !== null && _config_parameterName !== void 0 ? _config_parameterName : DEFAULT_MCP_REASON_PARAMETER_NAME
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
return result;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Returns `true` when the JSON schema already declares a property named `name` under `properties`.
|
|
296
|
+
*
|
|
297
|
+
* Used as the collision guard so a handler that legitimately consumes its own field of the same name
|
|
298
|
+
* is never double-declared (schema injection) or stripped (arg extraction).
|
|
299
|
+
*
|
|
300
|
+
* @param schema - The candidate JSON schema object (may be `undefined`).
|
|
301
|
+
* @param name - The property name to look for.
|
|
302
|
+
* @returns Whether the schema's `properties` already contains `name`.
|
|
303
|
+
*/ function mcpSchemaDeclaresProperty(schema, name) {
|
|
304
|
+
var properties = schema === null || schema === void 0 ? void 0 : schema.properties;
|
|
305
|
+
return properties != null && (typeof properties === "undefined" ? "undefined" : _type_of$4(properties)) === 'object' && Object.prototype.hasOwnProperty.call(properties, name);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Returns a NEW JSON schema object with the reason parameter property merged into `properties` (and
|
|
309
|
+
* appended to `required` when configured). Never mutates the input — the static wire schemas are
|
|
310
|
+
* shared module-level constants reused across requests.
|
|
311
|
+
*
|
|
312
|
+
* Self-skips (returns the input schema unchanged) when the config is disabled or the schema already
|
|
313
|
+
* declares the parameter name. Defensive against a non-object / missing-`properties` input.
|
|
314
|
+
*
|
|
315
|
+
* @param inputSchema - The tool's resolved input schema.
|
|
316
|
+
* @param resolved - The resolved reason-parameter config.
|
|
317
|
+
* @returns A new schema carrying the reason property, or the original schema when skipped.
|
|
318
|
+
*/ function applyMcpReasonParameterToSchema(inputSchema, resolved) {
|
|
319
|
+
var result = inputSchema;
|
|
320
|
+
if (resolved.enabled && !mcpSchemaDeclaresProperty(inputSchema, resolved.parameterName)) {
|
|
321
|
+
var _base_type;
|
|
322
|
+
var base = (typeof inputSchema === "undefined" ? "undefined" : _type_of$4(inputSchema)) === 'object' && inputSchema != null ? inputSchema : {};
|
|
323
|
+
var existingProperties = _type_of$4(base.properties) === 'object' && base.properties != null ? base.properties : {};
|
|
324
|
+
var next = _object_spread_props$3(_object_spread$5({}, base), {
|
|
325
|
+
type: (_base_type = base.type) !== null && _base_type !== void 0 ? _base_type : 'object',
|
|
326
|
+
properties: _object_spread_props$3(_object_spread$5({}, existingProperties), _define_property$8({}, resolved.parameterName, {
|
|
327
|
+
type: 'string',
|
|
328
|
+
maxLength: resolved.maxLength,
|
|
329
|
+
description: resolved.description
|
|
330
|
+
}))
|
|
331
|
+
});
|
|
332
|
+
if (resolved.required) {
|
|
333
|
+
var existingRequired = Array.isArray(base.required) ? base.required : [];
|
|
334
|
+
next.required = existingRequired.includes(resolved.parameterName) ? _to_consumable_array$7(existingRequired) : _to_consumable_array$7(existingRequired).concat([
|
|
335
|
+
resolved.parameterName
|
|
336
|
+
]);
|
|
337
|
+
}
|
|
338
|
+
result = next;
|
|
339
|
+
}
|
|
340
|
+
return result;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Splits the auto-injected reason value out of a tool call's raw arguments.
|
|
344
|
+
*
|
|
345
|
+
* When enabled and the tool did NOT declare its own field of the same name: shallow-copies the args,
|
|
346
|
+
* deletes the parameter key, and coerces + clamps the value to `maxLength` (the client is not trusted).
|
|
347
|
+
* An empty / absent value yields `reason: undefined`.
|
|
348
|
+
*
|
|
349
|
+
* Otherwise (disabled, or the handler legitimately owns the field) returns the args unchanged so a
|
|
350
|
+
* field the handler actually consumes is never stripped.
|
|
351
|
+
*
|
|
352
|
+
* @param args - The raw `tools/call` arguments.
|
|
353
|
+
* @param resolved - The resolved reason-parameter config.
|
|
354
|
+
* @param toolDeclaresOwnReason - Whether the tool's own input schema already declares the parameter.
|
|
355
|
+
* @returns The extracted reason plus the (possibly stripped) args to dispatch.
|
|
356
|
+
*/ function extractMcpReasonFromArgs(args, resolved, toolDeclaresOwnReason) {
|
|
357
|
+
var result;
|
|
358
|
+
if (resolved.enabled && !toolDeclaresOwnReason && Object.prototype.hasOwnProperty.call(args, resolved.parameterName)) {
|
|
359
|
+
var rawValue = args[resolved.parameterName];
|
|
360
|
+
var nextArgs = _object_spread$5({}, args);
|
|
361
|
+
delete nextArgs[resolved.parameterName];
|
|
362
|
+
var stringValue = rawValue == null ? '' : String(rawValue);
|
|
363
|
+
var clamped = stringValue.length > resolved.maxLength ? stringValue.slice(0, resolved.maxLength) : stringValue;
|
|
364
|
+
result = {
|
|
365
|
+
reason: clamped.length > 0 ? clamped : undefined,
|
|
366
|
+
args: nextArgs
|
|
367
|
+
};
|
|
368
|
+
} else {
|
|
369
|
+
result = {
|
|
370
|
+
reason: undefined,
|
|
371
|
+
args: args
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
return result;
|
|
375
|
+
}
|
|
376
|
+
|
|
150
377
|
function _class_call_check$4(instance, Constructor) {
|
|
151
378
|
if (!(instance instanceof Constructor)) {
|
|
152
379
|
throw new TypeError("Cannot call a class as a function");
|
|
@@ -949,6 +1176,46 @@ function _unsupported_iterable_to_array$8(o, minLen) {
|
|
|
949
1176
|
*/ function applyWriteMarker(description, annotations) {
|
|
950
1177
|
return annotations.readOnlyHint === false ? "".concat(MCP_WRITE_TOOL_DESCRIPTION_PREFIX).concat(description) : description;
|
|
951
1178
|
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Assembles a statically-registered {@link McpToolDefinition} with consistent MCP annotations.
|
|
1181
|
+
*
|
|
1182
|
+
* Built-in tools (e.g. `whoami`, `model-get`, `batch-execute`) don't flow through
|
|
1183
|
+
* {@link buildToolFromCandidate}, so this is their analogous single source of truth: it derives the
|
|
1184
|
+
* read/write annotations from {@link BuildStaticToolDefinitionInput.effectiveReadOnly} via
|
|
1185
|
+
* {@link resolveMcpToolAnnotations}, applies the {@link MCP_WRITE_TOOL_DESCRIPTION_PREFIX} write
|
|
1186
|
+
* marker to the description, then mirrors the annotations onto both the definition's `annotations`
|
|
1187
|
+
* field and the frozen {@link McpToolDefinition.staticWireEntry}. Centralizing this guarantees no
|
|
1188
|
+
* built-in tool reaches `tools/list` un-annotated (which would surface as an uncategorized "other"
|
|
1189
|
+
* tool in clients that bucket by `readOnlyHint`).
|
|
1190
|
+
*
|
|
1191
|
+
* @param input - The tool identity, schemas, dispatch target, static handler, and read-only classification.
|
|
1192
|
+
* @returns A statically-registered {@link McpToolDefinition} to append to the MCP server factory's tool registry.
|
|
1193
|
+
*/ function buildStaticToolDefinition(input) {
|
|
1194
|
+
var name = input.name, inputSchema = input.inputSchema, outputSchema = input.outputSchema, dispatch = input.dispatch, staticHandler = input.staticHandler, effectiveReadOnly = input.effectiveReadOnly, rule = input.rule;
|
|
1195
|
+
var annotations = resolveMcpToolAnnotations(effectiveReadOnly);
|
|
1196
|
+
var description = applyWriteMarker(input.description, annotations);
|
|
1197
|
+
return {
|
|
1198
|
+
name: name,
|
|
1199
|
+
description: description,
|
|
1200
|
+
inputSchema: inputSchema,
|
|
1201
|
+
outputSchema: outputSchema,
|
|
1202
|
+
annotations: annotations,
|
|
1203
|
+
dispatch: dispatch,
|
|
1204
|
+
staticHandler: staticHandler,
|
|
1205
|
+
filterMetadata: {
|
|
1206
|
+
visibilityKind: 'declarative',
|
|
1207
|
+
rule: rule !== null && rule !== void 0 ? rule : {},
|
|
1208
|
+
effectiveReadOnly: effectiveReadOnly
|
|
1209
|
+
},
|
|
1210
|
+
staticWireEntry: buildStaticWireEntry({
|
|
1211
|
+
name: name,
|
|
1212
|
+
description: description,
|
|
1213
|
+
inputSchema: inputSchema,
|
|
1214
|
+
outputSchema: outputSchema,
|
|
1215
|
+
annotations: annotations
|
|
1216
|
+
})
|
|
1217
|
+
};
|
|
1218
|
+
}
|
|
952
1219
|
// MARK: Naming
|
|
953
1220
|
/**
|
|
954
1221
|
* The default specifier key used when a handler is not behind a specifier router.
|
|
@@ -1646,7 +1913,7 @@ function _ts_generator$5(thisArg, body) {
|
|
|
1646
1913
|
};
|
|
1647
1914
|
var name = MODEL_GET_TOOL_NAME;
|
|
1648
1915
|
var description = 'Fetch one or more Firestore model documents by key or bare id. Values containing `/` are treated as full keys; bare ids are auto-promoted to `<collectionName>/<id>` for root models. Subcollection models require full keys.';
|
|
1649
|
-
return {
|
|
1916
|
+
return buildStaticToolDefinition({
|
|
1650
1917
|
name: name,
|
|
1651
1918
|
description: description,
|
|
1652
1919
|
inputSchema: MODEL_GET_INPUT_SCHEMA,
|
|
@@ -1656,20 +1923,11 @@ function _ts_generator$5(thisArg, body) {
|
|
|
1656
1923
|
modelType: MODEL_GET_DISPATCH_MODEL_TYPE
|
|
1657
1924
|
},
|
|
1658
1925
|
staticHandler: handler,
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
effectiveReadOnly: true
|
|
1665
|
-
},
|
|
1666
|
-
staticWireEntry: buildStaticWireEntry({
|
|
1667
|
-
name: name,
|
|
1668
|
-
description: description,
|
|
1669
|
-
inputSchema: MODEL_GET_INPUT_SCHEMA,
|
|
1670
|
-
outputSchema: MODEL_GET_OUTPUT_SCHEMA
|
|
1671
|
-
})
|
|
1672
|
-
};
|
|
1926
|
+
effectiveReadOnly: true,
|
|
1927
|
+
rule: {
|
|
1928
|
+
requireAuthenticated: true
|
|
1929
|
+
}
|
|
1930
|
+
});
|
|
1673
1931
|
}
|
|
1674
1932
|
// MARK: Handler
|
|
1675
1933
|
function modelGetToolHandler(args, ctx, deps) {
|
|
@@ -1940,7 +2198,7 @@ function _object_spread$4(target) {
|
|
|
1940
2198
|
}
|
|
1941
2199
|
return target;
|
|
1942
2200
|
}
|
|
1943
|
-
function ownKeys$
|
|
2201
|
+
function ownKeys$2(object, enumerableOnly) {
|
|
1944
2202
|
var keys = Object.keys(object);
|
|
1945
2203
|
if (Object.getOwnPropertySymbols) {
|
|
1946
2204
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
@@ -1948,12 +2206,12 @@ function ownKeys$1(object, enumerableOnly) {
|
|
|
1948
2206
|
}
|
|
1949
2207
|
return keys;
|
|
1950
2208
|
}
|
|
1951
|
-
function _object_spread_props$
|
|
2209
|
+
function _object_spread_props$2(target, source) {
|
|
1952
2210
|
source = source != null ? source : {};
|
|
1953
2211
|
if (Object.getOwnPropertyDescriptors) {
|
|
1954
2212
|
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
1955
2213
|
} else {
|
|
1956
|
-
ownKeys$
|
|
2214
|
+
ownKeys$2(Object(source)).forEach(function(key) {
|
|
1957
2215
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
1958
2216
|
});
|
|
1959
2217
|
}
|
|
@@ -2017,7 +2275,7 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
2017
2275
|
var name = MODEL_INFO_TOOL_NAME;
|
|
2018
2276
|
var count = deps.manifest.length;
|
|
2019
2277
|
var description = "Browse the Firestore model catalog (".concat(count, " model").concat(count === 1 ? '' : 's', "). No args returns model groups + counts (start here). ") + '`model` (a modelType/identityConst/collectionPrefix string, or an array of them) returns full detail per match — misses are reported in `notFound`. ' + '`modelGroup` returns the summary list for that group. `all:true` returns the full catalog summary. ' + '`fields` (boolean) forces or suppresses persisted-field detail in list/multiple modes.';
|
|
2020
|
-
return {
|
|
2278
|
+
return buildStaticToolDefinition({
|
|
2021
2279
|
name: name,
|
|
2022
2280
|
description: description,
|
|
2023
2281
|
inputSchema: MODEL_INFO_INPUT_SCHEMA,
|
|
@@ -2027,20 +2285,11 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
2027
2285
|
modelType: MODEL_INFO_DISPATCH_MODEL_TYPE
|
|
2028
2286
|
},
|
|
2029
2287
|
staticHandler: handler,
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
effectiveReadOnly: true
|
|
2036
|
-
},
|
|
2037
|
-
staticWireEntry: buildStaticWireEntry({
|
|
2038
|
-
name: name,
|
|
2039
|
-
description: description,
|
|
2040
|
-
inputSchema: MODEL_INFO_INPUT_SCHEMA,
|
|
2041
|
-
outputSchema: MODEL_INFO_OUTPUT_SCHEMA
|
|
2042
|
-
})
|
|
2043
|
-
};
|
|
2288
|
+
effectiveReadOnly: true,
|
|
2289
|
+
rule: {
|
|
2290
|
+
requireAuthenticated: true
|
|
2291
|
+
}
|
|
2292
|
+
});
|
|
2044
2293
|
}
|
|
2045
2294
|
// MARK: Handler
|
|
2046
2295
|
function modelInfoToolHandler(args, _ctx, deps) {
|
|
@@ -2144,7 +2393,7 @@ function resolveModelInfoOutput(input, manifest) {
|
|
|
2144
2393
|
}
|
|
2145
2394
|
}
|
|
2146
2395
|
if (tables.length > 0) {
|
|
2147
|
-
result = _object_spread_props$
|
|
2396
|
+
result = _object_spread_props$2(_object_spread$4({}, output), {
|
|
2148
2397
|
enums: tables
|
|
2149
2398
|
});
|
|
2150
2399
|
}
|
|
@@ -2198,7 +2447,7 @@ function parseModelInfoInput(args) {
|
|
|
2198
2447
|
var modelGroup = parseModelGroupArg(args['modelGroup']);
|
|
2199
2448
|
var all = parseBooleanArg(args['all'], 'all');
|
|
2200
2449
|
var fields = parseBooleanArg(args['fields'], 'fields');
|
|
2201
|
-
return _object_spread$4(_object_spread_props$
|
|
2450
|
+
return _object_spread$4(_object_spread_props$2(_object_spread$4(_object_spread_props$2(_object_spread$4({}, modelQueries == null ? {} : {
|
|
2202
2451
|
modelQueries: modelQueries
|
|
2203
2452
|
}), {
|
|
2204
2453
|
modelIsArray: Array.isArray(args['model'])
|
|
@@ -2696,7 +2945,7 @@ var MODEL_INFO_OUTPUT_SCHEMA = {
|
|
|
2696
2945
|
type: 'string',
|
|
2697
2946
|
description: 'Present when `mode` is `"list"` from a `modelGroup` filter. The canonical group name.'
|
|
2698
2947
|
},
|
|
2699
|
-
model: _object_spread_props$
|
|
2948
|
+
model: _object_spread_props$2(_object_spread$4({}, MODEL_ROW_SCHEMA), {
|
|
2700
2949
|
description: 'Present when `mode` is `"single"`. The matched model entry (full detail unless `fields:false`).'
|
|
2701
2950
|
}),
|
|
2702
2951
|
notFound: {
|
|
@@ -2831,7 +3080,7 @@ function _object_spread$3(target) {
|
|
|
2831
3080
|
};
|
|
2832
3081
|
var name = MODEL_DECODE_TOOL_NAME;
|
|
2833
3082
|
var description = 'Decode a Firestore model key ("prefix/id", or subcollection path "parentPrefix/parentId/childPrefix/childId") into { leaf, ancestors, unresolvedPrefixes } using the registered manifest ('.concat(deps.manifest.length, " model").concat(deps.manifest.length === 1 ? '' : 's', ").");
|
|
2834
|
-
return {
|
|
3083
|
+
return buildStaticToolDefinition({
|
|
2835
3084
|
name: name,
|
|
2836
3085
|
description: description,
|
|
2837
3086
|
inputSchema: MODEL_DECODE_INPUT_SCHEMA,
|
|
@@ -2841,20 +3090,11 @@ function _object_spread$3(target) {
|
|
|
2841
3090
|
modelType: MODEL_DECODE_DISPATCH_MODEL_TYPE
|
|
2842
3091
|
},
|
|
2843
3092
|
staticHandler: handler,
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
effectiveReadOnly: true
|
|
2850
|
-
},
|
|
2851
|
-
staticWireEntry: buildStaticWireEntry({
|
|
2852
|
-
name: name,
|
|
2853
|
-
description: description,
|
|
2854
|
-
inputSchema: MODEL_DECODE_INPUT_SCHEMA,
|
|
2855
|
-
outputSchema: MODEL_DECODE_OUTPUT_SCHEMA
|
|
2856
|
-
})
|
|
2857
|
-
};
|
|
3093
|
+
effectiveReadOnly: true,
|
|
3094
|
+
rule: {
|
|
3095
|
+
requireAuthenticated: true
|
|
3096
|
+
}
|
|
3097
|
+
});
|
|
2858
3098
|
}
|
|
2859
3099
|
// MARK: Handler
|
|
2860
3100
|
function modelDecodeToolHandler(args, _ctx, deps) {
|
|
@@ -3061,7 +3301,7 @@ var MODEL_DECODE_OUTPUT_SCHEMA = {
|
|
|
3061
3301
|
var name = ENUM_INFO_TOOL_NAME;
|
|
3062
3302
|
var count = Object.keys(deps.enums).length;
|
|
3063
3303
|
var description = "Look up enum value→label tables by name (".concat(count, " enum").concat(count === 1 ? '' : 's', ' registered). Pass `enum` (a string or array of enum declaration names, e.g. "JobWorkerTimesheetState") to decode the raw persisted integer/string values a model field stores. Misses are reported in `notFound`.');
|
|
3064
|
-
return {
|
|
3304
|
+
return buildStaticToolDefinition({
|
|
3065
3305
|
name: name,
|
|
3066
3306
|
description: description,
|
|
3067
3307
|
inputSchema: ENUM_INFO_INPUT_SCHEMA,
|
|
@@ -3071,20 +3311,11 @@ var MODEL_DECODE_OUTPUT_SCHEMA = {
|
|
|
3071
3311
|
modelType: ENUM_INFO_DISPATCH_MODEL_TYPE
|
|
3072
3312
|
},
|
|
3073
3313
|
staticHandler: handler,
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
effectiveReadOnly: true
|
|
3080
|
-
},
|
|
3081
|
-
staticWireEntry: buildStaticWireEntry({
|
|
3082
|
-
name: name,
|
|
3083
|
-
description: description,
|
|
3084
|
-
inputSchema: ENUM_INFO_INPUT_SCHEMA,
|
|
3085
|
-
outputSchema: ENUM_INFO_OUTPUT_SCHEMA
|
|
3086
|
-
})
|
|
3087
|
-
};
|
|
3314
|
+
effectiveReadOnly: true,
|
|
3315
|
+
rule: {
|
|
3316
|
+
requireAuthenticated: true
|
|
3317
|
+
}
|
|
3318
|
+
});
|
|
3088
3319
|
}
|
|
3089
3320
|
// MARK: Handler
|
|
3090
3321
|
function enumInfoToolHandler(args, _ctx, deps) {
|
|
@@ -3347,7 +3578,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
3347
3578
|
var name = WHOAMI_TOOL_NAME;
|
|
3348
3579
|
var appLabel = (_ref = (_deps_auth_app = deps.auth.app) === null || _deps_auth_app === void 0 ? void 0 : _deps_auth_app.app) !== null && _ref !== void 0 ? _ref : 'this server';
|
|
3349
3580
|
var description = "Reports the authenticated caller's uid, raw custom claims, and decoded role set for `".concat(appLabel, "`. Returns `authenticated: false` for anonymous callers. Claim descriptions are drawn from the build-time auth manifest; only keys actually present on the live token are detailed.");
|
|
3350
|
-
return {
|
|
3581
|
+
return buildStaticToolDefinition({
|
|
3351
3582
|
name: name,
|
|
3352
3583
|
description: description,
|
|
3353
3584
|
inputSchema: WHOAMI_INPUT_SCHEMA,
|
|
@@ -3357,18 +3588,9 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
3357
3588
|
modelType: WHOAMI_DISPATCH_MODEL_TYPE
|
|
3358
3589
|
},
|
|
3359
3590
|
staticHandler: handler,
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
effectiveReadOnly: true
|
|
3364
|
-
},
|
|
3365
|
-
staticWireEntry: buildStaticWireEntry({
|
|
3366
|
-
name: name,
|
|
3367
|
-
description: description,
|
|
3368
|
-
inputSchema: WHOAMI_INPUT_SCHEMA,
|
|
3369
|
-
outputSchema: WHOAMI_OUTPUT_SCHEMA
|
|
3370
|
-
})
|
|
3371
|
-
};
|
|
3591
|
+
effectiveReadOnly: true,
|
|
3592
|
+
rule: {}
|
|
3593
|
+
});
|
|
3372
3594
|
}
|
|
3373
3595
|
// MARK: Handler
|
|
3374
3596
|
function whoamiToolHandler(ctx, deps) {
|
|
@@ -3764,7 +3986,7 @@ function _object_spread$1(target) {
|
|
|
3764
3986
|
}
|
|
3765
3987
|
return target;
|
|
3766
3988
|
}
|
|
3767
|
-
function ownKeys(object, enumerableOnly) {
|
|
3989
|
+
function ownKeys$1(object, enumerableOnly) {
|
|
3768
3990
|
var keys = Object.keys(object);
|
|
3769
3991
|
if (Object.getOwnPropertySymbols) {
|
|
3770
3992
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
@@ -3772,12 +3994,12 @@ function ownKeys(object, enumerableOnly) {
|
|
|
3772
3994
|
}
|
|
3773
3995
|
return keys;
|
|
3774
3996
|
}
|
|
3775
|
-
function _object_spread_props(target, source) {
|
|
3997
|
+
function _object_spread_props$1(target, source) {
|
|
3776
3998
|
source = source != null ? source : {};
|
|
3777
3999
|
if (Object.getOwnPropertyDescriptors) {
|
|
3778
4000
|
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
3779
4001
|
} else {
|
|
3780
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
4002
|
+
ownKeys$1(Object(source)).forEach(function(key) {
|
|
3781
4003
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
3782
4004
|
});
|
|
3783
4005
|
}
|
|
@@ -3931,7 +4153,7 @@ function _ts_generator$4(thisArg, body) {
|
|
|
3931
4153
|
};
|
|
3932
4154
|
var name = URL_MODELS_TOOL_NAME;
|
|
3933
4155
|
var description = 'Decode an app URL (or path) into the Firestore models its page renders. Pass a URL like `https://app.example.co/worker/abc/timesheets/list`; the tool matches it against the build-time route manifest and returns each model type plus the concrete key (route params + `{authUid}` substituted). Use `models` to filter to specific types, `keysOnly` for just the resolved keys, or `load: true` to fetch the documents via the same permission-checked path as `model-get` (cannot combine `load` with `keysOnly`).';
|
|
3934
|
-
return {
|
|
4156
|
+
return buildStaticToolDefinition({
|
|
3935
4157
|
name: name,
|
|
3936
4158
|
description: description,
|
|
3937
4159
|
inputSchema: URL_MODELS_INPUT_SCHEMA,
|
|
@@ -3941,20 +4163,11 @@ function _ts_generator$4(thisArg, body) {
|
|
|
3941
4163
|
modelType: URL_MODELS_DISPATCH_MODEL_TYPE
|
|
3942
4164
|
},
|
|
3943
4165
|
staticHandler: handler,
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
effectiveReadOnly: true
|
|
3950
|
-
},
|
|
3951
|
-
staticWireEntry: buildStaticWireEntry({
|
|
3952
|
-
name: name,
|
|
3953
|
-
description: description,
|
|
3954
|
-
inputSchema: URL_MODELS_INPUT_SCHEMA,
|
|
3955
|
-
outputSchema: URL_MODELS_OUTPUT_SCHEMA
|
|
3956
|
-
})
|
|
3957
|
-
};
|
|
4166
|
+
effectiveReadOnly: true,
|
|
4167
|
+
rule: {
|
|
4168
|
+
requireAuthenticated: true
|
|
4169
|
+
}
|
|
4170
|
+
});
|
|
3958
4171
|
}
|
|
3959
4172
|
// MARK: Handler
|
|
3960
4173
|
function urlModelsToolHandler(args, ctx, deps) {
|
|
@@ -4031,7 +4244,7 @@ function parseUrlModelsInput(args) {
|
|
|
4031
4244
|
}
|
|
4032
4245
|
currentUserUid = args.currentUserUid;
|
|
4033
4246
|
}
|
|
4034
|
-
return _object_spread$1(_object_spread_props(_object_spread$1({
|
|
4247
|
+
return _object_spread$1(_object_spread_props$1(_object_spread$1({
|
|
4035
4248
|
url: url
|
|
4036
4249
|
}, models === undefined ? {} : {
|
|
4037
4250
|
models: models
|
|
@@ -4811,7 +5024,7 @@ function _ts_generator$3(thisArg, body) {
|
|
|
4811
5024
|
};
|
|
4812
5025
|
var name = BATCH_EXECUTE_TOOL_NAME;
|
|
4813
5026
|
var description = 'Execute a batch of MCP operations server-side from an uploaded JSON/NDJSON file, returning a success/failure summary. Each line/element is an operation `{ call, modelType, specifier?, data }` matching any other write tool you could call individually. Generate the file with a script and upload it instead of invoking a per-record tool many times. Every operation is authorized against your visible tools before any run; a forbidden or malformed operation aborts the whole batch with nothing executed.';
|
|
4814
|
-
return {
|
|
5027
|
+
return buildStaticToolDefinition({
|
|
4815
5028
|
name: name,
|
|
4816
5029
|
description: description,
|
|
4817
5030
|
inputSchema: BATCH_EXECUTE_INPUT_SCHEMA,
|
|
@@ -4821,20 +5034,11 @@ function _ts_generator$3(thisArg, body) {
|
|
|
4821
5034
|
modelType: BATCH_EXECUTE_DISPATCH_MODEL_TYPE
|
|
4822
5035
|
},
|
|
4823
5036
|
staticHandler: handler,
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
effectiveReadOnly: false
|
|
4830
|
-
},
|
|
4831
|
-
staticWireEntry: buildStaticWireEntry({
|
|
4832
|
-
name: name,
|
|
4833
|
-
description: description,
|
|
4834
|
-
inputSchema: BATCH_EXECUTE_INPUT_SCHEMA,
|
|
4835
|
-
outputSchema: BATCH_EXECUTE_OUTPUT_SCHEMA
|
|
4836
|
-
})
|
|
4837
|
-
};
|
|
5037
|
+
effectiveReadOnly: false,
|
|
5038
|
+
rule: {
|
|
5039
|
+
requireAuthenticated: true
|
|
5040
|
+
}
|
|
5041
|
+
});
|
|
4838
5042
|
}
|
|
4839
5043
|
// MARK: Handler
|
|
4840
5044
|
function batchExecuteToolHandler(args, ctx, deps) {
|
|
@@ -5538,6 +5742,25 @@ function _object_spread(target) {
|
|
|
5538
5742
|
}
|
|
5539
5743
|
return target;
|
|
5540
5744
|
}
|
|
5745
|
+
function ownKeys(object, enumerableOnly) {
|
|
5746
|
+
var keys = Object.keys(object);
|
|
5747
|
+
if (Object.getOwnPropertySymbols) {
|
|
5748
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
5749
|
+
keys.push.apply(keys, symbols);
|
|
5750
|
+
}
|
|
5751
|
+
return keys;
|
|
5752
|
+
}
|
|
5753
|
+
function _object_spread_props(target, source) {
|
|
5754
|
+
source = source != null ? source : {};
|
|
5755
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
5756
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
5757
|
+
} else {
|
|
5758
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
5759
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
5760
|
+
});
|
|
5761
|
+
}
|
|
5762
|
+
return target;
|
|
5763
|
+
}
|
|
5541
5764
|
function _sliced_to_array(arr, i) {
|
|
5542
5765
|
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array$2(arr, i) || _non_iterable_rest();
|
|
5543
5766
|
}
|
|
@@ -5683,6 +5906,7 @@ var McpServerFactoryService_1;
|
|
|
5683
5906
|
_define_property$3(this, "_manifestLoaded", false);
|
|
5684
5907
|
_define_property$3(this, "_loggedSkips", false);
|
|
5685
5908
|
_define_property$3(this, "_warnedMissingRoleReader", false);
|
|
5909
|
+
_define_property$3(this, "_resolvedReasonConfig", void 0);
|
|
5686
5910
|
_define_property$3(this, "_analyticsService", void 0);
|
|
5687
5911
|
this.mcpConfig = mcpConfig;
|
|
5688
5912
|
this.dispatchService = dispatchService;
|
|
@@ -6385,11 +6609,32 @@ var McpServerFactoryService_1;
|
|
|
6385
6609
|
},
|
|
6386
6610
|
{
|
|
6387
6611
|
/**
|
|
6612
|
+
* Resolves the app's reason-parameter config once and caches it for the process lifetime.
|
|
6613
|
+
*
|
|
6614
|
+
* The underlying {@link McpModuleConfig.reasonParameter} value is fixed at boot, so the normalized
|
|
6615
|
+
* form is safe to memoize and reuse across every `tools/list` and `tools/call`.
|
|
6616
|
+
*
|
|
6617
|
+
* @returns The resolved reason-parameter config (defaults applied).
|
|
6618
|
+
*/ key: "_resolveReasonConfig",
|
|
6619
|
+
value: function _resolveReasonConfig() {
|
|
6620
|
+
var result = this._resolvedReasonConfig;
|
|
6621
|
+
if (result == null) {
|
|
6622
|
+
result = resolveMcpReasonParameterConfig(this.mcpConfig.reasonParameter);
|
|
6623
|
+
this._resolvedReasonConfig = result;
|
|
6624
|
+
}
|
|
6625
|
+
return result;
|
|
6626
|
+
}
|
|
6627
|
+
},
|
|
6628
|
+
{
|
|
6629
|
+
/**
|
|
6388
6630
|
* Resolves the wire-shape `tools/list` entry for a single tool.
|
|
6389
6631
|
*
|
|
6390
6632
|
* Hot-path short-circuit: tools without a `toolDetailsBuilder` reuse the precomputed,
|
|
6391
6633
|
* frozen {@link McpToolDefinition.staticWireEntry} verbatim — zero allocations per
|
|
6392
|
-
* request for the common case.
|
|
6634
|
+
* request for the common case. When the auto-injected reason parameter is enabled (the
|
|
6635
|
+
* default), the entry is no longer returned frozen-verbatim: its `inputSchema` is wrapped
|
|
6636
|
+
* with the reason property per request (`tools/list` is low-frequency, so the allocation is
|
|
6637
|
+
* acceptable). Tools that already declare the parameter name are still reused verbatim.
|
|
6393
6638
|
*
|
|
6394
6639
|
* Tools that opted in to {@link McpToolDetailsBuilder} get a fresh wire entry built
|
|
6395
6640
|
* from the builder's overrides. If the builder throws, the framework falls back to
|
|
@@ -6401,9 +6646,20 @@ var McpServerFactoryService_1;
|
|
|
6401
6646
|
* @returns The wire-shape entry to emit for this tool on `tools/list`.
|
|
6402
6647
|
*/ key: "_buildToolListEntry",
|
|
6403
6648
|
value: function _buildToolListEntry(tool, ctx, scopes) {
|
|
6649
|
+
var reasonConfig = this._resolveReasonConfig();
|
|
6404
6650
|
var result;
|
|
6405
6651
|
if (tool.toolDetailsBuilder == null) {
|
|
6406
6652
|
result = tool.staticWireEntry;
|
|
6653
|
+
if (reasonConfig.enabled) {
|
|
6654
|
+
var reasoned = applyMcpReasonParameterToSchema(tool.staticWireEntry.inputSchema, reasonConfig);
|
|
6655
|
+
// applyMcpReasonParameterToSchema self-skips (returns the same reference) on collision, so the
|
|
6656
|
+
// frozen-verbatim hot path still holds for tools that already declare the parameter name.
|
|
6657
|
+
if (reasoned !== tool.staticWireEntry.inputSchema) {
|
|
6658
|
+
result = _object_spread_props(_object_spread({}, tool.staticWireEntry), {
|
|
6659
|
+
inputSchema: reasoned
|
|
6660
|
+
});
|
|
6661
|
+
}
|
|
6662
|
+
}
|
|
6407
6663
|
} else {
|
|
6408
6664
|
var description = tool.description;
|
|
6409
6665
|
var inputSchema = tool.inputSchema;
|
|
@@ -6424,12 +6680,16 @@ var McpServerFactoryService_1;
|
|
|
6424
6680
|
} catch (error) {
|
|
6425
6681
|
this._logger.warn("MCP tool ".concat(tool.name, " toolDetails builder threw; falling back to defaults: ").concat(error.message));
|
|
6426
6682
|
}
|
|
6683
|
+
var resolvedInputSchema = inputSchema !== null && inputSchema !== void 0 ? inputSchema : {
|
|
6684
|
+
type: 'object'
|
|
6685
|
+
};
|
|
6686
|
+
if (reasonConfig.enabled) {
|
|
6687
|
+
resolvedInputSchema = applyMcpReasonParameterToSchema(resolvedInputSchema, reasonConfig);
|
|
6688
|
+
}
|
|
6427
6689
|
var wire = {
|
|
6428
6690
|
name: tool.name,
|
|
6429
6691
|
description: description,
|
|
6430
|
-
inputSchema:
|
|
6431
|
-
type: 'object'
|
|
6432
|
-
}
|
|
6692
|
+
inputSchema: resolvedInputSchema
|
|
6433
6693
|
};
|
|
6434
6694
|
if (tool.outputSchema != null) {
|
|
6435
6695
|
wire.outputSchema = tool.outputSchema;
|
|
@@ -6459,14 +6719,20 @@ var McpServerFactoryService_1;
|
|
|
6459
6719
|
* @returns The MCP tool response.
|
|
6460
6720
|
*/ function _handleToolCall(request, definitionsByName, ctx) {
|
|
6461
6721
|
return _async_to_generator$2(function() {
|
|
6462
|
-
var _request_params_arguments, _ctx_auth, toolName, definition,
|
|
6722
|
+
var _request_params_arguments, _ctx_auth, toolName, definition, rawArgs, startedAt, reasonConfig, declaresOwn, _extractMcpReasonFromArgs, reason, args, outcome, isSuccessful, toolKind;
|
|
6463
6723
|
return _ts_generator$2(this, function(_state) {
|
|
6464
6724
|
switch(_state.label){
|
|
6465
6725
|
case 0:
|
|
6466
6726
|
toolName = request.params.name;
|
|
6467
6727
|
definition = definitionsByName.get(toolName);
|
|
6468
|
-
|
|
6728
|
+
rawArgs = (_request_params_arguments = request.params.arguments) !== null && _request_params_arguments !== void 0 ? _request_params_arguments : {};
|
|
6469
6729
|
startedAt = Date.now();
|
|
6730
|
+
// Split the auto-injected reason out of the args: forward it to analytics, but never let it reach
|
|
6731
|
+
// the underlying handler. Tools that declare their own field of the same name keep it (driven by
|
|
6732
|
+
// the tool's own resolved inputSchema, not the reason-augmented wire schema).
|
|
6733
|
+
reasonConfig = this._resolveReasonConfig();
|
|
6734
|
+
declaresOwn = mcpSchemaDeclaresProperty(definition === null || definition === void 0 ? void 0 : definition.inputSchema, reasonConfig.parameterName);
|
|
6735
|
+
_extractMcpReasonFromArgs = extractMcpReasonFromArgs(rawArgs, reasonConfig, declaresOwn), reason = _extractMcpReasonFromArgs.reason, args = _extractMcpReasonFromArgs.args;
|
|
6470
6736
|
if (!(definition == null)) return [
|
|
6471
6737
|
3,
|
|
6472
6738
|
1
|
|
@@ -6516,6 +6782,7 @@ var McpServerFactoryService_1;
|
|
|
6516
6782
|
auth: ctx.auth,
|
|
6517
6783
|
readOnly: this.mcpConfig.readOnly === true,
|
|
6518
6784
|
args: args,
|
|
6785
|
+
reason: reason,
|
|
6519
6786
|
isSuccessful: isSuccessful,
|
|
6520
6787
|
error: outcome.error,
|
|
6521
6788
|
durationMs: Date.now() - startedAt
|
|
@@ -7357,18 +7624,20 @@ var FirebaseServerMcpAnalyticsService_1;
|
|
|
7357
7624
|
if (this._logEvents) {
|
|
7358
7625
|
var uidSuffix = event.uid ? " uid=".concat(event.uid) : '';
|
|
7359
7626
|
var durationSuffix = event.durationMs == null ? '' : " (".concat(event.durationMs, "ms)");
|
|
7627
|
+
var reasonSuffix = event.reason ? ' reason="'.concat(event.reason, '"') : '';
|
|
7360
7628
|
var outcome = event.isSuccessful ? 'Succeeded' : 'Failed';
|
|
7361
|
-
this._logger.log("MCP ".concat(event.toolName, " [").concat(event.toolKind, "] ").concat(outcome).concat(uidSuffix).concat(durationSuffix));
|
|
7629
|
+
this._logger.log("MCP ".concat(event.toolName, " [").concat(event.toolKind, "] ").concat(outcome).concat(uidSuffix).concat(durationSuffix).concat(reasonSuffix));
|
|
7362
7630
|
}
|
|
7363
7631
|
if (this.analyticsService != null) {
|
|
7364
|
-
var _event_call, _event_modelType, _event_specifier;
|
|
7632
|
+
var _event_call, _event_modelType, _event_specifier, _event_reason;
|
|
7365
7633
|
this.analyticsService.sendEventData(event.uid, this._eventName, {
|
|
7366
7634
|
tool: event.toolName,
|
|
7367
7635
|
toolKind: event.toolKind,
|
|
7368
7636
|
call: (_event_call = event.call) !== null && _event_call !== void 0 ? _event_call : '',
|
|
7369
7637
|
modelType: (_event_modelType = event.modelType) !== null && _event_modelType !== void 0 ? _event_modelType : '',
|
|
7370
7638
|
specifier: (_event_specifier = event.specifier) !== null && _event_specifier !== void 0 ? _event_specifier : '',
|
|
7371
|
-
success: event.isSuccessful
|
|
7639
|
+
success: event.isSuccessful,
|
|
7640
|
+
reason: (_event_reason = event.reason) !== null && _event_reason !== void 0 ? _event_reason : ''
|
|
7372
7641
|
});
|
|
7373
7642
|
}
|
|
7374
7643
|
}
|
|
@@ -7462,6 +7731,10 @@ exports.DEFAULT_BATCH_EXECUTE_MAX_PARALLEL = DEFAULT_BATCH_EXECUTE_MAX_PARALLEL;
|
|
|
7462
7731
|
exports.DEFAULT_JSON_SCHEMA_GENERATION_OPTIONS = DEFAULT_JSON_SCHEMA_GENERATION_OPTIONS;
|
|
7463
7732
|
exports.DEFAULT_MCP_ANALYTICS_EVENT_NAME = DEFAULT_MCP_ANALYTICS_EVENT_NAME;
|
|
7464
7733
|
exports.DEFAULT_MCP_PATH = DEFAULT_MCP_PATH;
|
|
7734
|
+
exports.DEFAULT_MCP_REASON_PARAMETER_DESCRIPTION = DEFAULT_MCP_REASON_PARAMETER_DESCRIPTION;
|
|
7735
|
+
exports.DEFAULT_MCP_REASON_PARAMETER_MAX_LENGTH = DEFAULT_MCP_REASON_PARAMETER_MAX_LENGTH;
|
|
7736
|
+
exports.DEFAULT_MCP_REASON_PARAMETER_NAME = DEFAULT_MCP_REASON_PARAMETER_NAME;
|
|
7737
|
+
exports.DEFAULT_MCP_REASON_PARAMETER_REQUIRED = DEFAULT_MCP_REASON_PARAMETER_REQUIRED;
|
|
7465
7738
|
exports.DEFAULT_MCP_SERVER_INSTRUCTIONS = DEFAULT_MCP_SERVER_INSTRUCTIONS;
|
|
7466
7739
|
exports.DEFAULT_MCP_SERVER_NAME = DEFAULT_MCP_SERVER_NAME;
|
|
7467
7740
|
exports.DEFAULT_SPECIFIER_KEY = DEFAULT_SPECIFIER_KEY;
|
|
@@ -7501,11 +7774,13 @@ exports.URL_MODELS_DISPATCH_MODEL_TYPE = URL_MODELS_DISPATCH_MODEL_TYPE;
|
|
|
7501
7774
|
exports.URL_MODELS_TOOL_NAME = URL_MODELS_TOOL_NAME;
|
|
7502
7775
|
exports.abbreviateMcpCallType = abbreviateMcpCallType;
|
|
7503
7776
|
exports.appMcpAnalyticsModuleMetadata = appMcpAnalyticsModuleMetadata;
|
|
7777
|
+
exports.applyMcpReasonParameterToSchema = applyMcpReasonParameterToSchema;
|
|
7504
7778
|
exports.applyWriteMarker = applyWriteMarker;
|
|
7505
7779
|
exports.batchOperationCoordKey = batchOperationCoordKey;
|
|
7506
7780
|
exports.buildDefaultMcpToolDescription = buildDefaultMcpToolDescription;
|
|
7507
7781
|
exports.buildDisambiguatedMcpToolName = buildDisambiguatedMcpToolName;
|
|
7508
7782
|
exports.buildMcpToolName = buildMcpToolName;
|
|
7783
|
+
exports.buildStaticToolDefinition = buildStaticToolDefinition;
|
|
7509
7784
|
exports.buildStaticWireEntry = buildStaticWireEntry;
|
|
7510
7785
|
exports.classifyVisibility = classifyVisibility;
|
|
7511
7786
|
exports.createBatchExecuteTool = createBatchExecuteTool;
|
|
@@ -7515,6 +7790,7 @@ exports.createModelGetTool = createModelGetTool;
|
|
|
7515
7790
|
exports.createModelInfoTool = createModelInfoTool;
|
|
7516
7791
|
exports.createUrlModelsTool = createUrlModelsTool;
|
|
7517
7792
|
exports.decodeFirestoreModelKey = decodeFirestoreModelKey;
|
|
7793
|
+
exports.extractMcpReasonFromArgs = extractMcpReasonFromArgs;
|
|
7518
7794
|
exports.findModelEntry = findModelEntry;
|
|
7519
7795
|
exports.formatMcpToolErrorResponse = formatMcpToolErrorResponse;
|
|
7520
7796
|
exports.formatMcpToolResponse = formatMcpToolResponse;
|
|
@@ -7523,10 +7799,12 @@ exports.handleStreamableHttpMcpRequest = handleStreamableHttpMcpRequest;
|
|
|
7523
7799
|
exports.matchRouteManifestUrl = matchRouteManifestUrl;
|
|
7524
7800
|
exports.mcpManifestKey = mcpManifestKey;
|
|
7525
7801
|
exports.mcpModuleMetadata = mcpModuleMetadata;
|
|
7802
|
+
exports.mcpSchemaDeclaresProperty = mcpSchemaDeclaresProperty;
|
|
7526
7803
|
exports.noopMcpAnalyticsService = noopMcpAnalyticsService;
|
|
7527
7804
|
exports.parseUrlModelsPathname = parseUrlModelsPathname;
|
|
7528
7805
|
exports.resolveEffectiveReadOnly = resolveEffectiveReadOnly;
|
|
7529
7806
|
exports.resolveEnumInfoOutput = resolveEnumInfoOutput;
|
|
7807
|
+
exports.resolveMcpReasonParameterConfig = resolveMcpReasonParameterConfig;
|
|
7530
7808
|
exports.resolveMcpToolAnnotations = resolveMcpToolAnnotations;
|
|
7531
7809
|
exports.resolveRequiredScope = resolveRequiredScope;
|
|
7532
7810
|
exports.validateMcpToolName = validateMcpToolName;
|