Python API¶
The client and the integrations are the stable Python surface. Everything else is reached through the CLI.
toolrank.client.ToolrankClient ¶
health ¶
health()
{ready, mode, tools, sources, scorer}; a server still building its index is no error.
catalog ¶
catalog(server=None)
{count, catalog, tools}: each tool's id (name), api_name, description, input
schema, annotations and, for OpenAPI operations, the HTTP method.
search ¶
search(query, *, k=None, instruction=None, full_schemas=False, session=None)
{search_id, mode, took_ms, rule, tools}.
rank ¶
rank(query, tools, *, instruction=None, session=None)
Score tools the caller has (MCP records: name, description, inputSchema,
optional server) for query; -> [{index, name, server?, score}], best first,
index being the tool's position in tools. Sent in chunks that stay under the
server's limits (RANK_CHUNK tools, RANK_BYTES of JSON).
call ¶
call(name, arguments=None, *, search_id=None, session=None)
{name, call_id, outcome, isError, http_status, content, structuredContent?}; a tool
that fails is a result with isError, not an exception.
toolrank.client.ToolrankError ¶
Bases: RuntimeError
Claude tool search¶
toolrank.integrations.anthropic.Toolbox ¶
One conversation's tools: the frozen tool list for the API, and what toolrank found and ran.
respond(response) answers a response's tool calls; approve(entry, arguments) may veto a
call; on_event(kind, details) sees every search, call and turn.
respond ¶
respond(response)
The user message that answers response's tool calls; None when there are none to
answer (end of turn, max_tokens, refusal, pause_turn: see run).
toolrank.integrations.anthropic.run ¶
run(llm, toolrank, task, *, model, max_tokens=4096, max_turns=12, **create)
A reference loop: llm is an anthropic.Anthropic() (or its .beta); create
goes to every messages.create. Stops when a response asks for no tool, on max_tokens,
refusal and unknown stop reasons, or after max_turns requests; pause_turn is sent
back as is.
OpenAI tool search¶
toolrank.integrations.openai.Toolbox ¶
One conversation's tools: what toolrank found and loaded, and the calls it ran.
respond(response) answers a response's tool searches and calls; approve(entry,
arguments) may veto a call; on_event(kind, details) sees every search, call and turn.
respond ¶
respond(response)
The items that answer response's tool searches and calls, in order; [] when it asks
for none or is incomplete.
toolrank.integrations.openai.run ¶
run(llm, toolrank, task, *, model, max_turns=12, **create)
A reference loop: llm is an openai.OpenAI(); create goes to every
responses.create. Stops when a response has nothing to answer, is incomplete, or after
max_turns requests.
LangGraph¶
toolrank.integrations.langgraph.Toolbox ¶
The catalogue (taken once) as LangChain tools, and the searches and calls made with it.
retrieve_tools(query) -> list[str] and aretrieve_tools search; k and
instruction go to every search (default: the server's); hits outside servers are
dropped. approve(entry, arguments) may veto a call; on_event(kind, details) sees every
search and call.
LlamaIndex¶
toolrank.integrations.llamaindex.ToolrankToolRetriever ¶
Bases: ObjectRetriever
An agent's tools from toolrank searches (see the module docstring).
k and instruction go to every search (default: the server's). approve(hit,
arguments) may veto a call; on_event(kind, details) sees every search and call.
LiteLLM¶
toolrank.integrations.litellm.ToolFilter ¶
The filter without LiteLLM: await ToolFilter(...)(data, call_type) -> a new request
dict with fewer tools, or None to send the request as it came.