Repository navigation
ADFA-7139: AI-Agent-MCP connects to the SQLite debugger automatically - #166
davidschachterADFA wants to merge 23 commits into
Conversation
davidschachterADFA
left a comment
There was a problem hiding this comment.
Review of head a89b585 (not stacked in this repo: base is main). Governing rules: addons CLAUDE.md and plugins/README.md (no written approve/request-changes rule, so the default severity table applied). plugin-review criteria read for compatibility, permissions and manifest only; the rubric was not scored. Static review only: no build, no device. Self-authored PR, so the verdict is COMMENT (a verdict was computed as COMMENT anyway: MINOR findings only). No earlier review rounds and no approvals existed.
MINOR
- AndroidManifest.xml:49 - the 26.43 floor predates the feature, and its stated reason does not hold on stage
- McpPlugin.kt:208 - a deactivation during the first endpoint read leaves a listener and live entries behind (PLAUSIBLE)
Findings without a diff anchor
MINOR: libs/plugin-api.jar is a binary, so this cannot be anchored. The jar was built from the unmerged CoGo branch (#2259, #2260, #2261 are all open and none is on stage), and it carries more than the two new classes: about 100 classes differ from the committed jar, and for interfaces such as DocumentationExtension and net.Host the methods are now Kotlin default methods (-Xjvm-default), plus MenuItem and PluginTooltipButton constructor overloads and a new PluginFragmentKt. Every plugin compiles against this jar, but only AI-Agent-MCP was built or tested. plugins/README.md says libs/ is filled from stage and that Publish addons overwrites the jars with CoGo's plugin-api-latest, so an API that is not yet released passes PR CI and fails Publish. Not reachable today: nothing breaks until this merges. The fix is to say in the description that this PR must not merge before #2259-#2261 land and a plugin-api-latest release carries DebuggerEndpointService, and ideally to refresh libs/ from stage after that rather than from the branch.
Checked and found sound: debugger.endpoints is a real PluginPermission in the new jar and is declared in plugin.permissions (manifest completeness); the service is called from Dispatchers.IO, as the API requires; SecurityException and IllegalStateException from getEndpoints are caught and keep the previous entries; the token stays out of logs, the Keystore store and McpServer; the bearer is read per request and the session key includes its fingerprint; only the automatic entry gets preApproved, and AI-Core still prompts on every contributed tool (ContributedToolHandler), as the README says; isReadOnly=true only changes mutatesProject to false in AI-Core, which is intended here; the endpoint-replaced-during-list race is guarded by recordTools; the retry fires only when the URL or token changed. Not verified: behaviour on a device (the description says so too), and how a Code on the Go 26.42 build treats an unknown permission.
davidschachterADFA
left a comment
There was a problem hiding this comment.
Re-run of the automated first pass after the earlier run's diff collision (its code-review step never ran on this PR). This review lists only the finding that was not already posted; the earlier review's findings (the 26.43 floor, the deactivation race in McpPlugin, and the libs/plugin-api.jar provenance) are not repeated. Head a89b585, not stacked (base is main). Static review only: no build, no device. Self-authored PR, so COMMENT.
MINOR
- McpConnections.kt:100 - a session for a replaced endpoint reads the new endpoint's token, so its close() sends it to the old port
NITPICK - none
The AI-Agent-MCP debugger entry compiles against DebuggerEndpointService,
DebuggerEndpoint and the debugger.endpoints permission, which the checked-in
plugin-api.jar lacks. The jar is rebuilt from CodeOnTheGo branch
sqlite-debugger/ADFA-7139, commit 8e7473b76 ("Add DebuggerEndpointService
and the debugger.endpoints permission"); the plugin-api module is unchanged
by the later commits on that branch.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
… debugger An app built in Code on the Go with cogo.sqliteDebugger=true serves its databases over MCP on 127.0.0.1. AI-Agent-MCP now offers that server to the Agent with nothing typed in. - One automatic server entry per endpoint reported by DebuggerEndpointService: http://127.0.0.1:<port>/mcp, the token kept in memory only and never stored in the Keystore. No endpoint means no entry and no error. - The endpoint is re-read before reconnecting after a refused connection, 401 or 403, so a relaunched app (new port and token) is picked up; its tools stay offered across the relaunch. A refused read is logged once. - For this entry only, tools whose readOnlyHint is exactly true (boolean) start switched on and others start off. Hand-added servers keep today's behaviour even when they claim the hint. AI-Core still asks for approval on every call of a contributed tool, so the pre-approval does not skip the prompt; automatic approval is ADFA-7147. - The manifest declares debugger.endpoints and plugin.min_ide_version 26.43: an older Code on the Go rejects the unknown permission at validation, so it cannot install this version at all. - Showing the entry in the settings screen is deferred to phase 2: the eight phase 1 tools are all read-only, so nothing needs switching on. Tests: no endpoint; stale endpoint (refused, 401, 403) re-read; relaunch through a fake MCP server keeps the tools; the annotation rule (true, false, missing, "true", 1, null); a hand-added server claiming the hint stays off; a repeated read failure is logged once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
The plugin README and the plugin's help page describe the automatic SQLite debugger entry, its read-only tool rule and the approval prompt. plugins/README.md lists debugger.endpoints among the permissions and says a plugin declaring it needs plugin.min_ide_version of at least 26.43. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…rst release with debugger.endpoints Code on the Go 26.43 to 26.46 are released and none carries PluginPermission.DEBUGGER_ENDPOINTS or DebuggerEndpointService. An unknown permission key does not only warn: PluginManager.loadPlugin (PluginManager.kt:568) calls PluginSecurityManager.validatePlugin, which returns false when validatePermissions (PluginSecurityManager.kt:50, :92) finds a key outside PluginPermission, and loadPlugin then fails with "plugin failed security validation". The same code is at tags 26.42 and 26.46 and on origin/stage. The warn-and-drop at PluginManager.kt:582 runs only after validation passed, so it never sees an unknown key from a manifest. 26.46 therefore rejects this plugin, and the floor must be the next release, 26.47 (26.46 was tagged 2026-11-10, weekly cadence). The manifest comment, plugin README and plugins/README.md say so. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…oint read leaves nothing behind The host's database read blocks and cannot be cancelled. If the plugin was deactivated meanwhile, the old coroutine resumed, re-installed the endpoint source and added the endpoint listener, which nothing removed; a quick re-activate added it twice. Now the launch checks the activation before and after the read, install() keeps neither the source nor the entries of a finished activation, and deactivate removes the listener after the scope ends so a late add is caught. McpPluginDebuggerStartTest fails without this (a listener is left registered when the activation ended during the read) and passes with it; it also checks that a live activation adds one listener. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…nds no token credentialsFor returned the entry's current token for any session of that id, so the old session's close() sent DELETE to the old port carrying the new process's token. The supplier now takes the url its session was built for and releases the token only while the entry still points there. ReplacedEndpointCredentialTest replaces an endpoint and checks the DELETE the old server saw: it fails without this (the DELETE carried "Bearer new-token") and passes with it. FakeMcpServer now records requests and can hand out a session id. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
a89b585 to
185d360
Compare
davidschachterADFA
left a comment
There was a problem hiding this comment.
Re-review of addons#166 at 185d360 (medium effort). Verdict computed: COMMENT (MINOR and NITPICK only; GitHub also refuses APPROVE/REQUEST_CHANGES on a self-authored PR). Nothing here blocks merge.
MINOR
- McpPlugin.kt:267 - the probe's
AutomaticServers.refresh()can repopulate the entries after deactivation, the same hazard as the earlier isActive thread but on the periodic path
NITPICK - 1 inline, not listed
Not stacked. Base is main. The PR is the counterpart of CodeOnTheGo #2261 (sqlite-debugger/ADFA-7139, tip of the #2259 > #2260 > #2261 stack): I read DebuggerEndpointService and DebuggerEndpoint there, and the bundled libs/plugin-api.jar here contains both classes and PluginPermission.DEBUGGER_ENDPOINTS with the same signatures. AI-Core's handling of read-only tools is addons#167, reviewed separately and not reviewed here.
Rules applied. The addons CLAUDE.md and plugins/README.md, and, for plugin criteria only (not scored), the plugin-review skill and RUBRIC: manifest completeness (both new permissions declared, min and max version present), no reflection into IDE internals (none found), resource discipline (the scope is cancelled and every listener is removed in deactivate and dispose), the html page and README updated, and libs/ carries the new API. None gives an approve/request-changes rule, so the skill's default table applied.
Prior threads (judged on the code at this head, not on the replies).
- AndroidManifest.xml:49 floor of 26.43: fixed. The floor is 26.47, which matches #2261's changelog entry (26.46 is the latest tag). I confirmed on CodeOnTheGo
stagethatPluginSecurityManager.validatePermissionsrejects an unknown permission key before the loader's warn-and-drop, so the manifest comment, README and plugins/README are right. - McpPlugin.kt:208 first read after deactivation: fixed for that path.
startDebuggerEntrycheckskeepGoingbefore and after the read and after adding the listener,installre-checks under the lock, and deactivate and dispose remove the listener after the scope ends. The periodic refresh is still open (finding above). - McpConnections.kt:100 token for a replaced endpoint: fixed.
credentialsFor(serverId, url)releases the token only while the entry's current URL equals the session's, so a replaced session (and itsclose()DELETE) sends none.
No thread needed a reply or an unresolve.
Static review only: no build, no device. Leads from the built-in review that I discarded: duplicate application IDs collapsing (the host keys rows by application ID, so one per app), EndpointRetry missing wrapped connect errors (the transport lets ConnectException through; the retry is for a refused connection), concurrent re-lists (McpConnections.session is locked), the 26.47 floor as a guess (the manifest comment says to raise it, and #2261 carries the same number), two tool caches (kept in step in list), trusting a loopback server's readOnlyHint (nothing authenticates a server beyond its token, the approval is still asked today, and honouring the hint is addons#167 and ADFA-7147; worth keeping in mind there because a dead app's port can be reused), and RepeatedFailureLog not resetting (documented as one per process).
…points The doc describing the host endpoint service sat on startDebuggerEntry above its own KDoc; it belongs to installDebuggerEndpoints, which reads the service. Comment-only change, so no test. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…ctivation is over probeHealth checked keepGoing only before the delay, then called AutomaticServers.refresh() without it, so a deactivation during the delay (or during the refresh's blocking read) let the refresh restore the automatic entries that install(null) had just cleared, and re-publish them. It now returns if the activation ended during the delay, passes keepGoing to refresh (which checks it after the read, before storing) and re-checks before settingsChanged(). startDebuggerEntry and installDebuggerEndpoints already guard each step. probeHealth is now internal with an intervalMs parameter so a test can drive it. Tests: McpPluginProbeHealthTest (ended during the delay; ended during the refresh read). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA
left a comment
There was a problem hiding this comment.
Round 2 at 5911aac (round 1 head 185d360), reviewed at effort medium, with attention to 3fc5002 and 5911aac. Not stacked (base main). Rules read: CLAUDE.md and plugins/README.md; the plugin-review skill was read for criteria only and not scored. This repo has no written approve/request-changes rule, so the skill's default applied; the PR is self-authored, so the event is COMMENT.
MINOR
- McpPlugin.kt (existing thread, reply posted): the refresh that EndpointRetry triggers from a tool call can still restore the entries after deactivation
No new thread was opened; the one open item went as a reply in its own thread: #166 (comment)
Re-check of earlier threads (judged on the code at head, not the replies):
- AndroidManifest.xml min_ide_version: fixed (26.47, with the manifest comment and both READMEs saying so; I did not re-check the IDE source behind it).
- McpPlugin.kt first read in activation: fixed. startDebuggerEntry checks isActive around the blocking read and after adding the listener, and deactivate and dispose remove it.
- McpConnections.kt token for a replaced endpoint: fixed. credentialsFor takes the session's URL and returns the token only while the entry still maps to it.
- McpPlugin.kt probe refresh after deactivation: partly fixed. probeHealth and AutomaticServers.refresh check keepGoing after the delay and, under the lock, before storing; tests McpPluginProbeHealthTest fail without those checks. The tool-call path (EndpointRetry, default keepGoing) is not covered, as the reply above says.
- McpPlugin.kt stacked KDoc: fixed (3fc5002; the endpoint-service block now sits on installDebuggerEndpoints).
Not verified: no build or test was run.
…eactivation AutomaticServers.refresh now stores nothing when the source it read is no longer the installed one, so a refresh started by EndpointRetry (default keepGoing) that was in flight when install(null) cleared the entries cannot bring them back. Every caller is covered, not only the ones passing keepGoing. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA
left a comment
There was a problem hiding this comment.
Round 4 at 994860e (previous head 5911aac), effort medium, with attention to 994860e. Not stacked (base main). Rules read: addons CLAUDE.md, plugins/README.md, plugins/AI-Agent-MCP/README.md; the plugin-review skill and RUBRIC were read for plugin criteria only and not scored. This repo has no written approve/request-changes rule, so the default severity table applied. The computed verdict is REQUEST_CHANGES (one confirmed IMPORTANT). It was submitted as COMMENT because the PR is self-authored, so GitHub refuses that verdict, and this run was non-interactive without --verdict.
IMPORTANT
- AutomaticServers.kt:175 - two reporting apps get tool names the model cannot tell apart
MINOR
- McpToolSource.kt:144 - a cancel between EndpointRetry's two attempts is lost
NITPICK - 2 inline, not listed
994860e checked and found sound. source is written only under the lock (install(null) and install(source, keepGoing)), and refresh now compares it with what it read, under that same lock, after the blocking read. Every ordering against install(null) therefore ends with no entries: a refresh that stores first is wiped by the clear() that follows, and one that stores later sees null. This holds for every caller: the probe, EndpointRetry from a tool call or from connect, and the first read in install. fromHost returns a new capturing lambda per activation, so a re-activation also drops the old activation's in-flight refresh. Within one activation source never changes, so no legitimate refresh is dropped. The keepGoing called under the lock is isActive, which takes no lock. Reading the new test, it fails without the change: the retry's refresh would store port 4001. Only the null branch is tested, not the replaced-source branch. I did not post that gap.
Earlier threads, judged on the code at this head, not on the replies.
- AndroidManifest.xml
min_ide_version: fixed (26.47; manifest comment and both READMEs agree). - McpPlugin.kt first endpoint read during deactivation: fixed (
startDebuggerEntrycheckskeepGoingaround the read and after adding the listener; deactivate and dispose remove it). - McpConnections.kt token for a replaced endpoint: fixed (
credentialsFor(serverId, url)sends the token only while the entry still maps to the session's URL). - McpPlugin.kt refresh after deactivation (probe, then the EndpointRetry path): fixed now. See the 994860e paragraph above.
- McpPlugin.kt stacked KDoc: fixed (the endpoint-service block sits on
installDebuggerEndpoints). - Round-1 body finding,
libs/plugin-api.jarbuilt from the unmerged CoGo branch: handled by the description's merge precondition (CodeOnTheGo #2259-#2261 are still open).
No thread needed a reply or an unresolve.
Leads from the built-in review that I discarded: recordTools notifying before toolsByServer is written (every caller of connect notifies again after it returns); the token and readOnlyHint trust going to a process that reuses a dead app's port (already considered in round 1; the approval is still asked, ADFA-7147 / addons#167); a duplicate re-list from the retry's refresh plus relistAutomatic (already considered in round 1; only duplicate work, and the session map is locked); isAutomatic matching a stored id by prefix (stored ids are UUIDs, McpServerStore.kt:303); servers() rebuilt on each call (a handful of entries); RepeatedFailureLog never reset (already considered in round 1; documented as one per process); AVAILABLE recorded after a dropped list (the re-list of the new endpoint and the next probe overwrite it).
Not verified: static review only. No build, no test run, no device.
…list notification @PARAM keepGoing was documented on the install overload that has no such parameter; it now sits on the two-argument overload that takes it. probeHealth called settingsChanged() after AutomaticServers.refresh returned true. refresh returns true only when it fired its change listeners, and McpPlugin.activate registers settingsChanged on them before probeHealth starts, so the agent was told twice. The call is removed; no test, since the agent is notified exactly as before. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…nt retry EndpointRetry runs a call a second time against the re-read endpoint. A cancel landing between the attempts found no live session to drop (the first had ended, the second not begun), so the retry went out anyway. McpToolSource now records a cancel for a running call and the retry's block checks it before opening a session, failing as an interrupted read, which is how a dropped connection already reports a cancel (classified as Cancelled, so the server is not marked degraded). Test: CancelBetweenAttemptsTest cancels from inside the retry's endpoint re-read; without the check the new endpoint receives the retry. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…y name and description Every SQLite debugger entry is named "SQLite debugger (<applicationId>)" and tool names use the first 10 identifier characters of the server name, so every entry's tools began sqlite_deb. With two apps reporting, the model saw sqlite_deb_query and sqlite_deb_query_2 with identical descriptions, and which app got "_2" followed the host's row order. Now, for automatic entries only: - the name prefix is db_ plus the first 7 characters of the application ID's last segment (db_notes_query); apps whose prefix would be shared (com.a.notes, com.b.notes) both use the first 5 characters of the segment plus 4 hex digits of a digest of the full application ID (notes_3fa1_query). It depends only on the set of IDs, so it is stable across restarts and row order, and stays within the 10-character prefix rule. The collision set is every automatic entry, not only those with tools on. - each description starts "<applicationId> (SQLite debugger): ", so the model and the approval dialog name the app. Hand-added servers keep McpToolText.exposedName(server.name, ...) and their own description. What depends on the names or descriptions: - ReadOnlyTrust.enabledTools and the stored knownTools/enabledTools use the server's own tool names (query), not the exposed ones: unchanged. - The tool source registration with AI-Core (listTools/getToolGroups): the exposed names and descriptions of these tools change once, on upgrade; group ids and display names do not. Calls resolve by exposed name from the same list, so listing and invoking agree. - AI-Core's session-grant key (addons#167, ContributedToolHandler.sessionApprovalKey = provider:tool name:digest(description, schema)): it changes once for these tools, so a grant given to the old text is not carried over, and it now differs per app, so an "Always Allow" for one app's query no longer covers another's. Tests: AppToolNamesTest (two apps; two with the same last segment, both row orders; one app with a hand-added server unchanged), McpToolTextTest (appPrefixes). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA
left a comment
There was a problem hiding this comment.
IMPORTANT
- AutomaticServers.kt:181 - two reporting apps' 16 always-on tools exceed AI-Core's 12-tool budget; four of the second app's are never offered
MINOR
- README.md:62 - the names keep only the first seven characters of the segment, which the README does not say
- README.md:76 - the PR description's merge note cites line numbers that d102bfe moved
- McpToolSource.kt:234 -
getValueon prefixes built from a different server-list read (not reachable in practice)
NITPICK - 1 inline, not listed
Round 5 at d102bfe (previous round at 994860e), effort medium, concentrating on 6e57f6a, 02704e7 and d102bfe. Not stacked (base main, nothing based on it). Rules read at head: addons CLAUDE.md, plugins/README.md, plugins/AI-Agent-MCP/README.md; the plugin-review skill and RUBRIC for plugin criteria only, not scored. This repo has no written approve/request-changes rule, so the default severity table applied. The computed verdict is REQUEST_CHANGES (one confirmed IMPORTANT). It is submitted as COMMENT because the PR is self-authored, so GitHub refuses that event, and this run was non-interactive without --verdict.
The fix commits, checked.
- 02704e7: the flag is set only for a call whose worker is running and cleared in the worker's
finally; the retry's block reads it before opening a session, andInterruptedIOExceptionclassifies asCancelled, so a cancelled call does not mark the SQLite debugger entry degraded. The new test fails without the check. Two residues, not posted: the check comes beforeliveSessions[callId] = session, so a cancel duringMcpConnections.session(target)is still missed (a sub-millisecond window: closing the stale session is a DELETE to the old, refused port); andcanceltestsrunningand adds tocancelledin two steps, so a cancel racing completion can leave one id incancelled. AI-Core gives every call a fresh UUID (ContributedToolHandler.execute), so no later call inherits it. - 6e57f6a:
refreshreturns true exactly when it fires its change listeners, andsettingsChangedis one of them from activation until deactivation or disposal. Deactivation removes the listener just before it unregisters the tool source, so the only notification the old call could add was one for a source being removed. No path lost a notification it needed. The@param keepGoingnow sits on the overload that takes it. - d102bfe: a prefix depends only on the set of application IDs (
distinctplus a count), never on row order, port or token. The host keeps each app's row and updates it in place, so the set and the names survive an IDE restart unless an app is uninstalled. Lengths: 10-character prefix + 24 +_20= 38, within AI-Core's 40. Application ID characters reduce to[a-z0-9_], and an empty segment becomesapp. A clash with a hand-added server's label (a server named "DB notes") or between two digest forms falls to the existing_2numbering, which depends on order, but the descriptions still name the app. Names change when a second app with the same prefix first reports (both switch to the digest form), as the README says. - Effect on #167:
sessionApprovalKeyis provider, tool name and a SHA-256 of description and schema. The application ID in the description now keeps each app's "Always Allow" separate; before this change, two apps' tools had equal descriptions and schemas. A switch to the digest form renames the tool, so its session grant lapses and the user is asked again, which fails safe.
Earlier threads, judged on the code at this head, not on the replies.
- AndroidManifest.xml
min_ide_version: fixed (26.47; manifest comment and both READMEs agree). - McpPlugin.kt first endpoint read during deactivation: fixed (
startDebuggerEntrycheckskeepGoingaround the read and after adding the listener). - McpConnections.kt token for a replaced endpoint: fixed (
credentialsFor(serverId, url)). - McpPlugin.kt refresh after deactivation: fixed (
refreshstores nothing unless the source it read is still installed, under the same lock asinstall(null)). - McpPlugin.kt stacked KDoc: fixed.
- AutomaticServers.kt indistinguishable tool names (IMPORTANT): fixed by d102bfe as described above.
- McpToolSource.kt cancel between the retry's attempts (MINOR): fixed for the window it named (the endpoint re-read); residues above.
- AutomaticServers.kt misplaced
@param keepGoingand McpPlugin.kt duplicatesettingsChanged()(NITPICKs): fixed. - Round-1 body finding,
libs/plugin-api.jarfrom the unmerged CodeOnTheGo branch: still covered by the description's merge precondition (CodeOnTheGo #2259, #2260 and #2261 are open).
No thread needed a reply or an unresolve.
Leads from the built-in review that I discarded. Two concurrent refreshes storing an older endpoint (needs a host read that began before the app reported to finish after a whole second refresh; the next call's retry or the next probe restores it). A stale McpServer snapshot closing the new session (the snapshot is taken microseconds before session(); the retry rebuilds it). Removed-entry cleanup outside the lock (needs an app's row to vanish and come back between two refreshes; DebuggerEndpointDao only updates a row in place across a relaunch). recordTools notifying before toolsByServer is written, a dropped list recorded as AVAILABLE, and the two tool caches (all considered in earlier rounds; every caller of connect notifies again after it returns, which is also why relistAutomatic's own settingsChanged() is not redundant). The duplicate SHA-256 helper (McpConnections.fingerprint is private and a full digest; sharing it is not worth a cross-package helper). My own: the application ID prefix spends about 45 of AI-Core's 200 prompt characters per SQLite debugger tool description, but what it pushes out of the long descriptions was mostly already past the cap.
Not verified: static review only. No build, no test run, no device.
…e tools An SQLite debugger entry now starts with list_databases, get_schema, query and get_events switched on, each only when the server advertises it with readOnlyHint: true. Its other tools stay known but off. A tool without readOnlyHint exactly true is still never switched on; hand-added servers are unchanged. This changes ADFA-7139's earlier rule, under which every read-only tool started on. Why: AI-Core describes at most 12 contributed tools per message (4 in compact mode), in order, and drops the rest, and every app has its own entry. With all 8 read-only tools on, two apps used the whole normal budget and a hand-added server pushed SQLite debugger tools out silently. Phase 2 adds the entry to settings so a user can switch the others on. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…exposedName reuses exposedNameWithPrefix README: SQLite debugger tool names keep the first seven characters of the application ID's last segment (com.example.myapplication gives db_myappli_query), not the whole segment. McpToolText: exposedName repeated the body of exposedNameWithPrefix; it now sanitises the server label and calls it. No behaviour change. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…ls to offer exposedTools read the server list for the app prefixes and again for the tool loop, so an app listed between the two reads had tools but no prefix and getValue threw. It now reads the list once and uses that snapshot for both. Test: a source whose second read of the list differs; the listing now reads once. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA
left a comment
There was a problem hiding this comment.
No new findings: CRITICAL, IMPORTANT, MINOR, NITPICK - none.
Merge-blocking: nothing from this review. Still open, from the PR's own text: the merge precondition (CodeOnTheGo #2259-#2261 merged; a plugin-api-latest release and a Code on the Go release carrying DebuggerEndpointService; libs/ refreshed with Update libs; plugin.min_ide_version rechecked against the real release number) and the device check that repo CLAUDE.md (Verification) asks for.
Round at 7122208 (previous round's head d102bfe), effort medium, focused on 96b49e3, eb97b3a and 7122208. Not stacked (base main). Rules read at head: CLAUDE.md, plugins/README.md, plugins/AI-Agent-MCP/README.md; the plugin-review skill was read for criteria only, not scored. This repo has no written approve/request-changes rule, so the pr-review default applied. The computed verdict is APPROVE (no findings). It is submitted as COMMENT because the PR is self-authored and this run is non-interactive.
Re-check of the 14 earlier threads (judged on the code at head, not the replies). All are fixed:
- AndroidManifest.xml (26.43 floor): fixed,
plugin.min_ide_versionis 26.47 andplugins/README.mdexplains why. Whether 26.47 really ships the service is the PR's precondition 4. - McpPlugin.kt (no isActive around the first endpoint read): fixed,
startDebuggerEntrycheckskeepGoingbefore and after the read and after adding the listener. - McpConnections.kt (token for a replaced endpoint's session): fixed,
credentialsForreleases the token only while the entry's URL is the session's. - McpPlugin.kt (refresh restoring entries after
install(null)): fixed,AutomaticServers.refreshstores nothing unlesssource === read(line 143). - McpPlugin.kt (stacked KDoc): fixed, it now sits on
installDebuggerEndpoints. - AutomaticServers.kt (same prefix for every app): fixed,
McpToolText.appPrefixesgives each app its own prefix. - McpToolSource.kt (cancel between retry attempts): fixed,
cancelledis checked inside the retry block before a session is opened. - AutomaticServers.kt (
@param keepGoingon the wrong overload): fixed. - McpPlugin.kt (duplicate
settingsChanged): fixed, removed fromprobeHealthafter refresh. - AutomaticServers.kt (two apps overflow AI-Core's budget): fixed for the case raised. Two apps now use 8 of 12. A third or fourth app, a hand-added server with many tools switched on, or compact mode still crowds some out, and the
ReadOnlyTrustKDoc and README now say so. - README.md (seven-character prefix): fixed, at lines 62-65.
- README.md (merge-note line numbers): fixed. The PR description's numbers match the head (README 47 and 83-85, html 73 and 140, ReadOnlyTrust.kt 11, McpToolSource.kt 295).
- McpToolSource.kt (
getValuecould throw): fixed,exposedToolsreadsMcpServers.all()once. - McpToolText.kt (duplicate sanitising): fixed,
exposedNamecallsexposedNameWithPrefix.
What checked out:
- 96b49e3: the
CORE_TOOLSnames match the toolsDatabaseTools.tools()defines in CodeOnTheGo (subprojects/sqlite-debugger, stack tip acab92691).enabledToolsstill requiresreadOnlyHinttrue. Only enabled tools are listed, soisReadOnly(and so a possible "Always Allow" once #167 lands) reaches those four only. The budget numbers (12, and 4 in compact mode) matchPromptToolBudgetonmain. - Stored state: an automatic entry is rebuilt from memory on every
servers()call and never reachesMcpServerStore.setKnownToolsruns only for servers that are not automatic, and the store writes explicit fields,automaticnot among them. So a user of an earlier build has nothing stored to migrate, and the entry starts with the four on the new build. The read and write paths for a hand-added server'sknownToolsandenabledToolsare untouched. Its exposed names are the same for every input:exposedNamepasses the same sanitised prefix toexposedNameWithPrefix. - 7122208:
AutomaticServers.servers()reads its volatile map once, so every automatic server in the loop has a prefix.resolve()goes through the sameexposedTools(), so listing and invoking agree. - eb97b3a: the README examples match
appPrefixes(db_plus seven characters; when two apps share that, five characters,_and four hex digits, withoutdb_).
Leads considered and not posted:
- Overlapping refreshes storing an older port: it heals itself, because the next call's ConnectException runs
EndpointRetry. recordToolsnotifying beforetoolsByServeris written: every connect path notifies again afterwards (relistAutomatic,probeHealth, activation).- A cancel racing the worker's
finallyleaves an id incancelled: AI-Core gives each call a fresh UUID, so the id never comes back. - A stale
McpServerclosing the live session:close()sends the DELETE but does not abort a request in flight, and the window is one relaunch. - Duplicate handshakes after a relaunch: cost only.
RepeatedFailureLognever resets: logging only.- A fallback prefix equal to another app's plain prefix: it needs a segment equal to four particular hex digits, and
disambiguatekeeps both callable. - Tools cached again for an entry just removed: never listed, and overwritten when the entry returns.
EndpointRetry's three lookups: a simplification, not a defect.getToolGroupsreading the server list apart fromexposedTools: a group can show no tools for one rebuild.
Not verified: no build and no device in this round.
… on the Go A plugin-api that does not match the host's fails with an Error (AbstractMethodError, NoSuchMethodError, another LinkageError), not an Exception. AutomaticServers.refresh caught only Exception around its read of DebuggerEndpointService.endpoints, so such an Error escaped the activation coroutine. Its scope (SupervisorJob + Dispatchers.IO) had no handler, so the Error reached Android's uncaught-exception handler and took down the IDE, whose process the plugin runs in. - refresh catches Throwable around the read, rethrows CancellationException, reports the failure through the existing RepeatedFailureLog (in full once, briefly after that) and keeps the previous entries. - McpToolCatalog.refreshAll does the same around connect, which calls the host's KeystoreSecretStore and ServerUrl: one server's Error now costs only that server, as an Exception already did. - settingsChanged guards notifyToolsChanged against Throwable, like healthChanged already guards notifyToolSourceStatusChanged: the registry is AI Core's, built against its own plugin-api. - The activation scope gets a CoroutineExceptionHandler as a backstop, logging through android.util.Log, so anything still unforeseen stops at this plugin's log. Tests: a source that throws AbstractMethodError keeps the entries unchanged and refresh returns false; startDebuggerEntry, the health probe and refreshAll survive an AbstractMethodError from the debugger service, the registry and the Keystore; an Error thrown in a coroutine of the plugin's scope never reaches the default uncaught-exception handler. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
… that start on The plugin tooltip still said every tool stays off until the user turns it on. Since 96b49e3 the automatic SQLite debugger entry turns four tools on by default (ReadOnlyTrust.CORE_TOOLS), as the README and the gallery page say. The tooltip, the in-IDE help page and the gallery card (addon.json) now say so too, and that the entry is not on the MCP servers screen in this version. "Asks for your approval every time" stays: AI-Core still asks on every call of a contributed tool until #167 lands. The merge note on #166 lists these lines for whichever of the two lands second. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…wer one AutomaticServers.refresh reads the host outside its lock and, before storing, checked only that the source was still installed. The probe's refresh and a failing call's EndpointRetry can overlap, so the read that started first could finish last and put back the endpoint the other had already replaced. The next failing call healed it through EndpointRetry, at the cost of one refused call. Each read now takes a number under the lock as it starts, and a read whose number is lower than the one already stored is dropped. Test: two interleaved refreshes, the older read released only after the newer one stored; the newer endpoint stays. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…rk.access The manifest has declared network.access,debugger.endpoints since 816e8cc, but the README, the gallery page (twice), the in-IDE help page and McpPlugin's class KDoc still said the plugin declares network.access and nothing else. Each now names both permissions and says what debugger.endpoints is for: reading the SQLite debugger endpoints Code on the Go stores. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
… IDE's handler again 57477d2 widened the catches around host calls from Exception to Throwable so that a LinkageError from a mismatched plugin-api would not crash Code on the Go. Throwable also takes in VirtualMachineError (OutOfMemoryError, StackOverflowError) and ThreadDeath. An OutOfMemoryError in the endpoint read was then logged every 20 s as a failed read, and the coroutine backstop swallowed one from any coroutine of the plugin instead of letting the IDE's handler see it. - AutomaticServers.refresh and McpToolCatalog.refreshAll catch Exception and LinkageError only, still rethrowing CancellationException first. - The backstop rethrows a VirtualMachineError or a ThreadDeath. The coroutine machinery passes a failure its handler rethrows, unwrapped, to the thread's uncaught-exception handler. Anything else is logged as before. - The other guards on paths that reach the host follow the same rule: McpPlugin's registry and service calls (settingsChanged, healthChanged, installDebuggerEndpoints, register/unregisterToolSource, resolveToolSourceRegistry), the connect calls of the probe and the relist, dispose's listener removal, the listener loops of McpServerStore, McpServerHealth and AutomaticServers (their listeners tell the host), and McpSession.close and McpConnections' closes (the DELETE reads the Keystore). runCatchingRecoverable is runCatching with that rule. - McpToolSource.runTool keeps Throwable, with a comment: it runs inside CompletableFuture.supplyAsync, which catches every Throwable itself, so narrowing it would only hand AI Core an exceptional future instead of a failure outcome. Tests: a read that throws OutOfMemoryError makes refresh throw it; an OutOfMemoryError escaping a coroutine of the plugin's scope reaches the default uncaught-exception handler; each other narrowed guard lets an OutOfMemoryError from its host call or listener through. The five linkage-error tests still pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
… without the service Code on the Go 26.47 was released on 2026-11-17 without DebuggerEndpointService or the debugger.endpoints permission: the CoGo stack that adds them (#2259 to #2261) is not merged yet. So the first release that can ship them is 26.48. plugin.min_ide_version, its manifest comment, the plugin README and plugins/README.md now say 26.48 or later. 26.48 is still a guess, valid only if the stack merges before that release is cut. The manifest and both READMEs say to recheck it against the real release number before merging. The plugin manager only displays min_ide_version and checks it is not blank; it never compares it with the running version, so a debug build of Code on the Go still loads the plugin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…es the caller 21944cf narrowed the listener loops of McpServerStore, McpServerHealth and AutomaticServers.fireChanged to runCatchingRecoverable, but missed the endpoint-listener loop in AutomaticServers.refresh, which kept a bare runCatching. McpPlugin's relist listener is the one registered there; an OutOfMemoryError or a StackOverflowError raised while it ran was swallowed, not passed on to the IDE's uncaught-exception handler. The loop now uses runCatchingRecoverable, like fireChanged in the same file: an Exception or a LinkageError still costs only that listener's call, and any other Error propagates to refresh's caller. The KDoc of addEndpointListener and refresh says so. The other bare runCatching calls stay, since none of them calls host code or a listener that does: - McpSession.cancel (McpSession.kt:194): HttpURLConnection.disconnect. - McpToolSource.cancel (McpToolSource.kt:133): McpSession.cancel above. - McpTranscriptDialog.copy (McpTranscriptDialog.kt:70): the platform ClipboardManager. - McpHttpClient.kt:118 drains a 202 body from the platform connection; :144 calls McpExchangeListener, whose only implementations are this plugin's own McpExchangeLog and NONE. - McpRedactor.kt:56 (URLDecoder) and McpLogFormat.kt:56 (org.json): JDK and platform parsing. Tests: an endpoint listener that throws OutOfMemoryError makes refresh throw it (with the bare runCatching: "expected java.lang.OutOfMemoryError to be thrown, but nothing was thrown"); one that throws AbstractMethodError costs only its own call, and the next listener still hears the relaunch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
… cannot remove its listener deactivate() called context.removePluginLifecycleListener first, inside a try that catches Exception only. A host whose plugin-api differs from this plugin's answers that call with a LinkageError (AbstractMethodError, NoSuchMethodError), which skipped every later step: the activation's scope kept running, its probe kept refreshing every 20 s, and the sessions, the tool catalogue and the automatic entries were never released. An Exception from the same call skipped them too, ending in the catch's "deactivation failed". The removal now goes through runCatchingRecoverable, as dispose()'s already does, and a failure is logged as a warning. The rest of the deactivation runs either way. Any other Error, an OutOfMemoryError above all, still propagates. Test: with removePluginLifecycleListener throwing AbstractMethodError, deactivate stops the activation's scope, clears the automatic entries and the cached tools, and lets nothing escape. Without the fix it fails with "the activation's scope must be stopped". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
ADFA-7139
AI-Agent-MCP connects to the SQLite debugger of the open project's app with nothing typed in, using the endpoint Code on the Go stores (Code on the Go side: appdevforall/CodeOnTheGo#2261, stacked on #2260 and #2259).
What it does
DebuggerEndpointService(http://127.0.0.1:<port>/mcp, token in memory only, never in the Keystore, not in the settings screen in this version). The endpoint is re-read before reconnecting after a refused connection, 401 or 403, so a relaunched app is picked up; its tools stay offered across the relaunch. Each endpoint read takes a ticket, so when reads overlap the newest wins: an older read never stores over a newer one. No endpoint: no entry, no error.LinkageErrorfrom a host call, such asAbstractMethodErrorfrom a plugin-api mismatch, or anException, is caught and logged, the entries are kept, and Code on the Go keeps running. Host calls catchLinkageErrorandException, notThrowable, so anOutOfMemoryErroris not logged away as a failed read. Guarded:AutomaticServers.refresh();McpToolCatalog.refreshAllaroundconnect(the host's Keystore andServerUrl);settingsChangedaroundnotifyToolsChanged; and, through a newrunCatchingRecoverablehelper (runCatchingwith that rule), McpPlugin's other registry and service calls, the probe's and relist's connects, the listener loops and the session closes. ACoroutineExceptionHandleronnewScope()is the backstop; it passes aVirtualMachineError(out of memory, stack overflow) or aThreadDeathon to the IDE's handler and logs anything else, so anOutOfMemoryErrororStackOverflowErrorin a host read crashes Code on the Go by design rather than leaving the plugin half-working.deactivate()removes its lifecycle listener throughrunCatchingRecoverabletoo, so aLinkageErrororExceptionfrom that call no longer skips stopping the scope and releasing the connections.McpToolSource.runToolkeepsThrowable, sinceCompletableFuture.supplyAsynccatches everyThrowableitself.list_databases,get_schema,queryandget_events, and only if theirreadOnlyHintis exactlytrue. The server's other tools (list_connections,explain_query_plan,get_stats,integrity_check) are known but start off, because AI-Core describes at most 12 contributed tools per message (4 in compact mode) and hand-added servers' tools come first. Phase 2 adds the entry to settings, so the others can be switched on. Hand-added servers are unchanged, even when they claim the hint.db_plus the first 7 characters of the application ID's last segment (com.example.notesgivesdb_notes_query), with a short digest when two apps would clash, and each description starts with the application ID.debugger.endpoints;plugin.min_ide_version26.48: Code on the Go 26.47 and older reject a plugin that declares an unknown permission (PluginSecurityManager.validatePermissions), and 26.43-26.47 are already released without the API (26.47 shipped on 2026-11-17 withoutDebuggerEndpointService). 26.48 holds only if the CoGo stack merges before that release is cut: recheck it against the real release number before merging. The README and plugins/README say "26.48 or later".libs/plugin-api.jarrefreshed from Code on the Gosqlite-debugger/ADFA-7139.Known: AI-Core asks for approval on every call of a contributed tool (
ContributedToolHandler), so these tools still prompt; the README, the tooltip, the in-IDE help and comments say so. Automatic approval: ADFA-7147. Showing the entry in settings: phase 2.Tests: no endpoint; stale endpoint (refused, 401, 403; no retry when nothing changed; no retry of a timeout); relaunch through a fake MCP server; the annotation rule (true, false, missing, "true", 1, null); a hand-added server claiming the hint stays off; failed reads keep the previous entries; seven linkage-error tests (an
AbstractMethodErrorfrom the endpoint read keeps the entries; one from an endpoint listener costs only that listener's call; a listener removal that throws one still stops the scope and releases the connections; the activation, the health probe andrefreshAllsurvive one fromDebuggerEndpointService, the registry and the Keystore; anErrorescaping a coroutine stops at the backstop, not at the IDE's handler); two interleaved endpoint reads, where the newer one stays; 16 tests that anOutOfMemoryErroris not swallowed (a read that throws one makesrefreshthrow it, one from an endpoint listener reaches the caller, one escaping a coroutine of the plugin's scope reaches the default uncaught-exception handler, and each other narrowed guard lets one from its host call or listener through).testDebugUnitTest: 220 unit tests pass at f95d21e;assemblePluginand the addons check pass.Merge precondition: do not merge until (1) CodeOnTheGo #2259, #2260 and #2261 are merged; (2) a
plugin-api-latestrelease and a Code on the Go release (expected 26.48, since 26.47 shipped without them; recheck against the real release number) carryDebuggerEndpointServiceanddebugger.endpoints; (3)libs/is refreshed from that release with Update libs (this branch's jar is built from the unmerged CoGo branch, so Publish addons would replace it with one lacking the API); (4)plugin.min_ide_versionis rechecked against the actual release number.Merge note: #167 (ADFA-7147 step 1) lets AI-Core offer "Always Allow" for read-only contributed tools. Whichever of #167 and this PR lands second must update the text here that says these tools ask on every call and never get "always allow":
README.md(lines 48-50 and 84-86),ai-agent-mcp.html(74-75, 142, 162-164),src/main/assets/docs/index.html(90-92, Approval), the tooltip inplugin/McpPlugin.kt(538-539), and the comments indebugger/ReadOnlyTrust.kt(9-11) andtools/McpToolSource.kt(297-299), at f95d21e.Device check: an earlier head of this PR was exercised on a Galaxy Note 20 (Android 13) against a CI build of the CoGo stack: every SQLite debugger MCP tool answered through it, and the Agent answered a database question through the automatic entry, with 3 approval taps. Not verified on a device: the current head, with the four-core-tool default and the
db_<7 chars>tool names.No layouts changed. Screen text did: the plugin tooltip, the in-IDE help (
assets/docs/index.html) and the gallery card (addon.json) now say four read-only tools of the SQLite debugger entry start on, and the docs namedebugger.endpointsbesidenetwork.access.🤖 Generated with Claude Code
https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn