bindClientTools() is the main helper from @threadplane/middleware/langgraph. It binds your server tools plus the current run's client-tool catalog onto a LangChain chat model.
import { bindClientTools, clientToolsChannel, clientToolsRouter,} from '@threadplane/middleware/langgraph';
There is no root JavaScript entry point for @threadplane/middleware; import from the /langgraph subpath. The Python package exposes equivalent snake_case helpers from threadplane.middleware.langgraph.
Related helpers in the same entry point include clientToolsChannel(), clientToolsRouter(), clientToolSpecs(), clientToolNames(), hasClientToolCall(), hasServerToolCall(), routeAfterAgent(), and lastMessage().
bindClientToolsfunction
Bind server tools + the client catalog stubs onto `llm`. Call this INSIDE the
agent node (per-run) — the client catalog arrives in state and may differ per run.
bindClientTools(llm: M, serverTools: unknown[], state: ClientToolsState): ReturnType<M["bindTools"]>
Parameters
Parameter
Type
Description
llm
M
serverTools
unknown[]
state
ClientToolsState
Returns
ReturnType<M["bindTools"]>
clientToolsChannelfunction
State channels for the client-tools catalog. Spread into Annotation.Root so a graph
declares the `tools` (primary) and `client_tools` (fallback) slices in one line:
const State = Annotation.Root({ ...MessagesAnnotation.spec, ...clientToolsChannel() });
Both are last-value-wins channels (the catalog is replaced per run, not accumulated).
clientToolsChannel(): object
Returns
object
clientToolsRouterfunction
A prebuilt conditional-edge callback. serverToolNames is bound once at construction;
the returned function takes only state.
graph.addConditionalEdges('agent', clientToolsRouter([]), ['tools', END]);
True if the last message calls at least one server (non-client) tool.
A call is server-side when its name is in serverToolNames OR is not a known
client tool (unknown tools are assumed server-side).
Routing helper for a LangGraph conditional edge. Returns `toolsNode` when the last
message has a server tool call (dispatch to the server ToolNode); otherwise `end`
(client-only calls — the browser executes them — and no-tool-call turns both end).