Luau Bindings — mcp
The
require("mcp")script API — a standalone client for Model Context Protocol servers, usable with no AI involved, which makes it handy for bringing up or debugging a server. It's also the bridge the AI subsystem uses to give models tools — but nothing about it requires a model. Design & native core: antos_mcp. Every function is[antos].
local mcp = require("mcp")
local conn = mcp.connect("http://localhost:8080/mcp")
for _, t in ipairs(mcp.tools(conn)) do print(t.name) end
Connecting
| Function | Behaviour |
|---|---|
mcp.connect(url) |
Handshake with an MCP server and return a connection, or nil, err. |
mcp.connect_named(name) |
Connect to a configured server by name (see mcp.servers). |
mcp.servers() |
List the configured servers (name, url, status). |
Configured servers are managed from the console with mcp add / mcp test, and persist in DBFS config.
Tools
| Function | Behaviour |
|---|---|
mcp.tools(conn) |
List a server's tools. The result is already shaped for ai.ask's overrides.tools, so it drops straight into a tool-use call. |
mcp.call(conn, name, args) |
Invoke a tool by name with an args table; returns its result, or nil, err. |
-- pure MCP, no model in sight — call a tool directly
local mcp = require("mcp")
local conn = mcp.connect_named("filesystem")
local res = mcp.call(conn, "read_file", { path = "/etc/hostname" })
print(res)
With the AI subsystem
Hand mcp.tools(conn) to ai.ask in overrides.tools and the model can call the server's tools; ai.ask runs the tool-use loop and returns the final reply. See AI subsystem → Tool use and MCP for the loop and configuration.
Related
- AI subsystem (MCP design & the tool-use loop — the reference)
- luau_ai (passing tools to a model) · AntOS Libraries