Reference
MCP / Agent Access
Dory exposes an MCP endpoint so external AI agents can safely read Dory connections, inspect schema, read saved queries, inspect monitoring summaries, run limited read-only SQL, and build analysis context.
Use cases
- Query Dory connections from Codex, Claude, or another MCP-capable client.
- Search tables, views, and columns before writing SQL.
- Read table structure, DDL, statistics, and previews.
- Run read-only SQL with bounded result size.
- Build analysis context or chart recommendations from query results.
- Read database monitoring summaries where supported.
Create an access token
- Open Dory settings.
- Go to Agent Access.
- Enter a token name such as
CodexorClaude Desktop. - Create the token.
- Copy the full token. It is only shown once.
Tokens use the dory_mcp_ prefix. If you lose the full token, revoke it and create a new one.
Default scopes
New tokens include the following read and analysis scopes:
| Scope | Capability |
|---|---|
connections:read | Read connection, database, and table metadata. |
query:read | Preview tables and run read-only SQL. |
analysis:run | Build result context, chart profiles, and analysis actions. |
schema:read | Search schema and read table profiles. |
saved_queries:read | Read saved queries. |
monitoring:read | Read monitoring summaries and slow or failed query samples. |
MCP tools do not return database passwords or connection secrets.
Codex CLI example
export DORY_MCP_TOKEN="dory_mcp_xxx"
codex mcp add dory --url https://your-dory.example.com/api/mcp --bearer-token-env-var DORY_MCP_TOKEN
codex mcp listUse a separate token for each client and revoke tokens that are no longer needed.
Generic MCP JSON example
{
"mcpServers": {
"dory": {
"type": "http",
"url": "https://your-dory.example.com/api/mcp",
"headers": {
"Authorization": "Bearer ${DORY_MCP_TOKEN}"
}
}
}
}Available tools
| Tool | Purpose |
|---|---|
dory_list_connections | List visible Dory connections. |
dory_list_databases | List databases for a connection. |
dory_list_tables | List tables and views for a database. |
dory_describe_table | Read columns, types, and table metadata. |
dory_get_database_summary | Build a high-level database summary. |
dory_get_table_profile | Read table profile and statistics. |
dory_search_schema | Search schema by table, view, or column name. |
dory_list_saved_queries | List saved queries available to the token. |
dory_get_saved_query | Read one saved query. |
dory_get_monitoring_summary | Read monitoring summaries where supported. |
dory_preview_table | Preview rows from a table. |
dory_run_readonly_sql | Execute read-only SQL with row limits. |
dory_build_result_context | Convert result data into agent-friendly context. |
dory_build_chart_profile | Build chart suggestions from result shape. |
dory_run_analysis | Run a higher-level analysis action. |
dory_run_readonly_sql rejects write statements and limits returned rows. Database-level read-only credentials are still recommended for production data.
Agent workflow
- Use
dory_list_connectionsto choose the right connection. - Use
dory_list_databasesanddory_list_tablesto locate relevant objects. - Use
dory_describe_tableordory_search_schemabefore writing SQL. - Use
dory_preview_tablefor small row samples. - Use
dory_run_readonly_sqlfor reviewed SELECT queries. - Use
dory_build_result_contextordory_build_chart_profileto summarize results.
Security guidance
- Create one token per client so audit and revocation are simple.
- Do not commit tokens to source control.
- Store tokens in environment variables or the client secret store.
- Revoke tokens when a client, laptop, or teammate no longer needs access.
- Use read-only database users for production connections.
- Treat schema names and sample rows as sensitive if they reveal customer or business data.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| MCP client returns 401 | Missing or invalid token. | Recreate the token and update the client environment. |
| Client cannot list connections | Token is missing connections:read or user has no access. | Create a token from the right Dory account and organization. |
| SQL is rejected | Statement is not read-only or contains unsupported syntax. | Use a plain SELECT query and remove write operations. |
| Too few rows returned | MCP row limits are applied. | Aggregate in SQL or narrow the query before requesting more rows. |
| Client cannot connect | URL is wrong or Dory is not reachable from the client. | Verify the /api/mcp URL in a reachable environment. |