lmmcp reference

Complete command-line subcommand and flag reference, HTTP and JSON-lines stdio REST routes, mcpServers configuration fields, _lmcode_ host functions and MCPServer methods, standard lmcode_std_v3 interfaces, and exit codes for lmmcp v0.1.0.

Host and CLI commands and flags

Command or flagArguments and optionsDescription
--versionnonePrint {"name":"lmmcp","version":"0.1.0"} as JSON on stdout and exit 0.
--lmcode-schema[--json]Print the embedded lmmcp schema JSON to stdout and exit 0.
--lmcode-signaturesnonePrint all 242 canonical signatures (16 host + 226 standard lmcode_std_v3) and exit 0.
--lmcode<file.dslb> [--lmcode <file2.dslb> ...] --config <config.json>Load and execute compiled LMScript bytecode files against the configured MCP servers and emit an LMCODE_RETURN frame.
openapinonePrint the OpenAPI 3.1 JSON document describing the lmmcp REST API and exit 0.
serve--config <file> [--listen 127.0.0.1:8080] [--read-only] [--token-env NAME | --token-file FILE]Start the HTTP REST gateway bound to a literal loopback IP address and print {"ok":true,"url":"http://..."} once ready.
stdio--config <file> [--read-only]Run the concurrent JSON-lines REST dispatcher over stdin and stdout ({id,method,path,query,body} -> {id,status,headers,body}).
servers--config <file> | --url <origin> [--read-only] [--token-env NAME | --token-file FILE]List configured MCP servers as a JSON envelope on stdout.
tools<server> (--config <file> | --url <origin>) [--read-only]List available tools and discovery schemas for <server>.
call<server> <tool> [--arg k=v ... | --json '{...}'] (--config <file> | --url <origin>) [--read-only]Invoke an MCP tool with string arguments (--arg) or typed JSON arguments (--json); exits 3 if the tool returns isError:true.
resources / templatesresources <server> | templates <server> (--config <file> | --url <origin>)List static MCP resources or RFC 6570 resource URI templates exposed by <server>.
read<server> <uri> (--config <file> | --url <origin>)Read a text or base64-encoded resource by URI from <server>.
prompts / promptprompts <server> | prompt <server> <name> [--arg k=v ... | --json '{...}'] (--config <file> | --url <origin>)List available prompts or render a named prompt with string argument values.

HTTP REST and JSON-lines stdio endpoints

MethodPath and queryDescription
GET/healthReturn gateway health status JSON envelope.
GET/v1/openapi.jsonReturn the OpenAPI 3.1 specification document.
GET/v1/serversList configured MCP server names and metadata.
GET/v1/servers/{server}/toolsList tools and input/output schemas for {server}.
POST/v1/servers/{server}/tools/{tool}/callCall {tool} on {server} with a JSON argument object body; returns HTTP 200 with error.code:"TOOL_ERROR" on MCP isError.
GET/v1/servers/{server}/resourcesList resources exposed by {server}.
GET/v1/servers/{server}/resources/read?uri=<encoded_uri>Read resource content (text or base64 blob with MIME type) for the specified URI.
GET/v1/servers/{server}/resources/templatesList resource URI templates exposed by {server}.
GET/v1/servers/{server}/promptsList prompt definitions exposed by {server}.
POST/v1/servers/{server}/prompts/{prompt}Render {prompt} on {server} with a JSON object of string arguments.
DELETE/v1/requests/{id}Cancel an active in-flight HTTP request (named via X-Request-ID) or stdio JSON-line request ID.

Host schema functions and MCPServer methods

Type / functionSignatureDescription
global functionmcp_server(name: string) -> MCPServerReturn a lightweight MCPServer handle bound to the configured server name (rejects null receivers on method calls).
global functionmcp_servers() -> JsonDispatch GET /v1/servers and return the {ok, data|error} Json envelope.
global functionmcp_tools(server: string) -> JsonDispatch GET /v1/servers/{server}/tools and return the Json envelope.
global functionmcp_call(server: string, tool: string, args: Json) -> JsonDispatch POST /v1/servers/{server}/tools/{tool}/call with args and return the Json envelope.
global functionmcp_resources(server: string) -> JsonDispatch GET /v1/servers/{server}/resources and return the Json envelope.
global functionmcp_templates(server: string) -> JsonDispatch GET /v1/servers/{server}/resources/templates and return the Json envelope.
global functionmcp_read(server: string, uri: string) -> JsonDispatch GET /v1/servers/{server}/resources/read?uri=... and return the Json envelope.
global functionmcp_prompts(server: string) -> JsonDispatch GET /v1/servers/{server}/prompts and return the Json envelope.
global functionmcp_prompt(server: string, name: string, args: Json) -> JsonDispatch POST /v1/servers/{server}/prompts/{name} with string-valued Json args and return the Json envelope.
MCPServersrv.tools() -> Json | srv.call(tool: string, args: Json) -> JsonList tools or call a tool on the target MCPServer handle.
MCPServersrv.resources() -> Json | srv.templates() -> Json | srv.read(uri: string) -> JsonList resources, list URI templates, or read a resource URI on the target MCPServer handle.
MCPServersrv.prompts() -> Json | srv.prompt(name: string, args: Json) -> JsonList prompts or render a named prompt on the target MCPServer handle.

Standard lmcode_std_v3 REST and CLI interfaces

Interface or functionSignature / annotationDescription
RestGet .. RestOptions@"/path/:param" fn h(x: RestExchange) -> void implements RestGetBind an HTTP GET, POST, PUT, DELETE, PATCH, HEAD, or OPTIONS route handler.
RestHandler@"/path" fn h(x: RestExchange) -> void implements RestHandlerBind a method-agnostic HTTP route handler.
CliCommand@"cmd" fn h(x: RestExchange) -> void implements CliCommandBind a named CLI subcommand dispatched by rest_cli.
CliOption@"--flag" fn h(x: RestExchange) -> void implements CliOptionBind a CLI option flag (--flag=val or --flag val) evaluated before the command handler.
rest_config / rest_routerest_config(key: string, val: string) -> void | rest_route(method: string, path: string, handler: string) -> voidConfigure host, port, or session (ephemeral or global) and dynamically register HTTP route handlers.
rest_serve / rest_stop / rest_clirest_serve() -> void | rest_stop() -> void | rest_cli(args: StrList) -> stringStart or stop the embedded standard HTTP server or dispatch CLI options, commands, and routes in-process.
RestExchangex.method() | x.path() | x.body() | x.param(string) | x.query(string) | x.header(string) | x.get(string) -> string | x.has_query(string) | x.has_header(string) -> bool | x.status(int) | x.set_header(string, string) | x.send(string) | x.json(string) | x.set(string, string) -> void | x.increment(string) -> intInspect request metadata, emit plain text or JSON responses, and read or mutate ephemeral/global session state.

Exit codes

Exit codeCategoryMeaning
0SuccessCLI action, HTTP/stdio server shutdown, or _lmcode_ bytecode program succeeded.
2Usage / config errorInvalid CLI arguments, unreadable or malformed config.json, unknown config keys, literal credential headers, or non-loopback --listen address.
3Tool / upstream / VM errorMCP tool returned isError:true on the CLI, upstream transport/auth/policy/secret-suppression error, broken stdout, or bytecode load/VM error in host mode.
4Cancelled / app errorOperation interrupted by SIGINT, SIGTERM, or SIGHUP in CLI/server modes, or application/host failure in _lmcode_ mode.