MCP ExplorerExplorer

Mcp Java Sample

@Saularch97on 9 months ago
1 MIT
FreeCommunity
AI Systems
Sample of an MCP server using Spring AI with Java

Overview

What is Mcp Java Sample

mcp-java-sample is a minimal Spring Boot application that implements an MCP (Model Controller Provider) server using Spring AI. It serves as an external MCP server for client applications.

Use cases

Use cases for mcp-java-sample include serving machine learning models to applications, providing data processing capabilities for client applications, and acting as a backend service for AI-driven solutions.

How to use

To use mcp-java-sample, clone the project from GitHub, build it using Maven, and configure your client to connect to the server by specifying the path to the generated JAR file and the desired host and port settings.

Key features

Key features include a minimalistic design, integration with Spring AI, easy configuration for client applications, and support for Java 21 and Maven 3.8+.

Where to use

mcp-java-sample can be used in various fields where model serving is required, such as machine learning applications, data processing services, and any client-server architecture needing a model controller.

Content

MCP Sample Java Application

This is a minimal Spring Boot application implementing an MCP (Model Controller Provider) server using Spring AI.
It is designed to be used as an external MCP server for client applications.


🚀 Getting Started

1. Clone the Project

    git clone [email protected]:Saularch97/mcp-java-sample.git
    cd openmeteomcp

2. Build the Project

  mvn clean package

The output will be located at target/openmeteomcp-0.0.1-SNAPSHOT.jar

⚙️ Client Configuration

To run the server from your client, insert the following configuration:

{
  "mcpServers": {
    "mcpopenmeteo": {
      "command": "java",
      "args": [
        "-jar",
        "<PATH_TO_YOUR_PROJECT>/openmeteomcp/target/openmeteomcp-0.0.1-SNAPSHOT.jar",
        "--port",
        "8080",
        "--host",
        "localhost"
      ]
    }
  }
}

Replace <PATH_TO_YOUR_PROJECT> with the actual path to your project directory.

📦 Project Dependencies

The project depends on the following Spring AI starter module:

<dependencies>
    <dependency>
        <groupId>org.springframework.ai</groupId>
        <artifactId>spring-ai-starter-mcp-server-webmvc</artifactId>
    </dependency>
</dependencies>

🧰 Requirements

  • Java 21
  • Maven 3.8+

To use the project just connect with an client, Cursor, ClaudeDesktop, Vscode etc.

img.png

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers