Add mcp-advanced module: resources, prompts, sampling and elicitation on Spring AI 2.0.2 and MCP Java SDK 2.1.0
An incident-desk MCP server with a fixed resource, two resource templates, a prompt, a tool that borrows the client's model (sampling) and a tool that asks the operator to approve a restart (elicitation). Driven by a plain SDK client in JUnit and by raw curl, so the JSON-RPC for both server-to-client requests is committed. Also captured: a client that declared neither capability (a gated tool degrades, an ungated one returns an isError result), a slow client hitting the server request timeout, and protocol=STATELESS silently dropping every tool that takes McpSyncRequestContext (one WARN line, an empty tools/list). Negotiated protocol version is 2025-11-25; the 2026-07-28 spec is not implemented by SDK 2.1.0. No docs/ folder. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b5jAFLJrmUXmbo5EuV
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package com.ankurm.mcpadvanced;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/** Fixed in-memory data so every run of the demo reads the same bytes. */
|
||||
@Component
|
||||
public class IncidentData {
|
||||
|
||||
private final Map<String, String> logs = Map.of(
|
||||
"INC-1042", """
|
||||
09:14:02 payments-api WARN connection pool at 48/50
|
||||
09:14:09 payments-api ERROR timeout acquiring connection after 30000ms
|
||||
09:14:09 payments-api ERROR timeout acquiring connection after 30000ms
|
||||
09:14:31 payments-api ERROR HTTP 503 returned to 212 clients
|
||||
09:15:02 payments-db WARN slow query 14.8s: SELECT * FROM ledger WHERE account_id = ?
|
||||
""",
|
||||
"INC-1043", """
|
||||
11:02:44 search-api WARN index segment merge running
|
||||
11:02:51 search-api INFO p99 latency 840ms (SLO 500ms)
|
||||
""");
|
||||
|
||||
private final Map<String, String> runbooks = Map.of(
|
||||
"payments", "1. Check pool metrics. 2. Look for slow queries on payments-db. 3. Restart payments-api only after approval.",
|
||||
"search", "1. Check segment merges. 2. Scale read replicas. 3. Restart is safe at any time.");
|
||||
|
||||
public String log(String incidentId) {
|
||||
return logs.get(incidentId);
|
||||
}
|
||||
|
||||
public String runbook(String service) {
|
||||
return runbooks.get(service);
|
||||
}
|
||||
|
||||
public List<String> incidentIds() {
|
||||
return logs.keySet().stream().sorted().toList();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user