Expand description
Lua MCP tool extensions.
Loads .lua tool scripts at server startup, extracts their parameter schemas,
and provides execution with a context bridge back into the Rust core
(search, get, sources).
§Architecture
Tool scripts follow the same sandboxed Lua VM model as connectors
(crate::connector_script), reusing all host APIs from
crate::lua_runtime. In addition, tools receive a context table with:
context.search(query, opts?)— search the knowledge basecontext.get(id)— retrieve a document by UUIDcontext.sources()— list connector statuscontext.config— tool-specific configuration fromctx.toml
§Script Interface
Every tool script defines a global tool table:
tool = {
name = "my_tool",
description = "Does something useful",
parameters = {
{ name = "query", type = "string", required = true, description = "Search query" },
},
}
function tool.execute(params, context)
local results = context.search(params.query)
return { results = results }
end§Configuration
[tools.script.my_tool]
path = "tools/my-tool.lua"
timeout = 30
api_key = "${MY_API_KEY}"See docs/LUA_TOOLS.md for the full specification.
Structs§
- LuaTool
Adapter - Adapter that wraps a Lua
ToolDefinitionas aTooltrait object. - Tool
Definition - Metadata extracted from a loaded Lua tool script.
- Tool
Info - Serializable tool info for the
/tools/listendpoint.
Functions§
- build_
tool_ list - Build the list of all tools (built-in + Lua) for the
/tools/listendpoint. - doc_
response_ 🔒to_ lua - Convert a document response to a Lua table.
- execute_
tool - Execute a tool script with the given parameters.
- json_
type_ 🔒name - Return a human-readable name for a JSON value’s type.
- list_
tools - List all configured tools and print their info.
- load_
single_ tool - Load a single tool script and extract its definition.
- load_
tool_ definitions - Load all tool scripts from config and extract their definitions.
- lua_
params_ 🔒to_ json_ schema - Convert Lua parameter declarations to OpenAI function-calling JSON Schema.
- register_
context_ 🔒bridge - Register the
contexttable in the Lua VM. - run_
lua_ 🔒tool - Run the Lua tool synchronously on a blocking thread.
- scaffold_
tool - Scaffold a new tool script from a template.
- search_
results_ 🔒to_ lua - Convert search results to a Lua array table.
- sources_
to_ 🔒lua - Convert source statuses to a Lua array table.
- test_
tool - Test a tool script with sample parameters.
- validate_
params - Validate incoming JSON parameters against a tool’s schema.