Get the FREE Ultimate OpenClaw Setup Guide →

mcp-hello-world

A Kotlin 'Hello World' example for the Model Context Protocol (MCP). This client-server demo uses STDIO for communication, where the client launches an MCP server to execute a simple 'greet' tool. Ideal for understanding MCP's fundamentals without complex LLM integrations.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio rwachters-mcp-hello-world java -jar server/build/libs/mcp-hello-world-server.jar

How to use

This MCP server is a minimal Kotlin-based Hello World example that exposes a single tool named greet. The server runs as a Java JAR and communicates with an MCP client via standard I/O when launched by the client. The paired client discovers the available tools on the server (in this case, greet) and allows an interactive session where you provide tool arguments (for greet, the name) and receive a personalized greeting as the response. The flow demonstrates the core MCP client-server interaction: tool discovery, argument collection, remote execution, and result handling, all without external AI models.

To use it, first build both server and client JARs, then run the client and point it at the server JAR. The client will start the server as a subprocess, establish a communication channel over stdio, and present an interactive prompt. You can see the tool list, select greet, enter the name, and observe the response printed back from the server as Hello, <name>!. This setup is ideal for learning MCP concepts and testing simple tool-based interactions.

How to install

Prerequisites:

  • Java 17 or later
  • Gradle (optional if you use the Gradle wrapper)

Step-by-step installation:

  1. Clone the repository git clone https://github.com/your-username/mcp-hello-world.git cd mcp-hello-world

  2. Build the server and client fat JARs ./gradlew :server:jar ./gradlew :client:jar

  3. Run the client (which will spawn the server as a subprocess) java -jar client/build/libs/mcp-hello-world-client.jar server/build/libs/mcp-hello-world-server.jar

Notes:

  • The server JAR is produced at server/build/libs/mcp-hello-world-server.jar
  • The client JAR is produced at client/build/libs/mcp-hello-world-client.jar
  • Ensure you run each command from the project root or adjust paths accordingly.

Additional notes

Tips and common issues:

  • Fat JARs: Ensure you build the fat JARs (server and client) so runtime dependencies are bundled. This prevents NoClassDefFoundError at runtime.
  • Duplicate entries in jars: If you see Duplicate entry errors during build, verify the jar task excludes META-INF and module-info.class as described in the project notes.
  • Connectivity: If the client cannot connect, verify the server JAR path provided to the client is correct and that the server process starts without permission issues.
  • Logging: If you see SLF4J warnings, you can add a SLF4J binding dependency (e.g., slf4j-simple) to silence the warning; it does not affect functionality.
  • Extending: To add more tools, implement additional Tool definitions in the server and expose them through the MCP Kotlin SDK, then re-build the jars.

Related MCP Servers

Sponsor this space

Reach thousands of developers