An llm4s tool set served over stdio (#3403), so a desktop MCP client can launch it as a subprocess: the client writes newline-delimited JSON-RPC to the process's standard input and reads the replies from its standard output. It speaks what MCPServer speaks over HTTP - initialize, ping, tools/list and tools/call, with notifications/cancelled interrupting a running call - with no session and no authentication: the client that started the process is the only one that can reach it.
object WeatherServer {
def main(args: Array[String]): Unit =
MCPStdioServer("weather", "1.0.0", Seq(forecastTool)).serve()
}
'''Standard output is the protocol.''' serve points System.out, and Scala's Console.out for the thread it runs on and the threads it starts, at standard error while it runs, so a stray println or a logger writing to the console cannot corrupt the stream; configure logging to standard error (or a file) so nothing else does.
When standard input ends - the client closed it, or exited - the session is over: calls still running are cancelled, as when an HTTP session ends, and serve returns once they finish or drain has passed.
Value parameters
- drain
-
the longest serve waits, after the input ends, for cancelled calls to finish
Attributes
- Companion
- object
- Source
- MCPStdioServer.scala
- Graph
-
- Supertypes
