Repository navigation
fix(claude-code): catch up to v2.1.118 (mcp_tool hook type) #767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -529,7 +529,7 @@ pub(super) fn validate_cc_hk_013_async_field( | |
| content: &str, | ||
| diagnostics: &mut Vec<Diagnostic>, | ||
| ) { | ||
| let known_non_command = ["prompt", "agent", "http"]; | ||
| let known_non_command = ["prompt", "agent", "http", "mcp_tool"]; | ||
| for_each_raw_hook(raw_value, |event, matcher_idx, hook_idx, hook| { | ||
| if hook.get("async").is_some() { | ||
| if let Some(hook_type) = hook.get("type").and_then(|t| t.as_str()) { | ||
|
|
@@ -604,7 +604,7 @@ pub(super) fn validate_cc_hk_016_unknown_type( | |
| content: &str, | ||
| diagnostics: &mut Vec<Diagnostic>, | ||
| ) { | ||
| let valid_types = ["command", "prompt", "agent", "http"]; | ||
| let valid_types = ["command", "prompt", "agent", "http", "mcp_tool"]; | ||
| for_each_raw_hook(raw_value, |event, matcher_idx, hook_idx, hook| { | ||
| if let Some(type_value) = hook.get("type") { | ||
| let hook_type_str; | ||
|
|
@@ -970,8 +970,8 @@ pub(super) fn validate_all_raw_hooks( | |
| let check_024 = config.is_rule_enabled("CC-HK-024"); | ||
| let check_025 = config.is_rule_enabled("CC-HK-025"); | ||
|
|
||
| let valid_types = ["command", "prompt", "agent", "http"]; | ||
| let known_non_command = ["prompt", "agent", "http"]; | ||
| let valid_types = ["command", "prompt", "agent", "http", "mcp_tool"]; | ||
| let known_non_command = ["prompt", "agent", "http", "mcp_tool"]; | ||
|
Comment on lines
+973
to
+974
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The References
|
||
| let valid_shells = ["bash", "powershell"]; | ||
| let tool_events = HooksSchema::TOOL_EVENTS; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2950,6 +2950,33 @@ fn test_cc_hk_016_agent_type_valid() { | |||||||||||||||||||||||||
| assert_eq!(cc_hk_016.len(), 0); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| #[test] | ||||||||||||||||||||||||||
| fn test_cc_hk_016_mcp_tool_type_valid() { | ||||||||||||||||||||||||||
| // Claude Code v2.1.118 added `type: "mcp_tool"` so hooks can invoke | ||||||||||||||||||||||||||
| // MCP tools directly. Without this fix, agnix would false-positive | ||||||||||||||||||||||||||
| // CC-HK-016 (unknown hook type) on every v2.1.118+ user that follows | ||||||||||||||||||||||||||
| // the docs. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| // CC-HK-016 (unknown hook type) on every v2.1.118+ user that follows | |
| // the docs. | |
| // CC-HK-016 (unknown hook type) for users on v2.1.118+ following | |
| // the release notes that introduced `mcp_tool`. |
Copilot
AI
Apr 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This regression test only asserts that CC-HK-016 doesn’t fire. Since Hook’s typed schema currently doesn’t include an mcp_tool variant, validation may still emit CC-HK-012 (schema mismatch) for the same input, and this test would pass anyway. Please strengthen the test to assert there are no diagnostics (or at least that CC-HK-012 is also absent) once mcp_tool is fully supported.
| let cc_hk_016: Vec<_> = diagnostics | |
| .iter() | |
| .filter(|d| d.rule == "CC-HK-016") | |
| .collect(); | |
| assert_eq!(cc_hk_016.len(), 0, "mcp_tool should be a valid hook type (Claude Code v2.1.118+)"); | |
| assert!( | |
| diagnostics.is_empty(), | |
| "mcp_tool should be fully supported and produce no diagnostics (including CC-HK-012 schema mismatch or CC-HK-016 unknown hook type), got: {:?}", | |
| diagnostics | |
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mcp_toolis added to the raw JSON allow-list, but typed parsing still usesschemas::hooks::Hook(internally-tagged enum) which currently only supportscommand|prompt|agent|http. That means configs containing{"type":"mcp_tool"...}will still failserde_json::from_valueand emit CC-HK-012, so this change likely shifts the failure from CC-HK-016 to CC-HK-012 rather than fully supporting v2.1.118. Consider adding anmcp_toolvariant toHook(with at least atoolfield and a#[serde(flatten)] _extramap if you want to avoid strict-field coupling) or otherwise adjusting typed parsing to accept this new type.