Skip to content

feat(mcp,tools): MCP identity propagation, tool quota, structured errors, OAP authorization#2703

Merged
bug-ops merged 1 commit intomainfrom
feat/issue-2479/mcp-primitives-oap
Apr 6, 2026
Merged

feat(mcp,tools): MCP identity propagation, tool quota, structured errors, OAP authorization#2703
bug-ops merged 1 commit intomainfrom
feat/issue-2479/mcp-primitives-oap

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Apr 6, 2026

Summary

Implements three missing MCP production primitives (arXiv:2603.13417, #2479) and OAP declarative pre-action authorization (arXiv:2603.20953, #2406).

MCP primitives (#2479)

  • Structured error codes: McpErrorCode enum (Transient/RateLimited/InvalidInput/AuthFailure/ServerError/NotFound/PolicyBlocked) with is_retryable(); McpError::code() covers all variants including security variants (SsrfBlocked/CommandNotAllowed/EnvVarBlockedPolicyBlocked)
  • Identity propagation: caller_id: Option<String> added to ToolCall and AuditEntry; channel provides identity when available
  • Per-session tool quota: max_tool_calls_per_session: Option<u32> in [tools] config; ToolOrchestrator counter incremented once per logical batch (not per retry)

OAP authorization (#2406)

  • [tools.authorization] config: AuthorizationConfig with enabled flag and per-tool allow/deny rules; capabilities: Vec<String> field present (matching deferred per MVP scope)
  • Policy evaluation: Authorization rules appended after policy.rules at startup (policy takes precedence); PolicyGateExecutor::execute()/execute_confirmed() return Err(ToolError::Blocked) when policy enabled — no silent passthrough
  • Audit integration: policy_match: Option<String> in AuditEntry, populated from PolicyDecision::trace on both allow and deny branches

Test plan

  • cargo +nightly fmt --check — clean
  • cargo clippy --workspace -- -D warnings — 0 warnings
  • cargo nextest run --workspace --lib --bins — 7663/7663 PASS (4 new tests for check_quota())
  • Verify [tools.authorization] config parses correctly in testing.toml
  • Verify quota enforcement blocks tool calls when max_tool_calls_per_session exceeded
  • Verify policy_match appears in audit log when authorization rule fires

Closes #2479
Closes #2406

…ors, OAP authorization (#2479, #2406)

Implements three missing MCP production primitives (arXiv:2603.13417) and
OAP declarative pre-action authorization (arXiv:2603.20953).

MCP primitives (#2479):
- Add McpErrorCode enum (Transient/RateLimited/InvalidInput/AuthFailure/
  ServerError/NotFound/PolicyBlocked) with is_retryable(); McpError::code()
  maps all variants including SsrfBlocked/CommandNotAllowed/EnvVarBlocked
  (PolicyBlocked), InvalidUrl/ToolListLocked (InvalidInput), Embedding (ServerError)
- Add caller_id: Option<String> to ToolCall and AuditEntry for identity propagation
- Add max_tool_calls_per_session: Option<u32> to [tools] config; counter in
  ToolOrchestrator incremented once per logical batch (not per retry)

OAP authorization (#2406):
- Add [tools.authorization] config section (AuthorizationConfig) with enabled flag
  and per-tool allow/deny rules; capabilities: Vec<String> field present,
  matching deferred (M4)
- Authorization rules appended after policy.rules at startup in runner.rs
  (policy takes precedence, documented)
- PolicyGateExecutor::execute()/execute_confirmed() return Err(ToolError::Blocked)
  when policy is enabled — no silent passthrough
- Add policy_match: Option<String> to AuditEntry, populated from
  PolicyDecision::trace on allow and deny branches
@github-actions github-actions Bot added documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate enhancement New feature or request size/L Large PR (201-500 lines) labels Apr 6, 2026
@bug-ops bug-ops merged commit 2292f0b into main Apr 6, 2026
27 checks passed
@bug-ops bug-ops deleted the feat/issue-2479/mcp-primitives-oap branch April 6, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate documentation Improvements or additions to documentation enhancement New feature or request rust Rust code changes size/L Large PR (201-500 lines)

Projects

None yet

1 participant