Skip to content
Docs
Chat2DB CLI
MCP and Agent Integration

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 --json

Enable MCP

Enable Pro MCP:

chat2db mcp enable --edition pro --json

Enable Local MCP:

chat2db mcp enable --edition local --json

enable 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 --json

This 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 --json

Common tools include:

  • list_all_datasources
  • list_all_databases
  • list_all_schemas
  • list_all_tables
  • get_tables_schema
  • text2sql
  • execute_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 \
  --json

Run SQL:

chat2db mcp call execute_sql \
  --args-json '{"dataSourceId":<data-source-id>,"databaseName":"postgres","schemaName":"public","sql":"select 1","pageSize":100}' \
  --edition pro \
  --json

Before 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 install

Install into Codex:

chat2db skill install --client codex --json

Install into Claude Code:

chat2db skill install --client claude-code --json

Update the Skill:

chat2db skill update --client codex --json

If you overwrite an existing skill, confirm the target directory and the effect of --force --yes.

Disable MCP

chat2db mcp disable --edition pro --json

Stop the app, runtime, and MCP together:

chat2db stop --edition pro --all --json

Safety Boundaries

  • Redact MCP tokens, HTTP headers, and Authorization values.
  • Pro and Local may compete for the same local MCP port; if state is ambiguous, run chat2db 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 --json

Port State Is ambiguous

Inspect Pro / Local:

chat2db status --json

Stop the edition you are not using:

chat2db stop --edition local --all --json

Agent Config Still Fails

Regenerate config and confirm token, URL, and edition:

chat2db mcp config --edition pro --json
chat2db mcp tools --edition pro --json