Get the Java MCP Gateway running in 5 minutes!
# Verify Java 21
java -version
# Should show: openjdk version "21.x.x"
# Verify Maven
mvn -version
# Should show: Apache Maven 3.9.x
# Verify Docker
docker --versionIf Java 21 is not installed:
# Using SDKMAN (recommended)
curl -s "https://get.sdkman.io" | bash
sdk install java 21.0.1-tem
sdk use java 21.0.1-temStart the server with live reload:
cd server-java
# Copy MCP server config
cp ../mcp_servers.yaml .
# Start in dev mode
make dev
# Or: ./mvnw spring-boot:run -Dspring-boot.run.profiles=devThat's it! The server is running on http://localhost:8000
# Health check
curl http://localhost:8000/actuator/health
# List MCP servers
curl http://localhost:8000/mcp/servers
# Actuator endpoints
open http://localhost:8000/actuator
# H2 Database Console
open http://localhost:8000/h2-consoleRun the full stack with PostgreSQL and Keycloak:
cd server-java
# Copy config
cp ../mcp_servers.yaml .
# Initialize and start everything
make init
# Or manually:
docker-compose up -dServices:
- Gateway: http://localhost:8000
- Keycloak: http://localhost:8080 (admin/admin)
- PostgreSQL: localhost:5432
# Get auth token
TOKEN=$(curl -X POST "http://localhost:8080/realms/mcp-gateway/protocol/openid-connect/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=testuser" \
-d "password=testpass" \
-d "grant_type=password" \
-d "client_id=mcp-gateway-client" \
| jq -r '.access_token')
# List servers
curl -H "Authorization: Bearer $TOKEN" http://localhost:8000/mcp/serversBuild and run optimized JAR:
cd server-java
# Build
./mvnw clean package
# Run
java -jar target/mcp-gateway-*.jar
# Or with custom settings
java -jar target/mcp-gateway-*.jar \
--spring.profiles.active=prod \
--server.port=8080curl http://localhost:8000/mcp/servers | jqcurl "http://localhost:8000/mcp/list-tools?mcp_server=default" | jqcurl -X POST http://localhost:8000/mcp/invoke?mcp_server=default \
-H "Content-Type: application/json" \
-d '{
"tool_name": "get_logs",
"parameters": {}
}' | jqcurl "http://localhost:8000/mcp/list-resources?mcp_server=default" | jqcurl -X POST http://localhost:8000/mcp/invoke-broadcast \
-H "Content-Type: application/json" \
-d '{
"tool_name": "health_check",
"parameters": {},
"tags": ["production"]
}' | jqEdit mcp_servers.yaml:
servers:
my-server:
url: http://localhost:3000/mcp
type: http
enabled: true
description: "My custom server"
tags: ["dev"]
tools: ["*"]Create .env file:
# Server
SERVER_PORT=8000
# Database (for production)
SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/mcp_gateway
SPRING_DATASOURCE_USERNAME=mcp_user
SPRING_DATASOURCE_PASSWORD=mcp_password
# Authentication
AUTH_ENABLED=false
KEYCLOAK_URL=http://localhost:8080
KEYCLOAK_REALM=mcp-gateway
# MCP Configuration
MCP_SERVERS_CONFIG=mcp_servers.yaml# Development
make dev # Start dev mode
make dev-debug # Start with debugger (port 5005)
# Building
make build # Build application
make build-skip-tests # Build without tests
# Testing
make test # Run tests
make test-coverage # Run with coverage
# Docker
make docker # Build Docker image
make docker-up # Start all services
make docker-down # Stop services
make docker-logs # View logs
# Database
make db-console # Open H2 console
make db-migrate # Run migrations
make db-reset # Reset database
# Monitoring
make health # Check health
make metrics # Show metrics
make info # Show app infocd server-java
make devThe application will:
- Start on port 8000
- Use H2 in-memory database
- Auto-reload on code changes
- Disable authentication
- Enable debug logging
Edit any Java file - the application will automatically reload!
# In another terminal
make testmake lint
make fmt# Find and kill process
lsof -ti:8000 | xargs kill -9
# Or use different port
SERVER_PORT=8001 make dev# Reset database
make db-reset
# Or use H2 in-memory (dev profile)
SPRING_PROFILES_ACTIVE=dev make dev# Disable auth for testing
AUTH_ENABLED=false make dev
# Or check Keycloak
curl http://localhost:8080# Clean and rebuild
make clean
make build
# Update dependencies
make deps- Read the docs: See README.md for detailed documentation
- Configure servers: Edit
mcp_servers.yamlto add your MCP servers - Enable auth: Set
AUTH_ENABLED=trueand configure Keycloak - Deploy: Use Docker Compose or build production JAR
- Monitor: Check
/actuatorendpoints for metrics and health
- Check logs:
make docker-logs - Health check:
curl http://localhost:8000/actuator/health - Metrics:
curl http://localhost:8000/actuator/metrics - GitHub Issues: Report a bug
# Start everything
cd server-java
make init
# Wait for services (30 seconds)
sleep 30
# Get token
TOKEN=$(curl -X POST "http://localhost:8080/realms/mcp-gateway/protocol/openid-connect/token" \
-d "username=admin" \
-d "password=admin" \
-d "grant_type=password" \
-d "client_id=mcp-gateway-client" \
| jq -r '.access_token')
# List servers
curl -H "Authorization: Bearer $TOKEN" \
http://localhost:8000/mcp/servers | jq
# List tools
curl -H "Authorization: Bearer $TOKEN" \
"http://localhost:8000/mcp/list-tools?mcp_server=default" | jq
# Invoke tool
curl -X POST -H "Authorization: Bearer $TOKEN" \
http://localhost:8000/mcp/invoke?mcp_server=default \
-H "Content-Type: application/json" \
-d '{"tool_name": "get_logs", "parameters": {}}' | jq
# Success!Ready to go! 🚀