Get the FREE Ultimate OpenClaw Setup Guide →

mcp-java-sdk-examples

A collection of MCP server examples developed by various Java SDKs

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio thought2code-mcp-java-sdk-examples java -jar path/to/mcp-server.jar \
  --env MCP_HOST="host to bind MCP server (default: localhost)" \
  --env MCP_PORT="port to bind MCP server (default: 8080)" \
  --env JAVA_HOME="Path to JDK 17+ installation" \
  --env MCP_LOG_LEVEL="log level (e.g., INFO, DEBUG)"

How to use

This MCP server collection demonstrates the MCP Java SDK capabilities through practical examples, including secure file system operations and other Java-based MCP features. You can explore resources (data loading into the LLM context), tools (actions or side-effectful operations), and prompts (reusable templates) as implemented by the Java SDK examples. Start by running the server instance corresponding to the example you’re interested in (for example, the Filesystem example demonstrates secure file operations with configurable access controls). Once the server is running, you can query resources to fetch data, invoke tools to perform actions, and try out predefined prompts to streamline LLM interactions with your backend.

How to install

Prerequisites:

  • Java 17 or later installed on your machine
  • Git and a Java build tool (Maven or Gradle) depending on the project setup

Installation steps:

  1. Clone the repository: git clone https://github.com/codeboyzhou/mcp-java-sdk-examples.git cd mcp-java-sdk-examples

  2. Build the project (choose the appropriate build tool for the project in use):

    • If using Maven: mvn -version mvn -B -DskipTests package
    • If using Gradle: gradle -version gradle build
  3. Locate the built artifact (e.g., a JAR) in the target or build/libs directory. Ensure you have a JAR for the MCP server example you want to run.

  4. Run the server (adjust the path to the JAR as needed): java -jar path/to/mcp-server.jar

  5. Verify the server is listening on the configured host/port and is accessible to clients. You may need to configure environment variables as described in the mcp_config section.

Additional notes

Tips and common issues:

  • Ensure you are running Java 17+ as required by the MCP Java SDK examples.
  • If the server fails to start, check that the port is not in use and that JAVA_HOME points to a valid JDK 17+ installation.
  • Use environment variables to customize host, port, and log level (MCP_HOST, MCP_PORT, MCP_LOG_LEVEL).
  • The repository may contain multiple example modules (e.g., Filesystem). Start the specific module you want to test by running its corresponding JAR.
  • For debugging, run with a higher log level (DEBUG) to see detailed MCP protocol interactions.

Related MCP Servers

Sponsor this space

Reach thousands of developers