Architecture

System design and structure of the MCP Lens application.

Overview

MCP Lens is a full-stack application with a Python/FastAPI backend and React/Vite frontend. The backend provides a REST API for managing MCP server connections, fetching tool definitions, and running multi-layer evaluations. The frontend delivers an interactive UI for browsing tools, viewing reports, and configuring servers.

Directory Structure

src/
  app/
    eval/            # Evaluation engine
      protocol.py    # Layer 1: MCP spec compliance
      quality.py     # Layer 2: Tool quality & overlap detection
      security.py    # Layer 3: Security analysis
      llm_eval.py    # Layer 4: LLM-assisted evaluation
      scoring.py     # Scoring & gate logic
      runner.py      # Orchestrates all layers
      model_adapter.py # LLM provider adapters
      llm_config.py  # Multi-LLM config loader (llm.json)
      regression.py  # Report comparison
    routes/
      servers.py     # CRUD endpoints for server configs
      tools.py       # Tool fetch, evaluation, false positives
      auth_routes.py # OAuth/DCR flows, token management
    database.py      # SQLAlchemy async models
    mcp_client.py    # MCP protocol client (JSON-RPC 2.0)
    auth.py          # OAuth token management, DCR
    config.py        # Configuration loader
  frontend/          # React + Vite + Tailwind UI
    src/
      components/
        ServerList.tsx      # Server cards
        ServerForm.tsx      # Add/edit server modal
        ToolsViewer.tsx     # Tool list + evaluation tabs
        EvaluationView.tsx  # Evaluation report
        ComparisonView.tsx  # Report comparison
        DownloadModal.tsx   # Export options
        LlmEvalModal.tsx   # LLM eval config
        AboutPage.tsx      # Evaluation rules reference
      api.ts              # API client
      types.ts            # TypeScript interfaces
tests/
  eval/               # Evaluation engine tests (531+)
llm.json.example      # Multi-LLM config template

Backend

Frontend

Architecture Diagram

Browser :5173 Frontend React + Vite Tailwind CSS ServerList EvaluationView ToolsViewer REST API Backend FastAPI :5002 Routes (servers, tools, auth) MCP Client (JSON-RPC) Eval: Protocol Eval: Quality Eval: Security Eval: LLM Scoring & Gating Auth (OAuth, DCR, Token) SQLite servers, tools, reports MCP MCP Servers Jira, GitHub, Slack ... Streamable HTTP / SSE API LLM Providers Gemini, Claude, GPT via llm.json config

Data Flow

1

Add Server

User adds MCP server via UI → stored in SQLite

2

Fetch Tools

User clicks "Fetch Tools" → backend connects via MCP client → tools cached in DB

3

Run Evaluation

4 layers execute sequentially → scored report saved to database

4

LLM Evaluation (optional)

Runs in parallel across selected models → merged into report

5

View & Export

Results displayed in UI → exportable as JSON/YAML/PDF

Security