anmiralles/quarkus-mcp-server-example
If you are the rightful owner of quarkus-mcp-server-example 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.
This document provides a comprehensive overview of setting up a Model Context Protocol (MCP) server using Quarkus, enabling interaction with REST APIs through defined tools.
Quarkus MCP Server Example
A comprehensive example demonstrating how to build a Model Context Protocol (MCP) server using Quarkus that exposes REST API operations as AI tools. This enables Large Language Models like Claude to interact with your application data through natural language using the Goose CLI.
šÆ What This Example Demonstrates
This project showcases the integration of three powerful technologies:
- Quarkus: Supersonic, subatomic Java framework for building modern applications
- MCP (Model Context Protocol): Open standard for connecting AI assistants to data sources and tools
- Goose CLI: AI-powered development assistant that can interact with MCP servers
š Table of Contents
- What is MCP?
- What is Quarkus?
- What is Goose?
- Solution Architecture
- Prerequisites
- Running the Example
- Usage Examples
š What is MCP?
Model Context Protocol (MCP) is an open standard that enables AI assistants to securely connect to and interact with various data sources and tools. Instead of building custom integrations for each AI assistant, MCP provides a universal protocol for:
- Tool Discovery: AI assistants can discover what tools are available
- Tool Execution: Safely execute operations on external systems
- Data Access: Retrieve and manipulate data from various sources
- Standardization: One implementation works with any MCP-compatible AI assistant
MCP Benefits
- Interoperability: Works with any MCP-compatible AI assistant
- Security: Controlled access to external resources
- Extensibility: Easy to add new tools and capabilities
- Standardization: No need for custom integrations per AI assistant
ā” What is Quarkus?
Quarkus is a Kubernetes-native Java framework designed for modern application development:
- Fast Startup: Sub-second startup times
- Low Memory Usage: Optimized for containerized environments
- Developer Joy: Live reload, unified configuration, and great tooling
- Cloud Native: Built for Kubernetes, serverless, and microservices
- Standards Based: Uses familiar Java standards (JAX-RS, CDI, JPA)
Quarkus for MCP
Quarkus is ideal for MCP servers because:
- Quick Development: Fast feedback loop with live reload
- Lightweight: Minimal resource usage for tool servers
- Native Compilation: Ultra-fast startup with GraalVM
- Rich Ecosystem: Extensive extensions for database, REST clients, etc.
š¦ What is Goose?
Goose is an AI-powered development assistant CLI that helps developers by:
- Natural Language Interface: Interact with your development environment using plain English
- MCP Integration: Connects to MCP servers to access external tools and data
- Context Awareness: Understands your project structure and codebase
- Tool Execution: Can execute commands, modify files, and interact with APIs
- Multi-Model Support: Works with various LLMs including Claude, GPT, etc.
Goose with MCP
When combined with MCP servers, Goose can:
- Query databases through natural language
- Interact with REST APIs without manual curl commands
- Perform complex operations by combining multiple tools
- Provide intelligent insights based on your application data
šļø Solution Architecture
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā MCP Integration Flow ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāā MCP Protocol āāāāāāāāāāāāāāāāāāā REST API āāāāāāāāāāāāāāāā
ā ā (JSON-RPC over ā ā (HTTP/JSON) ā ā
ā Goose āāāāāāāāāāāāāāāāāāāāāāŗā Quarkus MCP āāāāāāāāāāāāāāāāāŗā Quarkus ā
ā CLI ā STDIO/SSE) ā Server ā ā Applications ā
ā ā ā ā ā MS ā
āāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāā
ā ā ā
ā ā ā
āāāāāāāā¼āāāāāāā āāāāāāā¼āāāāāā āāāāāāāāā¼āāāāāāāā
ā ā ā ā ā ā
ā Claude ā ā MCP Tools ā ā PostgreSQL ā
ā LLM ā ā ā ā Database ā
ā ā ā ⢠list ā ā ā
āāāāāāāāāāāāāāā ā ⢠get ā āāāāāāāāāāāāāāāāā
ā ⢠filter ā
ā ⢠add ā
āāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Data Flow ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
1. User asks Goose: "Show me all applications from Spain"
ā
2. Goose sends MCP request to discover available tools
ā
3. MCP Server exposes tools: list_applications, get_applications_by_country, etc.
ā
4. Goose calls get_applications_by_country("Spain") tool
ā
5. MCP Server makes REST call to Applications MS
ā
6. Applications MS queries PostgreSQL database
ā
7. Results flow back through the chain to Goose
ā
8. Goose presents results to user in natural language
Component Responsibilities
Component | Purpose | Technology |
---|---|---|
Goose CLI | AI assistant interface, natural language processing | Go, LLM integration |
Quarkus MCP Server | Protocol bridge, tool definitions | Quarkus, MCP protocol |
Quarkus Applications MS | Business logic, data operations | Quarkus, JAX-RS, Hibernate |
PostgreSQL | Data persistence | Relational database |
Prerequisites
Before running this example, ensure you have the following installed:
- Java 21: Required for Quarkus applications
- Maven: Build tool for the Java projects
- Podman/Docker: Container runtime for PostgreSQL database
- Goose CLI: AI assistant tool (installation guide)
Installing Goose
# Using Go (requires Go 1.21+)
go install github.com/square/goose@latest
# Or download binary from releases
# https://github.com/square/goose/releases
š Running the Example
Step 1: Build the Project
mvn clean package
Step 2: Start PostgreSQL Database
podman run -d --name db-server \
-e POSTGRES_USER=test \
-e POSTGRES_PASSWORD=test \
-e POSTGRES_DB=applications \
-p 5432:5432 \
postgres:16
Step 3: Start the Applications Microservice
cd quarkus-applications-ms && mvn quarkus:dev
The applications service will start on http://localhost:8080
Step 4: (Optional) Add Sample Data
curl -i -X POST \
-F "name=Angel" \
-F "surname=Miralles" \
-F "personalId=12345R" \
-F "country=Spain" \
http://localhost:8080/application.html
curl -i -X POST \
-F "name=Juan" \
-F "surname=Garcia" \
-F "personalId=31234R" \
-F "country=Spain" \
http://localhost:8080/application.html
curl -i -X POST \
-F "name=Pedro" \
-F "surname=Rodriguez" \
-F "personalId=54321R" \
-F "country=Germany" \
http://localhost:8080/application.html
Step 5: Start Goose with MCP Server
goose session --with-extension="java -jar quarkus-mcp-server/target/quarkus-mcp-server-1.0.0-SNAPSHOT.jar"
š” Usage Examples
Once you have Goose running with the MCP server, you can interact with your application data using natural language:
Basic Queries
> Show me all applications in the system
> List applications from Spain
> Get application with ID 1
Filtered Queries
> Show me all applications from France with COMPLETED status
> List all STARTED applications
> Find applications from Germany
Data Management
> Add a new application for John Doe from USA with ID 67890
> Create an application for Maria Garcia from Mexico
Available MCP Tools
The MCP server exposes these tools to Goose:
Tool Name | Description | Parameters |
---|---|---|
list_applications | Lists all applications | None |
get_application_by_id | Get specific application | id: Long |
get_applications_by_country | Filter by country | countryName: String |
get_applications_by_country_and_status | Filter by country and status | countryName: String , status: ApplicationStatus |
add_application | Create new application | application: Application |
Application Status Values
STARTED
PREPROCESSED
PROCESSED
COMPLETED
CANCELED
ERROR
š§ Development
Development Mode
# Start applications service in dev mode (hot reload)
cd quarkus-applications-ms && mvn quarkus:dev
# Package MCP server for testing
cd quarkus-mcp-server && mvn package
Project Structure
quarkus-mcp-server-example/
āāā quarkus-applications-ms/ # REST API microservice
ā āāā src/main/java/me/amiralles/applications/
ā ā āāā boundary/ApplicationsResource.java # REST endpoints
ā ā āāā entity/Application.java # JPA entity
ā ā āāā control/ApplicationExceptionMapper.java
ā āāā src/main/resources/application.properties
āāā quarkus-mcp-server/ # MCP server
ā āāā src/main/java/me/amiralles/mcp/
ā ā āāā McpApplicationsServer.java # MCP tools definition
ā ā āāā client/ApplicationsClient.java # REST client
ā ā āāā model/Application.java # Data models
ā āāā src/test/java/
āāā deployment/docker-compose/ # Monitoring stack
š References
š License
This project is provided as an example for educational purposes.