Pudu programming language
Menu
Package

@chrismichaelps / pudu-lang-mcp

Model Context Protocol server for Pudu language documentation and compiler tools

0.1.1Apache-2.01

InstallClose

PuduLangMcp.pudu

Pudu32 lines1.0 KB

GitHub ↗
1/** @PuduLangMcp.Server.Root — serves MCP over stdio until input ends */2module PuduLangMcp34import Std.Io as Io5import PuduLangMcp.App.Context as Context6import PuduLangMcp.App.Dispatch as Dispatch7import PuduLangMcp.Generated.Docs as Docs8import PuduLangMcp.Services.Toolchain as Toolchain9import PuduLangMcp.Services.Workspace as Workspace1011/// Serves one client over stdin and stdout; answers the exit status.12export fn serve() -> Int {13  let context = Context.create(Toolchain.locate(), Workspace.fromEnvironment(), Docs.CHAPTERS, Docs.REVISION)14  var state = Dispatch.initial()15  loop {16    match Io.readLineOrEnd() {17      case Ok(Some(line)) => {18        let answered = Dispatch.respond(&context, &state, line)19        state = answered[0]20        for reply in answered[1] {21          if Io.writeLine(reply) != Ok(()) { return 1 }22        }23      }24      case Ok(None) => { return 0 }25      case Err(problem) => {26        let _reported = Io.writeErrorLine("pudu-lang-mcp: cannot read input: " + problem)27        return 128      }29    }30  }31}32