lmmcp guide

Overview

lmmcp is a thin, deterministic Go gateway and LMScript host built on the official Go MCP SDK and github.com/lmctl-ai/lmcode-go. It bridges local stdio child processes and remote Streamable HTTP or legacy HTTP+SSE MCP servers into a uniform REST API, single-document JSON CLI commands, concurrent JSON-lines over stdio, and bytecode-compiled _lmcode_ scripts without introducing an external database, web UI, or background daemon registry.

MCP transports, session lifecycle, and protocol revisions

Each entry under mcpServers in config.json configures either a local child process or a remote HTTP/SSE endpoint managed through a lazy per-server session:

Security, secret suppression, and network policy

lmmcp enforces strict input and output boundaries across configuration parsing, outbound dialing, and response serialization:

Standard lmcode_std_v3 REST and CLI interfaces

In addition to MCPServer and the mcp_* global functions, lmmcp embeds the 226-signature lmcode_std_v3 standard catalog via github.com/lmctl-ai/lmcode-go. Scripts can wrap MCP operations inside standard REST routes and stateless CLI commands:

p = _lmcode_ schema="examples/schema.json";
@"--server"
fn opt_server(x: RestExchange) -> void implements CliOption {
  x.set("server", x.query("server"));
}

@"resources"
fn cmd_resources(x: RestExchange) -> void implements CliCommand {
  let srv = mcp_server(x.get("server"));
  x.json(srv.resources().to_json());
}

@"/read/:server"
fn get_read(x: RestExchange) -> void implements RestGet {
  let res = mcp_read(x.param("server"), "mock://readme");
  x.json(res.to_json());
}

rest_config("session", "global");
let list_out = rest_cli(str_split("--server=fixture resources", " "));
let read_out = rest_cli(str_split("/read/fixture", " "));
$return = json_parse("{\"resources\":" + list_out + ",\"read\":" + read_out + "}");
end _lmcode_