Overview
When a user uploads a tabular file — a CSV or Excel/XLSX spreadsheet — as an input to a workflow or agent, MagOneAI gives the agent a SQL query tool scoped to that file’s data. The agent can then answer analytical questions about the file by writing and running real SQL, instead of trying to reason over thousands of rows of raw text. This is the “database tool” in MagOneAI. There is no connecting to external or live databases — the data the agent queries is the data your users provide as file inputs.Database tools work on uploaded tabular files. To query a live PostgreSQL, MySQL, or other production database, build a custom MCP tool that wraps your database access.
How it works
A tabular file is provided as input
A CSV or XLSX file reaches the agent as a workflow input (for example at the Start node) or directly as an agent input. See Triggers and execution for how files enter a workflow.
The file is converted to a queryable table
Behind the scenes, MagOneAI reads the file and converts it to an efficient columnar format. The column names and types are detected automatically.
The agent gets a dedicated query tool
For each tabular input, the agent receives its own SQL query tool, named after the input field. The tool’s description automatically includes the table’s columns and schema, so the agent knows exactly what it can query.
The agent writes and runs SQL
During its reasoning loop, the agent writes a
SELECT query, runs it against the file, and reads the results back — just like any other tool call.The query engine
Queries run on DuckDB, an in-process analytical SQL engine. Two things matter for how you design prompts and workflows:- It is read-only. Only
SELECTandWITH(CTE) queries are allowed.INSERT,UPDATE,DELETE, and any DDL (CREATE,DROP,ALTER, …) are rejected. The agent can read and analyze the uploaded data, but it can never modify it. - It speaks standard SQL. Aggregations, filters,
GROUP BY,ORDER BY, window functions, and CTEs all work, so the agent can express genuinely analytical questions.
Querying multiple files
If several tabular files are supplied together as an array of inputs — up to 10 files — each becomes its own table, and the agent can JOIN across them in a single query. Example: joining two uploaded files:What this is good for
Database tools shine whenever the answer lives in a spreadsheet and would be tedious or unreliable to reason over as plain text:- Aggregate questions — “What’s the total revenue by region?” or “What’s the average order value per month?”
- Data quality checks — “Which rows are missing an email address?” or “How many duplicate IDs are there?”
- Filtering and ranking — “List the top 10 accounts by spend” or “Show every order over AED 50,000.”
- Cross-file analysis — join an uploaded list against another uploaded export to find matches, gaps, or totals.
Using it in a workflow
Database tools are part of file handling and agent tooling — there’s no separate connection to configure.Accept a tabular file input
Define a file input on your workflow trigger or agent. Provide a CSV or XLSX file at run time. See Triggers and execution.
Run an Agent node
When the Agent node executes, the per-file query tool is attached automatically. No tool needs to be enabled by hand.
Prompt the agent to answer from the data
In the agent’s instructions, tell it to answer questions by querying the file. The agent will choose when to call the query tool during its tool-calling loop.
Troubleshooting
The agent didn't query the file
The agent didn't query the file
Symptoms: The agent answers from guesswork or says it can’t see the data.Solutions:
- Confirm the file was actually provided as an input to the workflow or agent.
- Confirm the file is CSV or Excel/XLSX — other file types don’t get a query tool.
- Make the instruction explicit: tell the agent to use the query tool to answer.
A write query was rejected
A write query was rejected
Symptoms: A query fails because it tried to modify data.Solutions:
- The engine is read-only by design. Rewrite the request as a
SELECTorWITHquery. - There is no way to write back to the file — database tools are for analysis only.
The agent used the wrong column names
The agent used the wrong column names
Symptoms: Queries fail with unknown-column errors.Solutions:
- Column names come from the file’s header row — make sure the spreadsheet has clear headers.
- Avoid duplicate or blank header cells, which make columns ambiguous.
A JOIN across files didn't work
A JOIN across files didn't work
Symptoms: The agent can only see one table.Solutions:
- Provide the files together as an array input (up to 10 files), so each becomes its own table.
- Make sure the files share a column the agent can join on.
Next steps
Triggers and execution
Learn how files enter a workflow as inputs
Agents overview
Understand how agents call tools during reasoning
Tools overview
See all the tools your agents can use
Custom MCP tools
Wrap a live database with a custom tool