MCP and Agent Integration
Chat2DB CLI can manage the Chat2DB desktop MCP endpoint and install Chat2DB-CLI-Skill so Codex, Claude Code, and other AI Agents can use local Chat2DB capabilities to inspect datasources, read metadata, or run controlled SQL.
MCP commands affect the local Chat2DB app and local ports. Start with:
chat2db status --json
chat2db mcp status --edition all --jsonEnable MCP
Enable Pro MCP:
chat2db mcp enable --edition pro --jsonEnable Local MCP:
chat2db mcp enable --edition local --jsonenable updates MCP settings for the selected edition and relaunches the app while waiting for /mcp to become available.
Print MCP Client Config
chat2db mcp config --edition pro --jsonThis command prints a generic MCP client config. It may include a local MCP token or header, so redact it before sharing.
List Tools
chat2db mcp tools --edition pro --jsonCommon tools include:
list_all_datasourceslist_all_databaseslist_all_schemaslist_all_tablesget_tables_schematext2sqlexecute_sql
The actual tool list is defined by chat2db mcp tools.
Call Tools
List datasources:
chat2db mcp call list_all_datasources \
--args-json '{}' \
--edition pro \
--jsonRun SQL:
chat2db mcp call execute_sql \
--args-json '{"dataSourceId":<data-source-id>,"databaseName":"postgres","schemaName":"public","sql":"select 1","pageSize":100}' \
--edition pro \
--jsonBefore calling execute_sql, verify the datasource, database, schema, and SQL. MCP exposes whatever the local Chat2DB app can access, so do not share MCP tokens or generated client configs with untrusted agents.
Install Chat2DB-CLI-Skill
Install into the current directory:
chat2db skill installInstall into Codex:
chat2db skill install --client codex --jsonInstall into Claude Code:
chat2db skill install --client claude-code --jsonUpdate the Skill:
chat2db skill update --client codex --jsonIf you overwrite an existing skill, confirm the target directory and the effect of --force --yes.
Disable MCP
chat2db mcp disable --edition pro --jsonStop the app, runtime, and MCP together:
chat2db stop --edition pro --all --jsonSafety Boundaries
- Redact MCP tokens, HTTP headers, and Authorization values.
- Pro and Local may compete for the same local MCP port; if state is
ambiguous, runchat2db status --json. A later version will optimize this by automatically selecting an available local non-well-known port. - Restrict database account permissions before letting an Agent run SQL.
- Use read-only accounts for production query workflows.
Troubleshooting
MCP Endpoint Is Unavailable
chat2db mcp status --edition all --json
chat2db mcp restart --edition pro --jsonPort State Is ambiguous
Inspect Pro / Local:
chat2db status --jsonStop the edition you are not using:
chat2db stop --edition local --all --jsonAgent Config Still Fails
Regenerate config and confirm token, URL, and edition:
chat2db mcp config --edition pro --json
chat2db mcp tools --edition pro --json