Repository navigation
feat(cli): run queries from the shell with tablepro query - #3762
Merged
Merged
Conversation
datlechin
enabled auto-merge (squash)
October 21, 2026 15:27
…ommand # Conflicts: # apple/TablePro/Models/Query/QueryHistorySource.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tablepro query --connection <name or id>runs one statement through TablePro and prints the rows ascsv,tsv,json,jsonlortable. SQL from the argument,-f <file>or stdin. Options:--database,--schema,--limit,--timeout,--read-only.tablepro connections --format jsonlists name, id and type only.tablepro-clihelper inContents/MacOS. Thetableproscript handsqueryandconnectionsto it; everything else still goes toopen -b.TABLEPRO_UI_TEST_SANDBOX. A revoked token is dropped and the run exits 3. Pairing starts only when stderr is a terminal.execute_querytakesread_only. A statement that is not a read is refused with-33007before the approval prompt and before Safe Mode, whatever the connection level and token scope allow.clientInfo.nameistablepro-cli. Recorded even with "Log MCP queries in history" off, as AppleScript is. A stored all-sources filter widens to include it.What a client can do now that it could not:
read_onlyonly adds a refusal. The command is an ordinary paired token with the scope the user picks, and it clears the same gates as any MCP client.tablepro-cli, the same way itsclientInfoalready names it in Connected Clients. The audit log still names the token.Docs: TableProApp/docs#111
Test plan
CLIArgumentsTests,CLIRowWriterTests,CLIFailureTests,CLIPairingTests,CLIRunnerTests,CLITokenStoreTests(TableProMCPTests): parsing, every format, exit status mapping, PKCE and the callback listener, the runner against a mock server, sandbox token storage.ExecuteQueryReadOnlyTests: on a Read & Write connection aread_onlywrite is refused with no prompt and no driver call; a read still runs.CLIPairingContractTests: the app parses the command's pair link as a read-only loopback pairing, and its approve and deny redirects reach the command's callback parser.MCPCommandLineHistoryTests,QueryHistorySourceTests,ExecuteQueryToolTests, the MCP write policy matrix.tableproscript against a sandboxed Debug build launched in the background, token in the sandbox file:--format csv "SELECT 1 AS n"printednand1and exited 0;--read-onlywith anINSERTexited 3 and the table kept its rows;--timeout 1on a long recursive query exited 4. Also checked: json from stdin, table with an escape shown,connections, an unknown name (2), two statements (2), a missing table (1), the--limitnote,-f, and a bogus token (3, token file removed). History recorded every run undercommand_linewith MCP history off.Not in this PR
execute_queryanswers with the whole result, capped by the MCP row limit.DROPandTRUNCATEare refused with a message that namesconfirm_destructive_operation, an MCP tool the command does not offer.Fixes #3617