Skip to content

feat(mcp): framework-native permission scoping with #[mcp(...)] + ToolPolicy + x-mcp OpenAPI#198

Merged
Tuntii merged 4 commits into
mainfrom
feat/mcp-permission-scoping
Jun 19, 2026
Merged

feat(mcp): framework-native permission scoping with #[mcp(...)] + ToolPolicy + x-mcp OpenAPI#198
Tuntii merged 4 commits into
mainfrom
feat/mcp-permission-scoping

Conversation

@Tuntii

@Tuntii Tuntii commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Summary

Implements proper framework-level permission scoping for MCP tools as requested in recent feedback.

  • Introduces McpOperation struct + x-mcp OpenAPI extension for rich metadata.
  • Adds #[rustapi_rs::mcp(skip)], #[mcp(write, require="confirm")], #[mcp(readonly)] support in route macros.
  • ToolPolicy::ReadOnly is now the safe default (only GET etc. exposed unless opted in).
  • Automatic classification of read vs write based on HTTP method.
  • Permission and requiresConfirmation metadata included in tools/list responses so agents know the blast radius.
  • Updated discovery logic, Route/Operation builders, e2e tests, examples, and extensive Cookbook documentation.

Motivation

Auto-exposing every endpoint (including destructive ones) has real blast radius for AI agents. Permission scoping must be native to the framework, not bolted on later.

Changes

  • rustapi-openapi: McpOperation + x-mcp
  • rustapi-macros: parsing for #[mcp(...)]
  • rustapi-core: .mcp() on Route
  • rustapi-mcp: ToolPolicy, filtering in discovery, metadata in responses
  • Docs + 05-mcp-server example updated with more ReadOnly examples.

Testing

  • Local cargo check passes for affected crates.
  • Will monitor GitHub Actions.

Feedback welcome on the API design (e.g. more granular Custom policy later).

…olPolicy + x-mcp extension

- Add McpOperation struct in rustapi-openapi (serialized as x-mcp)
- Support #[rustapi_rs::mcp(skip)], #[mcp(write, require="confirm")], #[mcp(readonly)] in macros
- Add .mcp() to Route builder and Operation
- ToolPolicy::ReadOnly as safe default (All for writes)
- Method-based read/write classification
- Permission + requiresConfirmation in tools/list response
- Rich metadata from x-mcp OpenAPI extension
- Updated discovery, e2e tests, docs, examples, cookbook

Addresses agent blast radius. More examples in cookbook.
@github-actions github-actions Bot added the feat label Jun 19, 2026
@Tuntii Tuntii merged commit 6c98606 into main Jun 19, 2026
5 of 7 checks passed
@Tuntii Tuntii deleted the feat/mcp-permission-scoping branch June 19, 2026 17:37
github-actions Bot pushed a commit that referenced this pull request Jun 19, 2026
…permission-scoping

feat(mcp): framework-native permission scoping with #[mcp(...)] + ToolPolicy + x-mcp OpenAPI 6c98606
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant