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-contributions.git
The following commit(s) were added to refs/heads/master by this push:
new 4c939c2 SLING-13423 : update MCP Java SDK to 2.1.0 (#9)
4c939c2 is described below
commit 4c939c28ba96234b28e798f714a705251bcadacb
Author: Robert Munteanu <[email protected]>
AuthorDate: Tue Nov 17 09:41:30 2026 +0100
SLING-13423 : update MCP Java SDK to 2.1.0 (#9)
---
pom.xml | 3 +-
.../server/impl/contribs/LogToolContribution.java | 74 ++++++++++------------
.../contribs/OsgiBundleDiagnosticContribution.java | 34 +++++-----
.../impl/contribs/RecentRequestsContribution.java | 36 +++++------
4 files changed, 66 insertions(+), 81 deletions(-)
diff --git a/pom.xml b/pom.xml
index 1be70db..8d8de05 100644
--- a/pom.xml
+++ b/pom.xml
@@ -41,6 +41,7 @@
<properties>
<sling.java.version>17</sling.java.version>
+ <mcp.sdk.version>2.1.0</mcp.sdk.version>
<!-- Run with
-Dslingfeature.app.vmOption=-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=30303
for debug mode-->
<slingfeature.app.vmOption />
</properties>
@@ -111,7 +112,7 @@
<dependency>
<groupId>io.modelcontextprotocol.sdk</groupId>
<artifactId>mcp-core</artifactId>
- <version>1.0.0</version>
+ <version>${mcp.sdk.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
diff --git
a/src/main/java/org/apache/sling/mcp/server/impl/contribs/LogToolContribution.java
b/src/main/java/org/apache/sling/mcp/server/impl/contribs/LogToolContribution.java
index 993f451..9d269c7 100644
---
a/src/main/java/org/apache/sling/mcp/server/impl/contribs/LogToolContribution.java
+++
b/src/main/java/org/apache/sling/mcp/server/impl/contribs/LogToolContribution.java
@@ -24,9 +24,7 @@ import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
-import java.util.stream.Collectors;
-import io.modelcontextprotocol.json.McpJsonMapperSupplier;
import
io.modelcontextprotocol.server.McpStatelessServerFeatures.SyncToolSpecification;
import io.modelcontextprotocol.spec.McpSchema.CallToolResult;
import io.modelcontextprotocol.spec.McpSchema.Tool;
@@ -49,47 +47,50 @@ public class LogToolContribution implements
McpServerContribution {
@Reference
private LogStore logStore;
- @Reference
- private McpJsonMapperSupplier jsonMapper;
-
private final SimpleDateFormat dateFormat = new
SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
@Override
public List<SyncToolSpecification> getSyncToolSpecification() {
- var schema = """
- {
- "type" : "object",
- "id" : "urn:jsonschema:LogFilterInput",
- "properties" : {
- "regex" : {
- "type" : "string",
- "description" : "Optional regex pattern to filter log
messages. If not provided, all logs are returned."
- },
- "logLevel" : {
- "type" : "string",
- "description" : "Minimum log level to return. Options:
%s. Defaults to %s.",
- "enum" : %s
- },
- "maxEntries" : {
- "type" : "integer",
- "description" : "Maximum number of log entries to
return. Defaults to 200.",
- "minimum" : 1,
- "maximum" : 1000
- }
- }
- }
- """.formatted(
- validLogLevelValuesAsCsv(), getHighestLogLevelName(),
validLogLevelValuesAsJsonSchemaEnum());
+ var schema = Map.<String, Object>of(
+ "type",
+ "object",
+ "properties",
+ Map.of(
+ "regex",
+ Map.of(
+ "type",
+ "string",
+ "description",
+ "Optional regex pattern to filter log
messages. If not provided, all logs are returned."),
+ "logLevel",
+ Map.of(
+ "type",
+ "string",
+ "description",
+ "Minimum log level to return. Options: " +
validLogLevelValuesAsCsv() + ". Defaults to "
+ + getHighestLogLevelName() + ".",
+ "enum",
+ getValidLogLevelNames()),
+ "maxEntries",
+ Map.of(
+ "type",
+ "integer",
+ "description",
+ "Maximum number of log entries to return.
Defaults to 200.",
+ "minimum",
+ 1,
+ "maximum",
+ 1000)),
+ "additionalProperties",
+ false);
return List.of(new SyncToolSpecification(
- Tool.builder()
- .name("logs")
+ Tool.builder("logs", schema)
.description("Retrieve logs with optional filtering. "
+ "Supports filtering by regex pattern, log
level (" + validLogLevelValuesAsCsv()
+ "), "
+ "and maximum number of entries. Returns most
recent logs first.")
- .inputSchema(jsonMapper.get(), schema)
.build(),
(exchange, request) -> {
String regexPattern = (String)
request.arguments().get("regex");
@@ -217,15 +218,6 @@ public class LogToolContribution implements
McpServerContribution {
return String.join(", ", getValidLogLevelNames());
}
- private String validLogLevelValuesAsJsonSchemaEnum() {
- StringBuilder result = new StringBuilder();
- result.append("[ ");
- result.append(
- getValidLogLevelNames().stream().map(name -> '"' + name +
'"').collect(Collectors.joining(", ")));
- result.append(" ]");
- return result.toString();
- }
-
private boolean isValidLogLevel(String logLevelName) {
try {
LogLevel.valueOf(logLevelName);
diff --git
a/src/main/java/org/apache/sling/mcp/server/impl/contribs/OsgiBundleDiagnosticContribution.java
b/src/main/java/org/apache/sling/mcp/server/impl/contribs/OsgiBundleDiagnosticContribution.java
index 6abb702..809a38c 100644
---
a/src/main/java/org/apache/sling/mcp/server/impl/contribs/OsgiBundleDiagnosticContribution.java
+++
b/src/main/java/org/apache/sling/mcp/server/impl/contribs/OsgiBundleDiagnosticContribution.java
@@ -22,9 +22,9 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
import java.util.stream.Collectors;
-import io.modelcontextprotocol.json.McpJsonMapperSupplier;
import
io.modelcontextprotocol.server.McpStatelessServerFeatures.SyncToolSpecification;
import io.modelcontextprotocol.spec.McpSchema.CallToolResult;
import io.modelcontextprotocol.spec.McpSchema.Tool;
@@ -54,9 +54,6 @@ import
org.osgi.service.component.runtime.dto.UnsatisfiedReferenceDTO;
@Component
public class OsgiBundleDiagnosticContribution implements McpServerContribution
{
- @Reference
- private McpJsonMapperSupplier jsonMapperSupplier;
-
@Reference
private ServiceComponentRuntime scr;
@@ -70,25 +67,24 @@ public class OsgiBundleDiagnosticContribution implements
McpServerContribution {
@Override
public List<SyncToolSpecification> getSyncToolSpecification() {
- var schema = """
- {
- "type" : "object",
- "id" : "urn:jsonschema:DiagnoseBundleInput",
- "properties" : {
- "bundleSymbolicName" : {
- "type" : "string",
- "description" : "The symbolic name of the bundle to
diagnose. If not provided, will diagnose all problematic bundles."
- }
- }
- }
- """;
+ var schema = Map.<String, Object>of(
+ "type",
+ "object",
+ "properties",
+ Map.of(
+ "bundleSymbolicName",
+ Map.of(
+ "type",
+ "string",
+ "description",
+ "The symbolic name of the bundle to diagnose.
If not provided, will diagnose all problematic bundles.")),
+ "additionalProperties",
+ false);
return List.of(new SyncToolSpecification(
- Tool.builder()
- .name("diagnose-osgi-bundle")
+ Tool.builder("diagnose-osgi-bundle", schema)
.description(
"Diagnose why an OSGi bundle or component
isn't starting. Provides detailed information about unsatisfied dependencies,
missing packages, and component configuration issues.")
- .inputSchema(jsonMapperSupplier.get(), schema)
.build(),
(exchange, request) -> {
String bundleSymbolicName = (String)
request.arguments().get("bundleSymbolicName");
diff --git
a/src/main/java/org/apache/sling/mcp/server/impl/contribs/RecentRequestsContribution.java
b/src/main/java/org/apache/sling/mcp/server/impl/contribs/RecentRequestsContribution.java
index 148b6cc..884bf18 100644
---
a/src/main/java/org/apache/sling/mcp/server/impl/contribs/RecentRequestsContribution.java
+++
b/src/main/java/org/apache/sling/mcp/server/impl/contribs/RecentRequestsContribution.java
@@ -19,12 +19,12 @@
package org.apache.sling.mcp.server.impl.contribs;
import java.util.List;
+import java.util.Map;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
-import io.modelcontextprotocol.json.McpJsonMapperSupplier;
import
io.modelcontextprotocol.server.McpStatelessServerFeatures.SyncToolSpecification;
import io.modelcontextprotocol.spec.McpSchema.CallToolResult;
import io.modelcontextprotocol.spec.McpSchema.Tool;
@@ -39,13 +39,10 @@ import org.osgi.service.component.annotations.Reference;
public class RecentRequestsContribution implements McpServerContribution {
private final RequestInfoProvider requestInfoProvider;
- private final McpJsonMapperSupplier jsonMapperSupplier;
@Activate
- public RecentRequestsContribution(
- @Reference RequestInfoProvider requestInfoProvider, @Reference
McpJsonMapperSupplier jsonMapperSupplier) {
+ public RecentRequestsContribution(@Reference RequestInfoProvider
requestInfoProvider) {
this.requestInfoProvider = requestInfoProvider;
- this.jsonMapperSupplier = jsonMapperSupplier;
}
private String describe(RequestInfo ri) {
@@ -57,27 +54,26 @@ public class RecentRequestsContribution implements
McpServerContribution {
@Override
public List<SyncToolSpecification> getSyncToolSpecification() {
- var schema = """
- {
- "type" : "object",
- "id" : "urn:jsonschema:RecentRequestsInput",
- "properties" : {
- "path" : {
- "type" : "string",
- "description" : "Optional regex pattern to filter
requests by path. If not provided, all recent requests are returned."
- }
- }
- }
- """;
+ var schema = Map.<String, Object>of(
+ "type",
+ "object",
+ "properties",
+ Map.of(
+ "path",
+ Map.of(
+ "type",
+ "string",
+ "description",
+ "Optional regex pattern to filter requests by
path. If not provided, all recent requests are returned.")),
+ "additionalProperties",
+ false);
return List.of(new SyncToolSpecification(
- Tool.builder()
- .name("recent-requests")
+ Tool.builder("recent-requests", schema)
.description(
"Returns all recent requests matching the
specified path regex. "
+ "Contains information about method,
path, user id and a verbose log of internal operations, "
+ "including authentication, resource
resolution, script resolution, nested scripts/servlets and filters.")
- .inputSchema(jsonMapperSupplier.get(), schema)
.build(),
(exchange, request) -> {
String pathRegex = (String)
request.arguments().get("path");