Update the ClientCapabilities.Elicitation record to accept optional "form"
and "url" fields as defined in the MCP 2025-11-25 specification.
Previously, deserializing an InitializeRequest with
`{"capabilities":{"elicitation":{"form":{}}}}` would fail with
UnrecognizedPropertyException because the Elicitation record was empty.
Changes:
- Add nested Form and Url marker records to Elicitation
- Add no-arg constructor for backward compatibility (serializes to {})
- Add elicitation(boolean form, boolean url) builder method
- Add comprehensive tests for deserialization and serialization
Fixes#724
- We do not support full version negotiation, but this commit allows the
client to the send the correct version to match that of the server.
- There is one limitation: the GET /mcp request happens too early,
before we have deserialized the initialization response, so we do not
know the negotiated version yet. This request will have the client
latest version as Mcp-Protocol-Version value.
Signed-off-by: Daniel Garnier-Moiroux <git@garnier.wf>
Change progressToken from String to Object throughout McpSchema
to allow both String and Number token types.
This makes it compliant with the MCP spec.
Resolves: #659
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
- Improve McpClientSession error handling to preserve custom error codes
and data from McpError instances.
- Add aggregated exception messages to error data field for better debugging.
- Include test coverage for various McpClientSession error scenarios.
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Unifies client/server implementation names under "Java SDK" branding
and updates all versions to 0.15.0.
Resolves: #638
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
- Remove automatic additionalProperties: false injection (JSON Schema spec compliance)
- Support String input for structuredContent in validate() method
- Move tests to mcp-json-jackson2 module with proper dependencies
- Replace wildcard imports with explicit imports
Complies with JSON Schema Test Suite:
15e4505/tests/draft2020-12/additionalProperties.json\#L112
Fixes#584
BREAKING CHANGE: Additional properties now allowed by default when not explicitly specified.
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
- Enhanced DefaultMcpUriTemplateManager to use Pattern.quote() for escaping special regex characters like '?'
- Replaced simple string replacement regex generation with robust pattern building
- Added test case to verify URI matching with query parameters (e.g., "file://name/search?={search}")
- Fixed typo: renamed DeafaultMcpUriTemplateManagerFactory to DefaultMcpUriTemplateManagerFactory
- Updated all references across server classes and tests
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Convert primitive int types to Integer wrapper class for:
- JSONRPCError.code
- CreateMessageRequest.maxTokens (including constructor and builder)
This allows these fields to be nullable, properly representing
optional parameters in the MCP protocol schema.
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
This pull-request removes the name member from the @JsonSubTypes.Type annotations when using JsonTypeInfo.Id.DEDUCTION.
With DEDUCTION, Jackson ignores the name entirely because it's inferring the type from the structure.
Ensure warnings are logged for all non-compliant responses to JSON-RPC
notifications, including empty responses. Empty responses now display
as "[empty]" in log messages for better clarity.
Resolves#586
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
- When the client sends `notification/initalized`, servers must respond
with HTTP 202 and an empty body. We checked for the absence of a
Content-Type header to verify whether the body was empty.
- However, some servers will send an empty body with a Content-Type
header, and that header may have an unsupported, default type such as
`text/html` or `text/plain`.
- Now we we also use the Content-Length header to check for an empty
body. This header is optional in HTTP/2, so we do not make it our
primary mechanism for detecting empty bodies.
- As part of this PR, we also move hard-coded HTTP header names to the
HttpHeaders interface. While they are not defined by the MCP spec,
they are used by it and are core to implementing the protocol.
Therefore, they have their place in a core interface.
- Fixes#582
Signed-off-by: Daniel Garnier-Moiroux <git@garnier.wf>
From the JSonTypeInfo Javadocs:
> If deduction is being used annotation properties visible, property and include are ignored.
This is causing issues with serialization downstream.
- Replace McpError with appropriate standard exceptions (IllegalArgumentException, IllegalStateException) for validation errors
- Change tool/prompt registration to replace existing items instead of rejecting duplicates with warningsi
- Change addTool behavior to replace existing tools instead of throwing errors
- Change addPrompt() to allow replacing existing prompts with warning instead of throwing error
- Make removal operations idempotent - log warnings instead of throwing errors for non-existent items
- Change removePrompt() to log warning instead of throwing error for non-existent prompts
- Change removeTool() to gracefully handle non-existent tools with warnings instead of errors
- Add listTools() and listPrompts() methods to all server variants (async, sync, stateless)
- Add listTools() method to all server classes for tool enumeration
- Add listPrompts() method to all server implementations for retrieving registered prompts
- Improve error construction using McpError.builder() pattern for protocol-specific errors
- Update error handling in session classes to properly propagate McpError JSON-RPC errors
- Use proper error codes (INVALID_PARAMS) for prompt not found scenarios
- Update tests to reflect new lenient behavior for duplicate registrations and removals
- Add aggregateExceptionMessages() utility method utility to aggregate the exception chains
- Update McpServerSession and McpStreamableServerSession to use the aggregated errors in the json-rpc-error data section
This change makes the MCP server APIs more resilient and user-friendly by using appropriate exception types,
supporting item replacement, and providing listing capabilities while maintaining backward compatibility.
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
- Provide separation of concerns between static resources and parameterized resource templates.
- Add AsyncResourceTemplateSpecification and SyncResourceTemplateSpecification for both McpServerFeatures and McpStatelessServerFeatures
- Change resource template storage from List to Map to acomodate the resource read handler.
- Add runtime management methods: addResourceTemplate(), removeResourceTemplate(), listResourceTemplates()
- Improve error handling by using IllegalArgumentException/IllegalStateException instead of McpError
- Add new interfaces (Meta, Identifier) and reorganize schema hierarchy
- Enhance completion request validation with better error messages
- Add ResourceTemplate.Builder for easier template construction
- Update all server implementations (Async, Sync, Stateless) consistently
- Add type-safe constants for reference types (PromptReference.TYPE, ResourceReference.TYPE)
- Add tests for new resource template management functionality
- Clean up imports and remove unused dependencies
Co-authored-by: Pascal Vantrepote <pascal@confluent.io>
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
see: https://modelcontextprotocol.io/specification/2025-06-18/server/resources#error-handling
Resource not found should send a JSON RPC response such as:
```json
{
"jsonrpc": "2.0",
"id": 5,
"error": {
"code": -32002,
"message": "Resource not found",
"data": {
"uri": "file:///nonexistent.txt"
}
}
}
```
This PR also changes some instances where a `McpError` was thrown instead of being passed in the reactive chain with `Mono.error`
functional style
The mcp module packages dependencies but has no sources, causing
Maven release failures. Skip source and javadoc JAR generation
to fix deployment errors.
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
- Set MCP_2025_06_18 as upper supported protocol version for streamable-http and stateless transport
- Update LATEST_PROTOCOL_VERSION constant to reflect new upper bound
- Update test expectations for new protocol version usage
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
- Replace @ValueSource with @MethodSource for parameterized tests
- Add clientsForTesting() methods to provide test arguments consistently
- Remove hardcoded Spring-related labels from framework-agnostic mcp-test module
- Move mcp-test's utility classes from io.modelcontextprotocol.utils to io.modelcontextprotocol.util
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
* extract mcp-core
- This change extracts classes previously in `mcp` to `mcp-core`; a new module which does not depend on `mcp-json-jackon2`.
- `mcp` module is now an umbrella module that brings `mcp-json-jackon2` and `mcp-core`
* add mcp-core to bom
BREAKING CHANGE: All source code in the previously `mcp` module is moved to the `mcp-core`. the `mcp` now is just an aggregation for `mcp-core` + `mcp-json-jackson2` for backward compatibility.
This change won't affect the end users, but will cause conflicts for the existing PRs.