diff --git a/pkgs/mcpx/internal/mcpclient/client.go b/pkgs/mcpx/internal/mcpclient/client.go index 53d24b07b0..72cb2d912e 100644 --- a/pkgs/mcpx/internal/mcpclient/client.go +++ b/pkgs/mcpx/internal/mcpclient/client.go @@ -472,7 +472,7 @@ func (c *Client) finishLegacy(ctx context.Context, ir initResult) error { return fmt.Errorf("initialized notification: %w", err) } // The standalone GET stream arrived with Streamable HTTP (2025-03-26). - if h, ok := c.t.(interface{ listen() }); ok && ir.ProtocolVersion >= "2025-03-26" { + if h, ok := c.t.(interface{ listen() }); ok && spec.AtOrAfter("2025-03-26")(ir.ProtocolVersion) { h.listen() } return nil diff --git a/pkgs/mcpx/internal/mcpclient/modern.go b/pkgs/mcpx/internal/mcpclient/modern.go index e05e2287ee..c905388f41 100644 --- a/pkgs/mcpx/internal/mcpclient/modern.go +++ b/pkgs/mcpx/internal/mcpclient/modern.go @@ -10,6 +10,7 @@ import ( "github.com/dezren39/mcpx/internal/defaults" "github.com/dezren39/mcpx/internal/mcpheaders" + "github.com/dezren39/mcpx/internal/spec" ) // The reserved _meta keys a 2026-07-28 request carries. @@ -129,7 +130,7 @@ func (c *Client) elicitModeDeclared(mode string) bool { case "", "form": return true case "url": - return h != nil && (c.Era == EraModern || c.Negotiated >= "2025-11-25") + return h != nil && (c.Era == EraModern || spec.AtOrAfter("2025-11-25")(c.Negotiated)) } return false } @@ -268,7 +269,7 @@ func CallerVersionFrom(ctx context.Context) string { // 2026-07-28 -- one that has a session a server can send requests on. func CallerLegacy(ctx context.Context) bool { v := CallerVersionFrom(ctx) - return v != "" && v < "2026-07-28" + return spec.Before("2026-07-28")(v) } // ErrNotRelayed is a handler declining a request it could not pass on, so diff --git a/pkgs/mcpx/internal/mcpserver/revisions.go b/pkgs/mcpx/internal/mcpserver/revisions.go index 5111e0fbb8..0a8e760b2e 100644 --- a/pkgs/mcpx/internal/mcpserver/revisions.go +++ b/pkgs/mcpx/internal/mcpserver/revisions.go @@ -3,6 +3,8 @@ package mcpserver import ( "encoding/json" "strings" + + "github.com/dezren39/mcpx/internal/spec" ) // Oldest is the earliest revision mcpx serves. @@ -31,17 +33,13 @@ const Oldest = "2024-11-05" // only revision that could have sent it. const Headerless = "2025-03-26" -// AtLeast compares revisions. -// -// Lexical comparison is correct because every revision is a date in -// ISO order, and that is not an accident of the naming -- the specification -// orders them this way on purpose. A test pins it so a future revision that -// breaks the assumption fails loudly rather than sorting wrong. +// AtLeast compares revisions, delegating to spec.AtOrAfter (#2211): the +// one predicate vocabulary lives in internal/spec, whose package comment +// prescribes asking the predicates rather than comparing date strings in +// place. Semantics are identical -- revisions are ISO dates, so lexical +// order is revision order, and the empty revision never satisfies a floor. func AtLeast(version, floor string) bool { - if version == "" { - return false - } - return version >= floor + return spec.AtOrAfter(floor)(version) } // Feature is something a revision either defines or does not. diff --git a/pkgs/mcpx/internal/mcpserver/server.go b/pkgs/mcpx/internal/mcpserver/server.go index 29b5ebaa39..e75a4c4b6b 100644 --- a/pkgs/mcpx/internal/mcpserver/server.go +++ b/pkgs/mcpx/internal/mcpserver/server.go @@ -1308,7 +1308,7 @@ const Latest = "2025-11-25" // Modern reports whether a version uses per-request metadata rather than a // handshake. -func Modern(version string) bool { return version >= "2026-07-28" } +func Modern(version string) bool { return spec.AtOrAfter("2026-07-28")(version) } // withoutTask removes the task field, so the background run of a request does // not ask to become a task again and recurse.