Commit graph

486 commits

Author SHA1 Message Date
Luca Chang
8a5a591d39 feat: Add elicitation support to MCP protocol
Implement elicitation capabilities allowing servers to request additional information
from users through clients during interactions. This feature provides a standardized
way for servers to gather necessary information dynamically while clients maintain
control over user interactions and data sharing.

- Add ElicitRequest and ElicitResult classes to McpSchema
- Implement elicitation handlers in client classes
- Add elicitation capabilities to server exchange classes
- Add tests for elicitation functionality with various scenarios
2025-06-10 13:37:23 +02:00
Dariusz Jędrzejczyk
07e7b8fd6b Add note about force pushes
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
2025-05-16 11:47:39 +02:00
Dariusz Jędrzejczyk
1adfa8a047 Add Contributing Guidelines and Code of Conduct
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
2025-05-16 11:47:39 +02:00
Dariusz Jędrzejczyk
2e13f9f9df Fix flaky WebFluxSse integration test
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
2025-05-15 10:25:46 +02:00
Dariusz Jędrzejczyk
f34662555a
Fix stdio tests - proper server-everything argument (#237)
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
2025-05-14 15:38:02 +02:00
Christian Tzolov
b2d3e0098e Next development version
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-05-12 15:04:05 +02:00
Dariusz Jędrzejczyk
0069c977ef Remove temporary delegate impl from McpAsyncServer
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
2025-05-09 14:56:27 +02:00
Dennis Kawurek
eae3840e7d
fix: Mockito inline mocking for Java 21+ (#207)
Before this fix the execution of the maven surefire
plugin with Java 21 logged warnings that mockito should be added as
a java agent, because the self-attaching won't be supported in future
java releases.
In Java 24 the test just broke.

This problem is solved by modifying the pom.xml of the parent and doing
this changes:

* Adding mockito as a java agent.
* Removing the surefireArgLine from the properties. This can be
added back when it's needed (for example when JaCoCo will be used).

Furthermore, the pom.xml in the mcp-spring-* modules now have
the byte-buddy dependency included, as the test would otherwise break
when trying to mock McpSchema#CreateMessageRequest.

Fixes #187

Co-authored-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
2025-05-08 12:44:51 +02:00
jito
e34babbe56
Add missing isInitialized method to McpSyncClient (#181)
The isInitialized method is present in McpAsyncClient and needs to be
mirrored in McpSyncClient.

Signed-off-by: jitokim <pigberger70@gmail.com>
2025-05-08 11:31:17 +02:00
Christian Tzolov
e610d853f9 feat: Add customizable URI template manager factory to MCP server
Implement URI template functionality for MCP resources, allowing dynamic
resource URIs with variables in the format {variableName}.

- Enable resource URIs with variable placeholders (e.g., "/api/users/{userId}")
- Automatic extraction of variable values from request URIs
- Validation of template arguments in completions
- Matching of request URIs against templates

- Add new URI template management interfaces and implementations
- Enhanced resource template listing to include templated resources
- Updated resource request handling to support template matching
- Test coverage for URI template functionality

- Adding a configurable uriTemplateManagerFactory field to both AsyncSpecification and SyncSpecification classes
- Adding builder methods to allow setting a custom URI template manager factory
- Modifying constructors to pass the URI template manager factory to the server implementation
- Updating the server implementation to use the provided factory
- Add bulk registration methods for async completions

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-29 07:11:39 +03:00
Francis Hodianto
261554bb7f
fix: propagate Reactor Context into client transport chain (#154) 2025-04-23 17:09:41 +02:00
wangzhi
9c92a2b8bf
Fix javadoc references and formatting (#149) 2025-04-23 17:03:10 +02:00
Richie Caputo
f70b98b4b4
feat(schema): add support for JSON Schema $defs and definitions (#146)
Added support for $defs and definitions properties in JsonSchema record to handle JSON Schema references properly. Added tests to verify both formats work correctly.

The JsonSchema test approach uses serialization/deserialization round-trip validation instead of property-by-property assertions. This makes tests more maintainable and less likely to break when new properties are added.

🤖 Generated with [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-04-23 16:47:48 +02:00
jito
86e3e9048f
Fix typo in WebFluxSseIntegrationTests (#142)
Signed-off-by: jitokim <pigberger70@gmail.com>
2025-04-23 16:27:10 +02:00
Dariusz Jędrzejczyk
866732c383
Polish #33
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
2025-04-23 11:06:26 +02:00
JermaineHua
04046ca05b
Optimize client nested streams in McpClientSession (#33)
Signed-off-by: JermaineHua <crazyhzm@apache.org>
2025-04-23 10:38:42 +02:00
JermaineHua
41c6bd9af0 Fix method not found error msg for server
Signed-off-by: JermaineHua <crazyhzm@apache.org>
2025-04-18 15:18:12 +02:00
jie.bao
e4091f458a feat(completion): fix the schema about CompleteResult
/**
 * The server's response to a completion/complete request
 */
export
interface CompleteResult extends Result {
  completion: {
    /**
     *
An array of completion values. Must not exceed 100 items.
     */

values: string[];
    /**
     * The total number of completion options
available. This can exceed the number of values actually sent in the
response.
     */
    total?: number;
    /**
     * Indicates whether
there are additional completion options beyond those provided in the
current response, even if the exact total is unknown.
     */

hasMore?: boolean;
  };
}
2025-04-18 15:13:56 +02:00
E550448
344f1b8383 feat(mcp): resolve absolute and relative message endpoint URIs (#150)
Improve endpoint URI handling by supporting both relative paths
and properly validated absolute URIs.

- Implement URI resolution in HttpClientSseClientTransport:
- Change baseUri field from String to URI type
- Add Utils.resolveUri method to handle both absolute and relative URIs
- Resolve relative URIs against the base URI
- Validate absolute URIs to ensure they match base URI's scheme, authority, and path
- Add parameterized tests for various URI resolution scenarios
- Add ByteBuddy dependency for HttpClient mocking and update Mockito

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-18 14:52:50 +02:00
Christian Tzolov
734d1732d6 Refactor: Simplify ServerCapabilities builder API for completions
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-17 09:28:08 +02:00
jitokim
7853efefda feat(completion): implement completion API support (#141)
Add completion API support to the MCP protocol implementation:

- Add CompleteRequest and CompleteResult schema classes
- Implement completion capabilities in ServerCapabilities
- Add completion handlers in McpAsyncServer and McpServer
- Add completion client methods in McpAsyncClient and McpSyncClient
- Add CompletionRefKey and completion specifications in McpServerFeatures
- Add integration test for completion functionality
- Fix isPresent() check to use isEmpty() in WebMvcSseServerTransportProvider
- Replace McpServerFeatures.CompletionRefKey by McpSchemaCompleteReference

Co-authored-by: Christian Tzolov <christian.tzolov@broadcom.com>

Signed-off-by: jitokim <pigberger70@gmail.com>
2025-04-16 21:16:21 +02:00
mackey0225
84adde16a5 fix: correct typos in variable names, method names, and commentsj (#159) 2025-04-16 08:07:24 +02:00
Dariusz Jędrzejczyk
f7f8ccd0ac Fix flaky test running blocking code in event loop (#155)
- Replace StepVerifier with assertWith for cleaner test assertions
- Add try-with-resources blocks for proper client resource management
- Use closeGracefully().block() for proper server shutdown

Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
2025-04-16 07:57:54 +02:00
mipengcheng3
472f07ec6d feat(mcp): add configurable request timeout to MCP server (#134)
Adds the ability to configure request timeouts for MCP server operations. This enhancement
allows setting a custom duration to wait for server responses before timing out requests,
which applies to all requests made through the client including tool calls, resource access,
and prompt operations.

- Add requestTimeout parameter to McpServerSession constructor
- Add requestTimeout field and builder method to server classes
- Pass timeout configuration through to session creation
- Add tests for both success and failure scenarios across different transport implementations
- Default timeout is set to 10 seconds if not explicitly configured.
2025-04-15 12:47:02 +02:00
a.darafeyeu
263e3741b2 feat(test): Use dynamic port allocation in integration tests (#133)
- Add TestUtil class with findAvailablePort() method to the mcp-test module
- Add findAvailablePort() method to TomcatTestUtil classes
- Replace hardcoded port numbers with dynamic port allocation

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-15 12:26:03 +02:00
James Ward
8068854227
add access to server instructions (#148) 2025-04-15 07:41:41 +02:00
Christian Tzolov
f348a83e5a Next development version
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-10 18:06:46 +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