Skip to content

Instantly share code, notes, and snippets.

@dacr
Created December 15, 2025 17:29
Show Gist options
  • Select an option

  • Save dacr/8035f68b4fe921492fce80ce82e05697 to your computer and use it in GitHub Desktop.

Select an option

Save dacr/8035f68b4fe921492fce80ce82e05697 to your computer and use it in GitHub Desktop.
dummy java mcp server / published by https://github.com/dacr/code-examples-manager #f6ab2228-9d0c-48e3-8d3a-b11c46152484/e92bd567900ce32d8879b37b26fad3d9bfb02101
// summary : dummy java mcp server
// keywords : artificial-intelligence, generative-ai, llm, ai, mcp, mcp-server, @testable
// publish : gist
// authors : David Crosson
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2)
// id : f6ab2228-9d0c-48e3-8d3a-b11c46152484
// created-on : 2025-07-18T15:24:45+02:00
// managed-by : https://github.com/dacr/code-examples-manager
// run-with : scala-cli $file
//> using scala 3.7.1
//> using dep org.slf4j:slf4j-api:2.0.17
//> using dep org.slf4j:slf4j-simple:2.0.17
//> using dep io.modelcontextprotocol.sdk:mcp:0.10.0
import io.modelcontextprotocol.server.McpServer
import io.modelcontextprotocol.server.transport.StdioServerTransportProvider
import io.modelcontextprotocol.spec.McpSchema.ServerCapabilities
import io.modelcontextprotocol.spec.McpServerTransportProvider
/*
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"protocolVersion": "2024-11-05"}}
{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}
*/
object ExampleServer {
def main(args: Array[String]): Unit = {
val transportProvider = StdioServerTransportProvider()
val capabilities = ServerCapabilities
.builder()
.resources(false, true)
.tools(true)
.prompts(true)
.logging()
.build()
val helloServer =
McpServer
.sync(transportProvider)
.serverInfo("hello-server", "1.0.0")
.capabilities(capabilities)
.build()
Thread.sleep(60000)
helloServer.close()
}
}
ExampleServer.main(args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment