feat(agent-mcp): in-app Streamable HTTP MCP server + FTP asset server - #1490
Open
sankarru wants to merge 5 commits into
Open
feat(agent-mcp): in-app Streamable HTTP MCP server + FTP asset server#1490sankarru wants to merge 5 commits into
sankarru wants to merge 5 commits into
Conversation
…ote) Adds HttpStreamableServerTransportProvider: a servlet-free Streamable HTTP server (request-response mode, GET 405 fallback) over a raw ServerSocket, plus CodeAssistMcpServer.startHttpServer() reusing the stdio tool wiring. ide-core starts it on port 8765 when the new "MCP server" AI setting is enabled (AllowAllGate behind the explicit opt-in) so opencode can drive the engine workspace remotely via adb forward + a remote MCP server URL. Tests: real SDK HttpClientStreamableHttpTransport handshake, tool calls, multi-session, and raw-wire checks (14 agent-mcp tests total).
Add an optional --http [port] flag to the agent-mcp CLI so the standalone binary can serve Streamable HTTP (request-response mode) instead of stdio. Reuses CodeAssistMcpServer.startHttpServer, the same code path the in-IDE server uses; defaults to port 8765.
- Hand-rolled passive-mode FTP server (PASV/EPSV, STOR/RETR/LIST/NLST/ SIZE/MDTM/MKD/RMD/DELE/CWD/CDUP) rooted at the workspace assets dir, bound to 127.0.0.1 with path-traversal protection. - '--ftp [port]' flag for standalone agent-mcp; default MCP port 8021. - AgentBackend hosts the server (pref settings.ai.ftpServer) and exposes an ftp_server MCP tool (action: start|stop|status). - AgentService.ftpServerSupported/Enabled + UI toggle in the More sheet (FtpServerToggleRow + PillToggle), reflected live in the MCP tool. - Raw-socket FtpServerTest covering STOR->SIZE->RETR->LIST->NLST->MDTM-> MKD/CWD/DELE/RMD round trip and traversal rejection.
- Send the 150 reply before accepting the data connection: clients open
the data socket only after reading 150, so accepting first deadlocked
every STOR/RETR/LIST transfer.
- resolve('') no longer recurses (infinite StackOverflow when listing
the root via 'LIST' with no argument).
- Test client now sends the data command before reading the 150 and
sets 10s socket timeouts so a server regression fails fast instead
of hanging CI.
AgentBackend.tools referenced ftpControlTool, which was declared later in the class body; property initializers cannot forward-reference in Kotlin, so the APK build failed to compile ide-core. Declare the tool first.
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
Extends the MCP server from #1482 (stdio) with an in-app Streamable HTTP transport plus an anonymous local FTP asset server, so the MCP agent can run remotely (e.g. over
adb forward) and consume files uploaded into the workspace.Changes
HttpMcpServer— Streamable HTTP (request-response) transport for the MCP serverFtpServer— anonymous local FTP asset server rooted at<project>/assets, plus FTP protocol deadlock fixCodeAssistMcpServer.startHttpServer/startFtpServer— the same code path the IDE uses--http [port](default 8765) and--ftp [port]flags for the standalone binaryHttpMcpServerTest,FtpServerTest(round-trip),CodeAssistMcpServerTestupdateAgentBackendhosts the in-app HTTP/FTP servers;ftpControlToolregistered before tools-registry init;AgentPluginwiringFtpServerToggleRow/PillToggleMore-menu toggle,BackendServicesplumbing,strings.xmlentriesDefault behavior is unchanged (stdio, mutating tools denied unless
--auto-accept).