Skip to content

Conversation

@backnotprop
Copy link
Contributor

This pull request represents a comprehensive frontend modernization of MCP Guardian, focusing on user experience improvements, technical debt reduction, and enterprise-grade polish.

It also includes a formal schema package for policy json

Key Changes

Monaco Editor Integration

  • Migrated from basic textarea inputs to Monaco Editor (VS Code's editor engine)
  • Implemented real-time JSON schema validation with IntelliSense support
  • Added custom cyberpunk-themed syntax highlighting for dark and light modes
  • Integrated auto-generated JSON schemas from Rust type definitions

Component Architecture Modernization

  • Complete migration from custom CSS components to Radix UI primitives
  • Implemented Tailwind CSS v4 with utility-first approach
  • Established consistent design system with cyberpunk aesthetic optimized for security professionals
  • Added comprehensive accessibility support (screen readers, keyboard navigation)

JSON Schema System

  • Created automated pipeline: Rust types → TypeScript bindings → JSON schemas
  • Implemented mcp-guardian-schema crate for schema generation
  • Real-time validation in all JSON editing contexts
  • Eliminated configuration errors through type-safe validation

Navigation and Layout Improvements

  • Replaced accordion-style entity management with modern sidebar navigation
  • Added search and filtering capabilities across all entity types
  • Implemented responsive design optimized for desktop workflows
  • Enhanced visual hierarchy and information density

Technical Debt Resolution

  • Standardized file naming conventions (PascalCase → kebab-case)
  • Implemented strict TypeScript configuration with comprehensive type safety
  • Eliminated deprecated dependencies and security vulnerabilities
  • Simplified component state management patterns

Visual Editor Development and Removal

Initial Implementation

The branch initially included development of a comprehensive visual editor for guard profiles using React Flow:

  • 16 custom node components for different interceptor types
  • Bidirectional conversion between JSON configuration and visual representation
  • Complex state management for node positioning and data synchronization
  • In-node configuration with expandable UI elements

Strategic Removal

After extensive development and testing, the visual editor was removed due to:

  • Excessive complexity introducing potential stability issues
  • Maintenance burden outweighing user value
  • Superior user experience provided by enhanced Monaco JSON editor
  • Focus shift toward simplicity and reliability

The removal eliminated 3,140 lines of complex code while maintaining all core functionality through the improved JSON editing experience.

Bundle Size and Performance

  • Removed React Flow dependency reducing bundle size
  • Optimized Monaco Editor integration with custom themes and validation
  • Implemented lazy loading patterns for editor components
  • Improved application startup time and memory usage

Testing and Validation

  • Comprehensive TypeScript compilation validation
  • Rust clippy linting for backend changes
  • Full application build verification
  • Schema validation testing across all entity types

Documentation

  • Created comprehensive component library documentation
  • Established design system guidelines
  • Documented schema generation pipeline
  • Added development workflow documentation

Impact Assessment

Positive Outcomes

  • Professional appearance suitable for enterprise security teams
  • Significantly improved JSON editing experience with real-time validation
  • Consistent, accessible component library
  • Simplified codebase with reduced maintenance burden
  • Type-safe configuration management

Risk Mitigation

  • Extensive testing of Monaco Editor integration
  • Fallback patterns for schema validation failures
  • Comprehensive error handling in JSON parsing
  • Maintained backward compatibility for all configuration formats

Migration Path

This update requires no configuration migration. All existing guard profiles, MCP servers, and server collections remain fully compatible. The improved editing experience enhances existing workflows without breaking changes.

Conclusion

This pull request delivers a modern, professional interface that maintains MCP Guardian's powerful security capabilities while significantly improving the user experience. The focus on JSON-based configuration with enhanced validation provides a robust foundation for future development while eliminating the complexity risks associated with visual editing approaches. Better secure, govern, and optimize your MCP deployments with MCP Guardian today - ramos out.

backnotprop and others added 30 commits April 1, 2025 16:54
Adds technical discovery notes documenting the MCP Guardian project structure, components, functionality, and business context. Documents key technical components: core library, proxy, CLI and desktop application along with UX analysis and business use cases.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Created GOALS.md with distinct objectives for Tauri app and core library
- Added DEVELOPMENT_PLAN.md to track overall development strategy
- Updated CLAUDE.md to reference new planning documents

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Outlines a focused approach to enhance the Tauri application as a demo centerpiece:
- Visual polish (colors, typography, component styling)
- UX refinements (navigation, message visualization, forms)
- Minimal code cleanup (file naming consistency)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Complete redesign of UI with cybersecurity-focused color system
- Added semantic CSS tokens using HSL colors for better maintainability
- Fixed dialog transparency issues for solid backgrounds
- Created comprehensive styling documentation for future development
- Enhanced message visualization with syntax highlighting
- Improved space efficiency for technical users
- Standardized component patterns across the application

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Added implementation status tracking in IMPLEMENTATION_STATUS.md
- Updated Phase 1 progress in PHASE1.md with completed items
- Marked completed visual design goals in GOALS.md
- Updated development plan with current progress

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Removed redundant IMPLEMENTATION_STATUS.md
- Reorganized PHASE1.md with detailed checkbox task list
- Added hierarchical task structure for better tracking
- Included implementation notes and next steps
- Consolidated all phase progress in a single document

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add Tailwind CSS v4 optimization tasks to Phase 1 plan
- Update STYLING_GUIDE.md with Tailwind v4 best practices and configuration
- Create example files for Tailwind v4 implementation
- Document Tailwind v4 features like @config directive and theme functions
- Provide examples of component styling with utility classes

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Update App.css to use Tailwind v4 @config directive
- Replace CSS variables with theme() functions throughout the CSS
- Refactor McpServerComponent to use Tailwind utility classes
- Modernize button styling with utility composition
- Add comments to encourage utility class usage over custom classes

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Update PHASE1.md to track completed Tailwind optimization tasks
- Document implementation progress in STYLING_GUIDE.md
- Add component refactoring approach guidelines
- Record implementation notes for May 18, 2023 milestone
- Update next steps to reflect current status

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Convert GuardProfileComponent to use Tailwind utility classes
- Convert ServerCollectionComponent to use Tailwind utility classes
- Replace custom CSS classes with utility compositions
- Maintain visual consistency while improving maintainability
- Implement consistent button styling across components

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add progress notes for May 20, 2023
- Document additional component refactoring progress
- Track implementation of consistent button styling patterns
- Document reusable patterns for common UI elements

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
…ntax

- Convert @theme directive to use correct CSS variable naming convention
- Replace theme() function calls with standard CSS var() references
- Fix unused imports in component files
- Update documentation with current implementation approach
- Create minimal tailwind.config.js file

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add new task for optimizing CSS by moving to component-level styling
- Update STYLING_GUIDE.md with best practices for component-level styling
- Emphasize that App.css should only contain truly global styles
- Add detailed guidelines for component vs. global styling approach
- Update next steps to prioritize CSS optimization task

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Refactor CreateMcpServerDialog to use Tailwind utilities instead of custom CSS classes
- Convert ToolCall and ToolCallResponse components to use inline Tailwind
- Refactor ConfirmDialog to eliminate dependency on global CSS classes
- Update PHASE1.md with implementation progress and next steps
- Add semantic class organization with helpful code comments

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add new horizontal HeaderNavigation component to replace sidebar
- Update documentation with design vision and tech specs
- Add reference images for the header design implementation
- Remove legacy Tailwind migration examples
- Update package.json with validation scripts

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add explicit instructions to use Tailwind utility classes in components
- Mark CSS optimization tasks as in-progress in PHASE1.md
- Add critical note that App.css should only contain theme variables and global styles
- Update DEVELOPMENT_PLAN.md with CSS optimization approach
- Document best practices for reducing App.css size

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Clarify that App.css should contain reusable UI patterns/components
- Specify that page-specific or niche component styles should use Tailwind utilities
- Emphasize the importance of avoiding style duplication across components
- Maintain a balanced approach between global styles and component-specific styling

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Create PHASE1-INTERJECT.md with comprehensive component library approach
- Integrate Radix UI primitives for accessible component foundations
- Establish component architecture with encapsulated styling
- Define variant-based APIs for consistent patterns across components
- Deprecate previous CSS optimization approach in favor of component library
- Update guidance in CLAUDE.md and DEVELOPMENT_PLAN.md

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Install Radix UI primitives and utility packages
- Create foundational UI components in /components/ui
- Implement Button, Dialog, Card, Badge, Input, FormField, and JSONViewer
- Fix dialog transparency with solid backgrounds
- Add utility functions for className merging
- Create comprehensive usage examples for documentation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Convert CreateMcpServerDialog to use new Dialog, Input, Button components
- Convert ConfirmDialog to use new Dialog and Button components
- Update PHASE1-INTERJECT.md progress
- Simplify component structure with compound pattern

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add Select component using Radix UI Select primitive
- Add Checkbox component using Radix UI Checkbox primitive
- Add Toast component using Radix UI Toast primitive
- Refactor ToolCall and ToolCallResponse to use new JSONViewer
- Simplify message components by leveraging reusable components
- Update progress in PHASE1-INTERJECT.md

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add Tabs component using Radix UI primitives
- Add NavigationMenu component for dropdown navigation
- Add Collapsible component for expandable content
- Add Alert component for notifications and feedback
- Refactor HeaderNavigation to use Badge component
- Update PHASE1-INTERJECT.md to reflect progress

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add Breadcrumb component for navigation hierarchy
- Add ProgressIndicator (linear progress and spinner)
- Add custom animation for progress component
- Update tailwind.config.js with animation configuration
- Update App.css with keyframes and animation variables
- Complete all component tasks in PHASE1-INTERJECT.md

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Complete the migration of all pages and components to use the new UI library
- Fix layout issues in collapsible components
- Improve button visibility with better styling
- Update documentation and backlog accessibility audit and tests

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
backnotprop and others added 28 commits April 2, 2025 20:25
- Add detailed section on visual styling and UX improvements
- Update task completion status for Guard Profile Visual Builder
- Document React Flow integration fixes and dark mode compatibility
- Add new subtasks for validation and tooltip enhancements
- Provide comprehensive progress tracking for middleware mental model implementation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
…rmation

- Added detailed descriptions and key capabilities for each interceptor type
- Improved visual presentation with color-coded and cyberpunk-inspired UI elements
- Added empty state for when no node is selected
- Added log level visualization for message log interceptor
- Enhanced chain interceptor display with execution order

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add expandable UI with toggle button to Filter node
- Implement compact form controls directly within the node
- Create custom event system for propagating node changes
- Convert property panel to documentation-only panel
- Update component documentation to reflect new approach
- Fix node visibility and interaction issues with proper z-index

This implementation provides a more intuitive UX where users configure nodes directly within the flow diagram, reducing context switching and creating a clearer mental model.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add amber tint to node background in dark mode for better contrast
- Increase shadow depth for better visibility
- Use different background colors for selected vs unselected states
- Ensure consistent visibility across light and dark themes

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Set nodesDraggable to true for all nodes
- Hide ReactFlow attribution using proOptions
- Remove unnecessary custom classes and event handling
- Simplify the node implementation to work better with React Flow

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Skip node reinitialization after initial load to preserve positions
- Use deep copies of nodes and edges to prevent reference issues
- Avoid resyncing nodes from profile once the flow is rendered

This minimal change ensures nodes can be dragged without resetting positions while maintaining the original rendering behavior.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Make input and output nodes draggable
- Allow position changes in the handleNodesChange filter
- Prevent only deletion of input/output nodes
- Maintain all node positions after dragging

This change allows users to reposition all nodes including input and output nodes while still preventing accidental deletion of required nodes.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Implement toggle button to collapse/expand the sidebar
- Show minimal interface with icon when sidebar is collapsed
- Add smooth animations for width transitions
- Maintain accessibility with appropriate button labels
- Use primary color for toggle button to align with design system

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Store and restore input/output node positions when changing node types
- Create a position map that tracks all node positions
- Reuse existing positions when reconstructing the graph
- Update node configuration to use draggable=true consistently

This ensures all draggable nodes maintain their positions even when the interceptor type is changed, providing a more consistent user experience.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Update PHASE4.md to reflect new completed features
- Enhance component README with sections on draggable nodes and UI space management
- Update CLAUDE.md with completed and future enhancements sections
- Add comprehensive documentation for all implemented features

This documentation update ensures future developers have clear guidance on the current state of the Guard Profile Builder and the design decisions behind its implementation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Completely redesign sidebar layout using absolute positioning
- Position toggle button entirely outside the sidebar
- Dynamically adjust button position based on sidebar state
- Add spacer element to maintain correct layout flow
- Fix z-index to ensure button is always clickable

This approach ensures the toggle button doesn't overlap or interfere with the sidebar border, providing a cleaner visual appearance while maintaining full functionality.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Move expanded state from the node to parent GuardProfileVisualBuilder
- Scope expanded state to profile+node combinations to handle multiple profiles
- Keep expanded state when updating the log level or switching profiles
- Fix state synchronization between parent and child components

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Make documentation panel collapsed by default
- Change sidebar button text from "EXPAND" to "SEE DOCUMENTATION"
- Change sidebar button text from "COLLAPSE" to "HIDE DOCUMENTATION"

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add namespace and profile_name to dependency array in GuardProfileComponent
- Ensure component state is fully reset when profile identity changes
- Add clarifying comments to improve code readability

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add container-based Chain node visualization to project roadmap
- Create detailed visual concepts for container-based Chain nodes
- Document implementation approach for container-based visualization
- Update component specifications with container node details
- Add task to Phase 4 plan as in-progress work

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Removes entire guard-profile-builder directory and React Flow integration
- Eliminates @xyflow/react dependency for reduced bundle size and complexity
- Simplifies guard-profile-component.tsx to use only Monaco JSON editor
- Removes tab-based switching between visual and JSON views
- Maintains full JSON schema validation and Monaco editor features
- Reduces potential bugs and maintenance overhead

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Remove dual state management (configText + currentGuardProfile)
- Use JSON string as single source of truth - parse only on save
- Eliminate unnecessary state synchronization complexity
- Maintain proper error handling for invalid JSON during save
- Cleaner, simpler component architecture

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Initialize configText with actual profile data instead of empty string
- Prevents Monaco from seeing empty string and defaulting to {}
- Eliminates race condition where Monaco overwrites state before useEffect runs
- Improves Monaco's empty value handling to be less aggressive
- Fixes first-opened guard profile showing empty {} instead of actual JSON

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Remove Shield icon import and usage from header
- Clean up logo section to show only "MCP Guardian" text
- Maintains proper spacing and alignment in header

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@backnotprop backnotprop requested a review from Copilot August 7, 2025 23:43
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request represents a comprehensive frontend modernization of MCP Guardian, focusing on user experience improvements, technical debt reduction, and enterprise-grade polish. The changes include migration from custom CSS to a modern component system based on Radix UI and Tailwind CSS, implementation of Monaco Editor for enhanced JSON editing, and a shift from accordion-style navigation to modern sidebar navigation.

  • Complete component library modernization with Radix UI primitives and cyberpunk theming
  • Migration from basic textarea to Monaco Editor with real-time JSON schema validation
  • Implementation of automated JSON schema generation system from Rust type definitions
  • Navigation overhaul from accordion-style to sidebar-based interface with search and filtering

Reviewed Changes

Copilot reviewed 131 out of 136 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
rename-files.sh / rename-components.sh Scripts for automated PascalCase to kebab-case file renaming
mcp-guardian/src/utils.ts Added utility function for Tailwind class merging
mcp-guardian/src/pages/*.tsx Complete page component rewrites with new sidebar navigation
mcp-guardian/src/main.tsx Added theme provider integration
mcp-guardian/src/components/ui/*.tsx New Radix UI-based component library with cyberpunk theming
mcp-guardian/src/components/*.tsx Updated component implementations using new UI primitives
mcp-guardian/src/components/json-editor/* Monaco Editor integration with JSON schema validation
Comments suppressed due to low confidence (3)

rename-components.sh:87

  • This React.useEffect() call is incorrectly placed outside of a React component. The useEffect hook must be called within a React functional component or custom hook, not in a global script context.
process_directory "$COMPONENTS_DIR/ui" "*.tsx"

mcp-guardian/src/components/json-valid-editor.tsx:16

  • The 'schema' parameter should have a more specific type instead of 'any'. Consider using a proper JSON schema type like 'JSONSchemaType' or at minimum 'object' to provide better type safety.
const JsonEditor: React.FC<JsonEditorProps> = ({

mcp-guardian/src/components/mcp-server-component.tsx:32

  • There is an extra closing parenthesis at the end of this line. The line should end with useState("{}"); instead of useState("{}")); // Initialize with valid empty JSON.
  const [configText, setConfigText] = useState("{}"); // Initialize with valid empty JSON

};
}
}, []);

Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

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

This React.useEffect() call is incorrectly placed at the module level outside of any React component. The useEffect hook can only be used inside React functional components or custom hooks.

Suggested change
// Custom hook to inject cyber select styles
function useCyberSelectStyles() {
React.useEffect(() => {
const styleId = "cyber-select-styles";
if (!document.getElementById(styleId) && typeof document !== 'undefined') {
const styleElement = document.createElement("style");
styleElement.id = styleId;
styleElement.textContent = cyberSelectStyles;
document.head.appendChild(styleElement);
return () => {
const element = document.getElementById(styleId);
if (element) {
document.head.removeChild(element);
}
};
}
}, []);
}

Copilot uses AI. Check for mistakes.
document.head.removeChild(element);
}
};
}
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

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

[nitpick] The cleanup function in useEffect is creating and removing DOM elements, but this pattern can lead to memory leaks if the component unmounts before the cleanup runs. Consider using a ref to track whether the component is still mounted.

Suggested change
}
createdByThisInstance.current = true;
}
return () => {
if (createdByThisInstance.current) {
const element = document.getElementById(styleId);
if (element) {
document.head.removeChild(element);
}
}
};

Copilot uses AI. Check for mistakes.
document.head.removeChild(element);
}
};
}
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

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

[nitpick] Similar to the card component, this cleanup pattern for dynamically injected styles could be improved by tracking component mount state to prevent cleanup after unmount.

Suggested change
}
// Add cyberpunk styles once, and clean up only when last instance unmounts
React.useEffect(() => {
const styleId = "cyber-input-styles";
cyberInputStyleRefCount++;
if (!document.getElementById(styleId)) {
const styleElement = document.createElement("style");
styleElement.id = styleId;
styleElement.textContent = cyberInputStyles;
document.head.appendChild(styleElement);
}
return () => {
cyberInputStyleRefCount--;
if (cyberInputStyleRefCount === 0) {
const element = document.getElementById(styleId);
if (element) {
document.head.removeChild(element);
}
}
};

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants