Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:CrewAIInc CrewAI AI Mind Tool

From Leeroopedia
Knowledge Sources
Domains Tools, Database_Query, MindsDB
Last Updated 2026-02-11 00:00 GMT

Overview

Concrete tool for natural language querying of databases through MindsDB's AI Minds platform provided by CrewAI.

Description

The AIMindTool class extends BaseTool to create a wrapper around MindsDB's Minds API. During initialization, it accepts datasource configurations (engine, connection_data, tables, description) and creates a Mind instance via the MindsDB client with randomly generated names using the crwai_mind_ and crwai_ds_ prefixes. Queries are executed through an OpenAI-compatible API endpoint at https://mdb.ai/, allowing natural language questions to be answered from structured data sources including PostgreSQL, MySQL, MariaDB, ClickHouse, Snowflake, and Google BigQuery. The tool requires the MINDS_API_KEY environment variable and the minds-sdk package dependency.

Usage

Use this tool when CrewAI agents need to query structured databases using natural language without writing SQL. Ideal for data analysis tasks where agents must extract insights from connected data sources.

Code Reference

Source Location

  • Repository: CrewAI
  • File: lib/crewai-tools/src/crewai_tools/tools/ai_mind_tool/ai_mind_tool.py
  • Lines: 1-102

Signature

class AIMindTool(BaseTool):
    name: str = "AIMind Tool"
    description: str = "A wrapper around AI-Minds..."
    args_schema: type[BaseModel] = AIMindToolInputSchema
    api_key: str | None = None
    datasources: list[dict[str, Any]] = Field(default_factory=list)
    mind_name: str | None = None

    def __init__(self, api_key: str | None = None, **kwargs): ...
    def _run(self, query: str): ...

Import

from crewai_tools import AIMindTool

I/O Contract

Inputs

Name Type Required Description
api_key str or None No MindsDB API key; falls back to MINDS_API_KEY env var
datasources list[dict[str, Any]] No List of datasource configs with engine, description, connection_data, and tables
query str Yes Natural language question to ask the AI Mind (runtime _run parameter)

Outputs

Name Type Description
_run() returns str AI-generated answer to the natural language query from the connected data sources

Usage Examples

Basic Usage

from crewai_tools import AIMindTool

tool = AIMindTool(
    api_key="your-minds-api-key",
    datasources=[{
        "engine": "postgres",
        "description": "Sales database",
        "connection_data": {
            "host": "localhost",
            "port": 5432,
            "database": "sales_db",
            "user": "user",
            "password": "pass"
        },
        "tables": ["orders", "customers"]
    }]
)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment