@haneinfo/mcp-server 3.5.0 → 4.0.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 +177 -12
- package/dist/admin-access.d.ts +24 -0
- package/dist/admin-access.d.ts.map +1 -0
- package/dist/admin-access.js +54 -0
- package/dist/admin-access.js.map +1 -0
- package/dist/authenticator.d.ts +31 -0
- package/dist/authenticator.d.ts.map +1 -0
- package/dist/authenticator.js +37 -0
- package/dist/authenticator.js.map +1 -0
- package/dist/deployment-config.d.ts +67 -0
- package/dist/deployment-config.d.ts.map +1 -0
- package/dist/deployment-config.js +157 -0
- package/dist/deployment-config.js.map +1 -0
- package/dist/discovery-push.service.d.ts +11 -9
- package/dist/discovery-push.service.d.ts.map +1 -1
- package/dist/discovery-push.service.js +27 -11
- package/dist/discovery-push.service.js.map +1 -1
- package/dist/enabled-resources.d.ts +53 -0
- package/dist/enabled-resources.d.ts.map +1 -0
- package/dist/enabled-resources.js +243 -0
- package/dist/enabled-resources.js.map +1 -0
- package/dist/iam-authenticator.d.ts +29 -0
- package/dist/iam-authenticator.d.ts.map +1 -0
- package/dist/iam-authenticator.js +269 -0
- package/dist/iam-authenticator.js.map +1 -0
- package/dist/index.d.ts +10 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/dist/mcp-tool.registry.d.ts +21 -76
- package/dist/mcp-tool.registry.d.ts.map +1 -1
- package/dist/mcp-tool.registry.js +66 -240
- package/dist/mcp-tool.registry.js.map +1 -1
- package/dist/mcp.controller.d.ts +21 -5
- package/dist/mcp.controller.d.ts.map +1 -1
- package/dist/mcp.controller.js +273 -48
- package/dist/mcp.controller.js.map +1 -1
- package/dist/mcp.module.d.ts +5 -0
- package/dist/mcp.module.d.ts.map +1 -1
- package/dist/mcp.module.js +71 -8
- package/dist/mcp.module.js.map +1 -1
- package/dist/mcp.service.d.ts +31 -18
- package/dist/mcp.service.d.ts.map +1 -1
- package/dist/mcp.service.js +784 -194
- package/dist/mcp.service.js.map +1 -1
- package/dist/pg-rate-limiter.d.ts +46 -0
- package/dist/pg-rate-limiter.d.ts.map +1 -0
- package/dist/pg-rate-limiter.js +161 -0
- package/dist/pg-rate-limiter.js.map +1 -0
- package/dist/plugin.d.ts +41 -4
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +26 -14
- package/dist/plugin.js.map +1 -1
- package/dist/prm.controller.d.ts +17 -0
- package/dist/prm.controller.d.ts.map +1 -0
- package/dist/prm.controller.js +77 -0
- package/dist/prm.controller.js.map +1 -0
- package/dist/protocol-config.d.ts +36 -0
- package/dist/protocol-config.d.ts.map +1 -0
- package/dist/protocol-config.js +142 -0
- package/dist/protocol-config.js.map +1 -0
- package/dist/rate-limit-config.d.ts +25 -0
- package/dist/rate-limit-config.d.ts.map +1 -0
- package/dist/rate-limit-config.js +85 -0
- package/dist/rate-limit-config.js.map +1 -0
- package/dist/rate-limit-http.d.ts +11 -0
- package/dist/rate-limit-http.d.ts.map +1 -0
- package/dist/rate-limit-http.js +68 -0
- package/dist/rate-limit-http.js.map +1 -0
- package/dist/request-state.d.ts +14 -9
- package/dist/request-state.d.ts.map +1 -1
- package/dist/request-state.js +37 -3
- package/dist/request-state.js.map +1 -1
- package/dist/types.d.ts +24 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -1
- package/dist/write-confirmation.d.ts +82 -0
- package/dist/write-confirmation.d.ts.map +1 -0
- package/dist/write-confirmation.js +207 -0
- package/dist/write-confirmation.js.map +1 -0
- package/haneinfo.plugin.json +19 -11
- package/package.json +23 -11
- package/prisma/mcp-rate-limit.prisma +34 -0
|
@@ -1,65 +1,30 @@
|
|
|
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
2
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
5
|
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;
|
|
22
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
7
|
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
-
var ownKeys = function(o) {
|
|
26
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
-
var ar = [];
|
|
28
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
-
return ar;
|
|
30
|
-
};
|
|
31
|
-
return ownKeys(o);
|
|
32
|
-
};
|
|
33
|
-
return function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
})();
|
|
41
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
10
|
};
|
|
44
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
45
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
46
13
|
};
|
|
47
|
-
var McpToolRegistry_1;
|
|
48
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
-
exports.McpToolRegistry = exports.
|
|
15
|
+
exports.McpToolRegistry = exports.MCP_DISABLED_TOOLS_SETTING = void 0;
|
|
50
16
|
exports.getConfiguredToolPrefix = getConfiguredToolPrefix;
|
|
51
17
|
exports.getToolAliasPrefix = getToolAliasPrefix;
|
|
52
|
-
|
|
53
|
-
const pluginApiContract = __importStar(require("@haneinfo/plugin-api"));
|
|
18
|
+
const commands_1 = require("@haneinfo/commands");
|
|
54
19
|
const plugin_api_1 = require("@haneinfo/plugin-api");
|
|
55
20
|
const common_1 = require("@nestjs/common");
|
|
21
|
+
const enabled_resources_1 = require("./enabled-resources");
|
|
22
|
+
const types_1 = require("./types");
|
|
56
23
|
/**
|
|
57
24
|
* Built-in setting (decision 202610-e6c1, point 12), declared only when `@haneinfo/settings` is
|
|
58
|
-
* installed:
|
|
25
|
+
* installed: command names listed here are hidden from `tools/list` and refused as `tool_unavailable`.
|
|
59
26
|
*/
|
|
60
27
|
exports.MCP_DISABLED_TOOLS_SETTING = 'mcp-server.disabledTools';
|
|
61
|
-
/** Error code returned (without running the handler) when a disabled tool is called by name. */
|
|
62
|
-
exports.MCP_TOOL_DISABLED = 'TOOL_DISABLED';
|
|
63
28
|
// Cross-app tool naming prefix (dev_docs 002 "consistent app prefixes across apps", dev_docs 023 §2.2) —
|
|
64
29
|
// only `[a-zA-Z0-9_-]` is allowed because the prefixed name must also satisfy MCP tool-calling
|
|
65
30
|
// name constraints (dev_docs 023 §3.1).
|
|
@@ -98,105 +63,46 @@ function getToolAliasPrefix() {
|
|
|
98
63
|
}
|
|
99
64
|
return prefix;
|
|
100
65
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
// Compatibility bridge for apps that consume this package from a local file before the
|
|
108
|
-
// plugin-api release carrying the shared scope contract is published. Released installations use
|
|
109
|
-
// plugin-api's implementation; the local fallback follows the same fail-closed grammar.
|
|
110
|
-
function parseScopeContract(scope) {
|
|
111
|
-
const shared = pluginApiContract.parseScope;
|
|
112
|
-
if (shared)
|
|
113
|
-
return shared(scope);
|
|
114
|
-
const separator = scope.lastIndexOf(':');
|
|
115
|
-
if (separator <= 0 || separator === scope.length - 1)
|
|
116
|
-
return null;
|
|
117
|
-
const resource = scope.slice(0, separator);
|
|
118
|
-
const action = scope.slice(separator + 1);
|
|
119
|
-
if (resource.split(':').some((segment) => segment.length === 0 || /[\s*]/.test(segment)) ||
|
|
120
|
-
/\s/.test(action) ||
|
|
121
|
-
action.includes(':')) {
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
return { resource, action };
|
|
125
|
-
}
|
|
126
|
-
function matchScopeContract(grantedScopes, requiredScope) {
|
|
127
|
-
const shared = pluginApiContract.matchScope;
|
|
128
|
-
if (shared)
|
|
129
|
-
return shared(grantedScopes, requiredScope);
|
|
130
|
-
if (grantedScopes.includes('*'))
|
|
131
|
-
return true;
|
|
132
|
-
const required = parseScopeContract(requiredScope);
|
|
133
|
-
if (!required || required.action === '*')
|
|
134
|
-
return false;
|
|
135
|
-
return grantedScopes.some((grantedScope) => {
|
|
136
|
-
const granted = parseScopeContract(grantedScope);
|
|
137
|
-
return (granted !== null &&
|
|
138
|
-
granted.resource === required.resource &&
|
|
139
|
-
(granted.action === '*' || granted.action === required.action));
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
function classifyToolAsReadOnly(requiredScopes, mutates) {
|
|
143
|
-
if (mutates)
|
|
144
|
-
return false;
|
|
145
|
-
if (requiredScopes.length === 0)
|
|
146
|
-
return false;
|
|
147
|
-
return requiredScopes.every((scope) => {
|
|
148
|
-
const parsed = parseScopeContract(scope);
|
|
149
|
-
return parsed !== null && READ_ACTIONS.has(parsed.action);
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
let McpToolRegistry = McpToolRegistry_1 = class McpToolRegistry {
|
|
153
|
-
constructor(scopeMatcher, settings, declarations) {
|
|
154
|
-
this.scopeMatcher = scopeMatcher;
|
|
66
|
+
/**
|
|
67
|
+
* Manages `mcp-server.disabledTools` and generates discovery catalog snapshots from the sealed
|
|
68
|
+
* `@haneinfo/commands` registry (`mcp-connector-contract.md` §9.2; W5-04b).
|
|
69
|
+
*/
|
|
70
|
+
let McpToolRegistry = class McpToolRegistry {
|
|
71
|
+
constructor(commandsOptions, settings, declarations, enabledResources) {
|
|
155
72
|
this.settings = settings;
|
|
156
73
|
this.declarations = declarations;
|
|
157
|
-
this.
|
|
158
|
-
|
|
159
|
-
// One entry per @McpTool(), pre-prefixing — the source list getCatalogSnapshot() derives
|
|
160
|
-
// its external-facing names from, so a dual-registered tool isn't reported twice (023 §2.1
|
|
161
|
-
// discovery push, T-9700).
|
|
162
|
-
this.logicalTools = [];
|
|
163
|
-
/** Registered name (bare or prefixed alias) -> logical name, for the disabled-tools setting. */
|
|
164
|
-
this.logicalNames = new Map();
|
|
165
|
-
/** Last value of mcp-server.disabledTools; always empty without @haneinfo/settings. */
|
|
74
|
+
this.enabledResources = enabledResources;
|
|
75
|
+
/** Last value of `mcp-server.disabledTools`; always empty without `@haneinfo/settings`. */
|
|
166
76
|
this.disabled = new Set();
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
this.dynamicLogical = [];
|
|
176
|
-
/** Registered source-tool name (bare or alias) -> logical name. */
|
|
177
|
-
this.dynamicLogicalNames = new Map();
|
|
178
|
-
this.skippedSourceNames = new Set();
|
|
77
|
+
if (commandsOptions?.commands) {
|
|
78
|
+
this.commands = commandsOptions.commands;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
const empty = (0, commands_1.createCommandRegistry)();
|
|
82
|
+
empty.seal();
|
|
83
|
+
this.commands = empty;
|
|
84
|
+
}
|
|
179
85
|
}
|
|
180
|
-
/** Declares mcp-server.disabledTools when the optional settings capability is installed. */
|
|
86
|
+
/** Declares `mcp-server.disabledTools` when the optional settings capability is installed. */
|
|
181
87
|
onModuleInit() {
|
|
182
88
|
this.declarations?.register({
|
|
183
89
|
code: exports.MCP_DISABLED_TOOLS_SETTING,
|
|
184
90
|
kind: 'setting',
|
|
185
91
|
type: 'stringList',
|
|
186
|
-
description: 'MCP tool names to switch off: they disappear from tools/list and a direct call is refused
|
|
92
|
+
description: 'MCP tool names to switch off: they disappear from tools/list and a direct call is refused as unavailable. Names that do not exist are ignored.',
|
|
187
93
|
default: [],
|
|
188
94
|
maxItems: 200,
|
|
189
95
|
maxLength: 128,
|
|
190
96
|
pattern: '[A-Za-z0-9_.-]+',
|
|
191
|
-
knownItems: () =>
|
|
97
|
+
knownItems: () => this.knownCommandNames(),
|
|
192
98
|
});
|
|
193
99
|
}
|
|
194
|
-
/** True only when
|
|
100
|
+
/** True only when `@haneinfo/settings` is installed; otherwise no tool can ever be disabled. */
|
|
195
101
|
get disabledToolsSupported() {
|
|
196
102
|
return this.settings !== undefined;
|
|
197
103
|
}
|
|
198
104
|
/**
|
|
199
|
-
* Re-reads mcp-server.disabledTools (served from the settings cache) before a request. Without
|
|
105
|
+
* Re-reads `mcp-server.disabledTools` (served from the settings cache) before a request. Without
|
|
200
106
|
* settings it does nothing. A failed read propagates, so a disabled tool never runs by accident.
|
|
201
107
|
*/
|
|
202
108
|
async refreshDisabledTools() {
|
|
@@ -206,146 +112,66 @@ let McpToolRegistry = McpToolRegistry_1 = class McpToolRegistry {
|
|
|
206
112
|
this.disabled = new Set(Array.isArray(names) ? names : []);
|
|
207
113
|
return this.disabled;
|
|
208
114
|
}
|
|
209
|
-
/** Whether a
|
|
115
|
+
/** Whether a command (by bare name or prefixed alias) is currently switched off. */
|
|
210
116
|
isToolDisabled(name) {
|
|
211
117
|
if (this.disabled.size === 0)
|
|
212
118
|
return false;
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Adds a runtime-changing tool source (decision 202610-c5e8). Its tools never override a
|
|
217
|
-
* registered tool, and MCP requests see them only after `refreshToolSources`.
|
|
218
|
-
*/
|
|
219
|
-
registerToolSource(source) {
|
|
220
|
-
this.sources.push(source);
|
|
221
|
-
}
|
|
222
|
-
/** True once a tool source is registered; false keeps every request path exactly as before. */
|
|
223
|
-
get hasToolSources() {
|
|
224
|
-
return this.sources.length > 0;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Lets every source recompute (each one throttles itself), then rebuilds the source tools. A
|
|
228
|
-
* name already registered, or taken by an earlier source tool, is skipped with one warning.
|
|
229
|
-
*/
|
|
230
|
-
async refreshToolSources() {
|
|
231
|
-
if (this.sources.length === 0)
|
|
232
|
-
return;
|
|
233
|
-
await Promise.all(this.sources.map((source) => source.refresh()));
|
|
234
|
-
const aliasPrefix = getToolAliasPrefix();
|
|
235
|
-
const map = new Map();
|
|
236
|
-
const logical = [];
|
|
237
|
-
const names = new Map();
|
|
238
|
-
const take = (name, tool, logicalName) => {
|
|
239
|
-
if (this.toolMap.has(name) || map.has(name)) {
|
|
240
|
-
if (!this.skippedSourceNames.has(name))
|
|
241
|
-
this.logger.warn(`Generated tool "${name}" skipped: the name is already registered`);
|
|
242
|
-
this.skippedSourceNames.add(name);
|
|
243
|
-
return false;
|
|
244
|
-
}
|
|
245
|
-
map.set(name, tool);
|
|
246
|
-
names.set(name, logicalName);
|
|
119
|
+
if (this.disabled.has(name))
|
|
247
120
|
return true;
|
|
248
|
-
};
|
|
249
|
-
for (const source of this.sources)
|
|
250
|
-
for (const tool of source.tools()) {
|
|
251
|
-
if (!take(tool.name, tool, tool.name))
|
|
252
|
-
continue;
|
|
253
|
-
logical.push(tool);
|
|
254
|
-
if (aliasPrefix)
|
|
255
|
-
take(`${aliasPrefix}_${tool.name}`, { ...tool, name: `${aliasPrefix}_${tool.name}` }, tool.name);
|
|
256
|
-
}
|
|
257
|
-
this.dynamicMap = map;
|
|
258
|
-
this.dynamicLogical = logical;
|
|
259
|
-
this.dynamicLogicalNames = names;
|
|
260
|
-
}
|
|
261
|
-
/** The current source tool registered under `name` (bare or alias), if any. */
|
|
262
|
-
getSourceTool(name) {
|
|
263
|
-
return this.dynamicMap.get(name);
|
|
264
|
-
}
|
|
265
|
-
/** Current source tools by registered name (aliases included), as of the last refresh. */
|
|
266
|
-
getSourceTools() {
|
|
267
|
-
return Array.from(this.dynamicMap.values());
|
|
268
|
-
}
|
|
269
|
-
hasScopesFor(ctx, tool) {
|
|
270
|
-
return tool.requiredScopes.every((scope) => this.matchesScope(ctx.scopes, scope));
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Whether this exact registration is visible to the caller. `includeDisabled` lets a direct call
|
|
274
|
-
* reach the handler wrapper, which then answers TOOL_DISABLED instead of running the tool.
|
|
275
|
-
*/
|
|
276
|
-
isListed(ctx, tool, options = {}) {
|
|
277
|
-
return ((this.toolMap.get(tool.name) === tool || this.dynamicMap.get(tool.name) === tool) &&
|
|
278
|
-
this.hasScopesFor(ctx, tool) &&
|
|
279
|
-
(options.includeDisabled === true || !this.isToolDisabled(tool.name)));
|
|
280
|
-
}
|
|
281
|
-
listTools(ctx) {
|
|
282
|
-
return [...this.toolMap.values(), ...this.dynamicMap.values()].filter((tool) => this.hasScopesFor(ctx, tool) && !this.isToolDisabled(tool.name));
|
|
283
|
-
}
|
|
284
|
-
/** A registered tool, or else the current source tool of that name. */
|
|
285
|
-
getTool(name) {
|
|
286
|
-
return this.toolMap.get(name) ?? this.dynamicMap.get(name);
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Internal registration inventory of registered tools (source tools: getSourceTools); request
|
|
290
|
-
* visibility must still go through listTools.
|
|
291
|
-
*/
|
|
292
|
-
getAllTools() {
|
|
293
|
-
return Array.from(this.toolMap.values());
|
|
294
|
-
}
|
|
295
|
-
getToolCount() {
|
|
296
|
-
return this.toolMap.size;
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* Registers `tool` under its bare name. When `MCP_TOOL_PREFIXED_ALIASES=true` is set, it is also
|
|
300
|
-
* registered as `<MCP_TOOL_PREFIX>_<name>` pointing at the same handler/scopes. Aliases are off by
|
|
301
|
-
* default; the bare name is the canonical one.
|
|
302
|
-
*/
|
|
303
|
-
registerTool(tool) {
|
|
304
|
-
this.registerSingle(tool);
|
|
305
|
-
this.logicalTools.push(tool);
|
|
306
|
-
this.logicalNames.set(tool.name, tool.name);
|
|
307
121
|
const aliasPrefix = getToolAliasPrefix();
|
|
308
|
-
if (aliasPrefix) {
|
|
309
|
-
this.
|
|
310
|
-
this.logicalNames.set(`${aliasPrefix}_${tool.name}`, tool.name);
|
|
122
|
+
if (aliasPrefix && name.startsWith(`${aliasPrefix}_`)) {
|
|
123
|
+
return this.disabled.has(name.slice(aliasPrefix.length + 1));
|
|
311
124
|
}
|
|
125
|
+
return false;
|
|
312
126
|
}
|
|
313
127
|
/**
|
|
314
|
-
* External-facing catalog snapshot
|
|
315
|
-
*
|
|
316
|
-
* or the prefixed alias when aliases are enabled.
|
|
128
|
+
* External-facing catalog snapshot derived from enabled resource surfaces
|
|
129
|
+
* (023 §2.1 discovery push, T-9700; `mcp-connector-contract.md` §1, §7.3, §9.2).
|
|
317
130
|
*/
|
|
318
|
-
getCatalogSnapshot() {
|
|
131
|
+
getCatalogSnapshot(kinds) {
|
|
132
|
+
const effectiveKinds = kinds ?? this.enabledResources?.getEnabledKinds() ?? ['employee'];
|
|
319
133
|
const aliasPrefix = getToolAliasPrefix();
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
134
|
+
const byName = new Map();
|
|
135
|
+
for (const kind of effectiveKinds) {
|
|
136
|
+
const surface = kind === 'admin' ? 'mcp-admin' : 'mcp';
|
|
137
|
+
for (const cmd of this.commands.list(surface)) {
|
|
138
|
+
if (this.enabledResources &&
|
|
139
|
+
!this.enabledResources.isCommandScopeAllowed(kind, cmd.scope)) {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
const name = aliasPrefix ? `${aliasPrefix}_${cmd.name}` : cmd.name;
|
|
143
|
+
if (!byName.has(name)) {
|
|
144
|
+
byName.set(name, {
|
|
145
|
+
name,
|
|
146
|
+
description: cmd.description ?? '',
|
|
147
|
+
requiredScopes: [cmd.scope],
|
|
148
|
+
readOnlyHint: cmd.access === 'read',
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
330
152
|
}
|
|
331
|
-
return
|
|
153
|
+
return [...byName.values()].sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
332
154
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
this.
|
|
155
|
+
knownCommandNames() {
|
|
156
|
+
const names = new Set();
|
|
157
|
+
for (const cmd of this.commands.list('mcp'))
|
|
158
|
+
names.add(cmd.name);
|
|
159
|
+
for (const cmd of this.commands.list('mcp-admin'))
|
|
160
|
+
names.add(cmd.name);
|
|
161
|
+
return [...names].sort();
|
|
338
162
|
}
|
|
339
163
|
};
|
|
340
164
|
exports.McpToolRegistry = McpToolRegistry;
|
|
341
|
-
exports.McpToolRegistry = McpToolRegistry =
|
|
165
|
+
exports.McpToolRegistry = McpToolRegistry = __decorate([
|
|
342
166
|
(0, common_1.Injectable)(),
|
|
343
167
|
__param(0, (0, common_1.Optional)()),
|
|
344
|
-
__param(0, (0, common_1.Inject)(
|
|
168
|
+
__param(0, (0, common_1.Inject)(types_1.MCP_COMMANDS_OPTIONS)),
|
|
345
169
|
__param(1, (0, common_1.Optional)()),
|
|
346
170
|
__param(1, (0, common_1.Inject)(plugin_api_1.SETTINGS)),
|
|
347
171
|
__param(2, (0, common_1.Optional)()),
|
|
348
172
|
__param(2, (0, common_1.Inject)(plugin_api_1.SETTING_DECLARATIONS)),
|
|
349
|
-
|
|
173
|
+
__param(3, (0, common_1.Optional)()),
|
|
174
|
+
__param(3, (0, common_1.Inject)(enabled_resources_1.McpEnabledResources)),
|
|
175
|
+
__metadata("design:paramtypes", [Object, Object, Object, enabled_resources_1.McpEnabledResources])
|
|
350
176
|
], McpToolRegistry);
|
|
351
177
|
//# sourceMappingURL=mcp-tool.registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-tool.registry.js","sourceRoot":"","sources":["../src/mcp-tool.registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mcp-tool.registry.js","sourceRoot":"","sources":["../src/mcp-tool.registry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAgCA,0DASC;AASD,gDAWC;AA7DD,iDAI4B;AAC5B,qDAM8B;AAC9B,2CAAiF;AACjF,2DAA0D;AAC1D,mCAA4F;AAE5F;;;GAGG;AACU,QAAA,0BAA0B,GAAG,0BAA0B,CAAC;AAErE,yGAAyG;AACzG,+FAA+F;AAC/F,wCAAwC;AACxC,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAE/C;;;;GAIG;AACH,SAAgB,uBAAuB;IACrC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IAC3C,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CACb,oBAA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request, Response } from 'express';
|
|
3
|
+
import { type McpRequestAuthenticator } from './authenticator';
|
|
4
|
+
import { type McpIamDeploymentConfig } from './deployment-config';
|
|
5
|
+
import { McpEnabledResources } from './enabled-resources';
|
|
2
6
|
import { McpService } from './mcp.service';
|
|
3
|
-
import {
|
|
7
|
+
import { type McpProtocolConfig } from './protocol-config';
|
|
8
|
+
import { type McpRateLimitConfig } from './rate-limit-config';
|
|
4
9
|
/**
|
|
5
10
|
* Extracts the correlation workflow id from request headers.
|
|
6
11
|
*/
|
|
7
12
|
export declare function extractWorkflowId(headers: Record<string, unknown>): string | null;
|
|
8
13
|
export declare class McpController {
|
|
9
14
|
private readonly mcpService;
|
|
10
|
-
private readonly
|
|
15
|
+
private readonly rateLimiter?;
|
|
11
16
|
private readonly nodeHandler;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
private readonly legacy2025NodeHandler;
|
|
18
|
+
private readonly authenticator;
|
|
19
|
+
private readonly rateLimitConfig;
|
|
20
|
+
private readonly protocolConfig;
|
|
21
|
+
private readonly enabledResources;
|
|
22
|
+
private readonly concurrencyLimiter;
|
|
23
|
+
constructor(mcpService: McpService, authenticator?: McpRequestAuthenticator, _deployment?: McpIamDeploymentConfig, rateLimiter?: McpRateLimiterPort | undefined, rateLimitConfig?: McpRateLimitConfig, protocolConfig?: McpProtocolConfig, enabledResources?: McpEnabledResources);
|
|
24
|
+
handleEmployee(req: Request, res: Response): Promise<void>;
|
|
25
|
+
handleAdmin(req: Request, res: Response): Promise<void>;
|
|
26
|
+
getHealth(challenge: string | undefined, res: Response, req?: Request): Promise<{
|
|
27
|
+
status: 'ok';
|
|
28
|
+
challenge?: string;
|
|
29
|
+
}>;
|
|
30
|
+
private handleMcpRequest;
|
|
15
31
|
}
|
|
16
32
|
//# sourceMappingURL=mcp.controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.controller.d.ts","sourceRoot":"","sources":["../src/mcp.controller.ts"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