Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions pkgs/mcpx/docs/spec/conformance-matrix.md

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion pkgs/mcpx/internal/conformance/authsplit.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down Expand Up @@ -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)"
}
}
}
}
17 changes: 10 additions & 7 deletions pkgs/mcpx/internal/conformance/authsplit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
32 changes: 32 additions & 0 deletions pkgs/mcpx/internal/conformance/coverage_authz.go
Original file line number Diff line number Diff line change
@@ -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)"},
)
}
14 changes: 14 additions & 0 deletions pkgs/mcpx/internal/conformance/overrides/authorization.json
Original file line number Diff line number Diff line change
@@ -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."
}
}
6 changes: 3 additions & 3 deletions pkgs/mcpx/internal/conformance/requirements.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
58 changes: 58 additions & 0 deletions pkgs/mcpx/internal/daemon/bearer_mcp_test.go
Original file line number Diff line number Diff line change
@@ -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")
}
})
}
}
Loading