From 7862529770a335ae9202218bd4d933603ff093ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20J=C4=99drzejczyk?= <2554306+chemicL@users.noreply.github.com> Date: Tue, 5 May 2026 10:24:43 +0200 Subject: [PATCH] Revert removed builders for Resource and ResourceTemplate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of fully breaking the API, this is a step which depreactes the existing non-argument builder. It allows the users to gradually migrate while preserving the necessary checks. Signed-off-by: Dariusz Jędrzejczyk <2554306+chemicL@users.noreply.github.com> --- .../modelcontextprotocol/spec/McpSchema.java | 55 +++++++++++++++++-- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/mcp-core/src/main/java/io/modelcontextprotocol/spec/McpSchema.java b/mcp-core/src/main/java/io/modelcontextprotocol/spec/McpSchema.java index b5d528116..6c7f56848 100644 --- a/mcp-core/src/main/java/io/modelcontextprotocol/spec/McpSchema.java +++ b/mcp-core/src/main/java/io/modelcontextprotocol/spec/McpSchema.java @@ -1212,11 +1212,16 @@ public static Builder builder(String uri, String name) { return new Builder(uri, name); } + @Deprecated + public static Builder builder() { + return new Builder(); + } + public static class Builder { - private final String uri; + private /* final */ String uri; - private final String name; + private /* final */ String name; private String title; @@ -1230,6 +1235,24 @@ public static class Builder { private Map meta; + @Deprecated + public Builder() { + } + + @Deprecated + public Builder uri(String uri) { + Assert.hasText(uri, "uri must not be empty"); + this.uri = uri; + return this; + } + + @Deprecated + public Builder name(String name) { + this.name = name; + Assert.hasText(name, "name must not be empty"); + return this; + } + private Builder(String uri, String name) { Assert.hasText(uri, "uri must not be empty"); Assert.hasText(name, "name must not be empty"); @@ -1330,11 +1353,16 @@ public static Builder builder(String uriTemplate, String name) { return new Builder(uriTemplate, name); } + @Deprecated + public static Builder builder() { + return new Builder(); + } + public static class Builder { - private final String uriTemplate; + private /* final */ String uriTemplate; - private final String name; + private /* final */ String name; private String title; @@ -1346,6 +1374,11 @@ public static class Builder { private Map meta; + @Deprecated + private Builder() { + + } + private Builder(String uriTemplate, String name) { Assert.hasText(uriTemplate, "uriTemplate must not be empty"); Assert.hasText(name, "name must not be empty"); @@ -1353,6 +1386,20 @@ private Builder(String uriTemplate, String name) { this.name = name; } + @Deprecated + public Builder uriTemplate(String uriTemplate) { + Assert.hasText(uriTemplate, "uriTemplate must not be empty"); + this.uriTemplate = uriTemplate; + return this; + } + + @Deprecated + public Builder name(String name) { + Assert.hasText(name, "name must not be empty"); + this.name = name; + return this; + } + public Builder title(String title) { this.title = title; return this;