StdioMcpClient¶
This docs was updated at: 2026-02-23
com.paragon.mcp.StdioMcpClient ยท Class
Extends McpClient
MCP client that communicates with a subprocess via stdio.
This client launches an MCP server as a subprocess and communicates using stdin/stdout. This is the standard transport for local MCP servers.
Example Usage¶
try (var mcp = StdioMcpClient.builder()
.command("npx", "-y", "@modelcontextprotocol/server-filesystem", "/tmp")
.build()) {
mcp.connect();
Agent agent = Agent.builder()
.name("FileAssistant")
.tools(mcp.asTools())
.build();
var result = agent.interact("List files in the directory");
}
See Also
McpClient
Methods¶
builder¶
Creates a new builder for StdioMcpClient.
Returns
a new builder
command¶
Sets the command to run.
Parameters
| Name | Description |
|---|---|
command |
the command and arguments |
Returns
this builder
command¶
Sets the command to run.
Parameters
| Name | Description |
|---|---|
command |
the command and arguments |
Returns
this builder
environment¶
Adds an environment variable.
Parameters
| Name | Description |
|---|---|
name |
the variable name |
value |
the variable value |
Returns
this builder
environment¶
Sets environment variables.
Parameters
| Name | Description |
|---|---|
environment |
the environment variables |
Returns
this builder
workingDirectory¶
Sets the working directory for the subprocess.
Parameters
| Name | Description |
|---|---|
directory |
the working directory |
Returns
this builder
objectMapper¶
Sets the ObjectMapper for JSON serialization.
Parameters
| Name | Description |
|---|---|
objectMapper |
the object mapper |
Returns
this builder
build¶
Builds the StdioMcpClient.
Returns
a new StdioMcpClient
Throws
| Type | Condition |
|---|---|
IllegalArgumentException |
if command is empty |