McpToolset hangs silently for ~5 minutes per retry (3 retries) when stdio command is an npm shim ("npx") on Windows
メンテナーはふだん 1 日以内に返信
評価
この issue はまだ評価されていません。
説明
Description
The examples/mcpfilesystem sample — and any McpToolset built with
command("npx") — appears to hang indefinitely on Windows. No error is
printed and no node.exe process is ever spawned; the caller just blocks
inside McpToolset.getTools().
After digging into it, the "hang" is actually a very slow failure loop:
each initialization attempt waits out the full default
initializationTimeout (5 minutes), and the sync retry logic re-runs the
same doomed initialization, so the program stays silent for a measured
900 seconds (~15 minutes: 3 attempts x 5-minute timeout) before a
McpToolLoadingException (wrapped
Client failed to initialize by explicit API call) finally surfaces —
and even that is invisible unless an SLF4J provider is on the classpath,
which the samples don't include by default.
Environment
- OS: Windows 11 Home (10.0.26200)
- JDK: Oracle 21.0.5
- google-adk: 1.13.0
- Maven: 3.9.8
- Node.js: 24.15.0 (npx 11.12.1, standard npm-for-Windows install with
npx.cmdshim)
Root cause
On Windows, npm installs command shims as batch scripts (npx.cmd), not
executables. Java's ProcessBuilder cannot execute a bare npx command
(it is not a PE executable and is not resolved through PATHEXT), so the
stdio subprocess never starts.
A plain new ProcessBuilder("npx", "-v").start() on the same machine
fails immediately with CreateProcess error=2, which confirms the
JVM/OS-level cause. Inside ADK, however, the failure is masked by:
McpSessionManager.initializeSession(...)defaults the
initializationTimeoutto 5 minutes
(core/src/main/java/com/google/adk/tools/mcp/McpSessionManager.java,
theDuration.ofMinutes(5)fallback), soclient.initialize()waits
for a response from a process that never started.- The sync
McpToolset.getTools()retry logic (MAX_RETRIES = 3,
100 ms delay) then re-runs the same doomed initialization. - Without an SLF4J provider (the default for the samples), even the
retry ERROR logs are swallowed, leaving zero output on the console.
Observed log once an SLF4J provider is added (full run, timestamps from
the measured repro):
ERROR com.google.adk.tools.mcp.McpToolset - Unexpected error during tool loading, retry attempt 1
java.lang.RuntimeException: Client failed to initialize by explicit API call
at io.modelcontextprotocol.client.LifecycleInitializer...
ERROR ... retry attempt 2
ERROR ... retry attempt 3
ERROR com.google.adk.tools.mcp.McpToolset - Failed to load tools after multiple retries due to unexpected error.
com.google.adk.tools.mcp.McpToolsetException$McpToolLoadingException
(total elapsed: 900,857 ms)
Minimal reproduction (public API only)
StdioServerParameters params = StdioServerParameters.builder()
.command("npx") // hangs; "npx.cmd" works
.args(ImmutableList.of(
"-y", "@modelcontextprotocol/server-filesystem", "<some-dir>"))
.build();
McpToolset toolset = new McpToolset(params.toServerParameters());
List<BaseTool> tools = toolset.getTools(null).toList().blockingGet();
// blocks: ~5 min per attempt, up to 3 retries, then throws
Observed behavior
| command | result |
|---|---|
npx |
silent block, measured 900 s (~15 min) total, then McpToolLoadingException; no node.exe ever spawned |
npx.cmd |
OK in ~3.5 s, 14 tools loaded |
Workaround
Use the .cmd extension explicitly on Windows:
.command("npx.cmd")
Suggestions
- Add a Windows note to
examples/mcpfilesystem/README.md(lowest
effort, immediate relief for new users). - Optionally, fail fast with a clear error when the configured command
cannot be executed at all (e.g. probe withProcessBuilder.start()
before the 5-minute timeout), or auto-map well-known npm shims
(npx/npm/node) to their.cmdvariants on Windows.
Happy to send a PR for either suggestion. Thanks!
- 主要言語
- Java
- スター
- 1.8k
- フォーク
- 440
- 平均マージ
- 3日 16時間
- マージ済み PR(30日)
- 92
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
google/adk-java のほかの issue
-
InMemorySessionService.appendEvent recreates a deleted session対応中かも @hirematha が 4 日前に担当しました。 オープンneeds review
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
google/adk-java#1697 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Runner drops callbackContextData written in onUserMessageCallback when it resumes an invocation対応中かも @hirematha が 4 日前に担当しました。 オープンneeds review
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
google/adk-java#1695 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
AgentExecutor ignores the A2A contextId when creating a session, so multi-turn conversations start over every turn対応中かも @hirematha が 2 日前に担当しました。 オープンneeds review
google/adk-java#1718 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
runLive passes partial events to appendEvent and never aggregates text chunks, unlike ADK Python対応中かも @hemasekhar-p が 18 日前に担当しました。 オープンneeds review
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
google/adk-java#1648 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
FirestoreSessionService compares event timestamps as text, reordering or skipping same-second events対応中かも @hemasekhar-p が 18 日前に担当しました。 オープンneeds review
難易度 3/5 1〜2日 初心者へのやさしさ 50/100
google/adk-java#1646 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
google/adk-java の issue をすべて見る
似ている issue
-
bug/错误
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
FCL-Team/FoldCraftLauncher#1982 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] micronaut-serde-oracle-jdbc-json brings a second OJDBC driver onto the runtime classpath対応中かも @ZARAYACH が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
micronaut-projects/micronaut-serialization#1494 · コメント 4 件 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
メンテナーはふだん 2 日以内に返信
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
vitruv-tools/Vitruv-Change#600 ·
メンテナーはふだん 1 日以内に返信
-
code-health feature/sync OS/Android QA/Test-Plan-Specified QA/Yes
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
brave/brave-browser#60327 ·
メンテナーはふだん 1 日以内に返信