Skip to content

Commit eb637f3

Browse files
authored
feat: surface structured rejection fields from gRPC response (RFC-008 B8) (#61)
* feat: surface structured rejection fields from gRPC response (RFC-008 B8) - Regenerate mcp_pb2.py from updated proto with error_code, rejection_detail, requested_capability, presented_capability fields (15-18) and SCOPE_INSUFFICIENT enum value (9) - Add SCOPE_INSUFFICIENT to deny_reason_map in evaluate_tool_access() - Return error_code, requested_capability, presented_capability in the evaluate_tool_access() result dict - Restore try/except TypeError handler for descriptor pool collisions * fix: address Copilot review feedback on RFC-008 B8 - Remove duplicated import block in mcp_pb2.py - Remove grpcio>=1.76.0 version gate from mcp_pb2_grpc.py (SDK supports grpcio>=1.60.0) - Remove unused warnings import from mcp_pb2_grpc.py - Add rejection_detail to evaluate_tool_access() return dict - Add unit tests for structured rejection fields
1 parent 8e7e36a commit eb637f3

4 files changed

Lines changed: 209 additions & 46 deletions

File tree

capiscio_sdk/_rpc/client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,7 @@ def evaluate_tool_access(
16071607
mcp_pb2.MCP_DENY_REASON_TOOL_NOT_ALLOWED: "tool_not_allowed",
16081608
mcp_pb2.MCP_DENY_REASON_ISSUER_UNTRUSTED: "issuer_untrusted",
16091609
mcp_pb2.MCP_DENY_REASON_POLICY_DENIED: "policy_denied",
1610+
mcp_pb2.MCP_DENY_REASON_SCOPE_INSUFFICIENT: "scope_insufficient",
16101611
}
16111612

16121613
auth_level_map = {
@@ -1636,6 +1637,10 @@ def evaluate_tool_access(
16361637
"evidence_json": response.evidence_json,
16371638
"evidence_id": response.evidence_id,
16381639
"timestamp": timestamp_str,
1640+
"error_code": response.error_code,
1641+
"rejection_detail": response.rejection_detail,
1642+
"requested_capability": response.requested_capability,
1643+
"presented_capability": response.presented_capability,
16391644
}
16401645

16411646
def verify_server_identity(

0 commit comments

Comments
 (0)