Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion packages/core/src/core/coreToolScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,9 +625,15 @@ export class CoreToolScheduler {
? toolCall.tool.serverName
: undefined;

// Extract annotations from the tool instance
const toolAnnotations: Record<string, unknown> = {};
if (toolCall.tool.isReadOnly) {
toolAnnotations['readOnlyHint'] = true;
}

const { decision, rule } = await this.config
.getPolicyEngine()
.check(toolCallForPolicy, serverName);
.check(toolCallForPolicy, serverName, toolAnnotations);
Comment on lines +629 to +636

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

security-high high

Incomplete Tool Annotation Propagation

The implementation of tool annotation matching is incomplete. Here, the toolAnnotations object is manually populated with only the readOnlyHint annotation. Any other annotations provided by MCP servers or defined in policy rules are ignored. This means rules intended to restrict tools based on other semantic annotations (e.g., a rule to deny tools with a "dangerous" annotation) will never match, as those annotations are never passed to the policy engine.

Remediation:

  • Update the AnyDeclarativeTool interface and DiscoveredMCPTool to store and expose all available tool annotations.
  • Update this scheduler to collect and propagate all annotations from the tool instance to the PolicyEngine.


if (decision === PolicyDecision.DENY) {
const { errorMessage, errorType } = getPolicyDenialError(
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/policy/policies/plan.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ decision = "allow"
priority = 70
modes = ["plan"]

# Allow MCP tools with read-only hint in Plan mode
[[rule]]
mcpName = "*"
toolAnnotations = { readOnlyHint = true }
decision = "allow"
priority = 70
modes = ["plan"]

[[rule]]
toolName = ["ask_user", "exit_plan_mode"]
decision = "ask_user"
Expand Down
Loading