Skip to main content

chatlas.tools()

Give a chatlas chat access to an existing Console session.

Usage

Source

chatlas.tools(console)

Pass the returned list 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.

Successful results return a chatlas.ContentToolResult carrying the ordered text and image content, with the server’s result _meta forwarded verbatim in extra (e.g. its io.modelcontextprotocol/serverInfo identity, which compatible chat UIs can use to attribute results; the metadata is inert otherwise). Tool errors raise, and requirements responses stay plain text (they are configuration responses, not cell executions). register() uses chatlas’s native MCP support instead, which also preserves image content.

Discovery includes every tool, even when the server has no send tool.

Parameters

console: MCPConsole | AsyncMCPConsole
A connected MCPConsole or AsyncMCPConsole. An async client’s tool must be used with chat.chat_async().

Returns

list[Tool]
A list of chatlas.Tool objects with the server’s live definitions.

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.tools(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.tools(console)]).