Skip to content

feat(agent-mcp): in-app Streamable HTTP MCP server + FTP asset server - #1490

Open
sankarru wants to merge 5 commits into
tyron12233:mainfrom
sankarru:feat/mcp-http-ftp
Open

feat(agent-mcp): in-app Streamable HTTP MCP server + FTP asset server#1490
sankarru wants to merge 5 commits into
tyron12233:mainfrom
sankarru:feat/mcp-http-ftp

Conversation

@sankarru

@sankarru sankarru commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

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

  • agent-mcp
    • HttpMcpServer — Streamable HTTP (request-response) transport for the MCP server
    • FtpServer — anonymous local FTP asset server rooted at <project>/assets, plus FTP protocol deadlock fix
    • CodeAssistMcpServer.startHttpServer/startFtpServer — the same code path the IDE uses
    • CLI: --http [port] (default 8765) and --ftp [port] flags for the standalone binary
    • tests: HttpMcpServerTest, FtpServerTest (round-trip), CodeAssistMcpServerTest update
  • ide-core: AgentBackend hosts the in-app HTTP/FTP servers; ftpControlTool registered before tools-registry init; AgentPlugin wiring
  • ide-ui: FtpServerToggleRow / PillToggle More-menu toggle, BackendServices plumbing, strings.xml entries

Default behavior is unchanged (stdio, mutating tools denied unless --auto-accept).

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant