Repository navigation
|
The documentation provided to integrate MCP server to an agent is as per version 0.1.0. |
Replies: 3 comments 1 reply
|
check this out @arani87 : As MCP Client : Hope this help. |
|
The links @Ashfaqbs posted above are the right docs, but they don't include a complete Streamable HTTP example, so here is one — with one version warning first. Version warning: this will probably not compile on 0.5.0. import com.google.adk.JsonBaseModel;
import com.google.adk.agents.LlmAgent;
import com.google.adk.tools.mcp.McpToolset;
import com.google.adk.tools.mcp.StreamableHttpServerParameters;
import java.time.Duration;
import java.util.List;
import java.util.Map;
// 1. Describe the remote MCP server (Streamable HTTP transport).
// Defaults: timeout 30s, readTimeout 5min, empty headers, terminateOnClose(true).
StreamableHttpServerParameters remoteParams =
StreamableHttpServerParameters.builder()
.url("https://your-mcp-server.example.com/mcp")
.headers(Map.of("Authorization", "Bearer " + serviceToken))
.timeout(Duration.ofSeconds(10)) // initialization timeout
.readTimeout(Duration.ofSeconds(60)) // per-request timeout
.build();
// 2. Turn the server's tools into an ADK toolset.
// Pass an allowlist of tool names (or a ToolPredicate) — an unfiltered
// toolset exposes whatever the server lists, including tools added later.
McpToolset remoteTools = new McpToolset(
remoteParams,
JsonBaseModel.getMapper(),
List.of("get_invoice", "list_invoices"));
// 3. Give the toolset to the agent like any other tool.
LlmAgent agent = LlmAgent.builder()
.name("billing_assistant")
.model("gemini-2.5-flash")
.instruction("Answer billing questions using the remote MCP tools.")
.tools(remoteTools)
.build();Two things worth knowing before you run it in production:
If you must stay on 0.5.0: use the older SSE transport instead — Docs: https://google.github.io/adk-docs/tools-custom/mcp-tools/ (the page @Ashfaqbs linked above). |
|
Hi @arani87 — just following up on my comment from a couple of days ago, which adds a complete Streamable HTTP MCP example to the docs @Ashfaqbs linked. Did that unblock your setup? If it worked, marking the answer as accepted would help others find it. Happy to clarify if anything is still unclear. |
The links @Ashfaqbs posted above are the right docs, but they don't include a complete Streamable HTTP example, so here is one — with one version warning first.
Version warning: this will probably not compile on 0.5.0.
StreamableHttpServerParameterswas added in March 2026, after 0.5.0 (January 2026). If you stay on 0.5.0, use the SSE fallback at the bottom instead; to use the code below, upgrade to a release that containsStreamableHttpServerParameters.