Class McpStdioServerConfig

java.lang.Object
com.github.copilot.sdk.json.McpServerConfig
com.github.copilot.sdk.json.McpStdioServerConfig

public final class McpStdioServerConfig extends McpServerConfig
Configuration for a local/stdio MCP (Model Context Protocol) server.

Use this to configure an MCP server that is launched as a local subprocess and communicates via standard input/output.

Example Usage


 var server = new McpStdioServerConfig().setCommand("npx")
 		.setArgs(List.of("-y", "@modelcontextprotocol/server-filesystem", "/path")).setTools(List.of("*"));

 var config = new SessionConfig().setMcpServers(Map.of("filesystem", server));
 
Since:
1.3.0
See Also:
  • Constructor Details

    • McpStdioServerConfig

      public McpStdioServerConfig()
  • Method Details

    • getType

      public String getType()
      Gets the server type discriminator.
      Returns:
      always "stdio"
    • getCommand

      public String getCommand()
      Gets the command to run the MCP server.
      Returns:
      the command
    • setCommand

      public McpStdioServerConfig setCommand(String command)
      Sets the command to run the MCP server.
      Parameters:
      command - the command
      Returns:
      this config for method chaining
    • getArgs

      public List<String> getArgs()
      Gets the arguments to pass to the command.
      Returns:
      the arguments list, or null
    • setArgs

      public McpStdioServerConfig setArgs(List<String> args)
      Sets the arguments to pass to the command.
      Parameters:
      args - the arguments list
      Returns:
      this config for method chaining
    • getEnv

      public Map<String,String> getEnv()
      Gets the environment variables to pass to the server.
      Returns:
      the environment variables map, or null
    • setEnv

      public McpStdioServerConfig setEnv(Map<String,String> env)
      Sets the environment variables to pass to the server.
      Parameters:
      env - the environment variables map
      Returns:
      this config for method chaining
    • getWorkingDirectory

      public String getWorkingDirectory()
      Gets the working directory for the server process.
      Returns:
      the working directory path, or null
    • setWorkingDirectory

      public McpStdioServerConfig setWorkingDirectory(String workingDirectory)
      Sets the working directory for the server process.
      Parameters:
      workingDirectory - the working directory path
      Returns:
      this config for method chaining
    • setTools

      public McpStdioServerConfig setTools(List<String> tools)
      Description copied from class: McpServerConfig
      Sets the list of tools to include from this server.

      An empty list means none; use "*" to include all tools.

      Overrides:
      setTools in class McpServerConfig
      Parameters:
      tools - the list of tool names, or null
      Returns:
      this config for method chaining
    • setTimeout

      public McpStdioServerConfig setTimeout(Integer timeout)
      Description copied from class: McpServerConfig
      Sets an optional timeout in milliseconds for tool calls to this server.
      Overrides:
      setTimeout in class McpServerConfig
      Parameters:
      timeout - the timeout in milliseconds, or null for the default
      Returns:
      this config for method chaining