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

Status.pudu

Pudu33 lines1.5 KB

GitHub ↗
1/** @App.Tools.Status.Handler — reports the toolchain and server state */2module PuduLangMcp.App.Tools.Status34import Std.Option as Option5import Std.Result as Result6import Std.Sync as Sync7import PuduLangMcp.App.Context as Context8import PuduLangMcp.Constants.Server as Server9import PuduLangMcp.Domain.Catalog.Arguments as Arguments10import PuduLangMcp.Errors.ToolError as ToolError1112/// Answers the server's version, toolchain, library, workspace, index, and corpus.13export fn toolchain(context: &Context.Context, args: &Arguments.Args) -> Result[Str, ToolError.ToolFailure] {14  let compiler = match context.toolchain.compiler {15    case Some(path) => path + " (" + (if context.toolchain.version.isEmpty() { "version unknown" } else { "pudu " + context.toolchain.version }) + ")"16    case None => "not found. " + ToolError.explain(&ToolError.ToolchainMissing)17  }18  let index = match Result.unwrapOr(Sync.get(&context.index), Context.Broken("unreadable")) {19    case Context.Building => "building"20    case Context.Ready(entries) => "ready, " + show(entries.length()) + " public declarations"21    case Context.Broken(reason) => "unavailable: " + reason22  }23  Ok([24      "server: " + Server.SERVER_NAME + " " + Server.SERVER_VERSION,25      "compiler: " + compiler,26      "standard library: " + Option.unwrapOr(context.toolchain.library, "not found"),27      "workspace: " + context.workspace.root,28      "importable modules: " + show(context.moduleFiles.length()),29      "reference index: " + index,30      "documentation: " + show(context.chapters.length()) + " documents, revision " + context.docsRevision31    ].join("\n"))32}33