@ttoss/http-server-mcp 0.26.1 → 0.26.2

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
@@ -372,7 +372,7 @@ The `WWW-Authenticate: Bearer resource_metadata="…"` header is how MCP clients
372
372
  The two behaviors the [MCP authorization spec](https://spec.modelcontextprotocol.io/specification/2025-03-26/basic/authorization/) requires for client bootstrapping are built into the `auth` option, so you no longer need the hand-rolled middleware shown above:
373
373
 
374
374
  - **`publicMethods`** — JSON-RPC methods that bypass verification, read from the request body's `method` field. Defaults to `['initialize', 'tools/list']` so clients can discover the server before authenticating. Pass `[]` to require a token for every method, or a custom list to change the exempt set. Leaving it unset serves the full tool catalogue — every tool name, description, and input schema — to unauthenticated callers, and logs a one-time warning explaining that and how to close it. Set `publicMethods` explicitly (even to the same default) to silence the warning.
375
- - **`resourceMetadataUrl`** — the URL a `401` advertises as `WWW-Authenticate: Bearer resource_metadata="<url>"` (RFC 9728) instead of a bare `Bearer`, pointing MCP clients at the protected-resource metadata document. **You normally do not set it**: when the document is served — i.e. both `resourceServerUrl` and `authorizationServerUrl` are configured — it defaults to the RFC 9728 location this router serves it at, so the header and the routes cannot drift apart. Set it only to point at a document served elsewhere. When the document is not served, the header stays a bare `Bearer` rather than naming a location with no route.
375
+ - **`resourceMetadataUrl`** — the URL a `401` advertises as `WWW-Authenticate: Bearer resource_metadata="<url>"` (RFC 9728) instead of a bare `Bearer`, pointing MCP clients at the protected-resource metadata document. **You normally do not set it**: when the document is served — i.e. both `resourceServerUrl` and `authorizationServerUrl` are configured — it defaults to the RFC 9728 location this router serves it at, so the header and the routes cannot drift apart. When the document is not served, the header stays a bare `Bearer` rather than naming a location with no route. The field exists for the one configuration where this router deliberately does not serve the document — an `oauthServer()` in the same deployment already answers that path, so this router is mounted without `resourceServerUrl`/`authorizationServerUrl` to avoid two routers on one path, and has nothing to derive from. Compute the value with `protectedResourceMetadataUrl` from [`@ttoss/auth-core`](https://ttoss.dev/docs/modules/packages/auth-core) rather than typing it, so both halves apply the same §3.1 rule.
376
376
 
377
377
  ```typescript
378
378
  createMcpRouter(mcpServer, {
@@ -503,7 +503,7 @@ Creates a Koa router configured to handle MCP protocol requests.
503
503
  - `auth.requiredScopes` — Router-level scope guard; returns 403 if any scope is missing
504
504
  - `auth.resourceServerUrl` + `auth.authorizationServerUrl` — Enable the protected-resource metadata document, served at both `/.well-known/oauth-protected-resource` and the RFC 9728 path-derived `/.well-known/oauth-protected-resource<path>`; the metadata `resource` is set to `resourceServerUrl + path` so clients following `resource` land on the actual MCP endpoint
505
505
  - `auth.publicMethods` — JSON-RPC methods that bypass verification (default `['initialize', 'tools/list']`)
506
- - `auth.resourceMetadataUrl` — URL advertised in the RFC 9728 `WWW-Authenticate: Bearer resource_metadata="…"` header on a 401. Defaults to the location derived from `resourceServerUrl` + `path` (the one this router serves), so the header cannot drift from the routes; set it only to point at a document served elsewhere
506
+ - `auth.resourceMetadataUrl` — URL advertised in the RFC 9728 `WWW-Authenticate: Bearer resource_metadata="…"` header on a 401. Defaults to the location derived from `resourceServerUrl` + `path` (the one this router serves), so the header cannot drift from the routes; set it only when a separate `oauthServer()` serves the document and this router is mounted without `resourceServerUrl`/`authorizationServerUrl`
507
507
  - `auth.resourceIndicator` — Expected `aud` value(s) (RFC 8707); rejects tokens minted for a different resource. See [Resource indicator validation](#resource-indicator-validation-rfc-8707)
508
508
 
509
509
  **Returns:** `Router` — Koa router instance
package/dist/index.d.cts CHANGED
@@ -909,9 +909,28 @@ interface McpAuthOptions {
909
909
  * drift from the routes. The default applies only when the document is
910
910
  * actually served (both `resourceServerUrl` and `authorizationServerUrl`
911
911
  * set); otherwise the header stays a bare `Bearer` rather than advertising a
912
- * location with no route. Set it only to point at a document served
913
- * elsewhere; a hand-written value that names a location nothing serves fails
914
- * discovery silently.
912
+ * location with no route.
913
+ *
914
+ * **Leave it unset when this router serves the document.** It exists for the
915
+ * one configuration where that is deliberately not the case: an
916
+ * authorization server in the same deployment (`oauthServer({ resource })`)
917
+ * already answers `/.well-known/oauth-protected-resource`, so mounting this
918
+ * router with `resourceServerUrl` + `authorizationServerUrl` too would put
919
+ * two routers on one path. Omit both there and set this instead — without
920
+ * it the `401` is a bare `Bearer`, which never starts a client's discovery.
921
+ *
922
+ * Derive the value rather than typing it: `protectedResourceMetadataUrl`
923
+ * from `@ttoss/auth-core` applies the same RFC 9728 §3.1 rule the serving
924
+ * side does. A hand-written value that names a location nothing serves
925
+ * fails discovery silently.
926
+ *
927
+ * @example
928
+ * ```typescript
929
+ * // Only when oauthServer (not this router) serves the document.
930
+ * resourceMetadataUrl: protectedResourceMetadataUrl({
931
+ * resource: 'https://mcp.example.com/mcp',
932
+ * }),
933
+ * ```
915
934
  */
916
935
  resourceMetadataUrl?: string;
917
936
  /**
package/dist/index.d.mts CHANGED
@@ -910,9 +910,28 @@ interface McpAuthOptions {
910
910
  * drift from the routes. The default applies only when the document is
911
911
  * actually served (both `resourceServerUrl` and `authorizationServerUrl`
912
912
  * set); otherwise the header stays a bare `Bearer` rather than advertising a
913
- * location with no route. Set it only to point at a document served
914
- * elsewhere; a hand-written value that names a location nothing serves fails
915
- * discovery silently.
913
+ * location with no route.
914
+ *
915
+ * **Leave it unset when this router serves the document.** It exists for the
916
+ * one configuration where that is deliberately not the case: an
917
+ * authorization server in the same deployment (`oauthServer({ resource })`)
918
+ * already answers `/.well-known/oauth-protected-resource`, so mounting this
919
+ * router with `resourceServerUrl` + `authorizationServerUrl` too would put
920
+ * two routers on one path. Omit both there and set this instead — without
921
+ * it the `401` is a bare `Bearer`, which never starts a client's discovery.
922
+ *
923
+ * Derive the value rather than typing it: `protectedResourceMetadataUrl`
924
+ * from `@ttoss/auth-core` applies the same RFC 9728 §3.1 rule the serving
925
+ * side does. A hand-written value that names a location nothing serves
926
+ * fails discovery silently.
927
+ *
928
+ * @example
929
+ * ```typescript
930
+ * // Only when oauthServer (not this router) serves the document.
931
+ * resourceMetadataUrl: protectedResourceMetadataUrl({
932
+ * resource: 'https://mcp.example.com/mcp',
933
+ * }),
934
+ * ```
916
935
  */
917
936
  resourceMetadataUrl?: string;
918
937
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/http-server-mcp",
3
- "version": "0.26.1",
3
+ "version": "0.26.2",
4
4
  "description": "Model Context Protocol (MCP) server integration for @ttoss/http-server",
5
5
  "keywords": [
6
6
  "ai",