Skip to content

McpClient

Methods

call

McpClient:call(name, args) -> any

Call the tool named name with args (a table of arguments), returning { content = <string>, is_error = <bool> }. A tool that reports failure comes back with is_error = true rather than raising, so the model sees it; only a transport or protocol failure raises.

Parameters

  • name: string
  • args: any

Returns

  • any

close

McpClient:close()

Tear the session down explicitly. Rarely needed, since releasing the handle does the same: the session is cancelled and a stdio child is killed on drop.

connected

McpClient:connected() -> boolean

Whether the session is still live. Turns false once the server exits (a stdio child dying closes its transport), so a config can gate the server's tools on it or warn the user to /reload.

Returns

  • boolean

list_tools

McpClient:list_tools() -> any

The tools the server advertises, each a table shaped for registry:add: { name, description, parameters }. parameters is the server's raw JSON argument schema, named to match the field registry:add expects so a config can pass it straight through.

Returns

  • any

Metamethods

__tostring

McpClient.__tostring() -> ...any

Returns

  • ...any