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 flag | Arguments and options | Description |
|---|---|---|
| --version | none | Print {"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-signatures | none | Print 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. |
| openapi | none | Print 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 / templates | resources <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 / prompt | prompts <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
| Method | Path and query | Description |
|---|---|---|
| GET | /health | Return gateway health status JSON envelope. |
| GET | /v1/openapi.json | Return the OpenAPI 3.1 specification document. |
| GET | /v1/servers | List configured MCP server names and metadata. |
| GET | /v1/servers/{server}/tools | List tools and input/output schemas for {server}. |
| POST | /v1/servers/{server}/tools/{tool}/call | Call {tool} on {server} with a JSON argument object body; returns HTTP 200 with error.code:"TOOL_ERROR" on MCP isError. |
| GET | /v1/servers/{server}/resources | List 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/templates | List resource URI templates exposed by {server}. |
| GET | /v1/servers/{server}/prompts | List 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 / function | Signature | Description |
|---|---|---|
| global function | mcp_server(name: string) -> MCPServer | Return a lightweight MCPServer handle bound to the configured server name (rejects null receivers on method calls). |
| global function | mcp_servers() -> Json | Dispatch GET /v1/servers and return the {ok, data|error} Json envelope. |
| global function | mcp_tools(server: string) -> Json | Dispatch GET /v1/servers/{server}/tools and return the Json envelope. |
| global function | mcp_call(server: string, tool: string, args: Json) -> Json | Dispatch POST /v1/servers/{server}/tools/{tool}/call with args and return the Json envelope. |
| global function | mcp_resources(server: string) -> Json | Dispatch GET /v1/servers/{server}/resources and return the Json envelope. |
| global function | mcp_templates(server: string) -> Json | Dispatch GET /v1/servers/{server}/resources/templates and return the Json envelope. |
| global function | mcp_read(server: string, uri: string) -> Json | Dispatch GET /v1/servers/{server}/resources/read?uri=... and return the Json envelope. |
| global function | mcp_prompts(server: string) -> Json | Dispatch GET /v1/servers/{server}/prompts and return the Json envelope. |
| global function | mcp_prompt(server: string, name: string, args: Json) -> Json | Dispatch POST /v1/servers/{server}/prompts/{name} with string-valued Json args and return the Json envelope. |
| MCPServer | srv.tools() -> Json | srv.call(tool: string, args: Json) -> Json | List tools or call a tool on the target MCPServer handle. |
| MCPServer | srv.resources() -> Json | srv.templates() -> Json | srv.read(uri: string) -> Json | List resources, list URI templates, or read a resource URI on the target MCPServer handle. |
| MCPServer | srv.prompts() -> Json | srv.prompt(name: string, args: Json) -> Json | List prompts or render a named prompt on the target MCPServer handle. |
Standard lmcode_std_v3 REST and CLI interfaces
| Interface or function | Signature / annotation | Description |
|---|---|---|
| RestGet .. RestOptions | @"/path/:param" fn h(x: RestExchange) -> void implements RestGet | Bind an HTTP GET, POST, PUT, DELETE, PATCH, HEAD, or OPTIONS route handler. |
| RestHandler | @"/path" fn h(x: RestExchange) -> void implements RestHandler | Bind a method-agnostic HTTP route handler. |
| CliCommand | @"cmd" fn h(x: RestExchange) -> void implements CliCommand | Bind a named CLI subcommand dispatched by rest_cli. |
| CliOption | @"--flag" fn h(x: RestExchange) -> void implements CliOption | Bind a CLI option flag (--flag=val or --flag val) evaluated before the command handler. |
| rest_config / rest_route | rest_config(key: string, val: string) -> void | rest_route(method: string, path: string, handler: string) -> void | Configure host, port, or session (ephemeral or global) and dynamically register HTTP route handlers. |
| rest_serve / rest_stop / rest_cli | rest_serve() -> void | rest_stop() -> void | rest_cli(args: StrList) -> string | Start or stop the embedded standard HTTP server or dispatch CLI options, commands, and routes in-process. |
| RestExchange | x.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) -> int | Inspect request metadata, emit plain text or JSON responses, and read or mutate ephemeral/global session state. |
Exit codes
| Exit code | Category | Meaning |
|---|---|---|
| 0 | Success | CLI action, HTTP/stdio server shutdown, or _lmcode_ bytecode program succeeded. |
| 2 | Usage / config error | Invalid CLI arguments, unreadable or malformed config.json, unknown config keys, literal credential headers, or non-loopback --listen address. |
| 3 | Tool / upstream / VM error | MCP tool returned isError:true on the CLI, upstream transport/auth/policy/secret-suppression error, broken stdout, or bytecode load/VM error in host mode. |
| 4 | Cancelled / app error | Operation interrupted by SIGINT, SIGTERM, or SIGHUP in CLI/server modes, or application/host failure in _lmcode_ mode. |