You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(mcp): add Windows STDIO configuration guidance
Document how to configure MCP STDIO clients on Windows where npx
and other batch files require cmd.exe wrapper. Include cross-platform
programmatic configuration examples and reference implementation.
Copy file name to clipboardExpand all lines: spring-ai-docs/src/main/antora/modules/ROOT/pages/api/mcp/mcp-client-boot-starter-docs.adoc
+126Lines changed: 126 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -181,6 +181,132 @@ The Claude Desktop format looks like this:
181
181
}
182
182
----
183
183
184
+
=== Windows STDIO Configuration
185
+
186
+
IMPORTANT: On Windows, commands like `npx`, `npm`, and `node` are implemented as **batch files** (`.cmd`), not native executables. Java's `ProcessBuilder` cannot execute batch files directly and requires the `cmd.exe /c` wrapper.
187
+
188
+
==== Why Windows Needs Special Handling
189
+
190
+
When Java's `ProcessBuilder` (used internally by `StdioClientTransport`) attempts to spawn a process on Windows, it can only execute:
191
+
192
+
* Native executables (`.exe` files)
193
+
* System commands available to `cmd.exe`
194
+
195
+
Windows batch files like `npx.cmd`, `npm.cmd`, and even `python.cmd` (from the Microsoft Store) require the `cmd.exe` shell to execute them.
196
+
197
+
==== Solution: cmd.exe Wrapper
198
+
199
+
Wrap batch file commands with `cmd.exe /c`:
200
+
201
+
**Windows Configuration:**
202
+
[source,json]
203
+
----
204
+
{
205
+
"mcpServers": {
206
+
"filesystem": {
207
+
"command": "cmd.exe",
208
+
"args": [
209
+
"/c",
210
+
"npx",
211
+
"-y",
212
+
"@modelcontextprotocol/server-filesystem",
213
+
"C:\\Users\\username\\Desktop"
214
+
]
215
+
}
216
+
}
217
+
}
218
+
----
219
+
220
+
**Linux/macOS Configuration:**
221
+
[source,json]
222
+
----
223
+
{
224
+
"mcpServers": {
225
+
"filesystem": {
226
+
"command": "npx",
227
+
"args": [
228
+
"-y",
229
+
"@modelcontextprotocol/server-filesystem",
230
+
"/Users/username/Desktop"
231
+
]
232
+
}
233
+
}
234
+
}
235
+
----
236
+
237
+
==== Cross-Platform Programmatic Configuration
238
+
239
+
For applications that need to work across platforms without separate configuration files, use OS detection in your Spring Boot application:
NOTE: When using programmatic configuration with `@Bean`, add `@ConditionalOnMissingBean(McpSyncClient.class)` to avoid conflicts with auto-configuration from JSON files.
* `python.cmd` - Python (Microsoft Store installation)
301
+
* `pip.cmd` - Python package manager
302
+
* `mvn.cmd` - Maven wrapper
303
+
* `gradle.cmd` - Gradle wrapper
304
+
* Custom `.cmd` or `.bat` scripts
305
+
306
+
==== Reference Implementation
307
+
308
+
See link:https://github.com/spring-projects/spring-ai-examples/tree/main/model-context-protocol/filesystem[Spring AI Examples - Filesystem] for a complete cross-platform MCP client implementation that automatically detects the OS and configures the client appropriately.
309
+
184
310
=== Streamable-HTTP Transport Properties
185
311
186
312
Used for connecting to Streamable-HTTP and Stateless Streamable-HTTP MCP servers.
0 commit comments