trace-mcp 1.6.1 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  @echo off
2
- REM trace-mcp-guard v0.4.0
2
+ REM trace-mcp-guard v0.5.0
3
3
  REM trace-mcp PreToolUse guard (Windows)
4
- REM Blocks Read/Grep/Glob/Bash on source code files - redirects to trace-mcp tools.
4
+ REM Blocks Read/Grep/Glob/Bash on source code files + Agent(Explore) subagents - redirects to trace-mcp tools.
5
5
  REM Allows: non-code files, Read before Edit, safe Bash commands (git, npm, build, test).
6
6
  REM
7
7
  REM Consultation markers: trace-mcp server writes markers when tools access files.
@@ -138,6 +138,32 @@ if %errorlevel%==0 goto :allow
138
138
  call :deny "Use trace-mcp for code file discovery - it knows your project structure." "trace-mcp alternatives: get_project_map, search with file_pattern, get_outline. Use Glob only for non-code file patterns."
139
139
  goto :cleanup
140
140
 
141
+ :check_agent
142
+ REM --- Agent ---
143
+ REM Block Agent(Explore) and exploration-style Agent(general-purpose).
144
+ REM Each Agent subprocess costs ~50K tokens overhead (system prompt + CLAUDE.md + memory).
145
+ if /i not "%TOOL_NAME%"=="Agent" goto :check_bash
146
+
147
+ for /f "usebackq delims=" %%i in (`powershell -NoProfile -Command "try { (Get-Content '%TMPINPUT%' -Raw | ConvertFrom-Json).tool_input.subagent_type } catch { 'general-purpose' }"`) do set "SUBAGENT_TYPE=%%i"
148
+ for /f "usebackq delims=" %%i in (`powershell -NoProfile -Command "(Get-Content '%TMPINPUT%' -Raw | ConvertFrom-Json).tool_input.description"`) do set "DESCRIPTION=%%i"
149
+
150
+ REM Always block Explore agents
151
+ if /i "%SUBAGENT_TYPE%"=="Explore" (
152
+ call :deny "Agent(Explore) wastes ~50K tokens on overhead. Use trace-mcp tools instead (~4K tokens)." "trace-mcp alternatives: get_task_context, get_feature_context, batch with multiple search/get_outline/get_symbol calls, get_project_map."
153
+ goto :cleanup
154
+ )
155
+
156
+ REM Block general-purpose agents doing code exploration
157
+ if /i "%SUBAGENT_TYPE%"=="general-purpose" (
158
+ echo "%DESCRIPTION%" | findstr /i /r "explore investigate understand analyze analyse audit review study inspect catalog" >nul 2>&1
159
+ if !errorlevel!==0 (
160
+ call :deny "Agent(general-purpose) for code exploration wastes ~50K tokens. Use trace-mcp tools instead." "trace-mcp alternatives: get_task_context, get_feature_context, find_usages, get_call_graph, batch. Agent is OK for: writing code, running tests, web research, Plan mode."
161
+ goto :cleanup
162
+ )
163
+ )
164
+
165
+ goto :allow
166
+
141
167
  :check_bash
142
168
  REM --- Bash ---
143
169
  if /i not "%TOOL_NAME%"=="Bash" goto :allow
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bash
2
- # trace-mcp-guard v0.4.0
2
+ # trace-mcp-guard v0.5.0
3
3
  # trace-mcp PreToolUse guard
4
4
  # Blocks Read/Grep/Glob/Bash on source code files → redirects to trace-mcp tools.
5
5
  # Allows: non-code files, Read before Edit, safe Bash commands (git, npm, build, test).
@@ -202,5 +202,33 @@ if [[ "$TOOL_NAME" == "Bash" ]]; then
202
202
  exit 0
203
203
  fi
204
204
 
205
+ # --- Agent ---
206
+ # Block Agent(Explore) and exploration-style Agent(general-purpose).
207
+ # Each Agent subprocess costs ~50K tokens overhead (system prompt + CLAUDE.md + memory).
208
+ # trace-mcp tools (get_task_context, get_feature_context, batch) do the same for ~4K tokens.
209
+ if [[ "$TOOL_NAME" == "Agent" ]]; then
210
+ SUBAGENT_TYPE=$(echo "$INPUT" | jq -r '.tool_input.subagent_type // "general-purpose"')
211
+ DESCRIPTION=$(echo "$INPUT" | jq -r '.tool_input.description // ""' | tr '[:upper:]' '[:lower:]')
212
+
213
+ # Always block Explore agents — trace-mcp replaces them entirely
214
+ if [[ "$SUBAGENT_TYPE" == "Explore" ]]; then
215
+ deny \
216
+ "Agent(Explore) wastes ~50K tokens on overhead. Use trace-mcp tools instead (~4K tokens)." \
217
+ "trace-mcp alternatives:\\n- get_task_context { \\\"task\\\": \\\"your exploration goal\\\" } — focused context in one call\\n- get_feature_context { \\\"description\\\": \\\"what you need\\\" } — NL query → relevant symbols\\n- batch with multiple search/get_outline/get_symbol calls — parallel lookups\\n- get_project_map { \\\"summary_only\\\": true } — project overview"
218
+ fi
219
+
220
+ # Block general-purpose agents doing code exploration (not coding/testing/research)
221
+ if [[ "$SUBAGENT_TYPE" == "general-purpose" ]]; then
222
+ EXPLORE_RE='(explore|investigate|understand|analyze|analyse|audit|review|check .* (code|structure|architecture|implementation|pattern)|find .* (code|pattern|usage|definition)|study|deep dive|map .* (dependencies|imports)|catalog|inspect)'
223
+ if echo "$DESCRIPTION" | grep -qiE "$EXPLORE_RE"; then
224
+ deny \
225
+ "Agent(general-purpose) for code exploration wastes ~50K tokens. Use trace-mcp tools instead." \
226
+ "trace-mcp alternatives:\\n- get_task_context { \\\"task\\\": \\\"${DESCRIPTION}\\\" } — replaces exploration agents (~4K tokens)\\n- get_feature_context { \\\"description\\\": \\\"...\\\" } — NL query → relevant code\\n- find_usages / get_call_graph / get_change_impact — relationship analysis\\n- batch { \\\"calls\\\": [...] } — multiple lookups in one call\\nAgent is OK for: writing code, running tests, web research, Plan mode."
227
+ fi
228
+ fi
229
+
230
+ exit 0
231
+ fi
232
+
205
233
  # Allow everything else
206
234
  exit 0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trace-mcp",
3
- "version": "1.6.1",
3
+ "version": "1.7.0",
4
4
  "mcpName": "io.github.nikolai-vysotskyi/trace-mcp",
5
5
  "description": "Framework-aware code intelligence MCP server — 48+ frameworks, 68 languages",
6
6
  "type": "module",