> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mindsdb.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MindsDB's MCP Server Usage and Tools

**MindsDB** is an MCP server that enables your MCP applications to answer questions over large-scale federated data spanning databases, data warehouses, and SaaS applications.

## Start MindsDB as an MCP Server

Follow the steps below to use MindsDB as an MCP server.

1. Install MindsDB locally via [Docker](https://docs.mindsdb.com/setup/self-hosted/docker) or [Docker Desktop](https://docs.mindsdb.com/setup/self-hosted/docker-desktop).

2. [Connect your data source](/mindsdb_sql/sql/create/database) and/or [upload files](/mindsdb_sql/sql/create/file) to MindsDB in order to ask questions over your data.

   <Accordion title="Sample Data">
     You can use our sample dataset that stores the sales manager data.

     ```sql theme={null}
     CREATE DATABASE sales_manager_data
     WITH ENGINE = "postgres",
     PARAMETERS = {
         "user": "demo_user",
         "password": "demo_password",
         "host": "samples.mindsdb.com",
         "port": "5432",
         "database": "sales_manager_data"
     };
     ```
   </Accordion>

3. Start MindsDB MCP server.

   * **Without authentication** (suitable for local tools):

     ```bash theme={null}
     docker run --name mindsdb_container -p 47334:47334 mindsdb/mindsdb
     ```

   * **With PAT authentication** (suitable for remote):

     ```bash theme={null}
     docker run --name mindsdb_container -p 47334:47334 -e MINDSDB_USERNAME=admin -e MINDSDB_PASSWORD=password123 mindsdb/mindsdb
     ```

     Get a Bearer token:

     ```bash theme={null}
     curl -X POST -d '{"username":"admin","password":"password123"}' -H "Content-Type: application/json" http://localhost:47334/api/login
     ```

     Use this token as `Authorization: Bearer <token>` in your MCP client.

   * **With OAuth 2.0** (for enterprise deployments): configure `MINDSDB_MCP_OAUTH_ENABLED=true` along with `MINDSDB_MCP_OAUTH_ISSUER_URL`, `MINDSDB_MCP_OAUTH_CLIENT_ID`, and `MINDSDB_MCP_OAUTH_CLIENT_SECRET`.

4. To confirm the MindsDB MCP server is running use `http://127.0.0.1:47334/mcp/status`. A successful response means your MCP environment is ready.

## MCP Capabilities

### Tools

**`query`** — Executes SQL queries against MindsDB using MySQL syntax.

Parameters:

* `query` (required): SQL query string
* `context` (optional): Dict with default database, e.g. `{"db": "my_postgres"}`

Returns one of:

* `{"type": "table", "column_names": [...], "data": [...]}` — for SELECT results
* `{"type": "ok", "affected_rows": N}` — for INSERT/UPDATE/DELETE
* `{"type": "error", "error_code": N, "error_message": "..."}` — on failure

### Resources

MCP resources expose schema information for discovery:

| Resource URI                                     | Description                      |
| ------------------------------------------------ | -------------------------------- |
| `schema://databases`                             | Lists all connected data sources |
| `schema://databases/{db}/tables`                 | Lists tables in a database       |
| `schema://databases/{db}/tables/{table}/columns` | Lists columns with types         |
| `schema://knowledge_bases`                       | Lists knowledge bases            |

### Prompts

**`sample_table`** — Generates instructions to fetch 5 sample rows and describe a table's structure.

## Transport Modes

* **HTTP (SSE)**: `http://127.0.0.1:47334/mcp/sse`
* **HTTP (Streamable)**: `http://127.0.0.1:47334/mcp/streamable`
* **Stdio**: run with `--mcp-stdio` flag for local stdio-based transport

## Configuration

CORS, rate limiting, DNS rebinding protection, and OAuth settings for the MCP server are configured via the `api.mcp` section of `config.json` or the corresponding environment variables. See [Extend the Default MindsDB Configuration](/setup/custom-config#mcp-api) for the full parameter reference.
