Tool calling crashes with NameError: is_mcp_config on base install (without mcp extra)
Describe the bug
When the optional mcp extra is not installed (i.e. a plain pip install aisuite), passing any tools= argument to client.chat.completions.create(...) raises NameError: name 'is_mcp_config' is not defined. This breaks all tool / function calling for every provider on a base install — even plain OpenAI-style function tools that have nothing to do with MCP.
Root cause
In aisuite/client.py, is_mcp_config is imported in the same try block as the heavy mcp dependency:
# aisuite/client.py
try:
from .mcp.config import is_mcp_config # line 15
from .mcp.client import MCPClient # line 16 <-- fails if `mcp` not installed
MCP_AVAILABLE = True
except ImportError:
MCP_AVAILABLE = FalseIf from .mcp.client import MCPClient raises ImportError (because the mcp package isn't installed), the whole block is abandoned, so is_mcp_config is never bound and MCP_AVAILABLE = False.
But _process_mcp_configs still calls is_mcp_config in exactly that case:
if not MCP_AVAILABLE:
# If MCP not installed, check if user is trying to use it
if any(is_mcp_config(tool) for tool in tools if isinstance(tool, dict)): # line 174 NameError
raise ImportError(...)
return tools, []So the not MCP_AVAILABLE guard — the branch specifically meant to handle "mcp isn't installed" — itself references a name that only exists when mcp is installed.
To reproduce
pip install aisuite openai # base install, NO mcp extraimport aisuite as ai
client = ai.Client(provider_configs={"openai": {"api_key": "..."}})
client.chat.completions.create(
model="openai:gpt-4o-mini",
messages=[{"role": "user", "content": "What's the weather in Paris?"}],
tools=[{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
},
}],
)File "aisuite/client.py", line 174, in _process_mcp_configs
if any(is_mcp_config(tool) for tool in tools if isinstance(tool, dict)):
NameError: name 'is_mcp_config' is not definedExpected behavior
Plain function/tool calling should work without the mcp extra. Only the actual MCP code paths (MCPClient) should require the mcp package.
Suggested fix
is_mcp_config is a trivial pure dict check with no dependency on the mcp package, so it should not be gated behind the MCP import. Either import it unconditionally:
from .mcp.config import is_mcp_config # no external deps
try:
from .mcp.client import MCPClient
MCP_AVAILABLE = True
except ImportError:
MCP_AVAILABLE = Falseor define a local fallback in the except branch.
Workaround
Install the mcp extra: pip install 'aisuite[mcp]' (this binds is_mcp_config, so tool calling works).
Environment
- aisuite installed from
main - Python 3.13, Windows
- Reproduced while validating a new provider's tool-calling support against a base install.
Source: andrewyng/aisuite