You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2026/03/12 14:10:18 UTC

(sling-org-apache-sling-mcp-server) branch master updated: fix(deps): update to MCP SDK 1.0.0 (#6)

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-mcp-server.git


The following commit(s) were added to refs/heads/master by this push:
     new c6e65ad  fix(deps): update to MCP SDK 1.0.0 (#6)
c6e65ad is described below

commit c6e65ada6532a0cd74e729d79e5dc04433f969b8
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Thu Mar 12 15:10:13 2026 +0100

    fix(deps): update to MCP SDK 1.0.0 (#6)
    
    This also allows us to remove a couple of workarounds.
---
 bnd-legacy.bnd                                     |  7 +--
 bnd.bnd                                            |  6 ---
 pom.xml                                            |  4 +-
 src/main/features/main.json                        |  6 ++-
 .../mcp/server/impl/McpJsonMapperProvider.java     | 52 ----------------------
 .../apache/sling/mcp/server/impl/McpServlet.java   | 13 +++---
 6 files changed, 16 insertions(+), 72 deletions(-)

diff --git a/bnd-legacy.bnd b/bnd-legacy.bnd
index 8a6fd89..ff9d505 100644
--- a/bnd-legacy.bnd
+++ b/bnd-legacy.bnd
@@ -1,8 +1,5 @@
-# 1. workaround for https://github.com/modelcontextprotocol/java-sdk/issues/562
-# 2. compatibility with javax.servlet
-Private-Package: io.modelcontextprotocol.json.jackson, \
-    io.modelcontextprotocol.json.schema.jackson, \
-    jakarta.servlet, \
+# ensure compatibility with javax.servlet
+Private-Package: jakarta.servlet, \
     jakarta.servlet.annotation, \
     jakarta.servlet.descriptor, \
     jakarta.servlet.http, \
diff --git a/bnd.bnd b/bnd.bnd
deleted file mode 100644
index a4ad25e..0000000
--- a/bnd.bnd
+++ /dev/null
@@ -1,6 +0,0 @@
-# workaround for https://github.com/modelcontextprotocol/java-sdk/issues/562
-Private-Package: io.modelcontextprotocol.json.jackson, \
-    io.modelcontextprotocol.json.schema.jackson
-
-# Strictly control exports to prevent bnd from exporting packages that from embedded dependencies
--exportcontents: org.apache.sling.mcp.server.spi
diff --git a/pom.xml b/pom.xml
index 08355b5..63106eb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -122,8 +122,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 2ba0354..668d583 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
@@ -28,8 +28,8 @@ 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.McpJsonMapperSupplier;
+import io.modelcontextprotocol.json.schema.JsonSchemaValidatorSupplier;
 import io.modelcontextprotocol.server.McpServer;
 import io.modelcontextprotocol.server.McpStatelessRequestHandler;
 import io.modelcontextprotocol.server.McpStatelessServerFeatures.SyncPromptSpecification;
@@ -96,13 +96,14 @@ public class McpServlet extends SlingAllMethodsServlet {
     public McpServlet(
             BundleContext ctx,
             Config config,
-            @Reference McpJsonMapper jsonMapper,
+            @Reference McpJsonMapperSupplier jsonMapperSupplier,
+            @Reference JsonSchemaValidatorSupplier jsonSchemaValidatorSupplier,
             @Reference(cardinality = MULTIPLE, policyOption = GREEDY) List<McpServerContribution> contributions)
             throws IllegalAccessException, NoSuchMethodException {
 
         transportProvider = HttpServletStatelessServerTransport.builder()
                 .messageEndpoint(ENDPOINT)
-                .jsonMapper(jsonMapper)
+                .jsonMapper(jsonMapperSupplier.get())
                 .contextExtractor(request -> McpTransportContext.create(Map.of(
                         "resourceResolver",
                         ((BridgedJakartaHttpServletRequest) request)
@@ -140,8 +141,8 @@ public class McpServlet extends SlingAllMethodsServlet {
 
         syncServer = McpServer.sync(transportProvider)
                 .serverInfo(config.serverTitle(), serverVersion)
-                .jsonMapper(jsonMapper)
-                .jsonSchemaValidator(new DefaultJsonSchemaValidator())
+                .jsonMapper(jsonMapperSupplier.get())
+                .jsonSchemaValidator(jsonSchemaValidatorSupplier.get())
                 .instructions(config.instructions())
                 .completions(completions)
                 .capabilities(ServerCapabilities.builder()