DEV Community

Rui Wang for BigdataSight

Posted on Originally published at bigdatasight.com

MCP or CLI? Why I Use Both for AI Data Analysis

When I explore data with an AI assistant, I want to ask follow-up questions, check a calculation, and try another angle. Once I have a useful query, I want to save it and run it again on the next export. MCP and the CLI fit these parts of my workflow well.

I build BigdataSight, a native Mac data workspace with both interfaces. Here is an example of how they work together. The sample execution records below were created for demonstration.

A worked example

Suppose we have execution records from several services and want to know which service had the most failures yesterday. Save these records as runs.csv:

run_id,service,status,finished_at
r1,billing,failed,2026-10-18 09:00:00
r2,billing,succeeded,2026-10-18 10:00:00
r3,billing,failed,2026-10-18 11:00:00
r4,search,succeeded,2026-10-18 12:00:00
r5,search,failed,2026-10-18 13:00:00
r6,ingest,succeeded,2026-10-18 14:00:00
r7,billing,cancelled,2026-10-18 15:00:00
r8,billing,failed,2026-10-19 00:00:00
Enter fullscreen mode Exit fullscreen mode

For this example, yesterday is October 18, 2026. We count only succeeded and failed attempts, treat both the reporting window and timestamps as UTC, and return the failure count and rate, ordered by failure count. Each row is one attempt, including retries.

Explore through MCP

MCP lets an AI client discover tools and contextual resources. A connected assistant can inspect the file's columns and preview a few rows before writing a query. I would start with this prompt:

Use BigdataSight to inspect the runs file I added. Show its schema and a short preview.

For October 18, 2026 in UTC, use finished_at to count succeeded and failed attempts by service. Return finished attempts, failed attempts, and failure percentage, ordered by failure count.

Show the SQL before running it. Ask if the timestamp type or status values need clarification.
Enter fullscreen mode Exit fullscreen mode

Checking the schema first helps catch details such as a timestamp stored as text or a status field that uses error for failures. The assistant can then adjust the query to the actual data.

With finished_at parsed as a UTC timestamp, the query is:

SELECT
    service,
    COUNT(*) AS finished_runs,
    SUM(CASE WHEN status = 'failed' THEN 1 ELSE 0 END) AS failed_runs,
    ROUND(
        100.0 * SUM(CASE WHEN status = 'failed' THEN 1 ELSE 0 END)
        / COUNT(*),
        2
    ) AS failure_pct
FROM runs
WHERE finished_at >= TIMESTAMP '2026-10-18 00:00:00'
  AND finished_at < TIMESTAMP '2026-10-19 00:00:00'
  AND status IN ('succeeded', 'failed')
GROUP BY service
ORDER BY failed_runs DESC, service;
Enter fullscreen mode Exit fullscreen mode

Use the actual table name from your SQL workbench in place of runs, and adjust timestamp handling to match the column's type. The example returns:

service finished_runs failed_runs failure_pct
billing 3 2 66.67
search 2 1 50.00
ingest 1 0 0.00

Billing has two failures out of three completed attempts. Its cancelled attempt and the failure at midnight on October 19 fall outside our definition. The SQL makes the date range and denominator easy to check.

Save the query as a command

In BigdataSight 1.2, open the source and put the reviewed SQL in the editor. Select the source under Settings → External Access and choose Structure and data access, then use Run → Copy as Command…. The copy window lets you select a shell, result-row limit, and timeout.

Install bds through Command Line → Set Up bds…, select sh in the copy window, and save the copied command as daily-failures.sh:

sh ./daily-failures.sh > daily-failures-result.json
Enter fullscreen mode Exit fullscreen mode

The generated command includes the source selection and sends the query to bds query --request -. The output file contains the JSON query response, subject to the chosen result-row limit. Check the command's exit status before using the result. To keep earlier results, choose a new output filename each time: > overwrites an existing file.

Each saved command uses a specific date range and data source. For a reusable script, ask the AI assistant to extract those values into parameters. Review the script and try it on a known date before adding it to your daily workflow.

Choose the interface that fits the work

I like MCP when I am exploring data in a connected AI client: source discovery, query results, and follow-up questions stay in one conversation. A saved CLI command is convenient when I want to repeat a calculation or include it in a script.

An AI coding assistant with terminal access can also inspect CLI help and run queries directly. And a connected MCP client can repeat a known query. Both support exploration and execution; the surrounding workflow guides my choice. MCP requires client support for the server's tools, while scripts need to handle shell quoting, exit statuses, and JSON output.

Start a task in one place, retrieve it in another

For a longer query or export, BigdataSight 1.2 Pro supports independent tasks. Ask the AI client to submit a supported operation as a task and keep the returned task ID. You can close that MCP connection and check progress later from the terminal.

Replace TASK_ID_FROM_RECEIPT with the returned ID:

printf '%s\n' '{"version":1,"jobID":"TASK_ID_FROM_RECEIPT"}' |
  bds jobs get --request -
Enter fullscreen mode Exit fullscreen mode

Once the task completes, retrieve its result:

printf '%s\n' '{"version":1,"jobID":"TASK_ID_FROM_RECEIPT"}' |
  bds jobs result --request -
Enter fullscreen mode Exit fullscreen mode

To check this handoff, I supplied the same eight records directly in SQL, submitted the query through MCP, and closed the connection. CLI and a new MCP session both retrieved the same three summary rows.

Running the saved query calculates a fresh result from the selected source. Retrieving a completed task gives you the result captured by that run. If the source changes, you can keep the earlier result for comparison.

Keep the Mac awake while a task runs. Tasks expire 24 hours after submission, and retrieval requires the relevant source access and Pro entitlement. Save results you want to keep before they expire.

Using this workflow

For a calculation I plan to reuse, I keep the SQL, source selection, dates, timezone, status definitions, and result-row limit alongside the output. That gives me what I need to review or adjust the next run.

Queries run on the Mac. Schemas, previews, and results returned to an AI client may be sent to its model provider; check the client's data settings when choosing what to share.

You can try local CSV and Parquet queries with BigdataSight's free Viewer. Pro adds more formats, remote sources, comparisons, broader exports, and independent tasks. The steps here use BigdataSight 1.2. See the setup guide to get started.

Where would a saved command help most in your AI data analysis workflow?

Disclosure: We build BigdataSight, a native Mac data workstation.

AI-assistance disclosure: I used an AI coding assistant to help research and edit this article. I reviewed the final argument and the linked specifications before publishing.

Top comments (0)