Direct tool calling
The call_tool method calls one MCP tool of a connector directly, without a conversation or a model.
Call a tool directly when you:
- Already know which tool to call and with which arguments.
- Want the raw tool output for further processing.
- Build pipelines that chain tool calls in code.
- Want to check the tools of a connector before you use them in conversations.
When the model must pick the tools, use connectors in conversations instead. In both cases, connect the connector before you call its tools.
Call a tool directly
Call a tool directly
To call a tool, pass the name or ID of the connector, the name of the tool, and the arguments that the tool expects.
import asyncio
from mistralai.client import Mistral
client = Mistral(api_key="your-api-key")
async def main() -> None:
result = await client.beta.connectors.call_tool_async(
connector_id_or_name="my_deepwiki",
tool_name="read_wiki_structure",
arguments={"repoName": "sqlite/sqlite"},
)
# result.content is a list of content blocks (TextContent, ImageContent, etc.)
for item in result.content:
if hasattr(item, "text"):
print(item.text)
asyncio.run(main())The content array of the response contains the typed blocks that the MCP server returns: text, image, audio, resource link, or embedded resource.
Tip
Tool names must match exactly. To check the names, list the tools of the connector.
Chain multiple tool calls
Chain multiple tool calls
To build a pipeline, call several tools in sequence. The model isn't involved at any step.
import asyncio
from mistralai.client import Mistral
client = Mistral(api_key="your-api-key")
async def main() -> None:
# First call: get the repository structure
structure = await client.beta.connectors.call_tool_async(
connector_id_or_name="my_deepwiki",
tool_name="read_wiki_structure",
arguments={"repoName": "sqlite/sqlite"},
)
for item in structure.content:
if hasattr(item, "text"):
print("Structure:", item.text[:300])
# Second call: ask a question about the repo
answer = await client.beta.connectors.call_tool_async(
connector_id_or_name="my_deepwiki",
tool_name="ask_wiki_question",
arguments={
"repoName": "sqlite/sqlite",
"question": "What is the purpose of the VDBE?",
},
)
for item in answer.content:
if hasattr(item, "text"):
print("Answer:", item.text[:300])
asyncio.run(main())