Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified libs/plugin-api.jar
Binary file not shown.
31 changes: 28 additions & 3 deletions plugins/AI-Agent-MCP/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ Configuration → MCP servers**:
1. **Add server** — name, endpoint URL, optional token.
2. **Connect** — saves the server, performs the MCP handshake and lists the tools
it offers, all in one step.
3. Switch on the tools you want. **They start off**: one popular GitHub server
3. Switch on the tools you want. **They start off** (except the read-only tools
of the automatic debugger entry, below): one popular GitHub server
advertises around ninety tools, which would fill a phone-sized context window
on its own.
4. **Clear stored credential** — removes the stored token and headers. The token
Expand All @@ -47,6 +48,26 @@ Every remote tool asks for approval on every call, and there is no "always
allow" for contributed tools — they run outside the Agent's own path
containment, so the dialog is the only gate.

### The SQLite debugger entry

For an app built in Code on the Go with `cogo.sqliteDebugger=true`, the plugin
adds a server entry on its own, named "SQLite debugger (<application ID>)", with
no URL or token to type. Code on the Go stores the port and token the running
debug app reports; the plugin reads them through the `DebuggerEndpointService`
(permission `debugger.endpoints`, so it needs Code on the Go 26.47 or later) and
points the entry at `http://127.0.0.1:<port>/mcp`. A relaunched app gets a new
port and token, and the plugin reads them again after a refused connection. An
app that has not reported yet has no entry, and no error is shown.

- It is held in memory only and is **not shown in the settings screen in this
version**, so there is no switch to turn it off there.
- The tools that declare MCP's `readOnlyHint: true` start switched **on**. Any
other tool of that entry starts off. The hint is trusted for this entry only,
never for a server you add yourself.
- The Agent still asks for approval on every call: AI-Core makes every
contributed tool ask (it ignores the tool's own `requiresApproval`). Approving
read-only calls automatically is tracked in ADFA-7147.

## Transport

MCP's **Streamable HTTP** transport over `HttpURLConnection`:
Expand Down Expand Up @@ -105,10 +126,14 @@ Two dependencies were deliberately not taken:
- `http://` is accepted only for a server on this device (`localhost`, `127.0.0.0/8`,
`[::1]`), with or without credentials; any other host needs `https://`, since its
traffic would cross a network in the clear. The check is `McpUrlPolicy`, built on
the host's `ServerUrl` (plugin-api **26.42**, hence this plugin's
`min_ide_version`), and judges the URL as typed with no DNS lookup. Save refuses
the host's `ServerUrl` (plugin-api 26.42), and judges the URL as typed with no DNS lookup. Save refuses
such a URL, and the transport refuses it again, so a server saved before the rule
is listed with a warning and never contacted until it is switched to `https://`.
- The plugin declares the `debugger.endpoints` permission, to offer the SQLite debugger of the
open project's app without typing a port or token. Code on the Go 26.46 and older reject a
manifest that names a permission they do not know (`PluginSecurityManager.validatePlugin`), so this
version needs **26.47 or newer**, the first release that ships `DebuggerEndpointService`
(`plugin.min_ide_version`); users on 26.46 or older cannot install it.
- Redirects are never followed automatically. A 3xx is repeated only when it
resolves to the same origin, so the bearer token and the user's own headers
cannot be replayed to another host in one hop.
Expand Down
3 changes: 2 additions & 1 deletion plugins/AI-Agent-MCP/ai-agent-mcp.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ <h2>Usage</h2>
</ol>
<div class="note">
New tools always arrive switched <b>off</b>, including on the connection
that discovers them. Nothing a server adds later becomes visible to the model
that discovers them. The one exception is the read-only tools of the SQLite
debugger entry that Code on the Go supplies for your own debug app. Nothing a server adds later becomes visible to the model
without your say-so.
</div>

Expand Down
22 changes: 14 additions & 8 deletions plugins/AI-Agent-MCP/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,29 @@
android:name="plugin.author"
android:value="App Dev for All" />

<!-- 26.42: the first release whose plugin-api carries ServerUrl, which McpUrlPolicy
uses to allow http:// only to this device (ADFA-6314). 26.41 brought the
capability-tag contract (ADFA-6278). Do not lower it. -->
<!-- 26.47: the first release that knows the debugger.endpoints permission and carries
DebuggerEndpointService (ADFA-7139); 26.46 and older have neither. Their
PluginSecurityManager.validatePlugin rejects a manifest that names a permission it
does not know, so those IDEs cannot install this plugin version at all. Raise this if
the release that ships ADFA-7139 is not 26.47. 26.43 made plugin-api interface bodies
Java default methods, which the bundled plugin-api.jar relies on; 26.42 brought
ServerUrl, which McpUrlPolicy uses to allow http:// only to this device (ADFA-6314);
26.41 the capability-tag contract (ADFA-6278). Do not lower it. -->
<meta-data
android:name="plugin.min_ide_version"
android:value="26.42" />
android:value="26.47" />

<meta-data
android:name="plugin.max_ide_version"
android:value="26.99" />

<!-- network.access and nothing else: this plugin only speaks HTTP to the servers the user
configured. It never touches the filesystem, the project or the shell — which is the
whole reason MCP lives here instead of inside ai-core. -->
<!-- network.access: this plugin only speaks HTTP to the servers the user configured, plus the
debugger of the open project's app. debugger.endpoints: asks Code on the Go for that
app's port and token (ADFA-7139). It never touches the filesystem, the project or the
shell — which is the whole reason MCP lives here instead of inside ai-core. -->
<meta-data
android:name="plugin.permissions"
android:value="network.access" />
android:value="network.access,debugger.endpoints" />

<meta-data
android:name="plugin.main_class"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.itsaky.androidide.plugins.aiagentmcp.client

import android.util.Log
import com.itsaky.androidide.plugins.aiagentmcp.debugger.AutomaticServers
import com.itsaky.androidide.plugins.aiagentmcp.logging.LOG_PREFIX
import com.itsaky.androidide.plugins.aiagentmcp.security.UnavailableSecretException
import com.itsaky.androidide.plugins.aiagentmcp.security.UnreadableSecretException
Expand Down Expand Up @@ -58,7 +59,7 @@ object McpConnections {
stale = current?.second
// A supplier, not the values: the session is kept for the life of the process, and a
// token in one of its fields would be readable in a heap dump for just as long.
McpSession(server.url, { credentialsFor(server.id) })
McpSession(server.url, { credentialsFor(server.id, server.url) })
.also { sessions[server.id] = key to it }
}

Expand Down Expand Up @@ -87,13 +88,22 @@ object McpConnections {
* does not register, and it is what keeps the plaintext from outliving the request.
*
* @param serverId the server being called.
* @param url the url the calling session was built for. An automatic entry's token is released
* only while the entry still points there; a session for a replaced endpoint gets none, so
* its `close()` and any call still in flight cannot hand the new process's token to the old port.
* @return its token and headers; either may be empty.
* @throws UnreadableSecretException when a stored credential cannot be decrypted here. Sending
* the request without it would earn a 401 and tell the user their token was refused.
* @throws UnavailableSecretException when the keystore could not be reached to decrypt one, a
* failure to retry rather than to report as a lost credential.
*/
private fun credentialsFor(serverId: String): McpCredentials {
private fun credentialsFor(serverId: String, url: String): McpCredentials {
if (AutomaticServers.isAutomatic(serverId)) {
// Read per request, so a token refreshed on the same port is used without a new session.
val endpoint = AutomaticServers.endpoint(serverId)
val token = if (endpoint != null && AutomaticServers.urlFor(endpoint) == url) endpoint.token else ""
return McpCredentials(token, emptyMap())
}
val token = when (val stored = McpServerStore.token(serverId)) {
// Trimmed here, not by the store: the host's readAndMigrate migrates verbatim, and a
// legacy token saved with a stray newline is one `setRequestProperty` refuses to send.
Expand Down Expand Up @@ -123,7 +133,7 @@ object McpConnections {
private fun keyFor(server: McpServer): Key {
// Headers join the key for the same reason the token does: edit one and the old session
// would keep sending the old value until the IDE restarts.
val credentials = credentialsFor(server.id)
val credentials = credentialsFor(server.id, server.url)
return Key(
serverId = server.id,
url = server.url,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.itsaky.androidide.plugins.aiagentmcp.client

import android.util.Log
import com.itsaky.androidide.plugins.aiagentmcp.debugger.ReadOnlyTrust
import com.itsaky.androidide.plugins.aiagentmcp.logging.LOG_PREFIX
import com.itsaky.androidide.plugins.aiagentmcp.transport.JsonRpc
import com.itsaky.androidide.plugins.aiagentmcp.transport.McpExchangeListener
Expand Down Expand Up @@ -314,6 +315,9 @@ class McpSession(
name = name,
description = entry.optString("description"),
inputSchema = entry.optJSONObject("inputSchema")?.let(::toMap).orEmpty(),
readOnlyHint = ReadOnlyTrust.isReadOnlyHint(
entry.optJSONObject("annotations")?.opt("readOnlyHint")
),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ package com.itsaky.androidide.plugins.aiagentmcp.client
* @property name the tool's own name, unique within its server.
* @property description what it does, as the server describes it — untrusted remote text.
* @property inputSchema JSON Schema for the arguments, empty when the server sends none.
* @property readOnlyHint whether `annotations.readOnlyHint` was exactly boolean true. A claim by
* the server: only the automatic debugger entry acts on it.
*/
data class McpTool(
val name: String,
val description: String,
val inputSchema: Map<String, Any> = emptyMap(),
val readOnlyHint: Boolean = false,
)

/**
Expand Down
Loading
Loading