Get the FREE Ultimate OpenClaw Setup Guide →

mcp-spring-demo

Demonstration of MCP with Spring Server and Client, using Ollama

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio jonghough-mcp-spring-demo mvn spring-boot:run

How to use

This MCP server is a Spring-based demo that exposes an MCP Server connected to a PostgreSQL database for a Hospital domain. It provides multiple MCP Tools that enable CRUD operations on doctors, patients, and appointments via natural language requests. The server runs alongside a client app and an Ollama instance, enabling a complete end-to-end flow where user requests are translated into database actions. By default, the MCP Server listens on port 8080, while the MCP Client runs on port 8081 and communicates with Ollama on port 11434. To use the system, start Ollama and the database, then run the MCP Server and Client, and send tool requests via HTTP POST to /tool with a JSON message describing the desired operation.

How to install

Prerequisites:

  • Java 24 or a compatible JDK
  • Maven
  • Docker (for Ollama and local PostgreSQL setup)
  • Docker Compose (optional, for database setup with Flyway migrations)

Setup steps:

  1. Install prerequisites on your system (Java, Maven, Docker).

  2. Start the Ollama service (if not running separately):

docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
  1. Start the PostgreSQL database with migrations ( Flyway ) using Docker Compose if you have a docker-compose.yml configured as shown in the project:
docker compose up --build
  1. Build and run the MCP Server (from the mcp-server module directory):
mvn spring-boot:run
  1. Run the MCP Client (from the mcp-client module directory) if you want to test the client-side:
mvn spring-boot:run
  1. Verify the server is running on http://localhost:8080 and the client on http://localhost:8081.

Additional notes

Notes:

  • Ensure the PostgreSQL database is accessible on port 5432 and that Flyway migrations are applied to set up doctors, patients, and appointments tables.
  • The Ollama service should be reachable at http://localhost:11434 unless you customize the host/port.
  • If you change ports, update the client and Ollama configurations accordingly.
  • Typical environment variables you might configure include database URL, username, and password for the server to connect to PostgreSQL; these would be provided via your Spring configuration (e.g., application.properties or environment variables like SPRING_DATASOURCE_URL, SPRING_DATASOURCE_USERNAME, SPRING_DATASOURCE_PASSWORD).
  • If you encounter issues with the MCP Tools, check server logs for any tool registration or schema errors and verify that the database schema matches the expected models (doctors, patients, appointments).

Related MCP Servers

mcp-for-beginners

14.5k

This open-source curriculum introduces the fundamentals of Model Context Protocol (MCP) through real-world, cross-language examples in .NET, Java, TypeScript, JavaScript, Rust and Python. Designed for developers, it focuses on practical techniques for building modular, scalable, and secure AI workflows from session setup to service orchestration.

ai-code-helper

489

2025 年 AI 编程助手实战项目(作者:程序员鱼皮),基于 Spring Boot 3.5 + Java 21 + LangChain4j + AI 构建智能编程学习与求职辅导机器人,覆盖 AI 大模型接入、LangChain4j 核心特性、流式对话、Prompt 工程、RAG 检索增强、向量数据库、Tool Calling 工具调用、MCP 模型上下文协议、Web 爬虫、安全防护、Vue.js 前端开发、SSE 服务端推送等企业级 AI 应用开发技术。帮助开发者掌握 AI 时代必备技能,熟悉 LangChain 框架,提升编程学习效率和求职竞争力,成为企业需要的 AI 全栈开发人才。

api2mcp4j

96

This is a revolutionary AI MCP plugin with excellent pluggable and encapsulated features. With just a few lines of configuration, it can easily integrate into your Spring boot web program and give it MCP capabilities,inheriting the powerful engineering capabilities of the Spring series framework

LLaMa -Streamlit

43

AI assistant built with Streamlit, NVIDIA NIM (LLaMa 3.3:70B) / Ollama, and Model Control Protocol (MCP).

LSP4J

11

A Java MCP (Model Context Protocol) server that wraps JDTLS (Eclipse JDT Language Server) using LSP4J to provide Java IDE features to AI assistants like Claude.

mcp-llama3-client

8

A client for the MCP Flight Search service using Ollama and Llama 3.2 to provide a user-friendly flight search interface with Model Context Protocol tools

Sponsor this space

Reach thousands of developers