chatlas.tool()
Give a chatlas chat access to an existing Console session.
Usage
chatlas.tool(console)Pass the returned tool to chat.set_tools() after entering the Console context. Chatlas runs the tool-calling loop; Console keeps cell state between calls. Keep both the chat and connection for follow-up messages.
This uses the connected server’s schema, including its configured languages and requirements fields. register_tool(console.send) infers a schema from Python annotations and cannot describe those server settings. The adapter returns text, with placeholders for images; register() uses chatlas’s native MCP support to preserve image content.
Parameters
console: MCPConsole | AsyncMCPConsole-
A connected
MCPConsoleorAsyncMCPConsole. An async client’s tool must be used withchat.chat_async().
Returns
Tool-
A
chatlas.Toolwith the server’s livesenddefinition.
Examples
Install with pip install 'mcp-console[chatlas]'. For this OpenAI-backed chat, set OPENAI_API_KEY and set OPENAI_MODEL to your model ID. Chatlas prints the response and handles tool calls automatically:
import os
import mcp_console
from chatlas import ChatOpenAI
from mcp_console import MCPConsole
chat = ChatOpenAI(model=os.environ["OPENAI_MODEL"])
with MCPConsole() as console:
chat.set_tools([mcp_console.chatlas.tool(console)])
chat.chat(
"Use Python in Console to calculate the mean of [12, 15, 18, 20, 25]."
)
chat.chat(
"Use the same values in Console to calculate their sample standard deviation."
)set_tools() replaces the chat’s tools. If the chat already has tools, use chat.set_tools([*chat.get_tools(), mcp_console.chatlas.tool(console)]).