@tsed/platform-mcp 8.43.1 → 8.43.4
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/platform-mcp",
|
|
3
|
-
"version": "8.43.
|
|
3
|
+
"version": "8.43.4",
|
|
4
4
|
"description": "Model Context Protocol integration for Ts.ED HTTP adapters.",
|
|
5
5
|
"source": "./src/http/index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -51,14 +51,14 @@
|
|
|
51
51
|
"uuid": ">=11.0.2"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@tsed/barrels": "8.43.
|
|
55
|
-
"@tsed/core": "8.43.
|
|
56
|
-
"@tsed/di": "8.43.
|
|
57
|
-
"@tsed/exceptions": "8.43.
|
|
58
|
-
"@tsed/json-mapper": "8.43.
|
|
59
|
-
"@tsed/platform-http": "8.43.
|
|
60
|
-
"@tsed/schema": "8.43.
|
|
61
|
-
"@tsed/typescript": "8.43.
|
|
54
|
+
"@tsed/barrels": "8.43.4",
|
|
55
|
+
"@tsed/core": "8.43.4",
|
|
56
|
+
"@tsed/di": "8.43.4",
|
|
57
|
+
"@tsed/exceptions": "8.43.4",
|
|
58
|
+
"@tsed/json-mapper": "8.43.4",
|
|
59
|
+
"@tsed/platform-http": "8.43.4",
|
|
60
|
+
"@tsed/schema": "8.43.4",
|
|
61
|
+
"@tsed/typescript": "8.43.4",
|
|
62
62
|
"jose": "^6.1.3",
|
|
63
63
|
"typescript": "6.0.2",
|
|
64
64
|
"vitest": "4.1.4"
|
|
@@ -269,6 +269,36 @@ describe("PlatformMcpAuthService", () => {
|
|
|
269
269
|
expect(result.headers.get("www-authenticate")).toContain('scope="mcp:write"');
|
|
270
270
|
});
|
|
271
271
|
|
|
272
|
+
it("advertises the supported scopes in the challenge when no scope is required", async () => {
|
|
273
|
+
const service = inject(PlatformMcpAuthService);
|
|
274
|
+
const auth = createAuth({verifier: createVerifier(), scopesSupported: ["openid", "profile", "email"]});
|
|
275
|
+
|
|
276
|
+
const anonymous = (await service.verifyMcpRequest(auth, createContext())) as Response;
|
|
277
|
+
|
|
278
|
+
expect(anonymous.status).toBe(401);
|
|
279
|
+
expect(anonymous.headers.get("www-authenticate")).toContain('scope="openid profile email"');
|
|
280
|
+
// the supported scopes are only a hint: a token without them is still accepted
|
|
281
|
+
await expect(service.verifyMcpRequest(auth, createContext({authorization: "Bearer valid"}))).resolves.toEqual(authInfo);
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
it("advertises the required scopes rather than the supported ones", async () => {
|
|
285
|
+
const service = inject(PlatformMcpAuthService);
|
|
286
|
+
const auth = createAuth({verifier: createVerifier(), scopesSupported: ["mcp:read", "mcp:write"], requiredScopes: ["mcp:read"]});
|
|
287
|
+
|
|
288
|
+
const result = (await service.verifyMcpRequest(auth, createContext())) as Response;
|
|
289
|
+
|
|
290
|
+
expect(result.headers.get("www-authenticate")).toContain('scope="mcp:read"');
|
|
291
|
+
expect(result.headers.get("www-authenticate")).not.toContain("mcp:write");
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
it("sends no scope in the challenge when none is configured", async () => {
|
|
295
|
+
const service = inject(PlatformMcpAuthService);
|
|
296
|
+
|
|
297
|
+
const result = (await service.verifyMcpRequest(createAuth({verifier: createVerifier()}), createContext())) as Response;
|
|
298
|
+
|
|
299
|
+
expect(result.headers.get("www-authenticate")).not.toContain("scope=");
|
|
300
|
+
});
|
|
301
|
+
|
|
272
302
|
it("ignores the Host header of the request in the challenge", async () => {
|
|
273
303
|
const service = inject(PlatformMcpAuthService);
|
|
274
304
|
const auth = createAuth({verifier: createVerifier()});
|
|
@@ -81,7 +81,11 @@ export class PlatformMcpAuthService {
|
|
|
81
81
|
try {
|
|
82
82
|
return await verifyBearerToken($ctx.request.headers.authorization, options);
|
|
83
83
|
} catch (error) {
|
|
84
|
-
return bearerAuthChallengeResponse(error,
|
|
84
|
+
return bearerAuthChallengeResponse(error, {
|
|
85
|
+
...options,
|
|
86
|
+
// tell the client which scopes to request: the required ones, or the supported ones when none is enforced
|
|
87
|
+
requiredScopes: auth.requiredScopes?.length ? auth.requiredScopes : auth.scopesSupported
|
|
88
|
+
});
|
|
85
89
|
}
|
|
86
90
|
}
|
|
87
91
|
|