Skip to content

Commit fadcd69

Browse files
authored
mcp: allow configuring mcp encryption iterations in standalone mode (#1604)
**Description** Allows configuring the MCP session encryption iterations in standalone mode. We probably don't need to expose the entire seed and fallback mechanisms now when running the CLI, but allowing to configure the iterations will be helpful to make it easier to benchmark EAIGW with different configurations. **Related Issues/PRs (if applicable)** Follow-up of: #1598 **Special notes for reviewers (if applicable)** N/A Signed-off-by: Ignasi Barrera <[email protected]>
1 parent 28a1cf3 commit fadcd69

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

cmd/aigw/main.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,15 @@ type (
4141
}
4242
// cmdRun corresponds to `aigw run` command.
4343
cmdRun struct {
44-
Debug bool `help:"Enable debug logging emitted to stderr."`
45-
Path string `arg:"" name:"path" optional:"" help:"Path to the AI Gateway configuration yaml file. Defaults to $AIGW_CONFIG_HOME/config.yaml if exists, otherwise optional when at least OPENAI_API_KEY, AZURE_OPENAI_API_KEY or ANTHROPIC_API_KEY is set." type:"path"`
46-
AdminPort int `help:"HTTP port for the admin server (serves /metrics and /health endpoints)." default:"1064"`
47-
McpConfig string `name:"mcp-config" help:"Path to MCP servers configuration file." type:"path"`
48-
McpJSON string `name:"mcp-json" help:"JSON string of MCP servers configuration."`
49-
RunID string `name:"run-id" env:"AIGW_RUN_ID" help:"Run identifier for this invocation. Defaults to timestamp-based ID or $AIGW_RUN_ID. Use '0' for Docker/Kubernetes."`
44+
Debug bool `help:"Enable debug logging emitted to stderr."`
45+
Path string `arg:"" name:"path" optional:"" help:"Path to the AI Gateway configuration yaml file. Defaults to $AIGW_CONFIG_HOME/config.yaml if exists, otherwise optional when at least OPENAI_API_KEY, AZURE_OPENAI_API_KEY or ANTHROPIC_API_KEY is set." type:"path"`
46+
AdminPort int `help:"HTTP port for the admin server (serves /metrics and /health endpoints)." default:"1064"`
47+
McpConfig string `name:"mcp-config" help:"Path to MCP servers configuration file." type:"path"`
48+
McpJSON string `name:"mcp-json" help:"JSON string of MCP servers configuration."`
49+
RunID string `name:"run-id" env:"AIGW_RUN_ID" help:"Run identifier for this invocation. Defaults to timestamp-based ID or $AIGW_RUN_ID. Use '0' for Docker/Kubernetes."`
50+
51+
MCPSessionEncryptionIterations int `name:"mcp-session-encryption-iterations" help:"Number of iterations for MCP session encryption key derivation." default:"100000"`
52+
5053
mcpConfig *autoconfig.MCPServers `kong:"-"` // Internal field: normalized MCP JSON data
5154
dirs *xdg.Directories `kong:"-"` // Internal field: XDG directories, set by BeforeApply
5255
runOpts *runOpts `kong:"-"` // Internal field: run options, set by Validate

cmd/aigw/main_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ Flags:
136136
--run-id=STRING Run identifier for this invocation. Defaults to
137137
timestamp-based ID or $AIGW_RUN_ID. Use '0' for
138138
Docker/Kubernetes ($AIGW_RUN_ID).
139+
--mcp-session-encryption-iterations=100000
140+
Number of iterations for MCP session encryption
141+
key derivation.
139142
`,
140143
expPanicCode: ptr.To(0),
141144
},

cmd/aigw/run.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ type runCmdContext struct {
7878
// fakeClientSet is the fake client set for the k8s resources. The objects are written to this client set and updated
7979
// during the translation.
8080
fakeClientSet *fake.Clientset
81+
// mcpSessionEncryptionIterations is the number of iterations for MCP session encryption key derivation.
82+
mcpSessionEncryptionIterations int
8183
}
8284

8385
// run starts the AI Gateway locally for a given configuration.
@@ -361,6 +363,7 @@ func (runCtx *runCmdContext) mustStartExtProc(
361363
"--extProcAddr", fmt.Sprintf("unix://%s", runCtx.udsPath),
362364
"--adminPort", fmt.Sprintf("%d", runCtx.adminPort),
363365
"--mcpAddr", ":" + strconv.Itoa(internalapi.MCPProxyPort),
366+
"--mcpSessionEncryptionIterations", strconv.Itoa(runCtx.mcpSessionEncryptionIterations),
364367
}
365368
if runCtx.isDebug {
366369
args = append(args, "--logLevel", "debug")

0 commit comments

Comments
 (0)