marfrit 175244ab89 lmcp: review fixes 1, 4 and 6 — legacy routing that survives the transport
From @deus, bundle sha256 f38898d3…, verified byte-identical on arrival;
lmcp.lua sha256 57fb2413…, the checksum quoted in the handover. Only lmcp.lua
changes; versions.lua and envelope.lua are byte-identical to what is already on
this branch. luac -p passes on all three.

What the three fixes do, checked in the file rather than taken on trust — the
conformance suites are HTTP-only and structurally cannot see finding 1:

  #1  handle_request now DERIVES _legacy when it arrives unset, instead of
      relying on the HTTP transport to have pre-set it. Previously req._legacy
      was written in exactly one place (_dispatch_post) and read in three, and
      run_stdio calls handle_request directly — so on stdio initialize, ping and
      logging/setLevel fell through to -32601 Method not found. That is the
      first message any client sends, and it worked unconditionally on master.

  #6  An empty protocol version now counts as "none announced" rather than as
      an unknown one. Router and versions.check had disagreed: check("") returns
      true by rule a, while the router excluded "" from the legacy set and sent
      it down the new path to be rejected by the envelope.

  #4  Legacy replies go through jsonrpc_result_legacy, which does NOT inject
      resultType. The claim that these methods "keep the old shape" was not true
      on the wire before: legacy ping answered {"resultType":"complete"} where
      master answered {}.

Still open from the same review, deliberately not in this commit: #2 (the
server-initiated SSE machinery is unreachable — nothing sets sess.sse_conn since
the GET branch was removed), #3 (GET/DELETE answer 405 to legacy clients too,
because _legacy is consulted at method dispatch and not at HTTP verb routing),
#5 (routing accepts a header-only or _meta-only announcement, envelope.check
then demands both), #7 (-32021 mapped but never produced, -32600 unmapped).

Still NOT on master.
2026-08-11 14:21:41 +02:00
2026-04-14 19:58:40 +00:00

lmcp — Lua MCP server

Lightweight Model Context Protocol (MCP) server in pure Lua.

Runtime dependencies

  • Lua 5.1+
  • luasocket — needed for the TCP listener. Packaged as lua-socket on Arch/ALARM, lua-socket on Debian.

Files

File Role
lmcp.lua library: protocol handling, tool registration
server.lua HTTP server loop
json.lua vendored JSON encoder/decoder
example_server.lua sample server with a couple of tools

Install

Packaged as lmcp in the marfrit overlay repo:

# Arch / ALARM
sudo pacman -S lmcp

# Debian
sudo apt install lmcp

Files land under /usr/share/lua/5.4/ (Lua LUA_PATH). The example server installs as /usr/bin/lmcp-example.

S
Description
Lightweight MCP server in pure Lua. 2MB RSS. Zero deps beyond luasocket.
Readme 715 KiB
v1.2.3 Latest
2026-06-05 15:57:24 +00:00
Languages
Lua 86.7%
Python 8.6%
Shell 4.2%
Batchfile 0.5%