This is a Vanilla Kotlin-based MCP (Model Context Protocol) server using JSON-RPC 2.0 over stdin/stdout. It exposes two tool:
- 🔍 getMenu: Finds drinks listend on the menu allowing filtering by cost, ingredients, preparation and availability or neither of them.
- 🎯 getBeverage: Displays full information about the desired beverage.
- 📦 Java 17+ (ensure
JAVA_HOMEis set). - 🛠️ Executable Gradle Wrapper (
./gradlew). - (Optional) 🐚
jqfor pretty-printing JSON in the console. - (Optional) 🎛️
npx @modelcontextprotocol/inspectorfor interactive testing.
# From the project root:
./gradlew build shadowJarThis produces a "fat" JAR at build/libs/mcpstdio-all.jar 📦.
# From the project root:
./gradlew runecho '{"jsonrpc":"2.0","id":1,"method":"initialize"}' \
| java -jar build/libs/mcpstdio-all.jar | jq .echo '{"jsonrpc":"2.0","id":2,"method":"tools/list"}' \
| java -jar build/libs/mcpstdio-all.jar | jq .echo '{
"jsonrpc":"2.0",
"id":3,
"method":"tools/call",
"params":{
"name":"getBeverage",
"arguments":{
"name": "Americano,
}
}
}' | java -jar build/libs/mcpstdio-all.jar | jq .// Start the MCP server process:
val process = ProcessBuilder(
"java", "-jar", "/path/to/mcpstdio-all.jar"
).start()
// Read JSON-RPC responses from stdout:
val reader = BufferedReader(InputStreamReader(process.inputStream))
reader.lines().forEach { line ->
println("MCP Response: $line")
}
// Write JSON-RPC requests to process.outputStream when needed.npx @modelcontextprotocol/inspector --cli -- \
java -jar build/libs/mcpstdio-all.jarOnce connected, you can run commands:
initialize
notifications/initialized
tools/list
npx @modelcontextprotocol/inspector ./gradlew run -q- Select STDIO connection 🎛️
- Command:
java⚙️ - Arguments:
-jar build/libs/mcpstdio-all.jar📦 - Enter your session token 🔑 in the Dashboard settings.
Now you can interactively test your MCP server via a browser UI! 🚀