[1.0.0] 馃帀馃帀馃帀
Breaking Changes
Changed
McpToolChatconstructor no longer acceptsmodel,config, ortool_discovery_configparameters. Usefrom_config()or pass dependencies directly.McpToolChat.chat()now requires amodelparameter (string name orModelinstance) at call time.search_toolssynthetic tool renamed tosearch-toolsto avoid naming conflicts with FastMCP's underscore-prefixed tool conventions.- FastMCP upgraded from v2 to v3 (
fastmcp>=3.0.0). - FastAPI lifespan wraps
McpToolChatinasync withso the API server maintains persistent MCP connections for its lifetime. - Examples updated to use
async withpattern, replacing manual.close()calls. - Examples suppress harmless
"Event loop is closed"RuntimeErroron Python < 3.12 (subprocess transport cleanup afterasyncio.run()closes the loop).
Fixed
- MCP server connection lifecycle --
chat()now wraps its body inasync with self.mcp_client:, keeping the connection alive for the entire call. Previously eachlist_tools()andcall_tool()opened and closed a full connection cycle, restarting stdio server subprocesses on every operation.
Added
- Tool discovery -- defer tool loading and let the LLM search for tools on demand via BM25. Mark servers with
defer_loading: trueand enabletool_discoveryin config. The LLM receives asearch-toolsmeta-tool to find and load deferred tools as needed. SyntheticToolprotocol for tools handled internally by casual-mcp (not forwarded to MCP servers).SearchToolsToolis the primary implementation.BM25-based tool search indexfor relevance-ranked tool discovery across tool names and descriptions.McpToolChat.from_config(config)classmethod that builds all dependencies (MCP client, tool cache, model factory, server names, tool discovery) from a singleConfigobject.McpToolChatasync context manager --async with McpToolChat.from_config(config) as chat:keeps MCP connections alive across multiplechat()calls, avoiding reconnection overhead between turns. Without it, eachchat()call still manages its own connection automatically.- Call-time model selection -- pass
model="gpt-4.1"or aModelinstance tochat(). A singleMcpToolChatinstance can serve multiple models. - Call-time system prompt override -- pass
system="..."tochat()to override the default. Resolution order: explicit param > model template > constructor default. - Discovery statistics --
ChatStats.discoverytrackssearch_callsandtools_discoveredwhen tool discovery is enabled. ToolDiscoveryConfigmodel (enabled,defer_all,max_search_results).defer_loadingfield onStdioServerConfigandRemoteServerConfig.- CLI
toolscommand shows loaded/deferred status when discovery is enabled. - API
/chatendpoint supportsmodelandsystem_promptfields. manual_construction.pyexample showing direct constructor usage.
Removed
McpToolChat.generate()method and all session management (sessionsdict,get_session(),get_session_messages(),add_messages_to_session()). Callers should usechat()directly and manage their own message history.POST /generateandGET /generate/session/{session_id}API endpoints.GenerateRequestAPI model.generate_weather.py,generate_math.py,generate_session.pyexamples.