feat(inspector): primitive execution & always-visible event logs - #160
Conversation
…dpoint - Add "manual" to AgnosticInspectorEvent.source union - Add 6 manual event types (manual_tool_call, manual_tool_result, etc.) - Map manual events to "agent" category in getEventCategory/getEventSummary - Add POST /api/execute-primitive endpoint dispatching by kind (tool/resource/prompt) - Record manual events before/after execution with source: "manual" - 30s default timeout, overrideable via request body - Extend recordAgentEvent with optional source parameter Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove isStreaming from RightPanelProps and all usages - Always render Agent, Events, and Logs tabs - Replace handleClear/isClearDisabled with switch(activeTab) dispatch - Update right-panel tests for always-visible behavior Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ided - Action button enabled with primary style when onExecute prop exists - onClick switches to action mode (shows form), does not execute immediately - Remains disabled with "Coming soon" when onExecute is absent Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…mappers - mapToolResponse: maps tool call results to ExecutionResult (ok=!isError) - mapResourceResponse: maps resource read results with uri+mimeType - mapPromptResponse: maps prompt messages with role/content handling - executePrimitive: fetches /api/execute-primitive, dispatches to correct mapper - All mappers never throw, always return ExecutionResult Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…veDetail - Create handleExecutePrimitive in InspectorDashboard binding serverId as connectionId - Add onExecute prop to McpPrimitivesPanel and thread to PrimitiveDetail - selectedPrimitive.serverId used as connectionId for execute-primitive API Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Show "MANUAL" badge on events with source: "manual" - Add manualBadge styles (amber accent color) - Manual events appear in Agent panel with visual distinction Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- mapToolResponse: success content, error flag, empty data - mapResourceResponse: contents mapping, empty data - mapPromptResponse: messages with roles, empty data - executePrimitive: success flow, network error, non-200 response Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ugh component tree - executePrimitive with per-kind mappers (tool/resource/prompt) - createExecuteFn binds baseUrl + connectionId for ExecuteFn signature - Wire onExecute through InspectorDashboard -> McpPrimitivesPanel -> PrimitiveDetail - Thread baseUrl through to fetch calls (consistent with other hooks) - 22 unit tests for mappers and executePrimitive function Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Wrap Promise.race in try/finally to clear setTimeout on success - Prevents timer leak on successful executions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Backend /api/execute-primitive endpoint integration tests - Manual event type mapping tests (getEventCategory, getEventSummary) - VALID_INSPECTOR_EVENT_TYPES validation for all 6 manual types - 83 additional tests for comprehensive coverage Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR introduces a manual primitive execution feature enabling users to execute tools, resources, and prompts directly from the inspector dashboard. It adds a backend Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Dashboard as Inspector Dashboard
participant API as Backend API
participant MCP as MCP Client
participant EventSys as Event System
User->>Dashboard: Click Execute Button
Dashboard->>API: POST /api/execute-primitive<br/>(kind, name, params, connectionId)
API->>EventSys: Record manual_*_call event
API->>MCP: Execute primitive<br/>(callTool / readResource / getPrompt)
MCP-->>API: Primitive result or error
API->>EventSys: Record manual_*_result event
API-->>Dashboard: Execution result + duration
Dashboard->>Dashboard: Display result in UI
Dashboard-->>User: Show execution outcome
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Review: Primitive Execution & Always-Visible Event LogsThis PR implements manual execution of MCP primitives (tools/resources/prompts) from the inspector dashboard. Overall, the implementation is well-structured with excellent test coverage. However, there are several areas that need attention before merging. 🔴 Critical Issues1. Timeout Memory Leak in Backend EndpointLocation: packages/inspector/src/standalone-server.ts:~650-720 (execute-primitive endpoint) The timeout implementation using Promise.race has a critical issue. Even though commit f9f6f7f attempted to fix timer leaks with try/finally, the timeout timer will not be cleared if the Promise.race rejects (e.g., on connection error or MCP call failure). Fix: Wrap in try/catch/finally or ensure clearTimeout runs in all code paths 2. Type Safety Violation with 'as' AssertionsLocation: packages/inspector/src/dashboard/react/utils/executePrimitive.ts:79, 115, 168-170 Multiple uses of 'as ExecutionMeta' bypass TypeScript safety. Per AGENTS.md: NEVER introduce any in production code; use unknown + narrowing
|
…SDoc) - Remove no-op ternary for structuredContent in mapToolResponse - Add exhaustive default case to kind switch in executePrimitive - Add @PARAM JSDoc for source parameter in recordAgentEvent Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Code Review: feat(inspector): primitive execution & always-visible event logsOverviewThis PR implements manual (browse-mode) primitive execution from the inspector dashboard and makes event/agent logs always visible. The implementation is well-structured with 105 new tests covering the core functionality. ✅ Strengths1. Code Quality & Architecture
2. Backend Implementation (
|
Summary
/api/execute-primitiveendpoint dispatching tocallTool/readResource/getPromptby kind field, with 30s configurable timeout and manual event recordingexecutePrimitiveutility with per-kind response mappers (mapToolResponse,mapResourceResponse,mapPromptResponse), wired throughInspectorDashboard→McpPrimitivesPanel→PrimitiveDetailasonExecuteproponExecuteprovided (switches to action mode), RightPanel always renders all 3 tabs (Agent/Events/Logs) withisStreamingprop removed entirelymanual_tool_call,manual_tool_result, etc.) withsource: "manual"badge in AgentPanelAcceptance Criteria
/api/execute-primitiveendpoint routing through ConnectionRegistry by connectionIdexecutePrimitiveutility +onExecutewired through component treeonExecuteprovided; in-form Run button enabled when required inputs filledsource:manual(visually distinct via badge)isStreamingprop removedconnectionId(selectedPrimitive.serverId) passed throughexecutePrimitiveto/api/execute-primitiveExecutionResultshapesource:manualTest plan
pnpm -C packages/inspector test— 1621 tests should pass🤖 Generated with Claude Code