-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Consider this scala script :
//> 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 com.tjclp::fast-mcp-scala:0.1.1
//> using options "-Xcheck-macros" "-experimental"
import com.tjclp.fastmcp.core.*
import com.tjclp.fastmcp.macros.RegistrationMacro.*
import com.tjclp.fastmcp.server.{FastMcpServer, FastMcpServerSettings}
import zio.*
// Define annotated tools, prompts, and resources
object Example {
@Tool(name = Some("hello"), description = Some("Say hello"))
def hello(): String = "Hello, world!"
}
object ExampleServer extends ZIOAppDefault {
override def run = {
val settings = FastMcpServerSettings(
debug=true,
logLevel="DEBUG",
)
for {
server <- ZIO.succeed(FastMcpServer(name = "hello-mcp-server", settings = settings))
_ <- ZIO.attempt(server.scanAnnotations[Example.type])
_ <- ZIO.log("Starting stdio server...")
_ <- server
.runStdio()
.tapError(error => ZIO.log(s"Error running stdio: $error"))
.onInterrupt(ZIO.log("Server interrupted"))
} yield ()
}
}
ExampleServer.main(args)
Nothing happens when I try to invoke the hello tool :
scala-cli hello-mcp-server.sc
Compiling project (Scala 3.7.1, JVM (21))
Compiled project (Scala 3.7.1, JVM (21))
[ToolProcessor] registering tool: hello
timestamp=2025-07-18T12:54:49.559990339Z level=INFO thread=#zio-fiber-1418526459 message="Starting stdio server..." location=<empty>.hello$minusmcp$minusserver$_.ExampleServer.run file=hello-mcp-server.scala line=48
[FastMCPScala] Registering 1 tools with the MCP server:
[FastMCPScala] - Registering Tool: hello
[FastMCPScala] Processing 0 resource definitions for Java server registration...
[FastMCPScala] Registering 0 prompts...
[FastMCPScala] MCP Server 'hello-mcp-server' configured.
[FastMCPScala] 'hello-mcp-server' running on stdio – press Ctrl-C to stop.
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"protocolVersion": "2024-11-05"}}
[pool-1-thread-1] INFO io.modelcontextprotocol.server.McpAsyncServer - Client initialize request - Protocol: 2024-11-05, Capabilities: null, Info: null
{"jsonrpc":"2.0","id":0,"result":{"protocolVersion":"2024-11-05","capabilities":{"experimental":{},"logging":{},"tools":{"listChanged":true}},"serverInfo":{"name":"hello-mcp-server","version":"0.1.0"}}}
{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"hello"}}
Any idea ?
Metadata
Metadata
Assignees
Labels
No labels