Gemini Code Assist 'agent' mode without `npx mcp-remote` (1/3)
- 5 minutes read - 875 wordsFormer Microsoftie and Googler:
Good documentation Extend your agent with Model Context Protocol
Not such good documentation: Using agentic chat as a pair programmer
Definition of “good” being, I was able to follow the clear instructions and it worked first time. Well done, Microsoft!
This space is moving so quickly and I’m happy to alpha test these companies’ solutions but (a) Google’s portfolio is a mess. This week I’ve tried (and failed) to use Gemini CLI (because I don’t want to run Node.JS on my host machine and it doesn’t work in a container: issue #1437) and now this.
I’ll document my current status and let’s see what happens next.
I’m able to use Copilot (not my preference) to interact with a local, debugging MCP server for Ackal and a remote MCP server for Prometheus. So, I know, it should work.
I find it… weird that, for both Copilot (Chat) and Gemini (my preference) Code Assist Chat, I have to toggle them into Agent mode to use the MCP functionality. Why is that? It makes no sense.
Aside: I’m still not entirely sure which tool is providing code assist. I’m using the heuristic that Copilot puts a TAB completion prompt on the code’s line numbers whereas Gemini revises the code on screen and I can accept with a TAB. I’d prefer something akin to Google Docs whereas the “pair” programmer is identified by a name block appearing above the code.
I followed Google’s instructions and have Gemini Code Assist Chat and toggled it into Agent mode (an image would be useful in the documentation). The documentation explains the need for ~/.gemini/settings.json
but doesn’t explain the schema of the file.
It turns out (!?) that it must:
- run an stdio to HTTP proxy for HTTP-based MCP servers. I remain unsure whether it only supports Server-side Events (SSE) or streaming HTTP because I’ve been unable to get this to work beyond this point;
- what’s shown in the docs requires Node.JS installed plus
npx
plus a plugin calledmcp-remote
.
I faffed around with this for a while before solving the problem (thanks Claude) with some Rust code to replace the Node code with a nice standalone binary.
Cargo.toml
:
[package]
name = "mcp-remote"
version = "0.0.1"
edition = "2024"
[dependencies]
reqwest = { version = "0.11", features = ["json", "rustls-tls"], default-features = false }
tokio = { version = "1", features = ["full"] }
main.rs
:
use std::env;
use std::io::{self, BufRead, BufReader};
use reqwest;
use tokio;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
eprintln!("Usage: {} <remote-mcp-url> [--insecure]", args[0]);
std::process::exit(1);
}
let remote_url = &args[1];
let insecure = args.len() > 2 && args[2] == "--insecure";
let client = reqwest::Client::builder()
.danger_accept_invalid_certs(insecure)
.build()?;
let stdin = io::stdin();
let reader = BufReader::new(stdin.lock());
for line in reader.lines() {
let line = line?;
println!("{}", line);
// Forward the JSON-RPC message to the remote server
let response = client
.post(remote_url)
.header("Content-Type", "application/json")
.body(line)
.send()
.await?;
let body = response.text().await?;
println!("{}", body);
}
Ok(())
}
And:
~/.gemini/settings.json
:
{
"mcpServers": {
"my-server": {
"command": "/path/to/mcp-remote",
"args": ["http://localhost:7777/mcp","--insecure"]
}
}
}
> NOTE I’m unsure whether the path (/mcp
) is expected.
I know that this solution (basically) works because I run it directly and interact with the MCP server:
path/to/mcp-remote \
http://localhost:7777/mcp \
--insecure \
| jq -r .
And print:
{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}
And receive:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"tools": [
{
...
},
...
]
}
}
But, I’m unable to get Gemini to interact with it:
And the OUTPUT
from Gemini Code Assist Agent
is:
[INFO] 2025-06-26 11:59:12.426 AM -- [Config] GOOGLE_CLOUD_PROJECT: undefined
failed to start or connect to MCP server 'ackal-mcp-server' {"command":"/path/to/mcp-remote"};
McpError: MCP error -32001: Request timed out
Okay…. so some debugging progress…
I’m using the both excellent mark3labs mcp-go
module and Redpanda protoc-gen-go-mcp
protoc
plugin to generate an MCP server stub.
The MCP server can be configured WithHTTPContextFunc
that functions as an interceptor on all incoming requests.
I realized that the Gemini agent is making requests through the proxy that reach my MCP server. One problem is that these are ’empty’ requests and I’m unsure what the client’s expecting back:
Key | Value | Description |
---|---|---|
Method | POST |
|
URL | /mcp |
That’s useful |
Header | Content-Type=application/json |
|
Accept=*/* |
||
Content-Length=170 |
||
Body | Empty | |
Host | localhost:7777 |
IIUC the server is returning a 200
(Success) but that’s all (as it’s not being asked to do anything by the client). For some reason (what I don’t understand), the client is continuing to wait and for a different response.
Is it perhaps the proxy that’s at fault?
I added some extra flags to VS Code’s settings.json
:
"geminicodeassist.agentDebugMode": true
"geminicodeassist.verboseLogging": true
The OUTPUT
log includes an encapsulated JSON message:
{
"console_type": "GEMINI_CLI",
"application": 102,
"event_name": "start_session",
"client_install_id": "[REDACTED]",
"event_metadata": [
[
{
"gemini_cli_key": 1,
"value": "gemini-2.5-pro"
},
{
"gemini_cli_key": 2,
"value": "gemini-embedding-001"
},
{
"gemini_cli_key": 3,
"value": "false"
},
{
"gemini_cli_key": 4,
"value": ""
},
{
"gemini_cli_key": 5,
"value": "default"
},
{
"gemini_cli_key": 6,
"value": "false"
},
{
"gemini_cli_key": 7,
"value": "false"
},
{
"gemini_cli_key": 8,
"value": "true"
},
{
"gemini_cli_key": 7,
"value": "false"
},
{
"gemini_cli_key": 9,
"value": "ackal-mcp-server"
},
{
"gemini_cli_key": 7,
"value": "false"
},
{
"gemini_cli_key": 10,
"value": "false"
},
{
"gemini_cli_key": 11,
"value": "true"
}
]
]
}
Flummoxed :-(