docs/model-context-protocol/usage.mdx
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.
Follow the steps below to use MindsDB as an MCP server.
Install MindsDB locally via Docker or Docker Desktop.
Connect your data source and/or upload files 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.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"
};
Start MindsDB MCP server.
Without authentication (suitable for local tools):
docker run --name mindsdb_container -p 47334:47334 mindsdb/mindsdb
With PAT authentication (suitable for remote):
docker run --name mindsdb_container -p 47334:47334 -e MINDSDB_USERNAME=admin -e MINDSDB_PASSWORD=password123 mindsdb/mindsdb
Get a Bearer token:
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.
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.
query — Executes SQL queries against MindsDB using MySQL syntax.
Parameters:
query (required): SQL query stringcontext (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 failureMCP 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 |
sample_table — Generates instructions to fetch 5 sample rows and describe a table's structure.
http://127.0.0.1:47334/mcp/ssehttp://127.0.0.1:47334/mcp/streamable--mcp-stdio flag for local stdio-based transportCORS, 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 for the full parameter reference.