diff --git a/pkgs/mcpx/docs/spec/conformance-matrix.md b/pkgs/mcpx/docs/spec/conformance-matrix.md index a3f8700a61..ca8877fe2c 100644 --- a/pkgs/mcpx/docs/spec/conformance-matrix.md +++ b/pkgs/mcpx/docs/spec/conformance-matrix.md @@ -2,7 +2,7 @@ Generated by `internal/conformance` (`MCPX_UPDATE_MATRIX=1 go test ./internal/conformance -run TestMatrix`); do not edit. -Generated from inputs `e5d2f9202f0b998f` (sha256 of docs/spec/requirements.md, internal/conformance/overrides/*.json, internal/conformance/coverage*.go, internal/conformance/authsplit.json). `TestMatrix` regenerates this file and fails when it differs, so it describes the tree it is committed in. +Generated from inputs `10b53243a701a063` (sha256 of docs/spec/requirements.md, internal/conformance/overrides/*.json, internal/conformance/coverage*.go, internal/conformance/authsplit.json). `TestMatrix` regenerates this file and fails when it differs, so it describes the tree it is committed in. Every normative requirement of every revision (catalogue: `docs/spec/requirements.md`), for mcpx as a server and as a client. A requirement is *tested* when a named test verifies it in that revision, *n/a* when it does not bind mcpx in that role, and a *gap* when it binds mcpx and mcpx does not meet it yet, with the issue that tracks it. Run exactly the covering tests with `go run ./internal/conformance/cmd/covering`. @@ -34,8 +34,8 @@ Every normative requirement of every revision (catalogue: `docs/spec/requirement | 2025-03-26 | client | SHOULD NOT | 2 | 1 | 1 | 0 | 3 | | 2025-03-26 | client | MAY | 15 | 15 | 0 | 0 | 22 | | 2025-03-26 | client | other | 7 | 7 | 0 | 0 | 5 | -| 2025-06-18 | server | MUST | 52 | 51 | 1 | 0 | 49 | -| 2025-06-18 | server | MUST NOT | 10 | 9 | 1 | 0 | 8 | +| 2025-06-18 | server | MUST | 53 | 52 | 1 | 0 | 48 | +| 2025-06-18 | server | MUST NOT | 10 | 10 | 0 | 0 | 8 | | 2025-06-18 | server | SHOULD | 48 | 47 | 1 | 0 | 67 | | 2025-06-18 | server | SHOULD NOT | 4 | 3 | 1 | 0 | 1 | | 2025-06-18 | server | MAY | 15 | 15 | 0 | 0 | 20 | @@ -46,8 +46,8 @@ Every normative requirement of every revision (catalogue: `docs/spec/requirement | 2025-06-18 | client | SHOULD NOT | 2 | 1 | 1 | 0 | 3 | | 2025-06-18 | client | MAY | 13 | 13 | 0 | 0 | 22 | | 2025-06-18 | client | other | 10 | 8 | 2 | 0 | 8 | -| 2025-11-25 | server | MUST | 102 | 99 | 3 | 0 | 78 | -| 2025-11-25 | server | MUST NOT | 22 | 19 | 3 | 0 | 13 | +| 2025-11-25 | server | MUST | 103 | 100 | 3 | 0 | 77 | +| 2025-11-25 | server | MUST NOT | 22 | 20 | 2 | 0 | 13 | | 2025-11-25 | server | SHOULD | 73 | 70 | 3 | 0 | 86 | | 2025-11-25 | server | SHOULD NOT | 11 | 10 | 1 | 0 | 3 | | 2025-11-25 | server | MAY | 25 | 25 | 0 | 0 | 30 | @@ -58,8 +58,8 @@ Every normative requirement of every revision (catalogue: `docs/spec/requirement | 2025-11-25 | client | SHOULD NOT | 5 | 4 | 1 | 0 | 9 | | 2025-11-25 | client | MAY | 17 | 17 | 0 | 0 | 38 | | 2025-11-25 | client | other | 13 | 11 | 2 | 0 | 8 | -| 2026-07-28 | server | MUST | 113 | 110 | 3 | 0 | 111 | -| 2026-07-28 | server | MUST NOT | 44 | 42 | 2 | 0 | 20 | +| 2026-07-28 | server | MUST | 114 | 111 | 3 | 0 | 110 | +| 2026-07-28 | server | MUST NOT | 44 | 43 | 1 | 0 | 20 | | 2026-07-28 | server | SHOULD | 69 | 65 | 4 | 0 | 91 | | 2026-07-28 | server | SHOULD NOT | 11 | 10 | 1 | 0 | 9 | | 2026-07-28 | server | MAY | 29 | 29 | 0 | 0 | 32 | @@ -403,7 +403,7 @@ Every normative requirement of every revision (catalogue: `docs/spec/requirement | [streamable-http-auth-discovery-version-header](https://modelcontextprotocol.io/specification/2025-03-26/basic/authorization#server-metadata-discovery-headers) | SHOULD | client | n/a: addresses the other side | n/a: no OAuth | | [authz-optional](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#protocol-requirements) | OPTIONAL | both | n/a: optional feature mcpx does not implement | n/a: optional feature mcpx does not implement | | [authz-http-should-conform](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#protocol-requirements) | SHOULD | both | n/a: optional feature mcpx does not implement | n/a: optional feature mcpx does not implement | -| [authz-stdio-use-environment](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#protocol-requirements) | SHOULD NOT | both | **gap** not implemented: #1975 | **gap** not implemented: #1950 | +| [authz-stdio-use-environment](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#protocol-requirements) | SHOULD NOT | both | **gap** #1950: the merged #1975 bearer work (PR #2711) gates the HTTP surface only; the `env` auth type retrieves credentials from the environment for stdio children (mcpauth) but no test traces that retrieval into a stdio child end to end, so the server-side stdio row is not yet bound -- repointed from closed #1975 to live #1950 (task 14860) | **gap** not implemented: #1950 | | [authz-alt-transport-best-practice](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#protocol-requirements) | MUST | both | n/a: catalogue marks it n/a | n/a: catalogue marks it n/a | | [authz-implement-oauth21](https://modelcontextprotocol.io/specification/2025-03-26/basic/authorization#overview) | MUST | both | n/a: optional feature mcpx does not implement | n/a: optional feature mcpx does not implement | | [authz-dcr-should](https://modelcontextprotocol.io/specification/2025-06-18/basic/authorization#dynamic-client-registration) | SHOULD | both | n/a: optional feature mcpx does not implement | n/a: optional feature mcpx does not implement | @@ -792,7 +792,7 @@ Every normative requirement of every revision (catalogue: `docs/spec/requirement | [authorization-custom-auth-may](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#auth) | MAY | both | n/a: catalogue marks it n/a | n/a: catalogue marks it n/a | | [authz-optional](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#protocol-requirements) | OPTIONAL | both | n/a: optional feature mcpx does not implement | n/a: optional feature mcpx does not implement | | [authz-http-should-conform](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#protocol-requirements) | SHOULD | both | n/a: optional feature mcpx does not implement | n/a: optional feature mcpx does not implement | -| [authz-stdio-use-environment](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#protocol-requirements) | SHOULD NOT | both | **gap** not implemented: #1975 | **gap** not implemented: #1950 | +| [authz-stdio-use-environment](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#protocol-requirements) | SHOULD NOT | both | **gap** #1950: the merged #1975 bearer work (PR #2711) gates the HTTP surface only; the `env` auth type retrieves credentials from the environment for stdio children (mcpauth) but no test traces that retrieval into a stdio child end to end, so the server-side stdio row is not yet bound -- repointed from closed #1975 to live #1950 (task 14860) | **gap** not implemented: #1950 | | [authz-alt-transport-best-practice](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#protocol-requirements) | MUST | both | n/a: catalogue marks it n/a | n/a: catalogue marks it n/a | | [authz-as-implements-oauth21](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#overview) | MUST | auth-server | n/a: addresses the other side | n/a: addresses the other side | | [authz-dcr-should](https://modelcontextprotocol.io/specification/2025-06-18/basic/authorization#dynamic-client-registration) | SHOULD | both | n/a: optional feature mcpx does not implement | n/a: optional feature mcpx does not implement | @@ -802,8 +802,8 @@ Every normative requirement of every revision (catalogue: `docs/spec/requirement | [authz-server-validates-token](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#token-handling) | MUST | server | n/a: optional feature mcpx does not implement | n/a: addresses the other side | | [authz-server-validates-audience](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#token-handling) | MUST | server | n/a: optional feature mcpx does not implement | n/a: addresses the other side | | [authz-client-sends-only-own-as-tokens](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#token-handling) | MUST NOT | client | n/a: addresses the other side | **gap** not implemented: #1950 | -| [authz-accept-only-own-tokens](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#token-handling) | MUST | server | n/a: optional feature mcpx does not implement | n/a: addresses the other side | -| [authz-no-token-passthrough](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/security-considerations#access-token-privilege-restriction) | MUST NOT | server | **gap** not implemented: #1975 | n/a: addresses the other side | +| [authz-accept-only-own-tokens](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#token-handling) | MUST | server | tested: `daemon.TestMCPRejectsUnauthenticatedWhenBearerSet@all` | n/a: addresses the other side | +| [authz-no-token-passthrough](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/security-considerations#access-token-privilege-restriction) | MUST NOT | server | tested: `daemon.TestProxyKeepsUpstreamKeyWhenBearerSet@all` | n/a: addresses the other side | | [authz-error-status-codes](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#error-handling) | MUST | server | n/a: optional feature mcpx does not implement | n/a: addresses the other side | | [authz-server-prm-rfc9728](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#overview) | MUST | both | n/a: optional feature mcpx does not implement | n/a: optional feature mcpx does not implement | | [authz-prm-lists-authorization-servers](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/authorization-server-discovery#authorization-server-location) | MUST | server | n/a: optional feature mcpx does not implement | n/a: addresses the other side | @@ -1226,7 +1226,7 @@ Every normative requirement of every revision (catalogue: `docs/spec/requirement | [authorization-custom-auth-may](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#auth) | MAY | both | n/a: catalogue marks it n/a | n/a: catalogue marks it n/a | | [authz-optional](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#protocol-requirements) | OPTIONAL | both | n/a: optional feature mcpx does not implement | n/a: optional feature mcpx does not implement | | [authz-http-should-conform](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#protocol-requirements) | SHOULD | both | n/a: optional feature mcpx does not implement | n/a: optional feature mcpx does not implement | -| [authz-stdio-use-environment](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#protocol-requirements) | SHOULD NOT | both | **gap** not implemented: #1975 | **gap** not implemented: #1950 | +| [authz-stdio-use-environment](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#protocol-requirements) | SHOULD NOT | both | **gap** #1950: the merged #1975 bearer work (PR #2711) gates the HTTP surface only; the `env` auth type retrieves credentials from the environment for stdio children (mcpauth) but no test traces that retrieval into a stdio child end to end, so the server-side stdio row is not yet bound -- repointed from closed #1975 to live #1950 (task 14860) | **gap** not implemented: #1950 | | [authz-alt-transport-best-practice](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#protocol-requirements) | MUST | both | n/a: catalogue marks it n/a | n/a: catalogue marks it n/a | | [authz-as-implements-oauth21](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#overview) | MUST | auth-server | n/a: addresses the other side | n/a: addresses the other side | | [authz-dcr-may-deprecated](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/client-registration#dynamic-client-registration) | MAY | client, auth-server | n/a: addresses the other side | n/a: optional feature mcpx does not implement | @@ -1236,8 +1236,8 @@ Every normative requirement of every revision (catalogue: `docs/spec/requirement | [authz-server-validates-token](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#token-handling) | MUST | server | n/a: optional feature mcpx does not implement | n/a: addresses the other side | | [authz-server-validates-audience](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#token-handling) | MUST | server | n/a: optional feature mcpx does not implement | n/a: addresses the other side | | [authz-client-sends-only-own-as-tokens](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#token-handling) | MUST NOT | client | n/a: addresses the other side | **gap** not implemented: #1950 | -| [authz-accept-only-own-tokens](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#token-handling) | MUST | server | n/a: optional feature mcpx does not implement | n/a: addresses the other side | -| [authz-no-token-passthrough](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/security-considerations#access-token-privilege-restriction) | MUST NOT | server | **gap** not implemented: #1975 | n/a: addresses the other side | +| [authz-accept-only-own-tokens](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#token-handling) | MUST | server | tested: `daemon.TestMCPRejectsUnauthenticatedWhenBearerSet@all` | n/a: addresses the other side | +| [authz-no-token-passthrough](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/security-considerations#access-token-privilege-restriction) | MUST NOT | server | tested: `daemon.TestProxyKeepsUpstreamKeyWhenBearerSet@all` | n/a: addresses the other side | | [authz-error-status-codes](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#error-handling) | MUST | server | n/a: optional feature mcpx does not implement | n/a: addresses the other side | | [authz-server-prm-rfc9728](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#overview) | MUST | both | n/a: optional feature mcpx does not implement | n/a: optional feature mcpx does not implement | | [authz-prm-lists-authorization-servers](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/authorization-server-discovery#authorization-server-location) | MUST | server | n/a: optional feature mcpx does not implement | n/a: addresses the other side | @@ -1842,7 +1842,7 @@ Every normative requirement of every revision (catalogue: `docs/spec/requirement | [authorization-custom-auth-may](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#auth) | MAY | both | n/a: catalogue marks it n/a | n/a: catalogue marks it n/a | | [authz-optional](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#protocol-requirements) | OPTIONAL | both | n/a: optional feature mcpx does not implement | n/a: optional feature mcpx does not implement | | [authz-http-should-conform](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#protocol-requirements) | SHOULD | both | n/a: optional feature mcpx does not implement | n/a: optional feature mcpx does not implement | -| [authz-stdio-use-environment](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#protocol-requirements) | SHOULD NOT | both | **gap** not implemented: #1975 | **gap** not implemented: #1950 | +| [authz-stdio-use-environment](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#protocol-requirements) | SHOULD NOT | both | **gap** #1950: the merged #1975 bearer work (PR #2711) gates the HTTP surface only; the `env` auth type retrieves credentials from the environment for stdio children (mcpauth) but no test traces that retrieval into a stdio child end to end, so the server-side stdio row is not yet bound -- repointed from closed #1975 to live #1950 (task 14860) | **gap** not implemented: #1950 | | [authz-alt-transport-best-practice](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#protocol-requirements) | MUST | both | n/a: catalogue marks it n/a | n/a: catalogue marks it n/a | | [authz-as-implements-oauth21](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#overview) | MUST | auth-server | n/a: addresses the other side | n/a: addresses the other side | | [authz-dcr-may-deprecated](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/client-registration#dynamic-client-registration) | MAY | client, auth-server | n/a: addresses the other side | n/a: optional feature mcpx does not implement | @@ -1852,8 +1852,8 @@ Every normative requirement of every revision (catalogue: `docs/spec/requirement | [authz-server-validates-token](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#token-handling) | MUST | server | n/a: optional feature mcpx does not implement | n/a: addresses the other side | | [authz-server-validates-audience](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#token-handling) | MUST | server | n/a: optional feature mcpx does not implement | n/a: addresses the other side | | [authz-client-sends-only-own-as-tokens](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#token-handling) | MUST NOT | client | n/a: addresses the other side | **gap** not implemented: #1950 | -| [authz-accept-only-own-tokens](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#token-handling) | MUST | server | n/a: optional feature mcpx does not implement | n/a: addresses the other side | -| [authz-no-token-passthrough](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/security-considerations#access-token-privilege-restriction) | MUST NOT | server | **gap** not implemented: #1975 | n/a: addresses the other side | +| [authz-accept-only-own-tokens](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#token-handling) | MUST | server | tested: `daemon.TestMCPRejectsUnauthenticatedWhenBearerSet@all` | n/a: addresses the other side | +| [authz-no-token-passthrough](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/security-considerations#access-token-privilege-restriction) | MUST NOT | server | tested: `daemon.TestProxyKeepsUpstreamKeyWhenBearerSet@all` | n/a: addresses the other side | | [authz-error-status-codes](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#error-handling) | MUST | server | n/a: optional feature mcpx does not implement | n/a: addresses the other side | | [authz-server-prm-rfc9728](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization#overview) | MUST | both | n/a: optional feature mcpx does not implement | n/a: optional feature mcpx does not implement | | [authz-prm-lists-authorization-servers](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/authorization-server-discovery#authorization-server-location) | MUST | server | n/a: optional feature mcpx does not implement | n/a: addresses the other side | @@ -2576,9 +2576,9 @@ Every normative requirement of every revision (catalogue: `docs/spec/requirement ## Authorization rows: accepts, or requires refusal (#1972) -7 authorization rows are split per side of the wire into 8 bound row-sides: **8 permissive** and **0 validation**. A *permissive* row-side is satisfied by an interface that accepts every credential (#1950) — endpoint shape, discovery documents, registration, flows. A *validation* row-side cannot pass against such an interface: it needs a real check, named below, to refuse or challenge a credential (#1972). +8 authorization rows are split per side of the wire into 9 bound row-sides: **8 permissive** and **1 validation**. A *permissive* row-side is satisfied by an interface that accepts every credential (#1950) — endpoint shape, discovery documents, registration, flows. A *validation* row-side cannot pass against such an interface: it needs a real check, named below, to refuse or challenge a credential (#1972). -Validation row-sides per check: invalid 0, expired 0, wrong-resource 0, scope 0. Input: `internal/conformance/authsplit.json`; edits belong there, never in this file. +Validation row-sides per check: invalid 1, expired 0, wrong-resource 0, scope 0. Input: `internal/conformance/authsplit.json`; edits belong there, never in this file. | requirement | side | verdict | |---|---|---| @@ -2588,5 +2588,6 @@ Validation row-sides per check: invalid 0, expired 0, wrong-resource 0, scope 0. | authz-token-every-request | client | permissive | | authz-no-token-in-query | client | permissive | | authz-client-sends-only-own-as-tokens | client | permissive | +| authz-accept-only-own-tokens | server | validation: invalid — the #1975 bearer gate (PR #2711) accepts only the daemon's own configured token and refuses any other token with 401 on every route including /mcp (daemon.TestMCPRejectsUnauthenticatedWhenBearerSet); a shared-secret gate has no expiry, audience or scope to check, so 'invalid' is the only check it performs (task 14860) | | authz-no-token-passthrough | server | permissive | | authz-secure-token-storage | client | permissive | diff --git a/pkgs/mcpx/internal/conformance/authsplit.json b/pkgs/mcpx/internal/conformance/authsplit.json index 26f5c0960e..31a1928050 100644 --- a/pkgs/mcpx/internal/conformance/authsplit.json +++ b/pkgs/mcpx/internal/conformance/authsplit.json @@ -1,6 +1,11 @@ { "about": "The authorization rows split along accepts-vs-refuses (#1972): a permissive interface (#1950) satisfies a 'permissive' row-side; a 'validation' row-side needs a real check, named here. Checks: invalid, expired, wrong-resource, scope. Only catalogue-bound sides are judged: a side the catalogue marks n/a carries no verdict here (LoadAuthSplit refuses one) \u2014 since #2619 honoured each row's not-implemented-by-choice note (#1950 decision), most authorization sides are n/a and the validation target moved to the #1975 /mcp resource-server work.", - "checks": ["invalid", "expired", "wrong-resource", "scope"], + "checks": [ + "invalid", + "expired", + "wrong-resource", + "scope" + ], "rows": { "authz-bearer-header": { "client": { @@ -39,6 +44,15 @@ "client": { "verdict": "permissive" } + }, + "authz-accept-only-own-tokens": { + "server": { + "verdict": "validation", + "checks": [ + "invalid" + ], + "why": "the #1975 bearer gate (PR #2711) accepts only the daemon's own configured token and refuses any other token with 401 on every route including /mcp (daemon.TestMCPRejectsUnauthenticatedWhenBearerSet); a shared-secret gate has no expiry, audience or scope to check, so 'invalid' is the only check it performs (task 14860)" + } } } } diff --git a/pkgs/mcpx/internal/conformance/authsplit_test.go b/pkgs/mcpx/internal/conformance/authsplit_test.go index b75656e443..e03cf48a2f 100644 --- a/pkgs/mcpx/internal/conformance/authsplit_test.go +++ b/pkgs/mcpx/internal/conformance/authsplit_test.go @@ -25,15 +25,18 @@ func TestAuthSplit(t *testing.T) { // not-implemented-by-choice note (the #1950 decision: client OAuth // deferred, /mcp resource server planned at #1975), which marked most // authorization sides n/a -- including every validation side. The split - // therefore covers just the 8 bound sides, all permissive, and #1972's - // validation target lives with the #1975 work, not here (#2695). - if c.Rows != 7 || c.Sides != 8 { - t.Errorf("split covers %d rows / %d row-sides, want 7 rows / 8 row-sides", c.Rows, c.Sides) + // therefore covered just the 8 bound sides, all permissive, and #1972's + // validation target lived with the #1975 work, not here (#2695). + // The #1975 bearer gate has since merged (PR #2711), and #1950's + // remainder (task 14860) bound its first validation side: + // authz-accept-only-own-tokens (server) performs the "invalid" check. + if c.Rows != 8 || c.Sides != 9 { + t.Errorf("split covers %d rows / %d row-sides, want 8 rows / 9 row-sides", c.Rows, c.Sides) } - if c.Permissive != 8 || c.Validation != 0 { - t.Errorf("split is %d permissive / %d validation, want 8 / 0", c.Permissive, c.Validation) + if c.Permissive != 8 || c.Validation != 1 { + t.Errorf("split is %d permissive / %d validation, want 8 / 1", c.Permissive, c.Validation) } - for check, want := range map[string]int{"invalid": 0, "expired": 0, "wrong-resource": 0, "scope": 0} { + for check, want := range map[string]int{"invalid": 1, "expired": 0, "wrong-resource": 0, "scope": 0} { if c.PerCheck[check] != want { t.Errorf("%d validation row-sides need %q, want %d", c.PerCheck[check], check, want) } diff --git a/pkgs/mcpx/internal/conformance/coverage_authz.go b/pkgs/mcpx/internal/conformance/coverage_authz.go new file mode 100644 index 0000000000..7a98927aa9 --- /dev/null +++ b/pkgs/mcpx/internal/conformance/coverage_authz.go @@ -0,0 +1,32 @@ +package conformance + +// Authorization rows judged against the merged #1975 bearer work +// (PR #2711) for #1950's remainder (task 14860). The overrides in +// overrides/authorization.json re-judge these server sides to +// "applies" so the bindings and the recorded gap below -- not the +// catalogue's blanket pointer at closed #1975 -- decide the cells. +func init() { + register( + // The token the client presented to the daemon is never + // passed through: the upstream gets the configured provider + // key instead. + S("authz-no-token-passthrough", + "daemon.TestProxyKeepsUpstreamKeyWhenBearerSet@all"), + // The daemon accepts only its own configured bearer token, + // on the /mcp surface as on every route; anything else is a + // 401 before the MCP handler runs. + S("authz-accept-only-own-tokens", + "daemon.TestMCPRejectsUnauthenticatedWhenBearerSet@all"), + ) + registerGaps( + // Judged NOT satisfied by the bearer work: PR #2711 gates + // the HTTP surface and does not touch the stdio credential + // path. mcpauth's `env` auth type retrieves credentials + // from the environment for stdio children, but no test + // traces that retrieval into a stdio child's environment + // end to end, so the server side stays a gap -- repointed + // from closed #1975 to live #1950 with this reason. + Gap{ID: "authz-stdio-use-environment", Side: Server, Issue: "#1950", + Why: "the merged #1975 bearer work (PR #2711) gates the HTTP surface only; the `env` auth type retrieves credentials from the environment for stdio children (mcpauth) but no test traces that retrieval into a stdio child end to end, so the server-side stdio row is not yet bound -- repointed from closed #1975 to live #1950 (task 14860)"}, + ) +} diff --git a/pkgs/mcpx/internal/conformance/overrides/authorization.json b/pkgs/mcpx/internal/conformance/overrides/authorization.json new file mode 100644 index 0000000000..3392eeb666 --- /dev/null +++ b/pkgs/mcpx/internal/conformance/overrides/authorization.json @@ -0,0 +1,14 @@ +{ + "authz-no-token-passthrough": { + "server": "applies", + "why": "#1950 remainder (task 14860): the merged #1975 bearer work (PR #2711) is traced end to end by daemon.TestProxyKeepsUpstreamKeyWhenBearerSet -- the upstream receives the configured provider key, never the token the client presented to the daemon. Bound in coverage_authz.go." + }, + "authz-accept-only-own-tokens": { + "server": "applies", + "why": "#1950 remainder (task 14860): since the #1975 bearer gate (PR #2711) the daemon accepts exactly one token -- its own configured bearer token -- on every route including /mcp, and refuses every other token with 401; daemon.TestMCPRejectsUnauthenticatedWhenBearerSet is the conformance scenario. The catalogue note's '(accepts no tokens)' predates the gate. OAuth-issued-token validation remains not-implemented-by-choice (authz-server-validates-token is a different row and is untouched)." + }, + "authz-stdio-use-environment": { + "server": "applies", + "why": "#1950 remainder (task 14860): re-judged so the recorded gap in coverage_authz.go (pointing at live #1950, with the reason) renders instead of the blanket pointer at closed #1975. The client side is untouched and keeps the #1950 blanket gap per the recorded deferral." + } +} diff --git a/pkgs/mcpx/internal/conformance/requirements.json b/pkgs/mcpx/internal/conformance/requirements.json index 06cabea4f1..26b07d2120 100644 --- a/pkgs/mcpx/internal/conformance/requirements.json +++ b/pkgs/mcpx/internal/conformance/requirements.json @@ -5624,7 +5624,7 @@ "quote": "\"Implementations using an STDIO transport **SHOULD NOT** follow this specification, and instead retrieve credentials from the environment.\"", "applicability": { "client": "not-implemented:#1950", - "server": "not-implemented:#1975" + "server": "applies" }, "notes": { "client": "yes — `env` auth type for stdio children", @@ -5972,7 +5972,7 @@ "quote": "\"MCP servers **MUST** only accept tokens that are valid for use with their own resources. MCP servers **MUST NOT** accept or transit any other tokens.\"", "applicability": { "client": "n/a:addresses the other side", - "server": "n/a:optional feature mcpx does not implement" + "server": "applies" }, "notes": { "client": "n/a", @@ -5993,7 +5993,7 @@ "quote": "\"The MCP server **MUST NOT** pass through the token it received from the MCP client.\"", "applicability": { "client": "n/a:addresses the other side", - "server": "not-implemented:#1975" + "server": "applies" }, "notes": { "client": "n/a", diff --git a/pkgs/mcpx/internal/daemon/bearer_mcp_test.go b/pkgs/mcpx/internal/daemon/bearer_mcp_test.go new file mode 100644 index 0000000000..54d52387f4 --- /dev/null +++ b/pkgs/mcpx/internal/daemon/bearer_mcp_test.go @@ -0,0 +1,58 @@ +package daemon + +import ( + "net/http" + "net/http/httptest" + "strings" + "testing" +) + +// #1950 conformance scenario (bound in internal/conformance as +// authz-accept-only-own-tokens): on a bearer-configured transport the +// daemon's own MCP surface rejects unauthenticated requests. The gate +// is requireBearer over the whole handler chain (bearer.go: every /v1 +// and /mcp route); TestRequireBearer pins the gate on a /v1 route, so +// this drives the real Handler() mux with a stub MCP handler mounted +// the way production mounts it, and the /mcp route itself answers. +// Fixture tokens only -- never a real credential. +func TestMCPRejectsUnauthenticatedWhenBearerSet(t *testing.T) { + cases := []struct { + name string + set string + header string + want int + reached bool + }{ + {"set, no header", fixtureToken, "", http.StatusUnauthorized, false}, + {"set, wrong token", fixtureToken, "Bearer wrong-token-fixture-0123456789", http.StatusUnauthorized, false}, + {"set, wrong scheme", fixtureToken, "Basic " + fixtureToken, http.StatusUnauthorized, false}, + {"set, correct token", fixtureToken, "Bearer " + fixtureToken, http.StatusOK, true}, + {"unset, no header", "", "", http.StatusOK, true}, + {"unset, stray header ignored", "", "Bearer stray-fixture-0123456789abcd", http.StatusOK, true}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + reached := false + mcp := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + reached = true + w.WriteHeader(http.StatusOK) + }) + s := &Server{set: bearerSet(t, tc.set), MCP: mcp} + req := httptest.NewRequest(http.MethodPost, "/mcp", strings.NewReader(`{"jsonrpc":"2.0","id":1,"method":"ping"}`)) + if tc.header != "" { + req.Header.Set("Authorization", tc.header) + } + rec := httptest.NewRecorder() + s.Handler().ServeHTTP(rec, req) + if rec.Code != tc.want { + t.Fatalf("status %d, want %d (body %q)", rec.Code, tc.want, rec.Body.String()) + } + if reached != tc.reached { + t.Errorf("MCP handler reached = %v, want %v", reached, tc.reached) + } + if tc.want == http.StatusUnauthorized && rec.Header().Get("WWW-Authenticate") != "Bearer" { + t.Errorf("401 without a WWW-Authenticate: Bearer header") + } + }) + } +}