Skip to content

revert(mcp): drop policy expiry (expires_at) from mcp_policies - #826

Merged
jarvis9443 merged 2 commits into
mainfrom
revert/mcp-policy-expiry
Jul 28, 2026
Merged

revert(mcp): drop policy expiry (expires_at) from mcp_policies#826
jarvis9443 merged 2 commits into
mainfrom
revert/mcp-policy-expiry

Conversation

@jarvis9443

@jarvis9443 jarvis9443 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Scope trim for the layered MCP access policy (#822, Ref api7/AISIX-Cloud#1034): policy expiry turned out not to be a customer requirement, so the surface is reverted to its minimal shape before any release carries it. A policy's activity is now the enabled flag alone — a disabled policy neither grants nor denies.

  • McpPolicy loses expires_at (schema regenerated); ToolAcl::resolve drops its timestamp parameter and the /mcp mount no longer threads a clock into ACL resolution; the chrono dependency added for this leaves aisix-mcp.
  • Tests: the expiry cases collapse into enabled-only equivalents (12 model + 28 gateway + 16 proxy tests pass); the TS e2e suite never used the field (8/8 pass against a rebuilt binary).
  • Compatibility: the document schema is closed (deny_unknown_fields), so a stored row carrying expires_at would be rejected after this lands. No released version ever wrote the field (0.5.0 predates feat(mcp): layered MCP access policies — env default, team entitlement, key narrowing #822); only a policy saved with an expiry on a dev/main deployment inside the feature's two-day window would need one re-save. The paired control-plane revert (field off the API/UI/projection, and the never-released DB column dropped outright — the additive-only rule protects released shapes only) follows once this is on main.

Summary by CodeRabbit

  • Behavior Changes
    • MCP policies no longer expire based on time.
    • Disabled policies remain excluded from tool authorization decisions.
    • Omitted policy settings continue to default to enabled.
  • Schema Updates
    • Updated policy documentation to reflect current nullability and enabled-policy behavior.
    • Removed expiration-related fields and guidance from policy schemas.

Transition detail for that window: the loader skips a schema-rejected row and serves the rest, so a stored policy row still carrying expires_at is dropped whole until re-saved — its grant fails closed (visible immediately), and its deny overlay stops applying until the re-save. Both resolve with one save of the policy.

Product decision: policy expiry is not a customer requirement — keep
the MCP access policy surface minimal. The field shipped in #822 and
was never part of a cut release, so no stored documents carry it.

- McpPolicy loses expires_at; activity is the enabled flag alone
  (a disabled policy neither grants nor denies).
- ToolAcl::resolve drops its timestamp parameter; the /mcp mount no
  longer threads a clock into ACL resolution.
- Schema regenerated; the expiry test cases collapse into
  enabled-only equivalents. The e2e suite never used the field.

Compatibility: the document schema is closed, so a row carrying
expires_at would be rejected after this lands — no released version
ever wrote the field and the paired control-plane change stops
accepting it, so only a policy saved with an expiry on a dev/main
deployment inside the feature's two-day window would need one
re-save.
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

MCP policy expiration support was removed from the model, schemas, and ACL resolution. Policy filtering now uses only enabled, and MCP gateway and proxy callers no longer pass timestamps.

Changes

MCP policy expiry removal

Layer / File(s) Summary
Policy contract and schema updates
crates/aisix-core/src/models/mcp_policy.rs, crates/aisix-core/src/models/schema.rs, schemas/resources/mcp_policy.schema.json
McpPolicy no longer contains expires_at or is_active_at; documentation and tests now cover enabled-only behavior.
Enabled-only ACL resolution
crates/aisix-mcp/src/gateway.rs, crates/aisix-mcp/tests/gateway_aggregation.rs, crates/aisix-mcp/Cargo.toml
ToolAcl::resolve no longer accepts a timestamp and excludes disabled policies; related tests and the unused chrono dependency were updated.
MCP dispatch integration
crates/aisix-proxy/src/mcp.rs
MCP dispatch invokes ToolAcl::resolve without a current-time argument.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MCPClient
  participant dispatch
  participant ToolAcl
  participant AisixSnapshot
  MCPClient->>dispatch: MCP tool request
  dispatch->>ToolAcl: resolve(snapshot, key)
  ToolAcl->>AisixSnapshot: read enabled policy entries
  AisixSnapshot-->>ToolAcl: policy data
  ToolAcl-->>dispatch: resolved ACL
  dispatch-->>MCPClient: allow or deny tool call
Loading

Possibly related PRs

  • api7/aisix#822: Earlier implementation of time-based MCP policy activity and timestamp-aware ACL resolution.

Suggested reviewers: moonming

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
E2e Test Quality Review ✅ Passed PASS: The PR has real end-to-end MCP coverage plus readable integration tests, and the updated scenarios cover the new enabled-only ACL behavior without hidden ordering assumptions.
Security Check ✅ Passed PASS: The diff only removes MCP policy expiry plumbing; auth still short-circuits via AuthenticatedKey and ACLs, and no new secret logging/storage or ownership gaps were introduced.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: removing MCP policy expiry support and the expires_at field.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch revert/mcp-policy-expiry

Comment @coderabbitai help to get the list of available commands.

@jarvis9443
jarvis9443 merged commit ef28913 into main Jul 28, 2026
12 checks passed
@jarvis9443
jarvis9443 deleted the revert/mcp-policy-expiry branch July 28, 2026 01:35
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.

1 participant