Skip to content

feat: add capability_class to @guard decorator (RFC-008)#19

Merged
beonde merged 2 commits into
mainfrom
feat/rfc008-capability-class-allow-path
Apr 29, 2026
Merged

feat: add capability_class to @guard decorator (RFC-008)#19
beonde merged 2 commits into
mainfrom
feat/rfc008-capability-class-allow-path

Conversation

@beonde
Copy link
Copy Markdown
Member

@beonde beonde commented Apr 29, 2026

Summary

Adds capability_class and deny_on_unknown_class parameters to the @guard and @guard_sync decorators for RFC-008 capability class enforcement.

Changes

  • guard.py: Add capability_class: str | None and deny_on_unknown_class: bool | None params to:
    • evaluate_tool_access() low-level API
    • @guard async decorator (both overloads)
    • @guard_sync sync decorator
  • Wire both params through to gRPC EvaluateToolAccessRequest

Usage

@guard(capability_class="invoice-management")
async def create_invoice(amount: float) -> dict:
    ...

@guard(capability_class="finance.payroll", deny_on_unknown_class=False)
async def view_payroll() -> list:
    ...

Linked PRs

- Add capability_class: str | None param to @guard and @guard_sync decorators
- Add deny_on_unknown_class: bool | None param for PEP-level unknown class behavior
- Wire both params through evaluate_tool_access() to gRPC request
- Set capability_class and deny_on_unknown_class on proto request when provided

Part of: RFC-008 §5.5 capability class enforcement
Copilot AI review requested due to automatic review settings April 29, 2026 20:42
@github-actions
Copy link
Copy Markdown

✅ Integration tests passed! capiscio-core gRPC tests working.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds RFC-008 capability class enforcement hooks to the capiscio_mcp guard layer by introducing capability_class and deny_on_unknown_class parameters and wiring them through to the core gRPC EvaluateToolAccess request.

Changes:

  • Extend evaluate_tool_access() with capability_class and deny_on_unknown_class parameters and set corresponding gRPC request fields.
  • Extend @guard / @guard_sync decorator APIs (including overloads) to accept and forward these parameters.
  • Update docstrings/examples to reflect capability class usage.

Comment thread capiscio_mcp/guard.py
if capability_class:
request.capability_class = capability_class
if deny_on_unknown_class is not None:
request.deny_on_unknown_class = deny_on_unknown_class
Comment thread capiscio_mcp/guard.py
Comment on lines 478 to 489
def guard_sync(
func: Optional[Callable[P, R]] = None,
*,
config: Optional[GuardConfig] = None,
min_trust_level: Optional[int] = None,
tool_name: Optional[str] = None,
require_badge: bool = False,
capability_class: Optional[str] = None,
deny_on_unknown_class: Optional[bool] = None,
) -> Union[Callable[P, R], Callable[[Callable[P, R]], Callable[P, R]]]:
"""
Sync decorator to guard MCP tool execution.
Comment thread capiscio_mcp/guard.py
Comment on lines 442 to 449
# Evaluate access
result = await evaluate_tool_access(
tool_name=effective_tool_name,
params=params,
config=effective_config,
capability_class=capability_class,
deny_on_unknown_class=deny_on_unknown_class,
)
Regenerated from capiscio-core's updated mcp.proto which includes
the optional bool deny_on_unknown_class field (field 15) and the
updated comment clarifying proto3 bool default semantics.
@github-actions
Copy link
Copy Markdown

✅ Integration tests passed! capiscio-core gRPC tests working.

@beonde beonde merged commit 9f24899 into main Apr 29, 2026
10 checks passed
@beonde beonde deleted the feat/rfc008-capability-class-allow-path branch April 29, 2026 21:27
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.

2 participants