@absolutejs/mcp 0.10.2 → 0.10.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/README.md CHANGED
@@ -108,6 +108,7 @@ const server = new Elysia().use(
108
108
  // access-token checks; add your own (billing, role, MFA) on top.
109
109
  authorize: async (request) => {
110
110
  const token = await verifyBearer({
111
+ audience: "https://your.app/mcp",
111
112
  request,
112
113
  issuer: "https://your.app",
113
114
  requiredScope: "mcp",
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ var isRecord = (value) => typeof value === "object" && value !== null && !Array.
20
20
  // src/auth.ts
21
21
  var MS_PER_SECOND = 1000;
22
22
  var verifyBearer = async (config) => {
23
- const { issuer, request, verify, requiredScope } = config;
23
+ const { audience, issuer, request, verify, requiredScope } = config;
24
24
  const header = request.headers.get("authorization");
25
25
  if (!header?.startsWith("Bearer "))
26
26
  return { error: "Missing bearer token" };
@@ -32,6 +32,9 @@ var verifyBearer = async (config) => {
32
32
  return { error: "Not an access token" };
33
33
  if (payload.iss !== issuer)
34
34
  return { error: "Wrong issuer" };
35
+ const audiences = Array.isArray(payload.aud) ? payload.aud : [payload.aud];
36
+ if (audience !== undefined && !audiences.some((candidate) => candidate === audience))
37
+ return { error: "Wrong audience" };
35
38
  const expires = typeof payload.exp === "number" ? payload.exp : 0;
36
39
  if (expires * MS_PER_SECOND <= Date.now())
37
40
  return { error: "Token expired" };
package/dist/manifest.js CHANGED
@@ -8505,6 +8505,16 @@ var Type2 = exports_type6;
8505
8505
  // src/manifest.ts
8506
8506
  var manifest = defineManifest()({
8507
8507
  contract: 2,
8508
+ discovery: {
8509
+ audiences: ["agent-hosts", "mcp-clients"],
8510
+ intents: [
8511
+ "serve MCP tools",
8512
+ "connect an MCP client",
8513
+ "run durable MCP tasks"
8514
+ ],
8515
+ keywords: ["agents", "mcp", "tools", "oauth", "tasks", "elicitation"],
8516
+ protocols: ["MCP 2025-11-25", "OAuth 2.0"]
8517
+ },
8508
8518
  identity: {
8509
8519
  accent: "#0ea5e9",
8510
8520
  category: "ai",
@@ -1,5 +1,28 @@
1
1
  {
2
2
  "contract": 2,
3
+ "discovery": {
4
+ "audiences": [
5
+ "agent-hosts",
6
+ "mcp-clients"
7
+ ],
8
+ "intents": [
9
+ "serve MCP tools",
10
+ "connect an MCP client",
11
+ "run durable MCP tasks"
12
+ ],
13
+ "keywords": [
14
+ "agents",
15
+ "mcp",
16
+ "tools",
17
+ "oauth",
18
+ "tasks",
19
+ "elicitation"
20
+ ],
21
+ "protocols": [
22
+ "MCP 2025-11-25",
23
+ "OAuth 2.0"
24
+ ]
25
+ },
3
26
  "identity": {
4
27
  "accent": "#0ea5e9",
5
28
  "category": "ai",
@@ -5,6 +5,8 @@ export type VerifiedJwt = {
5
5
  };
6
6
  export type BearerVerifier = (token: string) => Promise<VerifiedJwt | undefined> | VerifiedJwt | undefined;
7
7
  export type VerifyBearerConfig = {
8
+ /** Require the access token to name this protected resource in `aud`. */
9
+ audience?: string;
8
10
  issuer: string;
9
11
  request: Request;
10
12
  /** Verify the JWT signature and decode it (e.g. `@absolutejs/auth`'s
@@ -20,7 +22,7 @@ export type BearerResult = {
20
22
  subject: string;
21
23
  };
22
24
  /** Verify the `Authorization: Bearer` token: signature (via your `verify`),
23
- * `token_use: access`, issuer, expiry, the required scope, and a subject.
25
+ * `token_use: access`, issuer, optional audience, expiry, required scope, and a subject.
24
26
  * Returns the decoded payload + parsed scopes + subject, or a reason string.
25
27
  * The reason is safe to surface in the 401 (never why the signature failed). */
26
28
  export declare const verifyBearer: (config: VerifyBearerConfig) => Promise<BearerResult>;
package/package.json CHANGED
@@ -58,5 +58,5 @@
58
58
  "typecheck": "tsc --noEmit --project tsconfig.json"
59
59
  },
60
60
  "types": "./dist/src/index.d.ts",
61
- "version": "0.10.2"
61
+ "version": "0.10.4"
62
62
  }