Commit graph

260 commits

Author SHA1 Message Date
Christian Tzolov
ea9c01a1a9 Release version 0.9.0 v0.9.0
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-10 17:22:37 +02:00
Christian Tzolov
2e953c81aa refactor(tests): improve notification assertions in HttpServletSseServerTransportProviderIntegrationTests
Replace index-based assertions with content-based lookups using a notification map.
    This change makes the tests more resilient by removing the dependency on
    notification order, which is important for asynchronous messaging tests.

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-10 17:16:50 +02:00
Christian Tzolov
63724f17a4 refactor(tests): improve notification assertions in WebFluxSseIntegrationTests
Replace index-based assertions with content-based lookups using a notification map.
This change makes the tests more resilient by removing the dependency on
notification order, which is important for asynchronous messaging tests.

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-10 16:54:28 +02:00
Christian Tzolov
c88ac937f3 feat(mcp): refactor logging to use exchange for targeted client notifications (#132)
Refactors the MCP logging system to use the exchange mechanism for sending
logging notifications only to specific client sessions rather than broadcasting to all clients.

- Move logging notification delivery from server-wide broadcast to per-session exchange
- Implement per-session minimum logging level tracking and filtering
- Add proper logging level filtering at the exchange level
- Change setLoggingLevel from notification to request/response pattern (breaking change)
- Deprecate global server.loggingNotification in favor of exchange.loggingNotification
- Add SetLevelRequest record to McpSchema
- Add integration test demonstrating filtered logging notifications

Resolves #131

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Co-authored-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
2025-04-10 15:46:32 +02:00
Christian Tzolov
2895d1589a
fix: Add null check for session in WebFluxSseServerTransportProvider (#138)
Add error handling to return a 404 NOT_FOUND response when a request
is made with a non-existent session ID. This prevents potential
NullPointerExceptions when processing requests with invalid session IDs.

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-10 13:18:55 +02:00
Christian Tzolov
391ec19fdc
refactor: change notification params type from Map<String,Object> to Object (#137)
* refactor: change notification params type from Map<String,Object> to Object

This change generalizes the parameter type for notification methods across the MCP framework,
allowing for more flexible parameter passing. Instead of requiring parameters to be structured
as a Map<String,Object>, the API now accepts any Object as parameters.

The primary motivation is to simplify client usage by allowing direct passing of strongly-typed
 objects without requiring conversion to a Map first, as demonstrated in the McpAsyncServer
logging notification implementation.

Affected components:

- McpSession interface and implementations
- McpServerTransportProvider interface and implementations
- McpSchema JSONRPCNotification record
---------

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-10 12:26:29 +02:00
a.darafeyeu
fab434c088 refactor(client): enhance HttpClientSseClientTransport with flexible customization API (#117)
- Add builder customizeClient() and customizeRequest() methods
- Enable HTTP client and request configuration through consumer-based customization
- Deprecate direct constructors in favor of the more flexible builder approach
- Add test coverage for customization capabilities

Co-authored-by: Christian Tzolov <christian.tzolov@broadcom.com>
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-09 16:40:52 +02:00
Christian Tzolov
fbea833384 Fix compilation issue introduced by the previous commit
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-09 16:17:16 +02:00
Christian Tzolov
13c4474b3e Change the URLs used to test blocking rest calls
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-09 16:05:39 +02:00
Christian Tzolov
8fc72aed88 feat(mcp): Add support for custom context paths in HTTP Servlet SSE server transport
Enhance HttpServletSseServerTransportProvider to support deployment under non-root context paths by:

- Adding baseUrl field and DEFAULT_BASE_URL constant
- Creating new constructor that accepts a baseUrl parameter
- Extending Builder with baseUrl configuration method
- Prepending baseUrl to message endpoint in SSE events
- Add HttpServletSseServerCustomContextPathTests to verify custom context path functionality
- Extract common Tomcat server setup code to TomcatTestUtil for test reuse

Related to #79

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-06 18:43:48 +02:00
Christian Tzolov
b21cfab10e refactor(webmvc): Rename messageBaseUrl to baseUrl for consistency
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-06 17:51:24 +02:00
zhangzhenhua
3fa4152287 feat(webflux): Add base URL support to WebFluxSseServerTransportProvider (#102)
Adds the ability to specify a base URL prefix for message endpoints in the
WebFlux SSE server transport provider. This enhancement allows for proper
URL construction when the server is running behind a proxy or in a context
with a base path.

- Add new constructor with baseUrl parameter
- Add basePath() method to Builder class
- Modify SSE endpoint event to include baseUrl prefix

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-06 16:27:26 +02:00
minguncle
0db4c0f70d feat(webmvc): Add support for custom context paths in WebMvcSseServerTransportProvider
Adds the ability to specify a base URL for message endpoints in WebMvcSseServerTransportProvider,
enabling proper handling of custom servlet context paths in Spring WebMVC applications.
This ensures that clients receive the correct full endpoint URL when connecting through SSE.

- Add messageBaseUrl field to WebMvcSseServerTransportProvider
- Create new constructor that accepts messageBaseUrl parameter
- Update endpoint event to include base URL in the message endpoint
- Add TomcatTestUtil class to simplify test server creation
- Add WebMvcSseCustomContextPathTests to verify custom context path functionality
- Refactor WebMvcSseIntegrationTests to use the new TomcatTestUtil

Co-authored-by: Christian Tzolov <christian.tzolov@broadcom.com>
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-06 15:31:49 +02:00
jitokim
734153a445 fix typo in WebFluxSseIntegrationTests
Signed-off-by: jitokim <pigberger70@gmail.com>
2025-04-06 10:51:52 +02:00
Oleksandr Popov
cd624a7d57 fix: correct typos and improve documentation (#35)
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-06 10:42:23 +02:00
jitokim
c3a7c1ac1e perf(webflux): optimize session broadcasting with Flux.fromIterable (#109)
Replace Flux.fromStream(sessions.values().stream()) with more efficient
Flux.fromIterable(sessions.values()) to eliminate unnecessary stream
conversion when broadcasting messages to active sessions

Signed-off-by: jitokim <pigberger70@gmail.com>
2025-04-06 08:54:30 +02:00
Renxia Wang
eb8e3744a7 feat(transport): Add customizable HTTP request builder support (#86)
Enhances FlowSseClient and HttpClientSseClientTransport to accept a custom HttpRequest.Builder,
allowing for greater flexibility when configuring HTTP requests.
This enables clients to customize headers, timeouts, and other request properties across
all SSE connections and message sending operations.

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-06 08:19:26 +02:00
Dennis Kawurek
8d5872fd66 feat(McpSchema): CallToolResult and CallToolRequest usability improvements (#87)
- Add constructor to CallToolResult with one String entry
- Add a new constructor to CallToolRequest that accepts JSON string arguments
- Implement a builder pattern for CallToolResult with methods for adding content items
- Add test coverage for new functionality

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Co-authored-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-05 19:48:19 +02:00
JermaineHua
bda3cab843 Fix MCP schema link error
Signed-off-by: JermaineHua <crazyhzm@apache.org>
2025-04-05 18:11:56 +02:00
codezjx
15a55b6b62
fix: add support to set instructions as mentioned in #98 (#99) 2025-04-05 13:13:15 +02:00
codeboyzz
79ec5b5ed1
fix(tests): Failed to start process with command npx on Windows (#85)
* fix(tests): Failed to start process with command npx on Windows platform while running mvn test
2025-03-29 06:08:23 +01:00
codeboyzhou
e401e9e848 feat(tests): Add unit tests for Assert and Utils classes (#70)
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-27 14:53:00 +01:00
Christian Tzolov
55ee15604a feat(webflux): Add configurable SSE endpoints to WebFlux transport (#41, #67)
Enhances WebFlux SSE transport implementation with customizable endpoint paths:
- Add configurable SSE endpoint support in both client and server transports
- Update tests to verify custom SSE endpoint functionality
- Implement builder pattern to support the new configuration options

Co-authored-by: haidao <wwulfric@gmail.com>
Co-authored-by: Harry <34418180+HarryFQG@users.noreply.github.com>
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-27 14:31:22 +01:00
or-givati
2934635d99 feat(mcp): customize transport endpoints and improve URI handling (#69)
- Add support for customizable SSE endpoints in HttpClientSseClientTransport
- Replace pathInfo with requestURI in HttpServletSseServerTransportProvider for more reliable endpoint matching
- Implement builder pattern to support the customization options

Related to #40

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Co-authored-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-27 12:58:22 +01:00
Christian Tzolov
25f3bad68d refactor: remove deprecated 0.7.0 code
These changes are part of the planned deprecation cycle announced in 0.8.0,
with the deprecated classes scheduled for removal in 0.9.0

- Delete WebFluxSseServerTransport, WebMvcSseServerTransport, StdioServerTransport, and HttpServletSseServerTransport
- Remove deprecated interfaces: ServerMcpTransport, ClientMcpTransport
- Delete DefaultMcpSession implementation
- Remove all deprecated test classes for the removed implementations
- Update references to use McpServerTransport and McpClientTransport interfaces
- Split MockMcpTransport into client and server implementations
  * Rename MockMcpTransport to MockMcpClientTransport in mcp/src/test
  * Create new MockMcpServerTransport implementation
  * Add MockMcpServerTransportProvider for server tests
  * Mark MockMcpTransport in mcp-test module as deprecated
  * Update all test classes to use the new implementations

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-27 00:01:45 +01:00
Christian Tzolov
7827cdc113
refactor(server): Fi StdioServerTransportProvider initialization flow (#74)
Extract message processing initialization from StdioMcpSessionTransport constructor into a
separate initProcessing() method.

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-26 12:09:46 +01:00
Christian Tzolov
a94163b282 Next development version
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-21 18:11:30 +01:00
Christian Tzolov
a72abf6e33
(pom) Enable automatic publishing to Maven Central (#63)
Set autoPublish to true in the Maven configuration to
automatically publish artifacts to the Central repository when the release is performed.

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-21 17:05:06 +01:00
Christian Tzolov
33329bfabb
feat(mcp): Add builder for CreateMessageRequest (#60)
- Implements a builder pattern for CreateMessageRequest
- Updates corresponding tests to use the new builder syntax
- Add ModelPreferences builder and ModelHint helper
- Use builder pattern for CreateMessageRequest in integration tests

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-21 16:43:27 +01:00
Christian Tzolov
3e2139fa27 refactor(McpSchema): convert StopReason enum values to camelCase
Change format from snake_case to camelCase:
- end_turn → endTurn
- stop_sequence → stopSequence
- max_tokens → maxTokens

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-20 21:59:55 +01:00
ryan xu
5bd950d668 Update PING request handler, return empty map instead of empty string
Co-authored-by: NAME <NAME@EXAMPLE.COM>
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-20 21:50:16 +01:00
Christian Tzolov
64f424d91b fix: update McpSchemaTests to align with changes in #9
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-20 21:50:16 +01:00
Piotr Roterski
c35e896aa2 Fix CreateMessageRequest includeContext enum values to match MCP specification 2025-03-20 21:50:16 +01:00
Dariusz Jędrzejczyk
34a733509d refactor: introduce session-based architecture for MCP server (#31)
This commit introduces a major refactoring of the MCP Java SDK to implement a session-based architecture
for server-side implementations. The changes improve the SDK's ability to handle multiple concurrent
client connections and provide an API better aligned with the MCP specification.

Key changes:

- Introduce McpServerTransportProvider interface to manage client connections
- Rename ClientMcpTransport to McpClientTransport and ServerMcpTransport to McpServerTransport
- Add exchange objects (McpAsyncServerExchange, McpSyncServerExchange) for client interaction
- Update handler signatures to include exchange parameter: (args) -> result to (exchange, args) -> result
- Rename Registration classes to Specification classes
- Update method names (e.g., rootsChangeConsumers to rootsChangeHandlers)
- Deprecate old interfaces and classes for removal in 0.9.0
- Add migration guide (migration-0.8.0.md)

Resolves #9, #15

Co-authored-by: Christian Tzolov <christian.tzolov@broadcom.com>
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-20 21:49:51 +01:00
Dariusz Jędrzejczyk
9c2b836e41 Sync async client tests between mcp and mcp-test module
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
2025-03-20 09:48:09 +01:00
Dariusz Jędrzejczyk
e996a5de1e Follow-up fix client tests reliability
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
2025-03-20 09:15:35 +01:00
Dariusz Jędrzejczyk
37120f2ae5 Improve client test reliability and execution time
This change uses VirtualTimeScheduler and pretends enough time has
passed to trigger a timeout on the initialization.
Another problem with reliability of the tests was that the used
testcontainer for the SSE server does not support multiple clients and
the existence of both the global client for the entire suite and some
customized local clients in some tests caused responses to be delivered
to the other client at some racing situations. Now each test creates a
dedicated client and performs cleanup locally.
While these tests were improved, two other issues were found and fixed.
The first one is that the closeGracefully of DefaultMcpSession was not
lazy and would trigger connection disposal before the returned Mono was
subscribed. The second one was dealing with closing the StdIo client
before the process was started. In such a case there should not be an
error but rather a warning and successful completion.
2025-03-19 18:33:18 +01:00
Christian Tzolov
92ec67a965 Increase the request timeout to 14 sec
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-19 12:19:24 +01:00
Christian Tzolov
264a0c9041 Address review comments
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-19 12:19:24 +01:00
Christian Tzolov
914a14a92a adjust test timeout values
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-19 12:19:24 +01:00
Christian Tzolov
1a673b3567 refactor: improve MCP client timeout handling and reactive testing
- Add configurable initialization timeout separate from request timeout
- Rename ServletSse* test classes to HttpSse* for better naming consistency
- Replace direct .block() calls with StepVerifier for better reactive testing
- Change ping() method to return Mono instead of Mono
- Improve error handling and reactive programming patterns throughout tests
- Chain reactive operations for cleaner test flow

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-19 12:19:24 +01:00
Christian Tzolov
6ef1b58034 Update README.md
Fix the build status badge
2025-03-19 07:28:35 +01:00
Dariusz Jędrzejczyk
ec5383c23a Add CI GitHub Action and rename snapshot publish workflow 2025-03-18 13:37:49 +01:00
He-Pin(kerr)
ab0baf9d8e chore: Make closeLatch a final. 2025-03-13 16:29:35 +01:00
Christian Tzolov
109aab20e8
feat(client): Improve initialization state handling in McpAsyncClient (#39)
- Add proper initialization state tracking using AtomicBoolean and Sinks
- Implement timeout handling for requests requiring initialization
- Ensure all client methods verify initialization state before proceeding
- Fix rootsListChangedNotification to check initialization state
- Improve error messages for uninitialized client operations
- improve JavaDoc
- Add tests to verify proper error handling for uninitialized clients
  - Replace hardcoded timeout constants with configurable getTimeoutDuration() method
  - Remove automatic initialization in setUp methods to allow explicit testing

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-13 15:13:50 +01:00
Christian Tzolov
4eff00c8da
feat(mcp): relax MCP Schema JSON deserialization constraints (#37)
* feat(mcp):  relax MCP Schema JSON deserialization constraints

- Add @JsonIgnoreProperties(ignoreUnknown = true) annotation to all record
classes in McpSchema to make JSON deserialization more robust by ignoring
unknown properties.
- Make the JsonSchema record public

Resolves #36

This improves compatibility with third-party implementations like Cursor that are not MCP Schema compliant.

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-10 12:36:54 +01:00
Christian Tzolov
1bee8d4744
refactor(mcp): remove redundant type field from Content implementations (#27)
- The type field and associated methods were redundant in Content implementations (TextContent, ImageContent, EmbeddedResource)
  as the type information is already handled by Jackson's polymorphic type handling via @JsonSubTypes annotation.
- Add default implementation that returns the appropriate type string based on the implementing class (text, image, or resource)
- Added comprehensive unit tests for McpSchema to validate serialization/deserialization behavior of all schema components.
- Add deserialization tests for all content types
- Add json-unit-assertj for flexible JSON testing -  ignores array order and extra array items, reducing test brittleness while
maintaining functional validation.

Resolves #26
Resolve https://github.com/spring-projects/spring-ai/issues/2350

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-03 13:57:41 +01:00
Christian Tzolov
b2c62d50cb
Update README with Maven wrapper commands and test prerequisites (#23)
Resolves #20

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-02-27 10:13:25 +01:00
Christian Tzolov
718042644a
refactor(client): improve validation and remove server methods (#14)
Add client initialization and capability validation checks

- New isInitialized() method to check client state
- Validate server capabilities before tool/resource operations
- Add clear error messages for common failure cases
- Remove server-side notification methods from client: sendResourcesListChanged(), promptListChangedNotification()
- Improve protocol version handling
- Testing improvements and new initialization tests
- Redesign MockMcpTransport internals and adapt tests
- Correct McpError messages
- clean unused imports

Resolves #13

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Co-authored-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
2025-02-27 10:00:04 +01:00
konczdev
d9c4818607 Generate OSGi metadata 2025-02-26 18:55:46 +01:00