test0r 9707f7ae93 v1.1.1: omit empty inputSchema.properties at registration
Same json.lua empty-table → [] gotcha that bit `ping` in v1.0.0-rc1
(project_json_empty_table_gotcha memory) bit again — this time on
tool inputSchemas with `properties = {}`. Symptom: spec-strict MCP
clients (Zod et al.) reject tools/list with:

  expected: record, code: invalid_type,
  path: [tools, N, inputSchema, properties],
  message: "Invalid input: expected record, received array"

Fix: in `lmcp:tool()`, normalise the registered inputSchema —
when `properties` is an empty Lua table, drop the key entirely.
JSON Schema permits omitting `properties` on `type: "object"`
(means "any object, no constraints" — exactly what a no-arg tool
wants).

Clone-before-mutate so the caller's table isn't trampled (matters
when a server author shares one schema across multiple
registrations).

Smoke tested locally with 3 tools (empty, default-nil, populated):
- `properties = {}` → emitted as `{"type":"object"}`
- nil schema → same default, same output
- populated properties → emitted intact with full shape

Discovered against hertz-tools live (lxc_list, network_status had
`properties = {}` — hertz hotfixed by hand before this commit;
this protects every future tool author from the same trap).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-17 22:39:56 +00: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 296 KiB
Languages
Lua 93.1%
Shell 6.2%
Batchfile 0.7%