Skip to content

microsoft/lets-learn-mcp-java

Repository files navigation

Learn MCP Java Tutorial

A comprehensive Java tutorial demonstrating Model Context Protocol (MCP) implementation with Quarkus server and LangChain4j client, featuring a monkey species dataset for hands-on learning.

πŸ“š Tutorial Overview

This project showcases a complete MCP ecosystem built in Java, including:

  • MCP Server: Quarkus-based HTTP SSE server with monkey species data tools
  • MCP Client: Interactive CLI client using LangChain4j and Ollama integration
  • Step-by-step Documentation: Complete guides for building MCP applications with GitHub Copilot

πŸš€ Quick Start

Prerequisites

  • Java 21+
  • Maven 3.8+
  • VS Code with Java Extension Pack
  • Ollama (for LLM integration)

Getting Started

  1. Clone the repository

    git clone https://github.com/brunoborges/monkey-mcp-java.git
    cd monkey-mcp-java
  2. Start the MCP Server

    cd monkey-mcp-server
    ./mvnw quarkus:dev
  3. Run the MCP Client

    cd monkey-mcp-client
    ./mvnw package
    java -jar target/monkey-mcp-client.jar

πŸ“– Tutorial Structure

This tutorial is organized into sequential parts:

Part Title Description
Part 1: Prerequisites and Setup Project Setup Install tools, understand MCP, and prepare your environment
Part 2: Building the MCP Server MCP Server Build a Quarkus-based MCP server with monkey species tools
Part 3: Building the MCP Client MCP Client Create an interactive CLI client using LangChain4j

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    MCP Protocol    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   AI Assistant  β”‚ ◄─────────────────►│   MCP Server     β”‚
β”‚ (VS Code, etc.) β”‚    (HTTP SSE)      β”‚ (Java/Quarkus)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                              β”‚
                                              β–Ό
                                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                       β”‚  Monkey Services β”‚
                                       β”‚ (Business Logic) β”‚
                                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ’ Featured Tools

The MCP server provides these monkey species tools:

  • List Species: Get all available monkey species
  • Species Details: Retrieve detailed information about specific species
  • Random Species: Get a random monkey species
  • Statistics: View dataset statistics and access counts

πŸ› οΈ Technology Stack

  • Java 21: Modern Java features and performance
  • Quarkus: Supersonic Subatomic Java Framework
  • LangChain4j: Java framework for building LLM applications
  • Ollama: Local LLM runtime
  • Maven: Build and dependency management
  • PicoCLI: Command-line interface framework

🎯 Learning Objectives

By completing this tutorial, you will:

  • Understand MCP protocol and its benefits
  • Build production-ready MCP servers with Quarkus
  • Create MCP clients using LangChain4j
  • Integrate with local LLMs using Ollama
  • Apply AI-assisted development with GitHub Copilot

πŸ“ Project Structure

monkey-mcp-java/
β”œβ”€β”€ 00_PROJECT_SETUP.md       # Prerequisites and environment setup
β”œβ”€β”€ 01_MCP_SERVER.md          # MCP Server implementation guide
β”œβ”€β”€ 02_MCP_CLIENT.md          # MCP Client implementation guide
β”œβ”€β”€ monkey-mcp-server/        # Quarkus MCP server project
β”‚   β”œβ”€β”€ src/main/java/        # Java source code
β”‚   └── pom.xml              # Maven dependencies
└── monkey-mcp-client/        # LangChain4j MCP client project
    β”œβ”€β”€ src/main/java/        # Java source code
    └── pom.xml              # Maven dependencies

🀝 Contributing

This is an educational project designed to teach MCP implementation in Java. Contributions, suggestions, and improvements are welcome!

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ”— Useful Links


Start your MCP journey: Part 1 - Prerequisites and Setup β†’

About

Learn how to build Java-based MCP Servers and Clients with LangChain4J and Quarkus

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Contributors

Languages