@webpieces/mcp-server 0.4.933 → 0.4.935
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 +29 -17
- package/package.json +6 -6
- package/src/McpToolRegistry.d.ts +13 -3
- package/src/McpToolRegistry.js +8 -8
- package/src/McpToolRegistry.js.map +1 -1
- package/src/WpMcpServer.js +2 -1
- package/src/WpMcpServer.js.map +1 -1
- package/src/__tests__/McpProfileFixtures.d.ts +20 -4
- package/src/__tests__/McpProfileFixtures.js +25 -9
- package/src/__tests__/McpProfileFixtures.js.map +1 -1
- package/src/__tests__/McpRemoteFixtures.d.ts +35 -7
- package/src/__tests__/McpRemoteFixtures.js +42 -14
- package/src/__tests__/McpRemoteFixtures.js.map +1 -1
- package/src/__tests__/WpMcpServerTestFixtures.d.ts +15 -3
- package/src/__tests__/WpMcpServerTestFixtures.js +18 -6
- package/src/__tests__/WpMcpServerTestFixtures.js.map +1 -1
|
@@ -7,19 +7,35 @@ const core_util_1 = require("@webpieces/core-util");
|
|
|
7
7
|
const McpToolCatalog_1 = require("../McpToolCatalog");
|
|
8
8
|
const WpMcpServerTestFixtures_1 = require("./WpMcpServerTestFixtures");
|
|
9
9
|
let ProfileApi = class ProfileApi {
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Learner-only tool.
|
|
12
|
+
*
|
|
13
|
+
* @summary Learner
|
|
14
|
+
*/
|
|
11
15
|
learner(_request) {
|
|
12
16
|
throw new Error('contract');
|
|
13
17
|
}
|
|
14
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Admin-only tool.
|
|
20
|
+
*
|
|
21
|
+
* @summary Admin
|
|
22
|
+
*/
|
|
15
23
|
admin(_request) {
|
|
16
24
|
throw new Error('contract');
|
|
17
25
|
}
|
|
18
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Shared tool that still requires admin authority.
|
|
28
|
+
*
|
|
29
|
+
* @summary Shared
|
|
30
|
+
*/
|
|
19
31
|
shared(_request) {
|
|
20
32
|
throw new Error('contract');
|
|
21
33
|
}
|
|
22
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* A third independently selectable group.
|
|
36
|
+
*
|
|
37
|
+
* @summary Course
|
|
38
|
+
*/
|
|
23
39
|
course(_request) {
|
|
24
40
|
throw new Error('contract');
|
|
25
41
|
}
|
|
@@ -29,7 +45,7 @@ tslib_1.__decorate([
|
|
|
29
45
|
(0, core_util_1.WpAuth)([(0, core_util_1.jwt)()]),
|
|
30
46
|
(0, core_util_1.WpAuthorization)({ authType: core_util_1.AuthorizationType.ALL_USERS }),
|
|
31
47
|
(0, core_util_1.Endpoint)(core_util_1.POST, '/learner', core_util_1.READ, core_util_1.RPC),
|
|
32
|
-
(0, core_util_1.WpMcpTool)('learner'
|
|
48
|
+
(0, core_util_1.WpMcpTool)('learner'),
|
|
33
49
|
tslib_1.__metadata("design:type", Function),
|
|
34
50
|
tslib_1.__metadata("design:paramtypes", [WpMcpServerTestFixtures_1.SearchRequest]),
|
|
35
51
|
tslib_1.__metadata("design:returntype", Promise)
|
|
@@ -38,7 +54,7 @@ tslib_1.__decorate([
|
|
|
38
54
|
(0, core_util_1.WpAuth)([(0, core_util_1.jwt)()]),
|
|
39
55
|
(0, core_util_1.WpAuthorization)({ authType: core_util_1.AuthorizationType.ROLES, roles: ['admin'] }),
|
|
40
56
|
(0, core_util_1.Endpoint)(core_util_1.POST, '/admin', core_util_1.READ, core_util_1.RPC),
|
|
41
|
-
(0, core_util_1.WpMcpTool)('admin',
|
|
57
|
+
(0, core_util_1.WpMcpTool)('admin', { profiles: ['admin'] }),
|
|
42
58
|
tslib_1.__metadata("design:type", Function),
|
|
43
59
|
tslib_1.__metadata("design:paramtypes", [WpMcpServerTestFixtures_1.SearchRequest]),
|
|
44
60
|
tslib_1.__metadata("design:returntype", Promise)
|
|
@@ -47,7 +63,7 @@ tslib_1.__decorate([
|
|
|
47
63
|
(0, core_util_1.WpAuth)([(0, core_util_1.jwt)()]),
|
|
48
64
|
(0, core_util_1.WpAuthorization)({ authType: core_util_1.AuthorizationType.ROLES, roles: ['admin'] }),
|
|
49
65
|
(0, core_util_1.Endpoint)(core_util_1.POST, '/shared', core_util_1.READ, core_util_1.RPC),
|
|
50
|
-
(0, core_util_1.WpMcpTool)('shared',
|
|
66
|
+
(0, core_util_1.WpMcpTool)('shared', { profiles: [core_util_1.Mcp.DEFAULT, 'admin'] }),
|
|
51
67
|
tslib_1.__metadata("design:type", Function),
|
|
52
68
|
tslib_1.__metadata("design:paramtypes", [WpMcpServerTestFixtures_1.SearchRequest]),
|
|
53
69
|
tslib_1.__metadata("design:returntype", Promise)
|
|
@@ -56,7 +72,7 @@ tslib_1.__decorate([
|
|
|
56
72
|
(0, core_util_1.WpAuth)([(0, core_util_1.jwt)()]),
|
|
57
73
|
(0, core_util_1.WpAuthorization)({ authType: core_util_1.AuthorizationType.ALL_USERS }),
|
|
58
74
|
(0, core_util_1.Endpoint)(core_util_1.POST, '/course', core_util_1.READ, core_util_1.RPC),
|
|
59
|
-
(0, core_util_1.WpMcpTool)('course',
|
|
75
|
+
(0, core_util_1.WpMcpTool)('course', { profiles: ['course-authoring'] }),
|
|
60
76
|
tslib_1.__metadata("design:type", Function),
|
|
61
77
|
tslib_1.__metadata("design:paramtypes", [WpMcpServerTestFixtures_1.SearchRequest]),
|
|
62
78
|
tslib_1.__metadata("design:returntype", Promise)
|
|
@@ -96,5 +112,5 @@ class SearchResponseValue extends WpMcpServerTestFixtures_1.SearchResponse {
|
|
|
96
112
|
}
|
|
97
113
|
}
|
|
98
114
|
const schema = WpMcpServerTestFixtures_1.SEARCH_API_CATALOG.file.tools[0];
|
|
99
|
-
exports.PROFILE_CATALOG = new McpToolCatalog_1.McpToolCatalog(new core_util_1.McpToolCatalogFile('ProfileApi', (0, core_util_1.getWpMcpTools)(ProfileApi).map((tool) => new core_util_1.McpToolDefinition(tool.name, tool.
|
|
115
|
+
exports.PROFILE_CATALOG = new McpToolCatalog_1.McpToolCatalog(new core_util_1.McpToolCatalogFile('ProfileApi', (0, core_util_1.getWpMcpTools)(ProfileApi).map((tool) => new core_util_1.McpToolDefinition(tool.name, `Profile ${tool.name} tool`, tool.methodName, 'Profile fixture', (0, core_util_1.mcpHintsForOperation)(core_util_1.READ, false), schema.inputSchema, schema.outputSchema, tool.profiles))), '(profile fixture)');
|
|
100
116
|
//# sourceMappingURL=McpProfileFixtures.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"McpProfileFixtures.js","sourceRoot":"","sources":["../../../../../../packages/http/mcp-server/src/__tests__/McpProfileFixtures.ts"],"names":[],"mappings":";;;;AAAA,yCAAuC;AACvC,oDAoB8B;AAC9B,sDAAmD;AACnD,uEAA8F;AAIvF,IAAe,UAAU,GAAzB,MAAe,UAAU;IAC5B
|
|
1
|
+
{"version":3,"file":"McpProfileFixtures.js","sourceRoot":"","sources":["../../../../../../packages/http/mcp-server/src/__tests__/McpProfileFixtures.ts"],"names":[],"mappings":";;;;AAAA,yCAAuC;AACvC,oDAoB8B;AAC9B,sDAAmD;AACnD,uEAA8F;AAIvF,IAAe,UAAU,GAAzB,MAAe,UAAU;IAC5B;;;;OAIG;IAKH,OAAO,CAAC,QAAuB;QAC3B,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC;IAED;;;;OAIG;IAKH,KAAK,CAAC,QAAuB;QACzB,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC;IAED;;;;OAIG;IAKH,MAAM,CAAC,QAAuB;QAC1B,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC;IAED;;;;OAIG;IAKH,MAAM,CAAC,QAAuB;QAC1B,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC;CACJ,CAAA;AApDqB,gCAAU;AAU5B;IAJC,IAAA,kBAAM,EAAC,CAAC,IAAA,eAAG,GAAE,CAAC,CAAC;I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K,CAAC;IACxB,CAAC;CACJ;AAED,MAAM,MAAM,GAAG,4CAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,QAAA,eAAe,GAAG,IAAI,+BAAc,CAC7C,IAAI,8BAAkB,CAClB,YAAY,EACZ,IAAA,yBAAa,EAAC,UAAU,CAAC,CAAC,GAAG,CACzB,CAAC,IAAuB,EAAE,EAAE,CACxB,IAAI,6BAAiB,CACjB,IAAI,CAAC,IAAI,EACT,WAAW,IAAI,CAAC,IAAI,OAAO,EAC3B,IAAI,CAAC,UAAU,EACf,iBAAiB,EACjB,IAAA,gCAAoB,EAAC,gBAAI,EAAE,KAAK,CAAC,EACjC,MAAM,CAAC,WAAW,EAClB,MAAM,CAAC,YAAY,EACnB,IAAI,CAAC,QAAQ,CAChB,CACR,CACJ,EACD,mBAAmB,CACtB,CAAC","sourcesContent":["import { injectable } from 'inversify';\nimport {\n ApiPath,\n ApiType,\n Endpoint,\n POST,\n READ,\n RPC,\n MCP,\n SVC_TO_SVC,\n Mcp,\n WpAuth,\n jwt,\n WpAuthorization,\n AuthorizationType,\n WpMcpTool,\n WpMcpToolMetadata,\n getWpMcpTools,\n McpToolCatalogFile,\n McpToolDefinition,\n mcpHintsForOperation,\n} from '@webpieces/core-util';\nimport { McpToolCatalog } from '../McpToolCatalog';\nimport { SEARCH_API_CATALOG, SearchRequest, SearchResponse } from './WpMcpServerTestFixtures';\n\n@ApiPath('/profile-spec')\n@ApiType(SVC_TO_SVC, MCP)\nexport abstract class ProfileApi {\n /**\n * Learner-only tool.\n *\n * @summary Learner\n */\n @WpAuth([jwt()])\n @WpAuthorization({ authType: AuthorizationType.ALL_USERS })\n @Endpoint(POST, '/learner', READ, RPC)\n @WpMcpTool('learner')\n learner(_request: SearchRequest): Promise<SearchResponse> {\n throw new Error('contract');\n }\n\n /**\n * Admin-only tool.\n *\n * @summary Admin\n */\n @WpAuth([jwt()])\n @WpAuthorization({ authType: AuthorizationType.ROLES, roles: ['admin'] })\n @Endpoint(POST, '/admin', READ, RPC)\n @WpMcpTool('admin', { profiles: ['admin'] })\n admin(_request: SearchRequest): Promise<SearchResponse> {\n throw new Error('contract');\n }\n\n /**\n * Shared tool that still requires admin authority.\n *\n * @summary Shared\n */\n @WpAuth([jwt()])\n @WpAuthorization({ authType: AuthorizationType.ROLES, roles: ['admin'] })\n @Endpoint(POST, '/shared', READ, RPC)\n @WpMcpTool('shared', { profiles: [Mcp.DEFAULT, 'admin'] })\n shared(_request: SearchRequest): Promise<SearchResponse> {\n throw new Error('contract');\n }\n\n /**\n * A third independently selectable group.\n *\n * @summary Course\n */\n @WpAuth([jwt()])\n @WpAuthorization({ authType: AuthorizationType.ALL_USERS })\n @Endpoint(POST, '/course', READ, RPC)\n @WpMcpTool('course', { profiles: ['course-authoring'] })\n course(_request: SearchRequest): Promise<SearchResponse> {\n throw new Error('contract');\n }\n}\n\n@injectable()\nexport class ProfileController extends ProfileApi {\n calls: string[] = [];\n override async learner(request: SearchRequest): Promise<SearchResponse> {\n this.calls.push('learner');\n return new SearchResponseValue(request.query);\n }\n override async admin(request: SearchRequest): Promise<SearchResponse> {\n this.calls.push('admin');\n return new SearchResponseValue(request.query);\n }\n override async shared(request: SearchRequest): Promise<SearchResponse> {\n this.calls.push('shared');\n return new SearchResponseValue(request.query);\n }\n override async course(request: SearchRequest): Promise<SearchResponse> {\n this.calls.push('course');\n return new SearchResponseValue(request.query);\n }\n}\n\nclass SearchResponseValue extends SearchResponse {\n constructor(query: string) {\n super();\n this.userId = 'profile';\n this.result = query;\n }\n}\n\nconst schema = SEARCH_API_CATALOG.file.tools[0];\nexport const PROFILE_CATALOG = new McpToolCatalog(\n new McpToolCatalogFile(\n 'ProfileApi',\n getWpMcpTools(ProfileApi).map(\n (tool: WpMcpToolMetadata) =>\n new McpToolDefinition(\n tool.name,\n `Profile ${tool.name} tool`,\n tool.methodName,\n 'Profile fixture',\n mcpHintsForOperation(READ, false),\n schema.inputSchema,\n schema.outputSchema,\n tool.profiles,\n ),\n ),\n ),\n '(profile fixture)',\n);\n"]}
|
|
@@ -32,31 +32,59 @@ export declare const REMOTE_MCP_CATALOG: McpToolCatalog;
|
|
|
32
32
|
/** The catalogs of every contract the gateway binds — one per contract, exactly as a build writes them. */
|
|
33
33
|
export declare const GATEWAY_CATALOGS: readonly McpToolCatalog[];
|
|
34
34
|
export declare abstract class RemoteMcpApi {
|
|
35
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Calls a remote Webpieces API.
|
|
37
|
+
*
|
|
38
|
+
* @summary Remote integration search
|
|
39
|
+
*/
|
|
36
40
|
search(_request: RemoteRequest): Promise<RemoteResponse>;
|
|
37
41
|
}
|
|
38
42
|
export declare abstract class MissingRemoteMcpApi {
|
|
39
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Intentionally absent route.
|
|
45
|
+
*
|
|
46
|
+
* @summary Missing remote integration search
|
|
47
|
+
*/
|
|
40
48
|
search(_request: RemoteRequest): Promise<RemoteResponse>;
|
|
41
49
|
}
|
|
42
50
|
export declare abstract class RefusedRemoteApi {
|
|
43
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Nothing listens on this port.
|
|
53
|
+
*
|
|
54
|
+
* @summary Refused remote call
|
|
55
|
+
*/
|
|
44
56
|
search(_request: RemoteRequest): Promise<RemoteResponse>;
|
|
45
57
|
}
|
|
46
58
|
export declare abstract class GarbageRemoteApi {
|
|
47
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* Answers an undecodable body.
|
|
61
|
+
*
|
|
62
|
+
* @summary Garbage remote response
|
|
63
|
+
*/
|
|
48
64
|
search(_request: RemoteRequest): Promise<RemoteResponse>;
|
|
49
65
|
}
|
|
50
66
|
export declare abstract class OidcFailRemoteApi {
|
|
51
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* Its OIDC token cannot be minted.
|
|
69
|
+
*
|
|
70
|
+
* @summary OIDC failure on remote
|
|
71
|
+
*/
|
|
52
72
|
search(_request: RemoteRequest): Promise<RemoteResponse>;
|
|
53
73
|
}
|
|
54
74
|
export declare abstract class LocalThrowApi {
|
|
55
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* Throws the requested failure in-process.
|
|
77
|
+
*
|
|
78
|
+
* @summary Local throw
|
|
79
|
+
*/
|
|
56
80
|
fail(_request: RemoteRequest): Promise<RemoteResponse>;
|
|
57
81
|
}
|
|
58
82
|
export declare abstract class RemoteThrowApi {
|
|
59
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* Throws the requested failure remotely.
|
|
85
|
+
*
|
|
86
|
+
* @summary Remote throw
|
|
87
|
+
*/
|
|
60
88
|
fail(_request: RemoteRequest): Promise<RemoteResponse>;
|
|
61
89
|
}
|
|
62
90
|
/**
|
|
@@ -80,7 +80,11 @@ exports.GATEWAY_CATALOGS = [
|
|
|
80
80
|
contractCatalog('RemoteThrowApi', searchTool('remote_throw', 'Remote throw', 'fail', 'Throws the requested failure remotely.')),
|
|
81
81
|
];
|
|
82
82
|
let RemoteMcpApi = class RemoteMcpApi {
|
|
83
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* Calls a remote Webpieces API.
|
|
85
|
+
*
|
|
86
|
+
* @summary Remote integration search
|
|
87
|
+
*/
|
|
84
88
|
search(_request) {
|
|
85
89
|
throw new Error('contract only');
|
|
86
90
|
}
|
|
@@ -90,7 +94,7 @@ tslib_1.__decorate([
|
|
|
90
94
|
(0, core_util_2.WpAuth)([(0, core_util_2.oidcSvcs)(['mcp-gateway'])]),
|
|
91
95
|
(0, core_util_2.WpAuthorization)({ authType: core_util_2.AuthorizationType.USERS_OR_SERVICES }),
|
|
92
96
|
(0, core_util_3.Endpoint)(core_util_3.POST, '/search', core_util_3.READ, core_util_3.RPC),
|
|
93
|
-
(0, core_util_3.WpMcpTool)('remote_integration_search'
|
|
97
|
+
(0, core_util_3.WpMcpTool)('remote_integration_search'),
|
|
94
98
|
tslib_1.__metadata("design:type", Function),
|
|
95
99
|
tslib_1.__metadata("design:paramtypes", [RemoteRequest]),
|
|
96
100
|
tslib_1.__metadata("design:returntype", Promise)
|
|
@@ -100,7 +104,11 @@ exports.RemoteMcpApi = RemoteMcpApi = tslib_1.__decorate([
|
|
|
100
104
|
(0, core_util_3.ApiType)(core_util_3.SVC_TO_SVC, core_util_3.MCP)
|
|
101
105
|
], RemoteMcpApi);
|
|
102
106
|
let MissingRemoteMcpApi = class MissingRemoteMcpApi {
|
|
103
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* Intentionally absent route.
|
|
109
|
+
*
|
|
110
|
+
* @summary Missing remote integration search
|
|
111
|
+
*/
|
|
104
112
|
search(_request) {
|
|
105
113
|
throw new Error('contract only');
|
|
106
114
|
}
|
|
@@ -110,7 +118,7 @@ tslib_1.__decorate([
|
|
|
110
118
|
(0, core_util_2.WpAuth)([(0, core_util_2.oidcSvcs)(['mcp-gateway'])]),
|
|
111
119
|
(0, core_util_2.WpAuthorization)({ authType: core_util_2.AuthorizationType.USERS_OR_SERVICES }),
|
|
112
120
|
(0, core_util_3.Endpoint)(core_util_3.POST, '/search', core_util_3.READ, core_util_3.RPC),
|
|
113
|
-
(0, core_util_3.WpMcpTool)('missing_remote_integration_search'
|
|
121
|
+
(0, core_util_3.WpMcpTool)('missing_remote_integration_search'),
|
|
114
122
|
tslib_1.__metadata("design:type", Function),
|
|
115
123
|
tslib_1.__metadata("design:paramtypes", [RemoteRequest]),
|
|
116
124
|
tslib_1.__metadata("design:returntype", Promise)
|
|
@@ -120,7 +128,11 @@ exports.MissingRemoteMcpApi = MissingRemoteMcpApi = tslib_1.__decorate([
|
|
|
120
128
|
(0, core_util_3.ApiType)(core_util_3.SVC_TO_SVC, core_util_3.MCP)
|
|
121
129
|
], MissingRemoteMcpApi);
|
|
122
130
|
let RefusedRemoteApi = class RefusedRemoteApi {
|
|
123
|
-
/**
|
|
131
|
+
/**
|
|
132
|
+
* Nothing listens on this port.
|
|
133
|
+
*
|
|
134
|
+
* @summary Refused remote call
|
|
135
|
+
*/
|
|
124
136
|
search(_request) {
|
|
125
137
|
throw new Error('contract only');
|
|
126
138
|
}
|
|
@@ -130,7 +142,7 @@ tslib_1.__decorate([
|
|
|
130
142
|
(0, core_util_2.WpAuth)([(0, core_util_2.oidcSvcs)(['mcp-gateway'])]),
|
|
131
143
|
(0, core_util_2.WpAuthorization)({ authType: core_util_2.AuthorizationType.USERS_OR_SERVICES }),
|
|
132
144
|
(0, core_util_3.Endpoint)(core_util_3.POST, '/search', core_util_3.READ, core_util_3.RPC),
|
|
133
|
-
(0, core_util_3.WpMcpTool)('refused_remote'
|
|
145
|
+
(0, core_util_3.WpMcpTool)('refused_remote'),
|
|
134
146
|
tslib_1.__metadata("design:type", Function),
|
|
135
147
|
tslib_1.__metadata("design:paramtypes", [RemoteRequest]),
|
|
136
148
|
tslib_1.__metadata("design:returntype", Promise)
|
|
@@ -140,7 +152,11 @@ exports.RefusedRemoteApi = RefusedRemoteApi = tslib_1.__decorate([
|
|
|
140
152
|
(0, core_util_3.ApiType)(core_util_3.SVC_TO_SVC, core_util_3.MCP)
|
|
141
153
|
], RefusedRemoteApi);
|
|
142
154
|
let GarbageRemoteApi = class GarbageRemoteApi {
|
|
143
|
-
/**
|
|
155
|
+
/**
|
|
156
|
+
* Answers an undecodable body.
|
|
157
|
+
*
|
|
158
|
+
* @summary Garbage remote response
|
|
159
|
+
*/
|
|
144
160
|
search(_request) {
|
|
145
161
|
throw new Error('contract only');
|
|
146
162
|
}
|
|
@@ -150,7 +166,7 @@ tslib_1.__decorate([
|
|
|
150
166
|
(0, core_util_2.WpAuth)([(0, core_util_2.oidcSvcs)(['mcp-gateway'])]),
|
|
151
167
|
(0, core_util_2.WpAuthorization)({ authType: core_util_2.AuthorizationType.USERS_OR_SERVICES }),
|
|
152
168
|
(0, core_util_3.Endpoint)(core_util_3.POST, '/search', core_util_3.READ, core_util_3.RPC),
|
|
153
|
-
(0, core_util_3.WpMcpTool)('garbage_remote'
|
|
169
|
+
(0, core_util_3.WpMcpTool)('garbage_remote'),
|
|
154
170
|
tslib_1.__metadata("design:type", Function),
|
|
155
171
|
tslib_1.__metadata("design:paramtypes", [RemoteRequest]),
|
|
156
172
|
tslib_1.__metadata("design:returntype", Promise)
|
|
@@ -160,7 +176,11 @@ exports.GarbageRemoteApi = GarbageRemoteApi = tslib_1.__decorate([
|
|
|
160
176
|
(0, core_util_3.ApiType)(core_util_3.SVC_TO_SVC, core_util_3.MCP)
|
|
161
177
|
], GarbageRemoteApi);
|
|
162
178
|
let OidcFailRemoteApi = class OidcFailRemoteApi {
|
|
163
|
-
/**
|
|
179
|
+
/**
|
|
180
|
+
* Its OIDC token cannot be minted.
|
|
181
|
+
*
|
|
182
|
+
* @summary OIDC failure on remote
|
|
183
|
+
*/
|
|
164
184
|
search(_request) {
|
|
165
185
|
throw new Error('contract only');
|
|
166
186
|
}
|
|
@@ -170,7 +190,7 @@ tslib_1.__decorate([
|
|
|
170
190
|
(0, core_util_2.WpAuth)([(0, core_util_2.oidcSvcs)(['mcp-gateway'])]),
|
|
171
191
|
(0, core_util_2.WpAuthorization)({ authType: core_util_2.AuthorizationType.USERS_OR_SERVICES }),
|
|
172
192
|
(0, core_util_3.Endpoint)(core_util_3.POST, '/search', core_util_3.READ, core_util_3.RPC),
|
|
173
|
-
(0, core_util_3.WpMcpTool)('oidc_fail_remote'
|
|
193
|
+
(0, core_util_3.WpMcpTool)('oidc_fail_remote'),
|
|
174
194
|
tslib_1.__metadata("design:type", Function),
|
|
175
195
|
tslib_1.__metadata("design:paramtypes", [RemoteRequest]),
|
|
176
196
|
tslib_1.__metadata("design:returntype", Promise)
|
|
@@ -180,7 +200,11 @@ exports.OidcFailRemoteApi = OidcFailRemoteApi = tslib_1.__decorate([
|
|
|
180
200
|
(0, core_util_3.ApiType)(core_util_3.SVC_TO_SVC, core_util_3.MCP)
|
|
181
201
|
], OidcFailRemoteApi);
|
|
182
202
|
let LocalThrowApi = class LocalThrowApi {
|
|
183
|
-
/**
|
|
203
|
+
/**
|
|
204
|
+
* Throws the requested failure in-process.
|
|
205
|
+
*
|
|
206
|
+
* @summary Local throw
|
|
207
|
+
*/
|
|
184
208
|
fail(_request) {
|
|
185
209
|
throw new Error('contract only');
|
|
186
210
|
}
|
|
@@ -190,7 +214,7 @@ tslib_1.__decorate([
|
|
|
190
214
|
(0, core_util_2.WpAuth)([(0, core_util_2.jwt)()]),
|
|
191
215
|
(0, core_util_2.WpAuthorization)({ authType: core_util_2.AuthorizationType.ALL_USERS }),
|
|
192
216
|
(0, core_util_3.Endpoint)(core_util_3.POST, '/throw', core_util_3.READ, core_util_3.RPC),
|
|
193
|
-
(0, core_util_3.WpMcpTool)('local_throw'
|
|
217
|
+
(0, core_util_3.WpMcpTool)('local_throw'),
|
|
194
218
|
tslib_1.__metadata("design:type", Function),
|
|
195
219
|
tslib_1.__metadata("design:paramtypes", [RemoteRequest]),
|
|
196
220
|
tslib_1.__metadata("design:returntype", Promise)
|
|
@@ -200,7 +224,11 @@ exports.LocalThrowApi = LocalThrowApi = tslib_1.__decorate([
|
|
|
200
224
|
(0, core_util_3.ApiType)(core_util_3.SVC_TO_SVC, core_util_3.MCP)
|
|
201
225
|
], LocalThrowApi);
|
|
202
226
|
let RemoteThrowApi = class RemoteThrowApi {
|
|
203
|
-
/**
|
|
227
|
+
/**
|
|
228
|
+
* Throws the requested failure remotely.
|
|
229
|
+
*
|
|
230
|
+
* @summary Remote throw
|
|
231
|
+
*/
|
|
204
232
|
fail(_request) {
|
|
205
233
|
throw new Error('contract only');
|
|
206
234
|
}
|
|
@@ -210,7 +238,7 @@ tslib_1.__decorate([
|
|
|
210
238
|
(0, core_util_2.WpAuth)([(0, core_util_2.oidcSvcs)(['mcp-gateway'])]),
|
|
211
239
|
(0, core_util_2.WpAuthorization)({ authType: core_util_2.AuthorizationType.USERS_OR_SERVICES }),
|
|
212
240
|
(0, core_util_3.Endpoint)(core_util_3.POST, '/throw', core_util_3.READ, core_util_3.RPC),
|
|
213
|
-
(0, core_util_3.WpMcpTool)('remote_throw'
|
|
241
|
+
(0, core_util_3.WpMcpTool)('remote_throw'),
|
|
214
242
|
tslib_1.__metadata("design:type", Function),
|
|
215
243
|
tslib_1.__metadata("design:paramtypes", [RemoteRequest]),
|
|
216
244
|
tslib_1.__metadata("design:returntype", Promise)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"McpRemoteFixtures.js","sourceRoot":"","sources":["../../../../../../packages/http/mcp-server/src/__tests__/McpRemoteFixtures.ts"],"names":[],"mappings":";;;AAiTA,4BAIC;;AArTD,oDAA2C;AAC3C,0DAAuE;AACvE,oDAAyJ;AACzJ,4BAA0B;AAC1B,yCAAuC;AACvC,oDAAm0B;AACn0B,0DAAyD;AACzD,0DAA2E;AAC3E,sDAAmD;AAEnD,wFAAwF;AAE3E,QAAA,WAAW,GAAG,sBAAU,CAAC,OAAO,CACzC,eAAe,EACf,8DAA8D,EAC9D,mBAAmB,CACtB,CAAC;AACW,QAAA,YAAY,GAAG,sBAAU,CAAC,OAAO,CAC1C,gBAAgB,EAChB,8DAA8D,EAC9D,oBAAoB,CACvB,CAAC;AACW,QAAA,cAAc,GAAG,wBAAwB,CAAC;AAC1C,QAAA,eAAe,GAAG,oBAAoB,CAAC;AACvC,QAAA,eAAe,GAAG,oBAAoB,CAAC;AACvC,QAAA,UAAU,GAAG,iCAAiC,CAAC;AAC/C,QAAA,mBAAmB,GAAG,2BAA2B,CAAC;AAClD,QAAA,kBAAkB,GAAG,uDAAuD,CAAC;AAC7E,QAAA,YAAY,GAAG,cAAc,CAAC;AAE3C,MAAa,aAAa;IACtB,kBAAkB;IAClB,KAAK,CAAU;IAEf,YAAY,KAAc;QACtB,IAAI,KAAK,KAAK,SAAS;YAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IAChD,CAAC;CACJ;AAPD,sCAOC;AAED,MAAa,cAAc;IACvB,qBAAqB;IACrB,IAAI,CAAU;IAEd,sBAAsB;IACtB,KAAK,CAAU;IAEf,aAAa;I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C,KAAK,IAAI,yBAAa,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACvD,MAAM,OAAO,GAAG,yBAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACpD,MAAM,UAAU,GAAG,OAAO,YAAY,yBAAa,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;YACrF,IACI,8BAAkB,CAAC,OAAO,CAAC,OAAO,CAAC;gBACnC,8BAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,QAAQ,CAAC,MAAM,CAAC,IAAI,EAC/E,CAAC;gBACC,MAAM,OAAO,CAAC;YAClB,CAAC;QACL,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC;CACJ;AAtBD,4DAsBC","sourcesContent":["import { Mcp } from '@webpieces/core-util';\nimport { AuthenticatedMachineIdentity } from '@webpieces/http-routing';\nimport { ClientRole, WpAuthorization, AuthorizationType, WpAuth, oidcSvcs, OidcAuthMethod, OidcAuthMethods, jwt as jwtAuth } from '@webpieces/core-util';\nimport 'reflect-metadata';\nimport { injectable } from 'inversify';\nimport { ApiBadRequestError, ApiCodedError, ApiConflictError, ApiConnectionError, ApiDependencyBackoffError, ApiDependencyError, ApiDependencyTimeoutError, ApiEndpointNotFoundError, ApiEndUserError, ApiErrorCodec, ApiErrorHttpStatus, ApiForbiddenError, ApiImplementationError, ApiNotFoundError, ApiNotImplementedError, ApiPath, ApiType, ApiPreconditionFailedError, ApiRateLimitedError, ApiRequestTimeoutError, ApiRetriesExhaustedError, ApiUnauthorizedError, ApiUnavailableError, ApiUnprocessableError, ApiUnsupportedMediaTypeError, ContextKey, Endpoint, ErrorTranslator, Filter, WebpiecesDefaultErrorTranslator, HttpResponseDto, LogLevel, Service, WebpiecesCoreHeaders, ApiJsonSchema, McpToolCatalogFile, McpToolDefinition, ObjectSchemaBuilder, WpMcpTool, WpMcpToolHints, MCP, POST, READ, RPC, SVC_TO_SVC } from '@webpieces/core-util';\nimport { RequestContext } from '@webpieces/core-context';\nimport { MethodMeta, OidcHook, WpResponse } from '@webpieces/http-routing';\nimport { McpToolCatalog } from '../McpToolCatalog';\n\n/** Contracts, controllers and test doubles for McpRemoteBinding.integration.spec.ts. */\n\nexport const REMOTE_USER = ContextKey.trusted<string>(\n 'mcpRemoteUser',\n 'verified by the MCP access-token authority before delegation',\n 'x-mcp-remote-user',\n);\nexport const REMOTE_ROLES = ContextKey.trusted<string>(\n 'mcpRemoteRoles',\n 'verified by the MCP access-token authority before delegation',\n 'x-mcp-remote-roles',\n);\nexport const REMOTE_SERVICE = 'mcp-remote-integration';\nexport const REFUSED_SERVICE = 'mcp-remote-refused';\nexport const GARBAGE_SERVICE = 'mcp-remote-garbage';\nexport const OIDC_TOKEN = 'oidc-for-mcp-remote-integration';\nexport const EXTERNAL_MCP_BEARER = 'external-mcp-access-token';\nexport const LOCAL_ENDPOINT_JWT = 'local-endpoint-jwt-that-must-not-cross-the-remote-hop';\nexport const GATEWAY_PATH = '/gateway/mcp';\n\nexport class RemoteRequest {\n /** Search text */\n query!: string;\n\n constructor(query?: string) {\n if (query !== undefined) this.query = query;\n }\n}\n\nexport class RemoteResponse {\n /** Delegated user */\n user!: string;\n\n /** Delegated roles */\n roles!: string;\n\n /** Result */\n result!: string;\n\n constructor(user?: string, roles?: string, result?: string) {\n if (user !== undefined) this.user = user;\n if (roles !== undefined) this.roles = roles;\n if (result !== undefined) this.result = result;\n }\n}\n\n/**\n * The generated tool catalogs these contracts would produce — what `wp-openapi` writes, one\n * `mcp-<ContractClass>-tools.json` per contract. Hand-built here because `@webpieces/mcp-server` does not depend on the\n * TypeScript compiler API; the runtime's job is to BE HANDED a catalog.\n */\nfunction describedString(description: string): ApiJsonSchema {\n const schema = new ApiJsonSchema('string');\n schema.description = description;\n return schema;\n}\n\nfunction searchTool(\n name: string,\n title: string,\n methodName: string,\n description: string,\n): McpToolDefinition {\n return new McpToolDefinition(\n name,\n title,\n methodName,\n description,\n new WpMcpToolHints(true, false, true, false),\n new ObjectSchemaBuilder().required('query', describedString('Search text')).build(),\n new ObjectSchemaBuilder()\n .required('user', describedString('Delegated user'))\n .required('roles', describedString('Delegated roles'))\n .required('result', describedString('Result'))\n .build(), [Mcp.DEFAULT],\n );\n}\n\n/** One contract's hand-built catalog, labelled as built in memory. */\nfunction contractCatalog(contractName: string, tool: McpToolDefinition): McpToolCatalog {\n return new McpToolCatalog(new McpToolCatalogFile(contractName, [tool]), '(built in memory by the spec)');\n}\n\nexport const REMOTE_MCP_CATALOG = contractCatalog(\n 'RemoteMcpApi',\n searchTool('remote_integration_search', 'Remote integration search', 'search', 'Calls a remote Webpieces API.'),\n);\n\n/** The catalogs of every contract the gateway binds — one per contract, exactly as a build writes them. */\nexport const GATEWAY_CATALOGS: readonly McpToolCatalog[] = [\n contractCatalog(\n 'MissingRemoteMcpApi',\n searchTool('missing_remote_integration_search', 'Missing remote integration search', 'search', 'Intentionally absent route.'),\n ),\n contractCatalog('RefusedRemoteApi', searchTool('refused_remote', 'Refused remote call', 'search', 'Nothing listens on this port.')),\n contractCatalog('GarbageRemoteApi', searchTool('garbage_remote', 'Garbage remote response', 'search', 'Answers an undecodable body.')),\n contractCatalog(\n 'OidcFailRemoteApi',\n searchTool('oidc_fail_remote', 'OIDC failure on remote', 'search', 'Its OIDC token cannot be minted.'),\n ),\n contractCatalog('LocalThrowApi', searchTool('local_throw', 'Local throw', 'fail', 'Throws the requested failure in-process.')),\n contractCatalog('RemoteThrowApi', searchTool('remote_throw', 'Remote throw', 'fail', 'Throws the requested failure remotely.')),\n];\n\n@ApiPath('/remote-mcp')\n@ApiType(SVC_TO_SVC, MCP)\nexport abstract class RemoteMcpApi {\n /** Calls a remote Webpieces API. */\n\n @WpAuth([oidcSvcs(['mcp-gateway'])])\n @WpAuthorization({ authType: AuthorizationType.USERS_OR_SERVICES })\n @Endpoint(POST, '/search', READ, RPC)\n @WpMcpTool('remote_integration_search', 'Remote integration search')\n search(_request: RemoteRequest): Promise<RemoteResponse> {\n throw new Error('contract only');\n }\n}\n\n@ApiPath('/missing-remote-mcp')\n@ApiType(SVC_TO_SVC, MCP)\nexport abstract class MissingRemoteMcpApi {\n /** Intentionally absent route. */\n\n @WpAuth([oidcSvcs(['mcp-gateway'])])\n @WpAuthorization({ authType: AuthorizationType.USERS_OR_SERVICES })\n @Endpoint(POST, '/search', READ, RPC)\n @WpMcpTool('missing_remote_integration_search', 'Missing remote integration search')\n search(_request: RemoteRequest): Promise<RemoteResponse> {\n throw new Error('contract only');\n }\n}\n\n@ApiPath('/refused-remote-mcp')\n@ApiType(SVC_TO_SVC, MCP)\nexport abstract class RefusedRemoteApi {\n /** Nothing listens on this port. */\n\n @WpAuth([oidcSvcs(['mcp-gateway'])])\n @WpAuthorization({ authType: AuthorizationType.USERS_OR_SERVICES })\n @Endpoint(POST, '/search', READ, RPC)\n @WpMcpTool('refused_remote', 'Refused remote call')\n search(_request: RemoteRequest): Promise<RemoteResponse> {\n throw new Error('contract only');\n }\n}\n\n@ApiPath('/garbage-remote-mcp')\n@ApiType(SVC_TO_SVC, MCP)\nexport abstract class GarbageRemoteApi {\n /** Answers an undecodable body. */\n\n @WpAuth([oidcSvcs(['mcp-gateway'])])\n @WpAuthorization({ authType: AuthorizationType.USERS_OR_SERVICES })\n @Endpoint(POST, '/search', READ, RPC)\n @WpMcpTool('garbage_remote', 'Garbage remote response')\n search(_request: RemoteRequest): Promise<RemoteResponse> {\n throw new Error('contract only');\n }\n}\n\n@ApiPath('/oidc-fail-remote-mcp')\n@ApiType(SVC_TO_SVC, MCP)\nexport abstract class OidcFailRemoteApi {\n /** Its OIDC token cannot be minted. */\n\n @WpAuth([oidcSvcs(['mcp-gateway'])])\n @WpAuthorization({ authType: AuthorizationType.USERS_OR_SERVICES })\n @Endpoint(POST, '/search', READ, RPC)\n @WpMcpTool('oidc_fail_remote', 'OIDC failure on remote')\n search(_request: RemoteRequest): Promise<RemoteResponse> {\n throw new Error('contract only');\n }\n}\n\n@ApiPath('/local-throw')\n@ApiType(SVC_TO_SVC, MCP)\nexport abstract class LocalThrowApi {\n /** Throws the requested failure in-process. */\n\n @WpAuth([jwtAuth()])\n @WpAuthorization({ authType: AuthorizationType.ALL_USERS })\n @Endpoint(POST, '/throw', READ, RPC)\n @WpMcpTool('local_throw', 'Local throw')\n fail(_request: RemoteRequest): Promise<RemoteResponse> {\n throw new Error('contract only');\n }\n}\n\n@ApiPath('/remote-throw')\n@ApiType(SVC_TO_SVC, MCP)\nexport abstract class RemoteThrowApi {\n /** Throws the requested failure remotely. */\n\n @WpAuth([oidcSvcs(['mcp-gateway'])])\n @WpAuthorization({ authType: AuthorizationType.USERS_OR_SERVICES })\n @Endpoint(POST, '/throw', READ, RPC)\n @WpMcpTool('remote_throw', 'Remote throw')\n fail(_request: RemoteRequest): Promise<RemoteResponse> {\n throw new Error('contract only');\n }\n}\n\n/**\n * One named throw, run identically behind the local and the remote binding.\n *\n * `expectedServerLevel` is the level of the ONE operator line the failure now produces on the server\n * that raised it — `LogApiCall`'s, at `warn` for `[API-server-resp-OTHER]` (a healthy rejection of\n * the caller's mistake) and `error` for `[API-server-resp-FAIL]`. `ApiErrorBoundary` no longer\n * writes a second line of its own (#961).\n */\nexport class ThrowCase {\n constructor(\n public readonly name: string,\n public readonly expectedKind: string,\n public readonly expectedServerLevel: LogLevel,\n public readonly raise: () => never,\n ) {}\n}\n\nexport const THROW_CASES: readonly ThrowCase[] = [\n new ThrowCase('end-user', 'end-user', 'warn', () => {\n throw new ApiEndUserError('The two passwords you entered do not match.', 'PW_MISMATCH');\n }),\n new ThrowCase('bad-request', 'bad-request', 'warn', () => {\n throw new ApiBadRequestError('internal column name', '$.query', 'query must be a word');\n }),\n new ThrowCase('unauthorized', 'unauthorized', 'warn', () => {\n throw new ApiUnauthorizedError('session internals');\n }),\n new ThrowCase('forbidden', 'forbidden', 'warn', () => {\n throw new ApiForbiddenError('acl internals');\n }),\n new ThrowCase('not-found', 'not-found', 'warn', () => {\n throw new ApiNotFoundError('row 7 missing');\n }),\n new ThrowCase('endpoint-not-found', 'endpoint-not-found', 'warn', () => {\n throw new ApiEndpointNotFoundError('route internals');\n }),\n new ThrowCase('request-timeout', 'request-timeout', 'error', () => {\n throw new ApiRequestTimeoutError('slow internals');\n }),\n new ThrowCase('rate-limited', 'rate-limited', 'error', () => {\n throw new ApiRateLimitedError('quota internals');\n }),\n new ThrowCase('conflict', 'conflict', 'warn', () => {\n throw new ApiConflictError('version internals');\n }),\n new ThrowCase('unprocessable', 'unprocessable', 'warn', () => {\n throw new ApiUnprocessableError('rule internals');\n }),\n new ThrowCase('precondition-failed', 'precondition-failed', 'warn', () => {\n throw new ApiPreconditionFailedError('etag internals');\n }),\n new ThrowCase('unsupported-media-type', 'unsupported-media-type', 'warn', () => {\n throw new ApiUnsupportedMediaTypeError('parser internals');\n }),\n new ThrowCase('not-implemented', 'not-implemented', 'error', () => {\n throw new ApiNotImplementedError('feature internals');\n }),\n new ThrowCase('coded-4xx', 'coded', 'warn', () => {\n throw new ApiCodedError('quota internals', 460, 'QUOTA');\n }),\n new ThrowCase('coded-5xx', 'coded', 'error', () => {\n throw new ApiCodedError('disk internals', 507);\n }),\n new ThrowCase('implementation', 'implementation', 'error', () => {\n throw new ApiImplementationError('bug internals');\n }),\n new ThrowCase('dependency', 'dependency', 'error', () => {\n throw new ApiDependencyError('upstream internals');\n }),\n new ThrowCase('unavailable', 'unavailable', 'error', () => {\n throw new ApiUnavailableError('maintenance internals');\n }),\n new ThrowCase('dependency-timeout', 'dependency-timeout', 'error', () => {\n throw new ApiDependencyTimeoutError('upstream slow internals');\n }),\n new ThrowCase('dependency-backoff', 'dependency-backoff', 'error', () => {\n throw new ApiDependencyBackoffError('backoff internals', 42);\n }),\n // A lower layer already retried and gave up: 502, decoded as itself on the remote hop, retry never.\n new ThrowCase('retries-exhausted', 'retries-exhausted', 'error', () => {\n throw new ApiRetriesExhaustedError(4, new ApiUnavailableError('createTask reset internals'));\n }),\n new ThrowCase('connection', 'implementation', 'error', () => {\n throw new ApiConnectionError('ECONNRESET internals');\n }),\n new ThrowCase('raw-error', 'implementation', 'error', () => {\n throw new Error('SECRET-raw-internals');\n }),\n new ThrowCase('thrown-string', 'implementation', 'error', () => {\n throw 'SECRET-string-internals';\n }),\n];\n\nexport function raiseFor(query: string): never {\n const found = THROW_CASES.find((candidate: ThrowCase) => candidate.name === query);\n if (!found) throw new Error(`unknown throw case ${query}`);\n return found.raise();\n}\n\n@injectable()\nexport class RemoteMcpController extends RemoteMcpApi {\n calls = 0;\n authorization?: string;\n\n override search(request: RemoteRequest): Promise<RemoteResponse> {\n this.calls += 1;\n this.authorization = RequestContext.getRequest()?.getHeader('authorization');\n return Promise.resolve(\n new RemoteResponse(\n RequestContext.getTrusted(REMOTE_USER) ?? 'missing-user',\n RequestContext.getTrusted(REMOTE_ROLES) ?? 'missing-roles',\n `remote:${request.query}`,\n ),\n );\n }\n}\n\n@injectable()\nexport class LocalThrowController extends LocalThrowApi {\n override async fail(request: RemoteRequest): Promise<RemoteResponse> {\n return raiseFor(request.query);\n }\n}\n\n@injectable()\nexport class RemoteThrowController extends RemoteThrowApi {\n override async fail(request: RemoteRequest): Promise<RemoteResponse> {\n return raiseFor(request.query);\n }\n}\n\nexport class RecordingOidcMinter {\n readonly audiences: string[] = [];\n\n constructor(\n private readonly failure?: Error,\n private readonly token = OIDC_TOKEN,\n ) {}\n\n mintIdToken(audience: string): Promise<string> {\n this.audiences.push(audience);\n if (this.failure) return Promise.reject(this.failure);\n return Promise.resolve(this.token);\n }\n}\n\nexport class RecordingOidcVerifier extends OidcHook {\n readonly tokens: string[] = [];\n readonly methods: OidcAuthMethod[] = [];\n\n override verifyOidc(token: string, methods: OidcAuthMethods): Promise<AuthenticatedMachineIdentity> {\n this.tokens.push(token);\n this.methods.push(...methods);\n if (token !== OIDC_TOKEN) throw new Error(`unexpected OIDC token '${token}'`);\n return Promise.resolve(new AuthenticatedMachineIdentity('oidc','test-service@example.test'));\n }\n}\n\n@injectable()\nexport class BoundaryProbeFilter extends Filter<MethodMeta, WpResponse<unknown>> {\n calls = 0;\n sawLogIdentity = false;\n sawTrustedUser?: string;\n\n override filter(\n meta: MethodMeta,\n next: Service<MethodMeta, WpResponse<unknown>>,\n ): Promise<WpResponse<unknown>> {\n this.calls += 1;\n this.sawLogIdentity =\n RequestContext.getUntrusted(WebpiecesCoreHeaders.CONTROLLER) ===\n 'RemoteMcpController' &&\n RequestContext.getUntrusted(WebpiecesCoreHeaders.METHOD) === 'search';\n this.sawTrustedUser = RequestContext.getTrusted(REMOTE_USER);\n return next.invoke(meta);\n }\n}\n\n/**\n * The documented gateway opt-out from http-client-node's \"a dependency's 4xx is OUR 500\" invariant:\n * an MCP gateway relays a Webpieces peer's typed failure so the model sees the same kind it would see\n * for a local binding. `relay = false` answers \"not mine\", which is the framework default.\n */\nexport class RelayWebpiecesPeerErrors implements ErrorTranslator {\n relay = true;\n\n private readonly fallback = new WebpiecesDefaultErrorTranslator();\n\n toWire(error: Error): HttpResponseDto {\n return this.fallback.toWire(error);\n }\n\n fromWire(response: HttpResponseDto, role: ClientRole): void {\n if (this.relay && ApiErrorCodec.isPayload(response.body)) {\n const decoded = ApiErrorCodec.decode(response.body);\n const statusCode = decoded instanceof ApiCodedError ? decoded.statusCode : undefined;\n if (\n ApiErrorHttpStatus.hasCode(decoded) &&\n ApiErrorHttpStatus.codeFor(decoded.kind, statusCode) === response.status.code\n ) {\n throw decoded;\n }\n }\n this.fallback.fromWire(response, role);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"McpRemoteFixtures.js","sourceRoot":"","sources":["../../../../../../packages/http/mcp-server/src/__tests__/McpRemoteFixtures.ts"],"names":[],"mappings":";;;AA6UA,4BAIC;;AAjVD,oDAA2C;AAC3C,0DAAuE;AACvE,oDAAyJ;AACzJ,4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AAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC;CACJ;AAtBD,4DAsBC","sourcesContent":["import { Mcp } from '@webpieces/core-util';\nimport { AuthenticatedMachineIdentity } from '@webpieces/http-routing';\nimport { ClientRole, WpAuthorization, AuthorizationType, WpAuth, oidcSvcs, OidcAuthMethod, OidcAuthMethods, jwt as jwtAuth } from '@webpieces/core-util';\nimport 'reflect-metadata';\nimport { injectable } from 'inversify';\nimport { ApiBadRequestError, ApiCodedError, ApiConflictError, ApiConnectionError, ApiDependencyBackoffError, ApiDependencyError, ApiDependencyTimeoutError, ApiEndpointNotFoundError, ApiEndUserError, ApiErrorCodec, ApiErrorHttpStatus, ApiForbiddenError, ApiImplementationError, ApiNotFoundError, ApiNotImplementedError, ApiPath, ApiType, ApiPreconditionFailedError, ApiRateLimitedError, ApiRequestTimeoutError, ApiRetriesExhaustedError, ApiUnauthorizedError, ApiUnavailableError, ApiUnprocessableError, ApiUnsupportedMediaTypeError, ContextKey, Endpoint, ErrorTranslator, Filter, WebpiecesDefaultErrorTranslator, HttpResponseDto, LogLevel, Service, WebpiecesCoreHeaders, ApiJsonSchema, McpToolCatalogFile, McpToolDefinition, ObjectSchemaBuilder, WpMcpTool, WpMcpToolHints, MCP, POST, READ, RPC, SVC_TO_SVC } from '@webpieces/core-util';\nimport { RequestContext } from '@webpieces/core-context';\nimport { MethodMeta, OidcHook, WpResponse } from '@webpieces/http-routing';\nimport { McpToolCatalog } from '../McpToolCatalog';\n\n/** Contracts, controllers and test doubles for McpRemoteBinding.integration.spec.ts. */\n\nexport const REMOTE_USER = ContextKey.trusted<string>(\n 'mcpRemoteUser',\n 'verified by the MCP access-token authority before delegation',\n 'x-mcp-remote-user',\n);\nexport const REMOTE_ROLES = ContextKey.trusted<string>(\n 'mcpRemoteRoles',\n 'verified by the MCP access-token authority before delegation',\n 'x-mcp-remote-roles',\n);\nexport const REMOTE_SERVICE = 'mcp-remote-integration';\nexport const REFUSED_SERVICE = 'mcp-remote-refused';\nexport const GARBAGE_SERVICE = 'mcp-remote-garbage';\nexport const OIDC_TOKEN = 'oidc-for-mcp-remote-integration';\nexport const EXTERNAL_MCP_BEARER = 'external-mcp-access-token';\nexport const LOCAL_ENDPOINT_JWT = 'local-endpoint-jwt-that-must-not-cross-the-remote-hop';\nexport const GATEWAY_PATH = '/gateway/mcp';\n\nexport class RemoteRequest {\n /** Search text */\n query!: string;\n\n constructor(query?: string) {\n if (query !== undefined) this.query = query;\n }\n}\n\nexport class RemoteResponse {\n /** Delegated user */\n user!: string;\n\n /** Delegated roles */\n roles!: string;\n\n /** Result */\n result!: string;\n\n constructor(user?: string, roles?: string, result?: string) {\n if (user !== undefined) this.user = user;\n if (roles !== undefined) this.roles = roles;\n if (result !== undefined) this.result = result;\n }\n}\n\n/**\n * The generated tool catalogs these contracts would produce — what `wp-openapi` writes, one\n * `mcp-<ContractClass>-tools.json` per contract. Hand-built here because `@webpieces/mcp-server` does not depend on the\n * TypeScript compiler API; the runtime's job is to BE HANDED a catalog.\n */\nfunction describedString(description: string): ApiJsonSchema {\n const schema = new ApiJsonSchema('string');\n schema.description = description;\n return schema;\n}\n\nfunction searchTool(\n name: string,\n title: string,\n methodName: string,\n description: string,\n): McpToolDefinition {\n return new McpToolDefinition(\n name,\n title,\n methodName,\n description,\n new WpMcpToolHints(true, false, true, false),\n new ObjectSchemaBuilder().required('query', describedString('Search text')).build(),\n new ObjectSchemaBuilder()\n .required('user', describedString('Delegated user'))\n .required('roles', describedString('Delegated roles'))\n .required('result', describedString('Result'))\n .build(), [Mcp.DEFAULT],\n );\n}\n\n/** One contract's hand-built catalog, labelled as built in memory. */\nfunction contractCatalog(contractName: string, tool: McpToolDefinition): McpToolCatalog {\n return new McpToolCatalog(new McpToolCatalogFile(contractName, [tool]), '(built in memory by the spec)');\n}\n\nexport const REMOTE_MCP_CATALOG = contractCatalog(\n 'RemoteMcpApi',\n searchTool('remote_integration_search', 'Remote integration search', 'search', 'Calls a remote Webpieces API.'),\n);\n\n/** The catalogs of every contract the gateway binds — one per contract, exactly as a build writes them. */\nexport const GATEWAY_CATALOGS: readonly McpToolCatalog[] = [\n contractCatalog(\n 'MissingRemoteMcpApi',\n searchTool('missing_remote_integration_search', 'Missing remote integration search', 'search', 'Intentionally absent route.'),\n ),\n contractCatalog('RefusedRemoteApi', searchTool('refused_remote', 'Refused remote call', 'search', 'Nothing listens on this port.')),\n contractCatalog('GarbageRemoteApi', searchTool('garbage_remote', 'Garbage remote response', 'search', 'Answers an undecodable body.')),\n contractCatalog(\n 'OidcFailRemoteApi',\n searchTool('oidc_fail_remote', 'OIDC failure on remote', 'search', 'Its OIDC token cannot be minted.'),\n ),\n contractCatalog('LocalThrowApi', searchTool('local_throw', 'Local throw', 'fail', 'Throws the requested failure in-process.')),\n contractCatalog('RemoteThrowApi', searchTool('remote_throw', 'Remote throw', 'fail', 'Throws the requested failure remotely.')),\n];\n\n@ApiPath('/remote-mcp')\n@ApiType(SVC_TO_SVC, MCP)\nexport abstract class RemoteMcpApi {\n /**\n * Calls a remote Webpieces API.\n *\n * @summary Remote integration search\n */\n\n @WpAuth([oidcSvcs(['mcp-gateway'])])\n @WpAuthorization({ authType: AuthorizationType.USERS_OR_SERVICES })\n @Endpoint(POST, '/search', READ, RPC)\n @WpMcpTool('remote_integration_search')\n search(_request: RemoteRequest): Promise<RemoteResponse> {\n throw new Error('contract only');\n }\n}\n\n@ApiPath('/missing-remote-mcp')\n@ApiType(SVC_TO_SVC, MCP)\nexport abstract class MissingRemoteMcpApi {\n /**\n * Intentionally absent route.\n *\n * @summary Missing remote integration search\n */\n\n @WpAuth([oidcSvcs(['mcp-gateway'])])\n @WpAuthorization({ authType: AuthorizationType.USERS_OR_SERVICES })\n @Endpoint(POST, '/search', READ, RPC)\n @WpMcpTool('missing_remote_integration_search')\n search(_request: RemoteRequest): Promise<RemoteResponse> {\n throw new Error('contract only');\n }\n}\n\n@ApiPath('/refused-remote-mcp')\n@ApiType(SVC_TO_SVC, MCP)\nexport abstract class RefusedRemoteApi {\n /**\n * Nothing listens on this port.\n *\n * @summary Refused remote call\n */\n\n @WpAuth([oidcSvcs(['mcp-gateway'])])\n @WpAuthorization({ authType: AuthorizationType.USERS_OR_SERVICES })\n @Endpoint(POST, '/search', READ, RPC)\n @WpMcpTool('refused_remote')\n search(_request: RemoteRequest): Promise<RemoteResponse> {\n throw new Error('contract only');\n }\n}\n\n@ApiPath('/garbage-remote-mcp')\n@ApiType(SVC_TO_SVC, MCP)\nexport abstract class GarbageRemoteApi {\n /**\n * Answers an undecodable body.\n *\n * @summary Garbage remote response\n */\n\n @WpAuth([oidcSvcs(['mcp-gateway'])])\n @WpAuthorization({ authType: AuthorizationType.USERS_OR_SERVICES })\n @Endpoint(POST, '/search', READ, RPC)\n @WpMcpTool('garbage_remote')\n search(_request: RemoteRequest): Promise<RemoteResponse> {\n throw new Error('contract only');\n }\n}\n\n@ApiPath('/oidc-fail-remote-mcp')\n@ApiType(SVC_TO_SVC, MCP)\nexport abstract class OidcFailRemoteApi {\n /**\n * Its OIDC token cannot be minted.\n *\n * @summary OIDC failure on remote\n */\n\n @WpAuth([oidcSvcs(['mcp-gateway'])])\n @WpAuthorization({ authType: AuthorizationType.USERS_OR_SERVICES })\n @Endpoint(POST, '/search', READ, RPC)\n @WpMcpTool('oidc_fail_remote')\n search(_request: RemoteRequest): Promise<RemoteResponse> {\n throw new Error('contract only');\n }\n}\n\n@ApiPath('/local-throw')\n@ApiType(SVC_TO_SVC, MCP)\nexport abstract class LocalThrowApi {\n /**\n * Throws the requested failure in-process.\n *\n * @summary Local throw\n */\n\n @WpAuth([jwtAuth()])\n @WpAuthorization({ authType: AuthorizationType.ALL_USERS })\n @Endpoint(POST, '/throw', READ, RPC)\n @WpMcpTool('local_throw')\n fail(_request: RemoteRequest): Promise<RemoteResponse> {\n throw new Error('contract only');\n }\n}\n\n@ApiPath('/remote-throw')\n@ApiType(SVC_TO_SVC, MCP)\nexport abstract class RemoteThrowApi {\n /**\n * Throws the requested failure remotely.\n *\n * @summary Remote throw\n */\n\n @WpAuth([oidcSvcs(['mcp-gateway'])])\n @WpAuthorization({ authType: AuthorizationType.USERS_OR_SERVICES })\n @Endpoint(POST, '/throw', READ, RPC)\n @WpMcpTool('remote_throw')\n fail(_request: RemoteRequest): Promise<RemoteResponse> {\n throw new Error('contract only');\n }\n}\n\n/**\n * One named throw, run identically behind the local and the remote binding.\n *\n * `expectedServerLevel` is the level of the ONE operator line the failure now produces on the server\n * that raised it — `LogApiCall`'s, at `warn` for `[API-server-resp-OTHER]` (a healthy rejection of\n * the caller's mistake) and `error` for `[API-server-resp-FAIL]`. `ApiErrorBoundary` no longer\n * writes a second line of its own (#961).\n */\nexport class ThrowCase {\n constructor(\n public readonly name: string,\n public readonly expectedKind: string,\n public readonly expectedServerLevel: LogLevel,\n public readonly raise: () => never,\n ) {}\n}\n\nexport const THROW_CASES: readonly ThrowCase[] = [\n new ThrowCase('end-user', 'end-user', 'warn', () => {\n throw new ApiEndUserError('The two passwords you entered do not match.', 'PW_MISMATCH');\n }),\n new ThrowCase('bad-request', 'bad-request', 'warn', () => {\n throw new ApiBadRequestError('internal column name', '$.query', 'query must be a word');\n }),\n new ThrowCase('unauthorized', 'unauthorized', 'warn', () => {\n throw new ApiUnauthorizedError('session internals');\n }),\n new ThrowCase('forbidden', 'forbidden', 'warn', () => {\n throw new ApiForbiddenError('acl internals');\n }),\n new ThrowCase('not-found', 'not-found', 'warn', () => {\n throw new ApiNotFoundError('row 7 missing');\n }),\n new ThrowCase('endpoint-not-found', 'endpoint-not-found', 'warn', () => {\n throw new ApiEndpointNotFoundError('route internals');\n }),\n new ThrowCase('request-timeout', 'request-timeout', 'error', () => {\n throw new ApiRequestTimeoutError('slow internals');\n }),\n new ThrowCase('rate-limited', 'rate-limited', 'error', () => {\n throw new ApiRateLimitedError('quota internals');\n }),\n new ThrowCase('conflict', 'conflict', 'warn', () => {\n throw new ApiConflictError('version internals');\n }),\n new ThrowCase('unprocessable', 'unprocessable', 'warn', () => {\n throw new ApiUnprocessableError('rule internals');\n }),\n new ThrowCase('precondition-failed', 'precondition-failed', 'warn', () => {\n throw new ApiPreconditionFailedError('etag internals');\n }),\n new ThrowCase('unsupported-media-type', 'unsupported-media-type', 'warn', () => {\n throw new ApiUnsupportedMediaTypeError('parser internals');\n }),\n new ThrowCase('not-implemented', 'not-implemented', 'error', () => {\n throw new ApiNotImplementedError('feature internals');\n }),\n new ThrowCase('coded-4xx', 'coded', 'warn', () => {\n throw new ApiCodedError('quota internals', 460, 'QUOTA');\n }),\n new ThrowCase('coded-5xx', 'coded', 'error', () => {\n throw new ApiCodedError('disk internals', 507);\n }),\n new ThrowCase('implementation', 'implementation', 'error', () => {\n throw new ApiImplementationError('bug internals');\n }),\n new ThrowCase('dependency', 'dependency', 'error', () => {\n throw new ApiDependencyError('upstream internals');\n }),\n new ThrowCase('unavailable', 'unavailable', 'error', () => {\n throw new ApiUnavailableError('maintenance internals');\n }),\n new ThrowCase('dependency-timeout', 'dependency-timeout', 'error', () => {\n throw new ApiDependencyTimeoutError('upstream slow internals');\n }),\n new ThrowCase('dependency-backoff', 'dependency-backoff', 'error', () => {\n throw new ApiDependencyBackoffError('backoff internals', 42);\n }),\n // A lower layer already retried and gave up: 502, decoded as itself on the remote hop, retry never.\n new ThrowCase('retries-exhausted', 'retries-exhausted', 'error', () => {\n throw new ApiRetriesExhaustedError(4, new ApiUnavailableError('createTask reset internals'));\n }),\n new ThrowCase('connection', 'implementation', 'error', () => {\n throw new ApiConnectionError('ECONNRESET internals');\n }),\n new ThrowCase('raw-error', 'implementation', 'error', () => {\n throw new Error('SECRET-raw-internals');\n }),\n new ThrowCase('thrown-string', 'implementation', 'error', () => {\n throw 'SECRET-string-internals';\n }),\n];\n\nexport function raiseFor(query: string): never {\n const found = THROW_CASES.find((candidate: ThrowCase) => candidate.name === query);\n if (!found) throw new Error(`unknown throw case ${query}`);\n return found.raise();\n}\n\n@injectable()\nexport class RemoteMcpController extends RemoteMcpApi {\n calls = 0;\n authorization?: string;\n\n override search(request: RemoteRequest): Promise<RemoteResponse> {\n this.calls += 1;\n this.authorization = RequestContext.getRequest()?.getHeader('authorization');\n return Promise.resolve(\n new RemoteResponse(\n RequestContext.getTrusted(REMOTE_USER) ?? 'missing-user',\n RequestContext.getTrusted(REMOTE_ROLES) ?? 'missing-roles',\n `remote:${request.query}`,\n ),\n );\n }\n}\n\n@injectable()\nexport class LocalThrowController extends LocalThrowApi {\n override async fail(request: RemoteRequest): Promise<RemoteResponse> {\n return raiseFor(request.query);\n }\n}\n\n@injectable()\nexport class RemoteThrowController extends RemoteThrowApi {\n override async fail(request: RemoteRequest): Promise<RemoteResponse> {\n return raiseFor(request.query);\n }\n}\n\nexport class RecordingOidcMinter {\n readonly audiences: string[] = [];\n\n constructor(\n private readonly failure?: Error,\n private readonly token = OIDC_TOKEN,\n ) {}\n\n mintIdToken(audience: string): Promise<string> {\n this.audiences.push(audience);\n if (this.failure) return Promise.reject(this.failure);\n return Promise.resolve(this.token);\n }\n}\n\nexport class RecordingOidcVerifier extends OidcHook {\n readonly tokens: string[] = [];\n readonly methods: OidcAuthMethod[] = [];\n\n override verifyOidc(token: string, methods: OidcAuthMethods): Promise<AuthenticatedMachineIdentity> {\n this.tokens.push(token);\n this.methods.push(...methods);\n if (token !== OIDC_TOKEN) throw new Error(`unexpected OIDC token '${token}'`);\n return Promise.resolve(new AuthenticatedMachineIdentity('oidc','test-service@example.test'));\n }\n}\n\n@injectable()\nexport class BoundaryProbeFilter extends Filter<MethodMeta, WpResponse<unknown>> {\n calls = 0;\n sawLogIdentity = false;\n sawTrustedUser?: string;\n\n override filter(\n meta: MethodMeta,\n next: Service<MethodMeta, WpResponse<unknown>>,\n ): Promise<WpResponse<unknown>> {\n this.calls += 1;\n this.sawLogIdentity =\n RequestContext.getUntrusted(WebpiecesCoreHeaders.CONTROLLER) ===\n 'RemoteMcpController' &&\n RequestContext.getUntrusted(WebpiecesCoreHeaders.METHOD) === 'search';\n this.sawTrustedUser = RequestContext.getTrusted(REMOTE_USER);\n return next.invoke(meta);\n }\n}\n\n/**\n * The documented gateway opt-out from http-client-node's \"a dependency's 4xx is OUR 500\" invariant:\n * an MCP gateway relays a Webpieces peer's typed failure so the model sees the same kind it would see\n * for a local binding. `relay = false` answers \"not mine\", which is the framework default.\n */\nexport class RelayWebpiecesPeerErrors implements ErrorTranslator {\n relay = true;\n\n private readonly fallback = new WebpiecesDefaultErrorTranslator();\n\n toWire(error: Error): HttpResponseDto {\n return this.fallback.toWire(error);\n }\n\n fromWire(response: HttpResponseDto, role: ClientRole): void {\n if (this.relay && ApiErrorCodec.isPayload(response.body)) {\n const decoded = ApiErrorCodec.decode(response.body);\n const statusCode = decoded instanceof ApiCodedError ? decoded.statusCode : undefined;\n if (\n ApiErrorHttpStatus.hasCode(decoded) &&\n ApiErrorHttpStatus.codeFor(decoded.kind, statusCode) === response.status.code\n ) {\n throw decoded;\n }\n }\n this.fallback.fromWire(response, role);\n }\n}\n"]}
|
|
@@ -30,13 +30,25 @@ export declare const IN_MEMORY = "(built in memory by the spec)";
|
|
|
30
30
|
export declare const SEARCH_API_CATALOG: McpToolCatalog;
|
|
31
31
|
export declare const REMOTE_SEARCH_API_CATALOG: McpToolCatalog;
|
|
32
32
|
export declare abstract class SearchApi {
|
|
33
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Search records owned by the authenticated user.
|
|
35
|
+
*
|
|
36
|
+
* @summary Search accounts
|
|
37
|
+
*/
|
|
34
38
|
search(_request: SearchRequest): Promise<SearchResponse>;
|
|
35
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Administrative search.
|
|
41
|
+
*
|
|
42
|
+
* @summary Admin search
|
|
43
|
+
*/
|
|
36
44
|
admin(_request: SearchRequest): Promise<SearchResponse>;
|
|
37
45
|
}
|
|
38
46
|
export declare abstract class RemoteSearchApi {
|
|
39
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Search a remote binding.
|
|
49
|
+
*
|
|
50
|
+
* @summary Remote search
|
|
51
|
+
*/
|
|
40
52
|
search(_request: SearchRequest): Promise<SearchResponse>;
|
|
41
53
|
}
|
|
42
54
|
export declare class SearchController extends SearchApi {
|
|
@@ -71,11 +71,19 @@ exports.REMOTE_SEARCH_API_CATALOG = new McpToolCatalog_1.McpToolCatalog(new core
|
|
|
71
71
|
searchTool('remote_search', 'Remote search', 'search', 'Search a remote binding.', new core_util_3.WpMcpToolHints(false, true, false, false)),
|
|
72
72
|
]), exports.IN_MEMORY);
|
|
73
73
|
let SearchApi = class SearchApi {
|
|
74
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* Search records owned by the authenticated user.
|
|
76
|
+
*
|
|
77
|
+
* @summary Search accounts
|
|
78
|
+
*/
|
|
75
79
|
search(_request) {
|
|
76
80
|
throw new Error('contract only');
|
|
77
81
|
}
|
|
78
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* Administrative search.
|
|
84
|
+
*
|
|
85
|
+
* @summary Admin search
|
|
86
|
+
*/
|
|
79
87
|
admin(_request) {
|
|
80
88
|
throw new Error('contract only');
|
|
81
89
|
}
|
|
@@ -85,7 +93,7 @@ tslib_1.__decorate([
|
|
|
85
93
|
(0, core_util_2.WpAuth)([(0, core_util_2.jwt)()]),
|
|
86
94
|
(0, core_util_2.WpAuthorization)({ authType: core_util_2.AuthorizationType.ALL_USERS }),
|
|
87
95
|
(0, core_util_3.Endpoint)(core_util_3.POST, '/search', core_util_3.READ, core_util_3.RPC),
|
|
88
|
-
(0, core_util_3.WpMcpTool)('account_search'
|
|
96
|
+
(0, core_util_3.WpMcpTool)('account_search'),
|
|
89
97
|
tslib_1.__metadata("design:type", Function),
|
|
90
98
|
tslib_1.__metadata("design:paramtypes", [SearchRequest]),
|
|
91
99
|
tslib_1.__metadata("design:returntype", Promise)
|
|
@@ -94,7 +102,7 @@ tslib_1.__decorate([
|
|
|
94
102
|
(0, core_util_2.WpAuth)([(0, core_util_2.jwt)()]),
|
|
95
103
|
(0, core_util_2.WpAuthorization)({ authType: core_util_2.AuthorizationType.ROLES, roles: ['admin'] }),
|
|
96
104
|
(0, core_util_3.Endpoint)(core_util_3.POST, '/admin', core_util_3.WRITE, core_util_3.RPC),
|
|
97
|
-
(0, core_util_3.WpMcpTool)('admin_search'
|
|
105
|
+
(0, core_util_3.WpMcpTool)('admin_search'),
|
|
98
106
|
tslib_1.__metadata("design:type", Function),
|
|
99
107
|
tslib_1.__metadata("design:paramtypes", [SearchRequest]),
|
|
100
108
|
tslib_1.__metadata("design:returntype", Promise)
|
|
@@ -104,7 +112,11 @@ exports.SearchApi = SearchApi = tslib_1.__decorate([
|
|
|
104
112
|
(0, core_util_3.ApiType)(core_util_3.SVC_TO_SVC, core_util_3.MCP)
|
|
105
113
|
], SearchApi);
|
|
106
114
|
let RemoteSearchApi = class RemoteSearchApi {
|
|
107
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* Search a remote binding.
|
|
117
|
+
*
|
|
118
|
+
* @summary Remote search
|
|
119
|
+
*/
|
|
108
120
|
search(_request) {
|
|
109
121
|
throw new Error('contract only');
|
|
110
122
|
}
|
|
@@ -114,7 +126,7 @@ tslib_1.__decorate([
|
|
|
114
126
|
(0, core_util_2.WpAuth)([(0, core_util_2.oidcSameProject)()]),
|
|
115
127
|
(0, core_util_2.WpAuthorization)({ authType: core_util_2.AuthorizationType.USERS_OR_SERVICES }),
|
|
116
128
|
(0, core_util_3.Endpoint)(core_util_3.POST, '/search', core_util_3.WRITE, core_util_3.RPC),
|
|
117
|
-
(0, core_util_3.WpMcpTool)('remote_search'
|
|
129
|
+
(0, core_util_3.WpMcpTool)('remote_search'),
|
|
118
130
|
tslib_1.__metadata("design:type", Function),
|
|
119
131
|
tslib_1.__metadata("design:paramtypes", [SearchRequest]),
|
|
120
132
|
tslib_1.__metadata("design:returntype", Promise)
|