Skip to content

IssacAX123/OpenLiberty-Work-Experience-Demos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenLiberty Work Experience Demos

A collection of OpenLiberty demonstrations showcasing REST API development and MCP (Model Context Protocol) integration.

📚 Overview

This repository contains two progressive demonstrations:

  1. Demo1 - Basic REST API with OpenLiberty
  2. Demo2 - REST API exposed as MCP tools using OpenLiberty's beta mcpServer-1.0 feature

🎯 What You'll Learn

  • Building REST APIs with OpenLiberty and JAX-RS
  • Implementing health checks with MicroProfile Health
  • Exposing REST endpoints as MCP tools
  • Working with OpenLiberty beta features
  • Creating AI-accessible tools via MCP protocol

📁 Repository Structure

OpenLiberty-Work-Experience-Demos/
├── README.md                    # This file
├── Demo1/                       # Basic REST API demo
│   ├── README.md               # Demo1 documentation
│   ├── pom.xml                 # Maven configuration
│   └── src/                    # Source code
│       └── main/
│           ├── java/           # Java source files
│           └── liberty/config/ # OpenLiberty configuration
│
└── Demo2/                       # MCP Server demo
    ├── README.md               # Demo2 documentation
    ├── QUICKSTART.md           # Quick start guide
    ├── pom.xml                 # Maven with beta features
    └── src/                    # Source code
        └── main/
            ├── java/           # Java source files
            └── liberty/config/ # OpenLiberty + MCP configuration

🚀 Quick Start

Prerequisites

  • Java 11 or higher
  • Maven 3.6 or higher
  • Git (for cloning)

Clone the Repository

git clone https://github.com/YOUR_USERNAME/OpenLiberty-Work-Experience-Demos.git
cd OpenLiberty-Work-Experience-Demos

Run Demo1 (Basic REST API)

cd Demo1
mvn liberty:dev

Access at: http://localhost:9080

Run Demo2 (MCP Server)

cd Demo2
mvn liberty:dev

Access at:

📖 Demos

Demo1: Basic REST API

A foundational OpenLiberty application demonstrating:

  • ✅ JAX-RS REST endpoints
  • ✅ JSON-B and JSON-P for data handling
  • ✅ MicroProfile Health checks
  • ✅ CDI (Contexts and Dependency Injection)

Endpoints:

  • GET /api/hello - Simple greeting
  • GET /api/hello/{name} - Personalized greeting
  • GET /api/info - Server information
  • GET /api/orders - List all orders
  • GET /api/orders/{orderId} - Get specific order
  • GET /api/orders/stats - Order statistics
  • GET /health - Health checks

📄 Full Demo1 Documentation

Demo2: MCP Server Integration

Extends Demo1 with OpenLiberty's beta mcpServer-1.0 feature:

  • ✅ All Demo1 features
  • ✅ MCP Server on port 3000
  • ✅ REST endpoints exposed as MCP tools
  • ✅ Server-Sent Events (SSE) support
  • ✅ AI assistant integration ready

MCP Tools (9 total):

  1. hello - Simple greeting
  2. hello_name - Personalized greeting
  3. get_server_info - Server information
  4. get_all_orders - List all orders
  5. get_order_by_id - Get specific order
  6. get_order_stats - Order statistics
  7. health_check - Overall health
  8. health_check_liveness - Liveness probe
  9. health_check_readiness - Readiness probe

📄 Full Demo2 Documentation | ⚡ Quick Start Guide

🔧 Technology Stack

Technology Version Purpose
OpenLiberty Latest Application server
Jakarta EE 9.1 Enterprise Java APIs
MicroProfile 5.0 Cloud-native features
JAX-RS 3.0 REST API framework
JSON-B 2.0 JSON binding
JSON-P 2.0 JSON processing
CDI 3.0 Dependency injection
Maven 3.6+ Build tool
Java 11+ Programming language

Demo2 Additional:

Technology Version Purpose
mcpServer-1.0 Beta MCP protocol support
OpenLiberty Beta Latest Beta features

📊 Feature Comparison

Feature Demo1 Demo2
REST Endpoints
Health Checks
Order Management
MCP Server
MCP Tools ✅ (9 tools)
AI Integration
SSE Support
Beta Features

🧪 Testing

Test REST Endpoints

# Hello endpoint
curl http://localhost:9080/api/hello

# Personalized greeting
curl http://localhost:9080/api/hello/Developer

# Server info
curl http://localhost:9080/api/info

# All orders
curl http://localhost:9080/api/orders

# Specific order
curl http://localhost:9080/api/orders/ORD-001

# Order statistics
curl http://localhost:9080/api/orders/stats

# Health check
curl http://localhost:9080/health

Test MCP Tools (Demo2 only)

# List available tools
curl -X POST http://localhost:3000/tools/list \
  -H "Content-Type: application/json" \
  -d '{}'

# Call hello tool
curl -X POST http://localhost:3000/tools/call \
  -H "Content-Type: application/json" \
  -d '{"name": "hello", "arguments": {}}'

# Call get_all_orders tool
curl -X POST http://localhost:3000/tools/call \
  -H "Content-Type: application/json" \
  -d '{"name": "get_all_orders", "arguments": {}}'

# Call get_order_by_id tool
curl -X POST http://localhost:3000/tools/call \
  -H "Content-Type: application/json" \
  -d '{"name": "get_order_by_id", "arguments": {"orderId": "ORD-001"}}'

🤖 AI Integration (Demo2)

Demo2 can be integrated with MCP-compatible AI assistants:

Claude Desktop

Add to your Claude Desktop config:

{
  "mcpServers": {
    "openliberty-demo": {
      "url": "http://localhost:3000"
    }
  }
}

Cline (VS Code Extension)

Add to Cline MCP settings:

{
  "servers": {
    "openliberty-demo": {
      "url": "http://localhost:3000"
    }
  }
}

📚 Learning Path

  1. Start with Demo1 - Understand basic REST API development with OpenLiberty
  2. Explore the code - Review the Java classes and configuration files
  3. Test the endpoints - Use curl or a browser to interact with the API
  4. Move to Demo2 - Learn about MCP integration
  5. Connect an AI client - Experience AI-powered tool usage
  6. Extend the demos - Add your own endpoints and tools

🛠️ Development

Building

# Build Demo1
cd Demo1
mvn clean package

# Build Demo2
cd Demo2
mvn clean package

Running in Dev Mode (Hot Reload)

# Demo1
cd Demo1
mvn liberty:dev

# Demo2
cd Demo2
mvn liberty:dev

Press Ctrl+C to stop the server.

Running in Production Mode

# Start
mvn liberty:run

# Stop (in another terminal)
mvn liberty:stop

🐛 Troubleshooting

Port Already in Use

If port 9080 or 3000 is already in use:

Demo1/Demo2 HTTP Port: Edit pom.xml:

<liberty.var.default.http.port>9081</liberty.var.default.http.port>

Demo2 MCP Port: Edit src/main/liberty/config/server.xml:

<mcpServer id="demo2McpServer" port="3001" ... />

Beta Feature Not Found (Demo2)

Ensure you have internet connection for Maven to download the beta runtime on first build:

mvn clean install -U

Build Failures

  1. Verify Java version: java -version (should be 11+)
  2. Verify Maven version: mvn -version (should be 3.6+)
  3. Clean and rebuild: mvn clean install

📖 Resources

OpenLiberty

Jakarta EE & MicroProfile

MCP (Model Context Protocol)

Maven

⚠️ Important Notes

  • Demo2 Beta Feature: The mcpServer-1.0 feature is a beta feature and may change in future releases. Do not use in production environments.
  • Security: These demos run without authentication for simplicity. Always implement proper security in production.
  • Fake Data: Order endpoints return fake/mock data for demonstration purposes.

🤝 Contributing

This is a demonstration project for educational purposes. Feel free to:

  • Fork the repository
  • Create your own demos
  • Submit issues for bugs or improvements
  • Share your learning experience

📝 License

This project is created for educational purposes as part of OpenLiberty work experience.

👨‍💻 Author

Created during OpenLiberty Work Experience program.

🙏 Acknowledgments

  • OpenLiberty team for the excellent framework and beta features
  • MicroProfile community for cloud-native specifications
  • Model Context Protocol team for the MCP specification

Happy Learning! 🚀

For detailed documentation, see the README files in each demo directory.

About

OpenLiberty demonstrations showcasing REST API development and MCP (Model Context Protocol) integration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages