You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-ai-docs/src/main/antora/modules/ROOT/pages/api/mcp/mcp-annotations-client.adoc
+34-34Lines changed: 34 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ The MCP Client Annotations provide a declarative way to implement MCP client han
4
4
These annotations simplify the handling of server notifications and client-side operations.
5
5
6
6
[IMPORTANT]
7
-
**All MCP client annotations MUST include a `clientId` parameter** to associate the handler with a specific MCP client connection. The `clientId` must match the connection name configured in your application properties.
7
+
**All MCP client annotations MUST include a `clients` parameter** to associate the handler with a specific MCP client connection. The `clients` must match the connection name configured in your application properties.
8
8
9
9
== Client Annotations
10
10
@@ -19,7 +19,7 @@ The `@McpLogging` annotation handles logging message notifications from MCP serv
19
19
@Component
20
20
public class LoggingHandler {
21
21
22
-
@McpLogging(clientId = "my-mcp-server")
22
+
@McpLogging(clients = "my-mcp-server")
23
23
public void handleLoggingMessage(LoggingMessageNotification notification) {
@@ -382,7 +382,7 @@ public class PromptListChangedHandler {
382
382
383
383
[source,java]
384
384
----
385
-
@McpPromptListChanged(clientId = "prompt-server")
385
+
@McpPromptListChanged(clients = "prompt-server")
386
386
public Mono<Void> handleAsyncPromptUpdate(List<McpSchema.Prompt> updatedPrompts) {
387
387
return Flux.fromIterable(updatedPrompts)
388
388
.flatMap(prompt -> validatePrompt(prompt))
@@ -409,18 +409,18 @@ public class McpClientApplication {
409
409
410
410
@Component
411
411
public class MyClientHandlers {
412
-
413
-
@McpLogging(clientId = "my-server")
412
+
413
+
@McpLogging(clients = "my-server")
414
414
public void handleLogs(LoggingMessageNotification notification) {
415
415
// Handle logs
416
416
}
417
-
418
-
@McpSampling(clientId = "my-server")
417
+
418
+
@McpSampling(clients = "my-server")
419
419
public CreateMessageResult handleSampling(CreateMessageRequest request) {
420
420
// Handle sampling
421
421
}
422
-
423
-
@McpProgress(clientId = "my-server")
422
+
423
+
@McpProgress(clients = "my-server")
424
424
public void handleProgress(ProgressNotification notification) {
425
425
// Handle progress
426
426
}
@@ -448,23 +448,23 @@ spring:
448
448
type: SYNC # or ASYNC
449
449
annotation-scanner:
450
450
enabled: true
451
-
# Configure client connections - the connection names become clientId values
451
+
# Configure client connections - the connection names become clients values
452
452
sse:
453
453
connections:
454
-
my-server: # This becomes the clientId
454
+
my-server: # This becomes the clients
455
455
url: http://localhost:8080
456
-
tool-server: # Another clientId
456
+
tool-server: # Another clients
457
457
url: http://localhost:8081
458
458
stdio:
459
459
connections:
460
-
local-server: # This becomes the clientId
460
+
local-server: # This becomes the clients
461
461
command: /path/to/mcp-server
462
462
args:
463
463
- --mode=production
464
464
----
465
465
466
466
[IMPORTANT]
467
-
The `clientId` parameter in annotations must match the connection names defined in your configuration. In the example above, valid `clientId` values would be: `"my-server"`, `"tool-server"`, and `"local-server"`.
467
+
The `clients` parameter in annotations must match the connection names defined in your configuration. In the example above, valid `clients` values would be: `"my-server"`, `"tool-server"`, and `"local-server"`.
468
468
469
469
== Usage with MCP Client
470
470
@@ -475,11 +475,11 @@ The annotated handlers are automatically integrated with the MCP client:
475
475
@Autowired
476
476
private List<McpSyncClient> mcpClients;
477
477
478
-
// The clients will automatically use your annotated handlers based on clientId
478
+
// The clients will automatically use your annotated handlers based on clients
479
479
// No manual registration needed - handlers are matched to clients by name
480
480
----
481
481
482
-
For each MCP client connection, handlers with matching `clientId` will be automatically registered and invoked when the corresponding events occur.
482
+
For each MCP client connection, handlers with matching `clients` will be automatically registered and invoked when the corresponding events occur.
0 commit comments