Repository navigation
[AskT49 SQL tool] feat(mcp): SQL analysis tools for signed-in users - #481
Draft
SylvainGravejat wants to merge 5 commits into
Draft
SylvainGravejat wants to merge 5 commits into
SylvainGravejat wants to merge 5 commits into
Conversation
client.assistantQueries wraps the user-scoped /v2/assistant_queries, /v2/assistant_views and /v2/assistant_guides endpoints through Transport.executeManual, so they share the SDK's auth, X-Account-ID, error mapping and timeout path. Calls require accountId; POST queries are not retried. These endpoints sit outside the API-key OpenAPI contract, so their response types live in the manager. Rebuilt from #436 onto current main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds sql_query, describe_views, query_guide and get_query_result in a new analytics toolset. They call the Terminal49 API's assistant query, view and guide endpoints, which authorize every call. The gateway serves analytics only to signed-in (OAuth) users, and only after GET /v2/assistant_views confirms the account has SQL access. That answer is cached for a minute per credential and account; a denial hides the tools and a transient failure keeps them listed. API keys, agent tokens and the shared token never get them, and an operator allowlist without analytics turns them off. The SQL tools use a client that never retries, run identical concurrent queries once, pass the API's messages through for rejected queries and unknown topics, and stop the model on rate limits and service failures. Co-Authored-By: Alex Garcia <alex.garcia@terminal49.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Alex Garcia <alex.garcia@terminal49.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The gateway mints a new API token for each signed-in request, so the SQL access check and the duplicate-query check now key on the caller's own token; before, neither could ever hit. The access check fits within the request deadline, and SQL calls time out after 20 seconds instead of running into the function limit. The SQL length limit counts bytes, as the API does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drops the CSV download advice, which MCP clients can't use, and no longer promises that duplicate queries always run once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
Contributor
Contributor
Shadow risk calibration
Calibration result: agreement. Shadow risk never blocks or enables merge. Keep it in observation mode until roughly 50 pull requests have human-reviewed labels, then calibrate before considering any policy use. |
This branch was successfully deployed
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.
Linear: DEV-13504
Adds read-only SQL analysis to the MCP server for signed-in users whose account has SQL access. It supersedes #436: the SDK manager is cherry-picked from it with its authorship, and most of the tool, discovery and caching code is ported from it onto the tool registry.
What it adds
Four tools in a new
analyticstoolset:query_guidedescribe_viewssql_querySELECTover theassistant_*views; returns a sample of rows and aresult_idget_query_resultWho gets the tools
usercredentials (OAuth) getanalytics. API keys, agent tokens and the shared token never do, even whenT49_MCP_TOOLSETSlists it.GET /v2/assistant_viewsconfirms the account has SQL access.T49_MCP_TOOLSETSunset, signed-in users getanalyticson top of the defaults. With it set, it must listanalytics, which makes the variable a kill switch.How the SQL calls behave
Docs
mcp/sql-queries.analyticsadded to the toolset docs.Tests
tools/sql-query.test.ts, and gateway cases intests/api-handler.test.ts.analyticsis requested.npm run agent-verifypasses. The smoke test still lists 30 tools for an API-key session.Before marking ready
Live check on a Vercel preview against staging:
The dashboard agent keeps its own SQL tools for now. Moving it to these tools, which means allowing
agentcredentials, is a separate change.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.