This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
CCO-MCP (Claude Code Oversight - Model Context Protocol) is a comprehensive audit and approval system for Claude Code tool calls. It consists of:
- A Node.js/TypeScript MCP server backend with Express REST API
- A React/TypeScript web dashboard UI
- Real-time updates via Server-Sent Events (SSE)
- Rule-based approval configuration system
# Build everything (backend + UI)
just build-all
# or
pnpm build:all
# Build backend only
just build
# or
pnpm build
# Build UI only
just build-ui
# or
pnpm build:ui
# Watch mode for backend
just build-watch
# or
pnpm build:watch# Run both backend and UI in development mode
just dev-all
# or
pnpm dev:all
# Run backend only
just dev
# or
pnpm dev
# Run UI only
just dev-ui
# or
pnpm dev:ui
# Inspect MCP server
just inspect
# or
pnpm inspect# Format code
just format
# or
pnpm format
# Check formatting
just format-check
# or
pnpm format:check
# Lint
just lint
# or
pnpm lint# Run tests (currently echoes no tests configured)
just test
# or
pnpm test
# E2E tests with recording options
just e2e-test # Without recording
just e2e-test-browser # Browser recording only
just e2e-test-terminal # Terminal recording only
just e2e-test-full # Both recordingsThe backend follows a modular architecture:
-
MCP Integration (
src/server.ts)- Implements the MCP server with
approval_prompttool - Handles polling mechanism for approval/denial
- Integrates with the audit service
- Implements the MCP server with
-
Express API (
src/app.ts)- REST endpoints for audit logs and configuration
- SSE endpoint for real-time updates
- Static file serving for UI in production
-
Audit Service (
src/audit/)- In-memory LRU cache with TTL support
- Event-driven architecture using EventEmitter
- Handles state transitions (NEEDS_REVIEW → APPROVED/DENIED)
-
Configuration Service (
src/services/ConfigurationService.ts)- Rule-based approval system with priority ordering
- Supports built-in tools and MCP server tools
- Hot-reload configuration with file watcher
- Tool matching logic for both types:
- Built-in: Direct tool name matching
- MCP: Format
mcp__serverName__toolName
-
Type System (
src/config/types.ts)- ToolMatch discriminated union:
type ToolMatch = BuiltInToolMatch | MCPToolMatch;
- Zod schemas for validation (
src/config/schema.ts)
- ToolMatch discriminated union:
The React UI uses modern patterns:
-
Real-time Updates (
src/contexts/SSEContext.tsx)- Server-Sent Events integration
- Automatic reconnection with exponential backoff
- Global SSE state management
-
Page Structure
/dashboard- Main audit log view (src/AppFinal.tsx)/config- Configuration management (src/pages/Configuration.tsx)
-
Component Organization
components/config/- Rule management componentscomponents/ui/- Reusable UI primitivescomponents/layout/- Header/footer components
-
State Management
- Custom hooks for API calls (
src/hooks/) - React Context for SSE connection
- Local state for UI interactions
- Custom hooks for API calls (
-
Styling
- Tailwind CSS with Blueprint-inspired theme
- Dark mode support
- CSS custom properties for theming
-
Tool Call Flow:
Claude Code → MCP approval_prompt → Audit Service → Express API → UI -
Configuration Updates:
UI → REST API → ConfigurationService → File System → Hot Reload -
Real-time Updates:
Audit Service Events → SSE Stream → React Context → UI Components
The new ToolMatch format distinguishes between tool types:
// Built-in tool
{
"tool": {
"type": "builtin",
"toolName": "Read"
}
}
// MCP server tool
{
"tool": {
"type": "mcp",
"serverName": "git",
"toolName": "git_status" // Optional
}
}-
Adding New Tools: Update the tool matching logic in
ConfigurationService.matchesTool() -
UI Components: Follow the existing pattern in
components/ui/for new components -
API Endpoints: Add routes in
src/routes/and update the router insrc/app.ts -
Configuration Changes: Update both types (
src/config/types.ts) and schemas (src/config/schema.ts) -
Build Process: The backend build copies UI dist files automatically via
tsup.config.ts
PORT- Server port (default: 8660)CCO_CONFIG_PATH- Configuration file path (default: ~/.cco-mcp/config.json)
- Build everything:
just build-all - The backend serves the UI from
/dist/ui - Run with:
just prodorpnpm prod - Docker support available via
docker-compose.yml