mcp-module

Dpun/mcp-module

3.1

If you are the rightful owner of mcp-module and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The Model Context Protocol (MCP) server is a cutting-edge technology that allows AI agents to interact directly with domain models, bypassing the need for traditional APIs.

Building an AI-Powered MCP Server with Spring AI: Querying Product Data without APIs

With the rise of AI assistants and chat-based user interfaces, there’s a growing need to expose backend data in a way that’s more intuitive and context-aware than traditional REST APIs. Enter Spring AI and the Model Context Protocol (MCP) — a powerful combination that enables AI agents to interact directly with domain models without custom APIs.

In this blog post, we’ll walk through how to set up an MCP server using Spring AI to query a simple Product table, which stores details like product name, code, quantity, and price. Instead of creating an API endpoint, we’ll leverage Spring AI’s MCP support to expose the product entity to an AI chat client.

Let’s dive in.

Step 1: Setting Up Your Spring Boot MCP Server

  • spring-boot-starter-data-jpa
  • spring-ai-starter-mcp-server-webflux
  • postgresql

Step 2: Setting Up Your Spring Boot MCP Client

  • spring-ai-starter-mcp-client-webflux
  • spring-ai-starter-model-ollama
  • spring-boot-starter-web

Use Spring Initializr or your IDE.

image