Add mcp-server module: order-lookup service exposed via @McpTool/@McpResource/@McpPrompt over Streamable HTTP

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FtpJvZfg4nvLvtzgJTDWpB
This commit is contained in:
Claude
2026-09-23 11:56:37 +00:00
parent c1fc41e0de
commit 9919da58a7
21 changed files with 704 additions and 0 deletions
@@ -0,0 +1,11 @@
package com.ankurm.mcpserver.domain;
import java.math.BigDecimal;
import java.util.List;
/**
* The existing domain type this module pretends predates MCP entirely -- the point of this
* article is exposing a service that already looks like this, not designing one around MCP.
*/
public record Order(String id, String customer, OrderStatus status, List<String> items, BigDecimal total) {
}
@@ -0,0 +1,41 @@
package com.ankurm.mcpserver.domain;
import java.math.BigDecimal;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.springframework.stereotype.Repository;
/**
* Stand-in for a real order-lookup service (a JPA repository, a call to another microservice,
* whatever it actually is at your shop). The MCP-facing code in {@code tools} never needs to
* change if this gets replaced with the real thing -- it depends on this interface's shape, not
* its storage.
*/
@Repository
public class OrderRepository {
private final Map<String, Order> orders = new LinkedHashMap<>();
public OrderRepository() {
orders.put("ORD-1001", new Order("ORD-1001", "Priya Nair", OrderStatus.SHIPPED,
List.of("Mechanical keyboard", "USB-C cable"), new BigDecimal("4899.00")));
orders.put("ORD-1002", new Order("ORD-1002", "Rohan Mehta", OrderStatus.PENDING,
List.of("27\" monitor"), new BigDecimal("18999.00")));
orders.put("ORD-1003", new Order("ORD-1003", "Ankita Rao", OrderStatus.DELIVERED,
List.of("Laptop stand", "Wireless mouse", "USB hub"), new BigDecimal("3450.00")));
orders.put("ORD-1004", new Order("ORD-1004", "Vikram Shah", OrderStatus.CANCELLED,
List.of("Graphics card"), new BigDecimal("42999.00")));
}
public Optional<Order> findById(String id) {
return Optional.ofNullable(orders.get(id));
}
public List<Order> findAll() {
return List.copyOf(orders.values());
}
}
@@ -0,0 +1,5 @@
package com.ankurm.mcpserver.domain;
public enum OrderStatus {
PENDING, SHIPPED, DELIVERED, CANCELLED
}