- Add JsonSchemaValidator interface and DefaultJsonSchemaValidator implementation - put the JsonSchemaValidator classes into a dedicated spec package - add schema caching to DefaultJsonSchemaValidator for better performance - Extend Tool schema to support outputSchema field for defining expected output structure - Add structuredContent field to CallToolResult for validated structured responses - Implement automatic validation of tool outputs against their defined schemas - Add comprehensive test coverage for structured output validation scenarios - Add json-schema-validator and json-unit-assertj dependencies for validation and testing - Update McpServer builders to accept custom JsonSchemaValidator instances - Ensure backward compatibility with existing tools without output schemas This implements the MCP specification requirement that tools with output schemas must provide structured results conforming to those schemas, with automatic validation and error handling for non-conforming outputs. https://modelcontextprotocol.io/specification/2025-06-18/server/tools#structured-content Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
223 lines
No EOL
6.5 KiB
XML
223 lines
No EOL
6.5 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
<modelVersion>4.0.0</modelVersion>
|
|
<parent>
|
|
<groupId>io.modelcontextprotocol.sdk</groupId>
|
|
<artifactId>mcp-parent</artifactId>
|
|
<version>0.11.0-SNAPSHOT</version>
|
|
</parent>
|
|
<artifactId>mcp</artifactId>
|
|
<packaging>jar</packaging>
|
|
<name>Java MCP SDK</name>
|
|
<description>Java SDK implementation of the Model Context Protocol, enabling seamless integration with language models and AI tools</description>
|
|
<url>https://github.com/modelcontextprotocol/java-sdk</url>
|
|
|
|
<scm>
|
|
<url>https://github.com/modelcontextprotocol/java-sdk</url>
|
|
<connection>git://github.com/modelcontextprotocol/java-sdk.git</connection>
|
|
<developerConnection>git@github.com/modelcontextprotocol/java-sdk.git</developerConnection>
|
|
</scm>
|
|
|
|
<build>
|
|
<plugins>
|
|
<plugin>
|
|
<groupId>biz.aQute.bnd</groupId>
|
|
<artifactId>bnd-maven-plugin</artifactId>
|
|
<version>${bnd-maven-plugin.version}</version>
|
|
<executions>
|
|
<execution>
|
|
<id>bnd-process</id>
|
|
<goals>
|
|
<goal>bnd-process</goal>
|
|
</goals>
|
|
<configuration>
|
|
<bnd><![CDATA[
|
|
Bundle-Name: Bundle ${project.groupId} : ${project.artifactId}
|
|
version: ${versionmask;===;${version_cleanup;${project.version}}}
|
|
Bundle-SymbolicName: ${project.groupId}.${project.artifactId}
|
|
Bundle-Version: ${version}
|
|
Automatic-Module-Name: ${project.groupId}.${project.artifactId}
|
|
Import-Package: jakarta.*;resolution:=optional, \
|
|
*;
|
|
Export-Package: io.modelcontextprotocol.*;version="${version}";-noimport:=true
|
|
-noimportjava: true;
|
|
-nouses: true;
|
|
-removeheaders: Private-Package
|
|
]]>
|
|
</bnd>
|
|
</configuration>
|
|
</execution>
|
|
</executions>
|
|
</plugin>
|
|
|
|
<plugin>
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
<artifactId>maven-jar-plugin</artifactId>
|
|
<configuration>
|
|
<archive>
|
|
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
|
</archive>
|
|
</configuration>
|
|
</plugin>
|
|
</plugins>
|
|
</build>
|
|
|
|
<dependencies>
|
|
|
|
<dependency>
|
|
<groupId>org.slf4j</groupId>
|
|
<artifactId>slf4j-api</artifactId>
|
|
<version>${slf4j-api.version}</version>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>com.fasterxml.jackson.core</groupId>
|
|
<artifactId>jackson-databind</artifactId>
|
|
<version>${jackson.version}</version>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>io.projectreactor</groupId>
|
|
<artifactId>reactor-core</artifactId>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>com.networknt</groupId>
|
|
<artifactId>json-schema-validator</artifactId>
|
|
<version>${json-schema-validator.version}</version>
|
|
</dependency>
|
|
|
|
<!-- Used by the HttpServletSseServerTransport -->
|
|
<dependency>
|
|
<groupId>jakarta.servlet</groupId>
|
|
<artifactId>jakarta.servlet-api</artifactId>
|
|
<version>${jakarta.servlet.version}</version>
|
|
<scope>provided</scope>
|
|
</dependency>
|
|
|
|
<!-- Test dependencies -->
|
|
|
|
<dependency>
|
|
<groupId>org.springframework</groupId>
|
|
<artifactId>spring-webmvc</artifactId>
|
|
<version>${springframework.version}</version>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
|
|
|
|
<dependency>
|
|
<groupId>io.projectreactor.netty</groupId>
|
|
<artifactId>reactor-netty-http</artifactId>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
|
|
<!-- The Spring Context is required due to the reactor-netty connector being dependent on
|
|
the Spring Lifecycle, as discussed here:
|
|
https://github.com/spring-projects/spring-framework/issues/31180 -->
|
|
<dependency>
|
|
<groupId>org.springframework</groupId>
|
|
<artifactId>spring-context</artifactId>
|
|
<version>${springframework.version}</version>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>org.springframework</groupId>
|
|
<artifactId>spring-test</artifactId>
|
|
<version>${springframework.version}</version>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>org.assertj</groupId>
|
|
<artifactId>assertj-core</artifactId>
|
|
<version>${assert4j.version}</version>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>org.junit.jupiter</groupId>
|
|
<artifactId>junit-jupiter-api</artifactId>
|
|
<version>${junit.version}</version>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>org.junit.jupiter</groupId>
|
|
<artifactId>junit-jupiter-params</artifactId>
|
|
<version>${junit.version}</version>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>org.mockito</groupId>
|
|
<artifactId>mockito-core</artifactId>
|
|
<version>${mockito.version}</version>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
|
|
<!-- Mockito cannot mock this class: class java.net.http.HttpClient. the bytebuddy helps. -->
|
|
<dependency>
|
|
<groupId>net.bytebuddy</groupId>
|
|
<artifactId>byte-buddy</artifactId>
|
|
<version>${byte-buddy.version}</version>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>io.projectreactor</groupId>
|
|
<artifactId>reactor-test</artifactId>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>org.testcontainers</groupId>
|
|
<artifactId>junit-jupiter</artifactId>
|
|
<version>${testcontainers.version}</version>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>org.awaitility</groupId>
|
|
<artifactId>awaitility</artifactId>
|
|
<version>${awaitility.version}</version>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>ch.qos.logback</groupId>
|
|
<artifactId>logback-classic</artifactId>
|
|
<version>${logback.version}</version>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>net.javacrumbs.json-unit</groupId>
|
|
<artifactId>json-unit-assertj</artifactId>
|
|
<version>${json-unit-assertj.version}</version>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
|
|
<!-- Tomcat dependencies for testing -->
|
|
<dependency>
|
|
<groupId>org.apache.tomcat.embed</groupId>
|
|
<artifactId>tomcat-embed-core</artifactId>
|
|
<version>${tomcat.version}</version>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>org.apache.tomcat.embed</groupId>
|
|
<artifactId>tomcat-embed-websocket</artifactId>
|
|
<version>${tomcat.version}</version>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>org.testcontainers</groupId>
|
|
<artifactId>toxiproxy</artifactId>
|
|
<version>${toxiproxy.version}</version>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
|
|
|
|
</dependencies>
|
|
|
|
|
|
</project> |