Commit a0cdc37
feat: Enhanced Tool Annotations Intelligence (Spec 035) (#342)
* feat: add GET /api/v1/annotations/coverage endpoint
Add annotation coverage reporting endpoint that shows how many upstream
tools have MCP annotations (hint booleans) vs those that don't, broken
down by server. A tool counts as annotated only if at least one of
ReadOnlyHint, DestructiveHint, IdempotentHint, or OpenWorldHint is set
(Title alone does not count).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* chore: regenerate OpenAPI spec for annotations/coverage endpoint
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat: add lethal trifecta session risk analysis and annotation-based filtering to retrieve_tools (Spec 035 F2+F4)
F2: Session risk analysis examines all connected servers' tool annotations
to detect the "lethal trifecta" — open-world access + destructive capabilities
+ write access. Returns risk level (high/medium/low) in every retrieve_tools
response as session_risk, with a warning when the trifecta is present.
F4: Three new optional boolean parameters (read_only_only, exclude_destructive,
exclude_open_world) allow agents to self-restrict tool discovery scope based on
MCP annotation hints. Nil annotations are treated as most permissive per spec.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat: add openWorldHint content trust scanning for tool calls (Spec 035 F3)
When a tool call is made via call_tool_read/write/destructive, code_execution,
or direct routing mode, check if the called tool has openWorldHint=true (or nil,
which defaults to true per MCP spec). Tag the activity record metadata with
"content_trust": "untrusted" for open-world tools, or "trusted" for closed-world
tools (openWorldHint=false). This enables downstream security review of tool
outputs that may contain untrusted external data.
Changes:
- Add IsOpenWorldTool() and ContentTrustForTool() helpers in contracts/intent.go
- Add content_trust field to EmitActivityToolCallCompleted event payload
- Add content_trust extraction in handleToolCallCompleted and
handleInternalToolCall activity service handlers
- Add EmitActivityInternalToolCallWithContentTrust for code_execution path
- Compute content trust in handleCallToolVariant, makeDirectModeHandler, and
code_execution handler (any open-world tool call marks entire execution)
- Add comprehensive tests: TestIsOpenWorldTool, TestContentTrustForTool,
TestHandleToolCallCompleted_ContentTrust,
TestHandleInternalToolCall_ContentTrust
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* docs: add Spec 035 Enhanced Tool Annotations Intelligence
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor: merge duplicated EmitActivityInternalToolCall functions
Consolidate EmitActivityInternalToolCallWithContentTrust into
EmitActivityInternalToolCall by adding contentTrust parameter to the
original function. Eliminates 35-line copy-paste duplication.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Code <noreply@anthropic.com>1 parent 13b9386 commit a0cdc37
15 files changed
Lines changed: 1400 additions & 73 deletions
File tree
- internal
- contracts
- httpapi
- runtime
- server
- oas
- specs/035-enhanced-annotations
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
81 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
119 | | - | |
| 118 | + | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
230 | 260 | | |
231 | 261 | | |
232 | 262 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
9 | 115 | | |
10 | 116 | | |
11 | 117 | | |
| |||
99 | 205 | | |
100 | 206 | | |
101 | 207 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
108 | 214 | | |
109 | 215 | | |
110 | 216 | | |
| |||
0 commit comments