Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 53 additions & 53 deletions README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*
* <p>
* Example usage: <pre>{@code
* &#64;McpElicitation(clientId = "my-client-id")
* &#64;McpElicitation(clients = "my-client-id")
* public ElicitResult handleElicitationRequest(ElicitRequest request) {
* return ElicitResult.builder()
* .message("Generated response")
Expand All @@ -33,7 +33,7 @@
* .build();
* }
*
* &#64;McpElicitation(clientId = "my-client-id")
* &#64;McpElicitation(clients = "my-client-id")
* public Mono<ElicitResult> handleAsyncElicitationRequest(ElicitRequest request) {
* return Mono.just(ElicitResult.builder()
* .message("Generated response")
Expand All @@ -53,9 +53,9 @@
public @interface McpElicitation {

/**
* Used as connection or client identifier to select the MCP client, the elicitation
* Used as connection or client identifier to select the MCP clients, the elicitation
* method is associated with.
*/
String clientId();
String[] clients();

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
public @interface McpLogging {

/**
* Used as connection or client identifier to select the MCP clients, the logging
* consumer is associated with. At least one client ID must be specified.
* Used as connection or clients identifier to select the MCP clients, the logging
* consumer is associated with. At least one client identifier must be specified.
*/
String clientId();
String[] clients();

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@

/**
* Used as connection or client identifier to select the MCP client, the progress
* consumer is associated with.
* consumer is associated with. At least one client identifier must be specified.
*/
String clientId();
String[] clients();

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
*
* <p>
* Example usage: <pre>{@code
* &#64;McpPromptListChanged
* &#64;McpPromptListChanged(clients = "test-client")
* public void onPromptListChanged(List<McpSchema.Prompt> updatedPrompts) {
* // Handle prompt list change notification with the updated prompts
* logger.info("Prompt list updated, now contains {} prompts", updatedPrompts.size());
* // Process the updated prompt list
* }
*
* &#64;McpPromptListChanged
* &#64;McpPromptListChanged(clients = "test-client")
* public Mono<Void> onPromptListChangedAsync(List<McpSchema.Prompt> updatedPrompts) {
* // Handle prompt list change notification asynchronously
* return processUpdatedPrompts(updatedPrompts);
Expand All @@ -54,11 +54,10 @@

/**
* Used as connection or client identifier to select the MCP client that the prompt
* change listener is associated with. If not specified, the listener is applied to
* all clients and will receive notifications from any connected MCP server that
* supports prompt list change notifications.
* change listener is associated with. At least one client identifier must be
* specified.
* @return the client identifier, or empty string to listen to all clients
*/
String clientId() default "";
String[] clients();

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
*
* <p>
* Example usage: <pre>{@code
* &#64;McpResourceListChanged
* &#64;McpResourceListChanged(clients = "test-client")
* public void onResourceListChanged(List<McpSchema.Resource> updatedResources) {
* // Handle resource list change notification with the updated resources
* logger.info("Resource list updated, now contains {} resources", updatedResources.size());
* // Process the updated resource list
* }
*
* &#64;McpResourceListChanged
* &#64;McpResourceListChanged(clients = "test-client")
* public Mono<Void> onResourceListChangedAsync(List<McpSchema.Resource> updatedResources) {
* // Handle resource list change notification asynchronously
* return processUpdatedResources(updatedResources);
Expand All @@ -53,12 +53,10 @@
public @interface McpResourceListChanged {

/**
* Used as connection or client identifier to select the MCP client that the resource
* change listener is associated with. If not specified, the listener is applied to
* all clients and will receive notifications from any connected MCP server that
* supports resource list change notifications.
* Used as connection or client identifier to select the MCP clients that the resource
* change listener is associated with.
* @return the client identifier, or empty string to listen to all clients
*/
String clientId() default "";
String[] clients();

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
*
* <p>
* Example usage: <pre>{@code
* &#64;McpSampling(clientId = "test-client")
* &#64;McpSampling(clients = "test-client")
* public CreateMessageResult handleSamplingRequest(CreateMessageRequest request) {
* // Process the request and return a result
* return CreateMessageResult.builder()
* .message("Generated response")
* .build();
* }
*
* &#64;McpSampling(clientId = "test-client")
* &#64;McpSampling(clients = "test-client")
* public Mono<CreateMessageResult> handleAsyncSamplingRequest(CreateMessageRequest request) {
* // Process the request asynchronously and return a result
* return Mono.just(CreateMessageResult.builder()
Expand All @@ -58,6 +58,6 @@
* Used as connection or client identifier to select the MCP client, the sampling
* method is associated with.
*/
String clientId();
String[] clients();

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
*
* <p>
* Example usage: <pre>{@code
* &#64;McpToolListChanged
* &#64;McpToolListChanged(clients = "test-client")
* public void onToolListChanged(List<McpSchema.Tool> updatedTools) {
* // Handle tool list change notification with the updated tools
* logger.info("Tool list updated, now contains {} tools", updatedTools.size());
* // Process the updated tool list
* }
*
* &#64;McpToolListChanged
* &#64;McpToolListChanged(clients = "test-client")
* public Mono<Void> onToolListChangedAsync(List<McpSchema.Tool> updatedTools) {
* // Handle tool list change notification asynchronously
* return processUpdatedTools(updatedTools);
Expand All @@ -53,12 +53,10 @@
public @interface McpToolListChanged {

/**
* Used as connection or client identifier to select the MCP client that the tool
* change listener is associated with. If not specified, the listener is applied to
* all clients and will receive notifications from any connected MCP server that
* supports tool list change notifications.
* @return the client identifier, or empty string to listen to all clients
* Used as connection or client identifier to select the MCP clients that the tool
* change listener is associated with.
* @return the client identifiers, or empty array to listen to all clients
*/
String clientId() default "";
String[] clients();

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,21 @@
package org.springaicommunity.mcp.method.changed.prompt;

import java.util.List;
import java.util.Objects;
import java.util.function.Function;

import io.modelcontextprotocol.spec.McpSchema;
import reactor.core.publisher.Mono;

public record AsyncPromptListChangedSpecification(String clientId,
public record AsyncPromptListChangedSpecification(String[] clients,
Function<List<McpSchema.Prompt>, Mono<Void>> promptListChangeHandler) {

public AsyncPromptListChangedSpecification {
Objects.requireNonNull(clients, "clients must not be null");
if (clients.length == 0) {
throw new IllegalArgumentException("At least one client Id must be specified");
}
Objects.requireNonNull(promptListChangeHandler, "promptListChangeHandler must not be null");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@
package org.springaicommunity.mcp.method.changed.prompt;

import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;

import io.modelcontextprotocol.spec.McpSchema;

public record SyncPromptListChangedSpecification(String clientId,
public record SyncPromptListChangedSpecification(String[] clients,
Consumer<List<McpSchema.Prompt>> promptListChangeHandler) {

public SyncPromptListChangedSpecification {
Objects.requireNonNull(clients, "clients must not be null");
if (clients.length == 0) {
throw new IllegalArgumentException("At least one client Id must be specified");
}
Objects.requireNonNull(promptListChangeHandler, "promptListChangeHandler must not be null");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@

package org.springaicommunity.mcp.method.changed.resource;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;

import io.modelcontextprotocol.spec.McpSchema;
import reactor.core.publisher.Mono;

public record AsyncResourceListChangedSpecification(String clientId,
public record AsyncResourceListChangedSpecification(String[] clients,
Function<List<McpSchema.Resource>, Mono<Void>> resourceListChangeHandler) {

public AsyncResourceListChangedSpecification {
Objects.requireNonNull(clients, "clients must not be null");
if (clients.length == 0 || Arrays.stream(clients).map(String::trim).anyMatch(String::isEmpty)) {
throw new IllegalArgumentException("clients must not be empty");
}
Objects.requireNonNull(resourceListChangeHandler, "resourceListChangeHandler must not be null");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,22 @@

package org.springaicommunity.mcp.method.changed.resource;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;

import io.modelcontextprotocol.spec.McpSchema;

public record SyncResourceListChangedSpecification(String clientId,
public record SyncResourceListChangedSpecification(String[] clients,
Consumer<List<McpSchema.Resource>> resourceListChangeHandler) {

public SyncResourceListChangedSpecification {
Objects.requireNonNull(clients, "clients must not be null");
if (clients.length == 0 || Arrays.stream(clients).map(String::trim).anyMatch(String::isEmpty)) {
throw new IllegalArgumentException("clients must not be empty");
}
Objects.requireNonNull(resourceListChangeHandler, "resourceListChangeHandler must not be null");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@

package org.springaicommunity.mcp.method.changed.tool;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;

import io.modelcontextprotocol.spec.McpSchema;
import reactor.core.publisher.Mono;

public record AsyncToolListChangedSpecification(String clientId,
public record AsyncToolListChangedSpecification(String[] clients,
Function<List<McpSchema.Tool>, Mono<Void>> toolListChangeHandler) {

public AsyncToolListChangedSpecification {
Objects.requireNonNull(clients, "clients must not be null");
if (clients.length == 0 || Arrays.stream(clients).map(String::trim).anyMatch(String::isEmpty)) {
throw new IllegalArgumentException("clients must not be empty");
}
Objects.requireNonNull(toolListChangeHandler, "toolListChangeHandler must not be null");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,21 @@

package org.springaicommunity.mcp.method.changed.tool;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;

import io.modelcontextprotocol.spec.McpSchema;

public record SyncToolListChangedSpecification(String clientId, Consumer<List<McpSchema.Tool>> toolListChangeHandler) {
public record SyncToolListChangedSpecification(String[] clients, Consumer<List<McpSchema.Tool>> toolListChangeHandler) {

public SyncToolListChangedSpecification {
Objects.requireNonNull(clients, "clients must not be null");
if (clients.length == 0 || Arrays.stream(clients).map(String::trim).anyMatch(String::isEmpty)) {
throw new IllegalArgumentException("clients must not be empty");
}
Objects.requireNonNull(toolListChangeHandler, "toolListChangeHandler must not be null");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@

package org.springaicommunity.mcp.method.elicitation;

import java.util.Arrays;
import java.util.Objects;
import java.util.function.Function;

import io.modelcontextprotocol.spec.McpSchema.ElicitRequest;
import io.modelcontextprotocol.spec.McpSchema.ElicitResult;
import reactor.core.publisher.Mono;

public record AsyncElicitationSpecification(String clientId,
public record AsyncElicitationSpecification(String[] clients,
Function<ElicitRequest, Mono<ElicitResult>> elicitationHandler) {

public AsyncElicitationSpecification {
Objects.requireNonNull(clientId, "clientId must not be null");
if (clientId.trim().isEmpty()) {
throw new IllegalArgumentException("clientId must not be empty");
Objects.requireNonNull(clients, "clients must not be null");
if (clients.length == 0 || Arrays.stream(clients).map(String::trim).anyMatch(String::isEmpty)) {
throw new IllegalArgumentException("clients must not be empty");
}
Objects.requireNonNull(elicitationHandler, "elicitationHandler must not be null");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@

package org.springaicommunity.mcp.method.elicitation;

import java.util.Arrays;
import java.util.Objects;
import java.util.function.Function;

import io.modelcontextprotocol.spec.McpSchema.ElicitRequest;
import io.modelcontextprotocol.spec.McpSchema.ElicitResult;

public record SyncElicitationSpecification(String clientId, Function<ElicitRequest, ElicitResult> elicitationHandler) {
public record SyncElicitationSpecification(String[] clients, Function<ElicitRequest, ElicitResult> elicitationHandler) {
public SyncElicitationSpecification {
Objects.requireNonNull(clientId, "clientId must not be null");
if (clientId.trim().isEmpty()) {
throw new IllegalArgumentException("clientId must not be empty");
Objects.requireNonNull(clients, "clients must not be null");
if (clients.length == 0 || Arrays.stream(clients).map(String::trim).anyMatch(String::isEmpty)) {
throw new IllegalArgumentException("clients must not be empty");
}
Objects.requireNonNull(elicitationHandler, "elicitationHandler must not be null");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@

package org.springaicommunity.mcp.method.logging;

import java.util.Arrays;
import java.util.Objects;
import java.util.function.Function;

import io.modelcontextprotocol.spec.McpSchema.LoggingMessageNotification;
import reactor.core.publisher.Mono;

public record AsyncLoggingSpecification(String clientId,
public record AsyncLoggingSpecification(String[] clients,
Function<LoggingMessageNotification, Mono<Void>> loggingHandler) {

public AsyncLoggingSpecification {
Objects.requireNonNull(clientId, "clientId must not be null");
if (clientId.trim().isEmpty()) {
throw new IllegalArgumentException("clientId must not be empty");
Objects.requireNonNull(clients, "clients must not be null");
if (clients.length == 0 || Arrays.stream(clients).anyMatch(String::isEmpty)) {
throw new IllegalArgumentException("clients must not be empty");
}
Objects.requireNonNull(loggingHandler, "loggingHandler must not be null");
}
Expand Down
Loading