Skip to content

Narrow per-agent MCP override type and add authz support#63

Merged
JAORMX merged 2 commits intomainfrom
jaosorior/narrow-per-agent-mcp-override
Mar 18, 2026
Merged

Narrow per-agent MCP override type and add authz support#63
JAORMX merged 2 commits intomainfrom
jaosorior/narrow-per-agent-mcp-override

Conversation

@JAORMX
Copy link
Copy Markdown
Contributor

@JAORMX JAORMX commented Mar 18, 2026

Summary

  • Replace AgentOverride.MCP (*MCPConfig) with a new MCPAgentOverride type exposing only Enabled and Authz — makes unsupported fields (Group, Port, Config) unrepresentable at compile time
  • Export MergeMCPAuthzConfig and add tighten-only per-agent authz merging in the composition root before VMCPProvider construction
  • Simplify resolveMCPConfig to Enabled-only overrides, removing dead Group/Port/Config code that was parsed but never had runtime effect
  • Update warnLocalConfigOverrides to warn about per-agent Authz instead of the removed fields

Test plan

  • task fmt && task lint — 0 issues
  • task test — all tests pass with race detector
  • CI passes (test, lint, build matrix)
  • Manual: config with agents.claude-code.mcp.authz.profile: observe parses correctly and the tighter profile propagates

Backward compatibility

Go's yaml.v3 silently drops unknown fields. Users with existing per-agent mcp.group/mcp.port/mcp.config in YAML will see those fields silently ignored — same as today since they never had runtime effect. The Go API change (AgentOverride.MCP type) is breaking for external consumers, acceptable at v0.0.x.

Fixes #62

🤖 Generated with Claude Code

JAORMX added a commit that referenced this pull request Mar 18, 2026
- Add os.Chmod after WriteFile for consistent 0600 on --force overwrite
- Update memory descriptions for ByteSize type ("4g", "512m")
- Narrow per-agent MCP template to enabled + authz only (PR #63)
- Add authz/config subsection checks to template test

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@JAORMX JAORMX requested a review from jhrozek March 18, 2026 11:13
Copy link
Copy Markdown
Contributor

@jhrozek jhrozek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

1 HIGH, 1 LOW finding (confidence ≥ 8 only).

The type narrowing from *MCPConfig to *MCPAgentOverride is a solid security improvement — making illegal states unrepresentable. DDD layer boundaries are respected throughout. MergeMCPAuthzConfig is well-designed and thoroughly tested.

However, the agent merge loop in MergeConfigs does wholesale replacement of AgentOverride values, which silently drops security-relevant fields set by the operator in global config.

LOW: Dead data flow in composition root

cmd/bbox/main.go:655-656 writes sandboxCfg.MCP.Config and sandboxCfg.MCP.Authz but the sandbox layer never reads them (pkg/sandbox/ has zero references to .MCP.Authz or .MCP.Config). Authz is resolved entirely at the composition root before VMCPProvider construction. These writes are harmless but potentially misleading for future readers. Consider removing them or adding a comment explaining they exist for SDK consumers.

🤖 Generated with Claude Code

Replace AgentOverride.MCP (*MCPConfig) with a new MCPAgentOverride
type that only exposes Enabled and Authz fields. This eliminates
dead Group/Port/Config override code that was parsed but never had
runtime effect, and adds tighten-only per-agent authz merging.

- Add MCPAgentOverride type in pkg/domain/config
- Export MergeMCPAuthzConfig for reuse by composition root
- Simplify resolveMCPConfig to Enabled-only overrides
- Merge per-agent authz before VMCPProvider construction
- Update warnLocalConfigOverrides for new type
- Rewrite tests for new semantics

Fixes #62

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@JAORMX JAORMX force-pushed the jaosorior/narrow-per-agent-mcp-override branch from 45f40e9 to 1e67a98 Compare March 18, 2026 11:21
mergeAgentOverride merges field-by-field instead of replacing the
entire AgentOverride struct. Security fields (EgressProfile, MCP.Authz)
use tighten-only semantics, AllowHosts are additive, and resource
fields use local-overrides-when-non-zero — matching existing top-level
merge patterns.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@JAORMX JAORMX merged commit ad368c5 into main Mar 18, 2026
7 checks passed
@JAORMX JAORMX deleted the jaosorior/narrow-per-agent-mcp-override branch March 18, 2026 12:47
JAORMX added a commit that referenced this pull request Mar 18, 2026
* bbox config init

Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>

* Address review feedback and sync with main

- Add os.Chmod after WriteFile for consistent 0600 on --force overwrite
- Update memory descriptions for ByteSize type ("4g", "512m")
- Narrow per-agent MCP template to enabled + authz only (PR #63)
- Add authz/config subsection checks to template test

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clarify and align per-agent MCP override semantics (mcp.config vs mcp.authz)

2 participants