This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to branch feat/mcp-sdk-1.0.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-mcp-server.git
commit c71dfc0bede3e66d7635f57f922d2871e79b41da Author: Robert Munteanu <[email protected]> AuthorDate: Tue Mar 3 15:39:39 2026 +0100 fix(deps): update to MCP SDK 1.0.0 This also allows us to remove a couple of workarounds. --- bnd.bnd | 4 -- pom.xml | 4 +- src/main/features/main.json | 6 ++- .../mcp/server/impl/McpJsonMapperProvider.java | 52 ---------------------- .../apache/sling/mcp/server/impl/McpServlet.java | 10 ++--- 5 files changed, 11 insertions(+), 65 deletions(-) diff --git a/bnd.bnd b/bnd.bnd index f1ef54d..10d3666 100644 --- a/bnd.bnd +++ b/bnd.bnd @@ -1,5 +1 @@ -# workaround for https://github.com/modelcontextprotocol/java-sdk/issues/562 -Private-Package: io.modelcontextprotocol.json.jackson, \ - io.modelcontextprotocol.json.schema.jackson - Sling-Initial-Content: SLING-INF/libs/sling/mcp/prompts;path:=/libs/sling/mcp/prompts;overwrite:=true \ No newline at end of file diff --git a/pom.xml b/pom.xml index ab1074a..4eb544a 100644 --- a/pom.xml +++ b/pom.xml @@ -109,8 +109,8 @@ </dependency> <dependency> <groupId>io.modelcontextprotocol.sdk</groupId> - <artifactId>mcp</artifactId> - <version>0.17.0</version> + <artifactId>mcp-core</artifactId> + <version>1.0.0</version> <scope>provided</scope> </dependency> <dependency> diff --git a/src/main/features/main.json b/src/main/features/main.json index ffae06a..cc041e2 100644 --- a/src/main/features/main.json +++ b/src/main/features/main.json @@ -5,7 +5,11 @@ "start-order": 25 }, { - "id": "io.modelcontextprotocol.sdk:mcp-core:0.17.0", + "id": "io.modelcontextprotocol.sdk:mcp-core:1.0.0", + "start-order": 25 + }, + { + "id": "io.modelcontextprotocol.sdk:mcp-json-jackson2:1.0.0", "start-order": 25 }, { diff --git a/src/main/java/org/apache/sling/mcp/server/impl/McpJsonMapperProvider.java b/src/main/java/org/apache/sling/mcp/server/impl/McpJsonMapperProvider.java deleted file mode 100644 index 5df93df..0000000 --- a/src/main/java/org/apache/sling/mcp/server/impl/McpJsonMapperProvider.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.sling.mcp.server.impl; - -import com.fasterxml.jackson.databind.ObjectMapper; -import io.modelcontextprotocol.json.McpJsonMapper; -import io.modelcontextprotocol.json.jackson.JacksonMcpJsonMapper; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; -import org.osgi.service.component.annotations.Activate; -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Deactivate; - -import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES; - -@Component -public class McpJsonMapperProvider { - - private ServiceRegistration<McpJsonMapper> serviceRegistration; - - @Activate - public void activate(BundleContext bundleContext) { - ObjectMapper objectMapper = new ObjectMapper(); - // work around https://github.com/modelcontextprotocol/java-sdk/issues/724 - objectMapper.configure(FAIL_ON_UNKNOWN_PROPERTIES, false); - McpJsonMapper jsonMapper = new JacksonMcpJsonMapper(objectMapper); - serviceRegistration = bundleContext.registerService(McpJsonMapper.class, jsonMapper, null); - } - - @Deactivate - public void deactivate() { - if (serviceRegistration != null) { - serviceRegistration.unregister(); - } - } -} diff --git a/src/main/java/org/apache/sling/mcp/server/impl/McpServlet.java b/src/main/java/org/apache/sling/mcp/server/impl/McpServlet.java index 643265c..0fda4c6 100644 --- a/src/main/java/org/apache/sling/mcp/server/impl/McpServlet.java +++ b/src/main/java/org/apache/sling/mcp/server/impl/McpServlet.java @@ -25,8 +25,7 @@ import java.util.List; import java.util.Map; import io.modelcontextprotocol.common.McpTransportContext; -import io.modelcontextprotocol.json.McpJsonMapper; -import io.modelcontextprotocol.json.schema.jackson.DefaultJsonSchemaValidator; +import io.modelcontextprotocol.json.McpJsonDefaults; import io.modelcontextprotocol.server.McpServer; import io.modelcontextprotocol.server.McpStatelessRequestHandler; import io.modelcontextprotocol.server.McpStatelessServerFeatures.SyncPromptSpecification; @@ -95,13 +94,12 @@ public class McpServlet extends SlingJakartaAllMethodsServlet { public McpServlet( BundleContext ctx, Config config, - @Reference McpJsonMapper jsonMapper, @Reference(cardinality = MULTIPLE, policyOption = GREEDY) List<McpServerContribution> contributions) throws IllegalAccessException, NoSuchMethodException { transportProvider = HttpServletStatelessServerTransport.builder() .messageEndpoint(ENDPOINT) - .jsonMapper(jsonMapper) + .jsonMapper(McpJsonDefaults.getMapper()) .contextExtractor(request -> McpTransportContext.create( Map.of("resourceResolver", ((SlingJakartaHttpServletRequest) request).getResourceResolver()))) .build(); @@ -132,8 +130,8 @@ public class McpServlet extends SlingJakartaAllMethodsServlet { syncServer = McpServer.sync(transportProvider) .serverInfo(config.serverTitle(), serverVersion) - .jsonMapper(jsonMapper) - .jsonSchemaValidator(new DefaultJsonSchemaValidator()) + .jsonMapper(McpJsonDefaults.getMapper()) + .jsonSchemaValidator(McpJsonDefaults.getSchemaValidator()) .instructions(config.instructions()) .completions(completions) .capabilities(ServerCapabilities.builder()
