Package com.google.genkit.plugins.mcp
Class MCPServerConfig
java.lang.Object
com.google.genkit.plugins.mcp.MCPServerConfig
Configuration for connecting to an MCP server.
Supports two transport types:
- STDIO: Launches a local process and communicates via standard I/O
- HTTP: Connects to a remote MCP server via HTTP/SSE
Example usage:
// STDIO transport - launch a local MCP server
MCPServerConfig filesystemServer = MCPServerConfig.stdio("npx", "-y", "@modelcontextprotocol/server-filesystem",
"/tmp");
// HTTP transport - connect to remote server
MCPServerConfig remoteServer = MCPServerConfig.http("http://localhost:3001/mcp");
// With environment variables
MCPServerConfig serverWithEnv = MCPServerConfig.builder().command("npx")
.args("-y", "@modelcontextprotocol/server-github").env("GITHUB_TOKEN", System.getenv("GITHUB_TOKEN"))
.build();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for MCPServerConfig.static enumTransport type for MCP communication. -
Method Summary
Modifier and TypeMethodDescriptionstatic MCPServerConfig.Builderbuilder()Creates a new builder.getArgs()Gets the command arguments.Gets the command for STDIO transport.getEnv()Gets the environment variables.Gets the transport type.getUrl()Gets the URL for HTTP transport.static MCPServerConfigCreates an HTTP server configuration.booleanWhether this server is disabled.static MCPServerConfigCreates a STDIO server configuration.static MCPServerConfigstreamableHttp(String url) Creates a Streamable HTTP server configuration.
-
Method Details
-
stdio
Creates a STDIO server configuration.- Parameters:
command- the command to executeargs- arguments for the command- Returns:
- the server configuration
-
http
Creates an HTTP server configuration.- Parameters:
url- the server URL- Returns:
- the server configuration
-
streamableHttp
Creates a Streamable HTTP server configuration.- Parameters:
url- the server URL- Returns:
- the server configuration
-
builder
Creates a new builder.- Returns:
- a new builder
-
getTransportType
Gets the transport type.- Returns:
- the transport type
-
getCommand
Gets the command for STDIO transport.- Returns:
- the command, or null for HTTP transport
-
getArgs
Gets the command arguments.- Returns:
- the arguments
-
getEnv
Gets the environment variables.- Returns:
- the environment variables
-
getUrl
Gets the URL for HTTP transport.- Returns:
- the URL, or null for STDIO transport
-
isDisabled
public boolean isDisabled()Whether this server is disabled.- Returns:
- true if disabled
-