Add HTTP (streamable) transport to MCP client + inline MCP tool rendering - #180
Merged
Conversation
The incremental-input delta (previous_response_id + delta items) was computed before ensure_connection() ran. When the server had closed the socket in the meantime, ensure_connection() correctly dropped the stale connection and cleared the delta state - but the request had already been built against the dead connection's response id, which the fresh connection does not know (store: false keeps response state only for the lifetime of one connection). The server then rejected the request with 400 previous_response_not_found. Ensure the connection is live before computing the delta, so a reconnect automatically falls back to sending the full transcript.
Extend MCP client mode with an HTTP streamable transport alongside stdio.
McpServerConfig now carries a typed, untagged McpTransport enum: an object
with a "url" is HTTP (with optional "headers"), one with a "command" is
stdio -- so existing mcp-servers.json files stay valid. ${VAR} substitution
now covers HTTP header values as well as stdio env values.
The client builds a reqwest-backed StreamableHttpClientTransport with custom
headers (rmcp feature transport-streamable-http-client-reqwest). Added an
in-process axum HTTP server integration test. The gpui MCP settings section
gains a transport selector (command/args/env vs url/headers).
MCP tools have dynamic mcp__<server>__<tool> names, so no renderer was registered for them and they fell back to a raw "[name]" placeholder. Add a McpToolRenderer (inline style) installed as the registry's MCP fallback (ToolBlockRendererRegistry::resolve). It shows a generic MCP icon, the bare tool name, and the server name as a right-aligned pill via a new ToolBlockRenderer::header_tag() hook. JSON output is pretty-printed and rendered in a monospace font; non-JSON output is shown verbatim.
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.
What
Adds an HTTP (streamable) transport to MCP client mode, alongside the existing stdio transport, and reworks how MCP tool blocks render in the gpui UI.
MCP client — HTTP transport
McpServerConfignow carries a typed,#[serde(untagged)]McpTransportenum. The JSON shape selects the transport:url(plus optionalheaders) → HTTPcommand(plusargs/env) → stdiomcp-servers.jsonfiles stay valid (backward compatible).${VAR}substitution now applies to HTTPheadersvalues as well as stdioenvvalues.StreamableHttpClientTransportwith custom headers (rmcp featuretransport-streamable-http-client-reqwest+reqwest).connect_stdio()/connect_http()are symmetric private helpers behindconnect().Example config:
{ "servers": { "jira": { "command": "npx", "args": ["-y", "some-jira-server"] }, "remote": { "url": "https://example.com/mcp", "headers": { "Authorization": "Bearer ${REMOTE_TOKEN}" } } } }gpui — MCP tool block rendering
Previously MCP tools (dynamic
mcp__<server>__<tool>names) had no registered renderer and fell back to a raw[name]placeholder. Now:McpToolRenderer(inline/lightweight style), installed as the registry's MCP fallback viaToolBlockRendererRegistry::resolve.get_me); the server name (github_tools_sap) shows as a right-aligned pill via a newToolBlockRenderer::header_tag()hook.Tests
${VAR}substitution for both transports.connects_and_calls_over_http) exercising the full HTTP path: connect,tools/list,tools/call.pretty_json/parse_mcp_nameunit tests.cargo fmt,clippy -D warnings, and the touched crates' tests are green; validated end-to-end against a real HTTP MCP server.Note
This branch also contains the pre-existing, unrelated commit
26875a47("Fix previous_response_not_found after WebSocket reconnect"), which was already on the branch before this work.