This project is a Spring Boot 3 application that exposes a legacy inventory service as an MCP (Model Context Protocol) server using Spring AI.
- Java 17 or higher
- Maven 3.8+
-
Build the project:
mvn clean install
-
Run the application:
mvn spring-boot:run
-
Access the MCP Server:
- The server will be running on
http://localhost:8080. - The MCP SSE endpoint is available at
http://localhost:8080/mcp.
- The server will be running on
getStockLevel: Retrieve current stock level for a product.updateLeadTime: Update supplier lead time for a purchase order.
inventory://warehouse/{warehouseCode}: Get a JSON snapshot of a warehouse's inventory.
In MCP, choosing between a Tool and a Resource depends on the intent of the interaction.
| Feature | Tools | Resources |
|---|---|---|
| Nature | Active (Action-oriented) | Passive (Data-oriented) |
| Interaction | LLM calls the tool to perform a task. | LLM reads the resource to gain context. |
| Side Effects | Can change system state (Write/Update). | Read-only (Idempotent). |
| Example | updateLeadTime(orderId, days) |
inventory://warehouse/WH001 |
Use a Tool when the LLM needs to do something or perform a calculation that requires specific parameters.
- Example:
getStockLevelis a tool because the LLM needs to provide aproductCodeto get a specific answer. It's a "query" action. - Example:
updateLeadTimeis a tool because it changes data in the system.
Use a Resource when you want to provide a "document" or a "snapshot" of data that the LLM can use as background knowledge.
- Example:
inventory://warehouse/{warehouseCode}is a resource because it provides a complete snapshot of everything in a warehouse. The LLM can then look through this data to answer multiple questions without making further tool calls.
You can test this server using the MCP Inspector: