diff --git a/pkgs/mcpx/docs/spec/conformance-matrix.md b/pkgs/mcpx/docs/spec/conformance-matrix.md index 32b5497aca..d3b741b507 100644 --- a/pkgs/mcpx/docs/spec/conformance-matrix.md +++ b/pkgs/mcpx/docs/spec/conformance-matrix.md @@ -684,8 +684,8 @@ Every normative requirement of every revision (catalogue: `docs/spec/requirement | [tools-declare-capability](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#capabilities) | MUST | server | tested: `conformance.TestFeaturesServer/2025-03-26/tools/tools-declare-capability` | n/a: addresses the other side | | [tools-list-changed-means-emit](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#capabilities) | (definition) | server | tested: `conformance.TestFeaturesServer/2025-03-26/tools/tools-list-changed-means-emit` | n/a: addresses the other side | | [tools-list-changed-notify](https://modelcontextprotocol.io/specification/2025-11-25/server/tools#list-changed-notification) | SHOULD | server | tested: `conformance.TestFeaturesServer/2025-03-26/tools/tools-list-changed-notify` | n/a: addresses the other side | -| [tools-annotations-untrusted](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#tool) | MUST | client | n/a: addresses the other side | **gap** #257: destructiveHint from any upstream decides whether a call is confirmed; a false hint (or readOnlyHint true) is trusted | -| [tools-annotations-hints-no-decisions](https://modelcontextprotocol.io/specification/2026-07-28/schema#toolannotations) | should (lowercase, schema) | client | n/a: addresses the other side | **gap** #257: the consumer confirmDestructive gate is decided by an untrusted upstream annotation | +| [tools-annotations-untrusted](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#tool) | MUST | client | n/a: addresses the other side | tested: `daemon.TestAnnotationClearsCallOnlyForLocallyDeclaredServers@2026-07-28` | +| [tools-annotations-hints-no-decisions](https://modelcontextprotocol.io/specification/2026-07-28/schema#toolannotations) | should (lowercase, schema) | client | n/a: addresses the other side | tested: `daemon.TestAnnotationClearsCallOnlyForLocallyDeclaredServers@2026-07-28` | | [tools-result-iserror-for-tool-errors](https://modelcontextprotocol.io/specification/2026-07-28/schema#calltoolresult) | SHOULD | server | tested: `conformance.TestFeaturesServer/2025-03-26/tools/tools-result-iserror-for-tool-errors` | n/a: addresses the other side | | [tools-result-lookup-errors-protocol](https://modelcontextprotocol.io/specification/2026-07-28/schema#calltoolresult) | should (lowercase) | server | tested: `conformance.TestFeaturesServer/2025-03-26/tools/tools-result-lookup-errors-protocol` | n/a: addresses the other side | | [tools-error-unknown-tool-protocol](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#error-handling) | (classification) | server | tested: `conformance.TestFeaturesServer/2025-03-26/tools/tools-error-unknown-tool-protocol` | n/a: addresses the other side | @@ -1105,8 +1105,8 @@ Every normative requirement of every revision (catalogue: `docs/spec/requirement | [tools-declare-capability](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#capabilities) | MUST | server | tested: `conformance.TestFeaturesServer/2025-06-18/tools/tools-declare-capability` | n/a: addresses the other side | | [tools-list-changed-means-emit](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#capabilities) | (definition) | server | tested: `conformance.TestFeaturesServer/2025-06-18/tools/tools-list-changed-means-emit` | n/a: addresses the other side | | [tools-list-changed-notify](https://modelcontextprotocol.io/specification/2025-11-25/server/tools#list-changed-notification) | SHOULD | server | tested: `conformance.TestFeaturesServer/2025-06-18/tools/tools-list-changed-notify` | n/a: addresses the other side | -| [tools-annotations-untrusted](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#tool) | MUST | client | n/a: addresses the other side | **gap** #257: destructiveHint from any upstream decides whether a call is confirmed; a false hint (or readOnlyHint true) is trusted | -| [tools-annotations-hints-no-decisions](https://modelcontextprotocol.io/specification/2026-07-28/schema#toolannotations) | should (lowercase, schema) | client | n/a: addresses the other side | **gap** #257: the consumer confirmDestructive gate is decided by an untrusted upstream annotation | +| [tools-annotations-untrusted](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#tool) | MUST | client | n/a: addresses the other side | tested: `daemon.TestAnnotationClearsCallOnlyForLocallyDeclaredServers@2026-07-28` | +| [tools-annotations-hints-no-decisions](https://modelcontextprotocol.io/specification/2026-07-28/schema#toolannotations) | should (lowercase, schema) | client | n/a: addresses the other side | tested: `daemon.TestAnnotationClearsCallOnlyForLocallyDeclaredServers@2026-07-28` | | [tools-result-iserror-for-tool-errors](https://modelcontextprotocol.io/specification/2026-07-28/schema#calltoolresult) | SHOULD | server | tested: `conformance.TestFeaturesServer/2025-06-18/tools/tools-result-iserror-for-tool-errors` | n/a: addresses the other side | | [tools-result-lookup-errors-protocol](https://modelcontextprotocol.io/specification/2026-07-28/schema#calltoolresult) | should (lowercase) | server | tested: `conformance.TestFeaturesServer/2025-06-18/tools/tools-result-lookup-errors-protocol` | n/a: addresses the other side | | [tools-error-unknown-tool-protocol](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#error-handling) | (classification) | server | tested: `conformance.TestFeaturesServer/2025-06-18/tools/tools-error-unknown-tool-protocol` | n/a: addresses the other side | @@ -1703,8 +1703,8 @@ Every normative requirement of every revision (catalogue: `docs/spec/requirement | [tools-declare-capability](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#capabilities) | MUST | server | tested: `conformance.TestFeaturesServer/2025-11-25/tools/tools-declare-capability` | n/a: addresses the other side | | [tools-list-changed-means-emit](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#capabilities) | (definition) | server | tested: `conformance.TestFeaturesServer/2025-11-25/tools/tools-list-changed-means-emit` | n/a: addresses the other side | | [tools-list-changed-notify](https://modelcontextprotocol.io/specification/2025-11-25/server/tools#list-changed-notification) | SHOULD | server | tested: `conformance.TestFeaturesServer/2025-11-25/tools/tools-list-changed-notify` | n/a: addresses the other side | -| [tools-annotations-untrusted](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#tool) | MUST | client | n/a: addresses the other side | **gap** #257: destructiveHint from any upstream decides whether a call is confirmed; a false hint (or readOnlyHint true) is trusted | -| [tools-annotations-hints-no-decisions](https://modelcontextprotocol.io/specification/2026-07-28/schema#toolannotations) | should (lowercase, schema) | client | n/a: addresses the other side | **gap** #257: the consumer confirmDestructive gate is decided by an untrusted upstream annotation | +| [tools-annotations-untrusted](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#tool) | MUST | client | n/a: addresses the other side | tested: `daemon.TestAnnotationClearsCallOnlyForLocallyDeclaredServers@2026-07-28` | +| [tools-annotations-hints-no-decisions](https://modelcontextprotocol.io/specification/2026-07-28/schema#toolannotations) | should (lowercase, schema) | client | n/a: addresses the other side | tested: `daemon.TestAnnotationClearsCallOnlyForLocallyDeclaredServers@2026-07-28` | | [tools-inputschema-no-params-recommended](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#tool) | RECOMMENDED | server | tested: `conformance.TestFeaturesServer/2025-11-25/tools/tools-inputschema-no-params-recommended` | n/a: addresses the other side | | [tools-name-length](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#tool-names) | SHOULD | server | tested: `conformance.TestFeaturesServer/2025-11-25/tools/tools-name-length` | n/a: addresses the other side | | [tools-name-case-sensitive](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#tool-names) | SHOULD | both | tested: `conformance.TestFeaturesServer/2025-11-25/tools/tools-name-case-sensitive` | tested: `conformance.TestFeaturesClient/2025-11-25/tools/tools-name-case-sensitive` | @@ -2407,8 +2407,8 @@ Every normative requirement of every revision (catalogue: `docs/spec/requirement | [tools-list-may-vary-by-auth](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#capabilities) | MAY | server | n/a: optional feature mcpx does not implement | n/a: addresses the other side | | [tools-list-may-be-empty-change](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#capabilities) | MAY | server | tested: `conformance.TestFeaturesServer/2026-07-28/tools/tools-list-may-be-empty-change` | n/a: addresses the other side | | [tools-list-deterministic-order](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#capabilities) | SHOULD | server | tested: `conformance.TestFeaturesServer/2026-07-28/tools/tools-list-deterministic-order` | n/a: addresses the other side | -| [tools-annotations-untrusted](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#tool) | MUST | client | n/a: addresses the other side | **gap** #257: destructiveHint from any upstream decides whether a call is confirmed; a false hint (or readOnlyHint true) is trusted | -| [tools-annotations-hints-no-decisions](https://modelcontextprotocol.io/specification/2026-07-28/schema#toolannotations) | should (lowercase, schema) | client | n/a: addresses the other side | **gap** #257: the consumer confirmDestructive gate is decided by an untrusted upstream annotation | +| [tools-annotations-untrusted](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#tool) | MUST | client | n/a: addresses the other side | tested: `daemon.TestAnnotationClearsCallOnlyForLocallyDeclaredServers@2026-07-28` | +| [tools-annotations-hints-no-decisions](https://modelcontextprotocol.io/specification/2026-07-28/schema#toolannotations) | should (lowercase, schema) | client | n/a: addresses the other side | tested: `daemon.TestAnnotationClearsCallOnlyForLocallyDeclaredServers@2026-07-28` | | [tools-inputschema-no-params-recommended](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#tool) | RECOMMENDED | server | tested: `conformance.TestFeaturesServer/2026-07-28/tools/tools-inputschema-no-params-recommended` | n/a: addresses the other side | | [tools-x-mcp-header-may](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#tool) | MAY | server | n/a: optional feature mcpx does not implement | n/a: addresses the other side | | [tools-x-mcp-header-not-empty](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#x-mcp-header) | MUST NOT | server | n/a: no tool mcpx serves declares an x-mcp-header parameter | n/a: addresses the other side | diff --git a/pkgs/mcpx/internal/api/boundaries.go b/pkgs/mcpx/internal/api/boundaries.go index f5714608ba..083e33fc30 100644 --- a/pkgs/mcpx/internal/api/boundaries.go +++ b/pkgs/mcpx/internal/api/boundaries.go @@ -66,7 +66,8 @@ func Boundaries() []Boundary { { Name: "elicit.confirmDestructive", Declares: "with it on, a call to a tool that may be destructive (annotated " + - "destructiveHint, or unannotated) does not run unless somebody confirms it", + "destructiveHint, or unannotated) does not run unless somebody confirms it; " + + "a remote server's annotation never clears the call (#2191)", State: Enforced, Refusals: []string{ "TestADestructiveCallIsRefusedWhenNobodyConfirms", diff --git a/pkgs/mcpx/internal/conformance/coverage_features.go b/pkgs/mcpx/internal/conformance/coverage_features.go index a3afca33be..6969a62bd0 100644 --- a/pkgs/mcpx/internal/conformance/coverage_features.go +++ b/pkgs/mcpx/internal/conformance/coverage_features.go @@ -19,6 +19,11 @@ func init() { C("tools-aggregator-disambiguate", "e2e.TestDuplicateNamespaceIsRejected@2026-07-28", "e2e.TestAliasExposesASubsetOfTheSameServer@2026-07-28"), C("tools-aggregator-not-by-servername", "e2e.TestDuplicateNamespaceIsRejected@2026-07-28"), + // Annotation trust (#2191): the confirmDestructive gate takes + // annotations at face value only from a locally declared (stdio) + // server; a remote upstream's hints never clear a call. + C("tools-annotations-untrusted", "daemon.TestAnnotationClearsCallOnlyForLocallyDeclaredServers@2024-11-05,2025-03-26,2025-06-18,2025-11-25,2026-07-28"), + C("tools-annotations-hints-no-decisions", "daemon.TestAnnotationClearsCallOnlyForLocallyDeclaredServers@2024-11-05,2025-03-26,2025-06-18,2025-11-25,2026-07-28"), SReq("conformance.TestFeaturesServer", "resources-sec-binary-encoded", "tools-declare-capability", @@ -102,8 +107,6 @@ func init() { registerGaps( Gap{ID: "resources-annotations-defs", Side: Client, Issue: "#207", Why: "mcpclient.Resource has no annotations field; they are dropped on parse"}, Gap{ID: "tools-display-name-precedence", Side: Client, Issue: "#207", Why: "tool title and annotations.title are carried but nothing that displays a tool uses them"}, - Gap{ID: "tools-annotations-untrusted", Side: Client, Issue: "#257", Why: "destructiveHint from any upstream decides whether a call is confirmed; a false hint (or readOnlyHint true) is trusted"}, - Gap{ID: "tools-annotations-hints-no-decisions", Side: Client, Issue: "#257", Why: "the consumer confirmDestructive gate is decided by an untrusted upstream annotation"}, Gap{ID: "prompts-validate-io", Side: Client, Issue: "#257", Why: "an upstream prompts/get result is passed on unvalidated"}, ) } diff --git a/pkgs/mcpx/internal/daemon/consumer.go b/pkgs/mcpx/internal/daemon/consumer.go index 93852cc0e7..bbfe1df68a 100644 --- a/pkgs/mcpx/internal/daemon/consumer.go +++ b/pkgs/mcpx/internal/daemon/consumer.go @@ -404,7 +404,7 @@ func (r *Registry) confirmDestructive(ctx context.Context, p *pool.Pool, tool st break } } - if found == nil || !destructiveHint(found.Annotations) { + if found == nil || annotationClearsCall(p, found) { return nil } path := p.Namespace() + "." + tool @@ -412,7 +412,7 @@ func (r *Registry) confirmDestructive(ctx context.Context, p *pool.Pool, tool st Server: p.Name(), Tool: tool, Session: cc.SessionID, - Message: fmt.Sprintf("%s.%s may be destructive: its server does not mark it read-only or non-destructive. Let this call proceed?", + Message: fmt.Sprintf("%s.%s may be destructive: no trusted annotation clears this call. Let this call proceed?", p.Namespace(), tool), Default: "false", TTL: r.consumer.AskTimeout, @@ -436,6 +436,28 @@ func (r *Registry) confirmDestructive(ctx context.Context, p *pool.Pool, tool st return nil } +// annotationClearsCall reports whether a tool's annotations may clear +// its call without asking. Tool annotations are hints, not decisions +// (#2191): the specification forbids basing a security decision on +// annotations from an untrusted server, and mcpx establishes trust in +// exactly one way today -- the server is one the user declared locally, +// a stdio command from their own configuration, whose annotations are +// part of the interface they chose to run. A remote upstream's +// readOnlyHint or destructiveHint:false is worth nothing here: a lying +// or compromised server could suppress every confirmation by claiming +// its tools are harmless, so for a remote server the annotation can +// never be the deciding input and the call is confirmed when in doubt. +func annotationClearsCall(p *pool.Pool, found *mcpclient.Tool) bool { + if p == nil || found == nil { + return false + } + cfg := p.Config() + if cfg == nil || !cfg.Stdio() { + return false + } + return !destructiveHint(found.Annotations) +} + // destructiveHint reads the one annotation mcpx acts on, with the // specification's defaults: destructiveHint is true when absent, and means // something only when readOnlyHint is not true. An absent hint was read as diff --git a/pkgs/mcpx/internal/daemon/destructive_test.go b/pkgs/mcpx/internal/daemon/destructive_test.go index 69df9cc2dc..ae7805906c 100644 --- a/pkgs/mcpx/internal/daemon/destructive_test.go +++ b/pkgs/mcpx/internal/daemon/destructive_test.go @@ -3,6 +3,10 @@ package daemon import ( "encoding/json" "testing" + + "github.com/dezren39/mcpx/internal/config" + "github.com/dezren39/mcpx/internal/mcpclient" + "github.com/dezren39/mcpx/internal/pool" ) // The specification's ToolAnnotations: destructiveHint defaults to true and @@ -27,3 +31,39 @@ func TestDestructiveHintUsesTheSpecDefaults(t *testing.T) { } } } + +// Annotations are hints, not decisions (#2191): a remote upstream's +// claim that its tool is read-only or non-destructive must never clear +// the confirmation, because a lying server could suppress every ask. +// Only a locally declared (stdio) server's annotations are taken at +// face value -- that server is the user's own configured command. +func TestAnnotationClearsCallOnlyForLocallyDeclaredServers(t *testing.T) { + tool := func(raw string) *mcpclient.Tool { + return &mcpclient.Tool{Name: "wipe", Annotations: json.RawMessage(raw)} + } + local := pool.New(&config.Resolved{Server: &config.Server{Command: "demo"}}) + remote := pool.New(&config.Resolved{Server: &config.Server{URL: "https://upstream.example/mcp"}}) + for _, c := range []struct { + name string + p *pool.Pool + raw string + want bool + }{ + {"local read-only clears", local, `{"readOnlyHint":true}`, true}, + {"local non-destructive clears", local, `{"destructiveHint":false}`, true}, + {"local destructive does not clear", local, `{"destructiveHint":true}`, false}, + {"local unannotated does not clear", local, ``, false}, + {"remote read-only does not clear", remote, `{"readOnlyHint":true}`, false}, + {"remote non-destructive does not clear", remote, `{"destructiveHint":false}`, false}, + {"remote read-only and non-destructive does not clear", remote, `{"readOnlyHint":true,"destructiveHint":false}`, false}, + } { + t.Run(c.name, func(t *testing.T) { + if got := annotationClearsCall(c.p, tool(c.raw)); got != c.want { + t.Errorf("annotationClearsCall(%s) = %v, want %v", c.raw, got, c.want) + } + }) + } + if annotationClearsCall(nil, tool(`{"readOnlyHint":true}`)) { + t.Error("a nil pool must never clear a call") + } +} diff --git a/pkgs/mcpx/internal/settings/consumer.go b/pkgs/mcpx/internal/settings/consumer.go index efa6bc9203..5d531cc3f5 100644 --- a/pkgs/mcpx/internal/settings/consumer.go +++ b/pkgs/mcpx/internal/settings/consumer.go @@ -69,7 +69,11 @@ func consumerSettings() []Setting { "client uses it to ask before acting. The specification's " + "defaults apply: a tool not annotated readOnlyHint, and not " + "annotated destructiveHint false, may be destructive, so an " + - "unannotated tool is asked about too. A script has no such step. " + + "unannotated tool is asked about too. Annotations are hints, " + + "not proof: a remote server's readOnlyHint or destructiveHint " + + "false never clears a call (#2191) -- only a locally declared " + + "(stdio) server's annotations are taken at face value. " + + "A script has no such step. " + "Turning this on gives it one. Off by default: it puts a question " + "on the path of every destructive call, and a caller that cannot " + "answer waits out the deadline before the call proceeds.",