CXA MCP Server

CXA MCP Server

Enables MCP-compatible agents to run real browser-based performance scans on any URL and receive a rich Markdown dashboard with Core Web Vitals, grades, and actionable recommendations.

Category
访问服务器

README

CXA MCP Server

Model Context Protocol server for CX Assurance – exposes an AI-accessible performance tool that lets any MCP-compatible agent (GitHub Copilot, Claude, Cursor, etc.) run real browser-based performance scans and receive a rich dashboard report.


Table of Contents

  1. Overview
  2. Architecture
  3. Project Structure
  4. Available Tools
  5. Getting Started
  6. Configuration
  7. Running the Server
  8. Testing
  9. Adding New Tool Categories
  10. MCP Client Configuration
  11. Logging
  12. Sample Performance Payload

Overview

The CXA MCP Server is a self-contained performance scanning engine powered by Puppeteer.
An agent can ask "Run a performance scan on https://example.com" and receive a rich Markdown dashboard covering:

  • Core Web Vitals – Load time, Speed Index (fixed – never negative), TTFB, FCP, DOM Content Loaded, Transfer Size
  • Performance grades – A+ through F per Web Vitals thresholds
  • Visual load bars – ASCII progress bars for quick visual comparison
  • Omni-channel results – Real load times across 6 browser/device profiles with per-profile grades
  • Mobile vs Desktop comparison – Average load time delta and % slower
  • Actionable recommendations – Targeted suggestions based on actual metric values

Scope: Performance only. Accessibility, SEO, and security data are intentionally excluded from this tool. No external API is called – all scanning is done locally with a real Chromium browser.


Architecture

Agent (Copilot / Claude / Cursor …)
        │
        │  JSON-RPC 2.0 (stdio)
        ▼
┌─────────────────────────────┐
│      MCP Server (stdio)      │
│  src/server.js               │
│                              │
│  ┌──────────────────────┐   │
│  │  Tool Registry        │   │  ← src/tools/index.js
│  │  performanceTool.js   │   │  ← src/tools/performanceTool.js
│  └──────────┬───────────┘   │
│             │                │
│  ┌──────────▼───────────┐   │
│  │  Service Layer        │   │  ← src/services/performanceService.js
│  └──────────┬───────────┘   │
│             │  orchestrates  │
│  ┌──────────▼───────────┐   │
│  │  Scanners             │   │  ← loadTimeScanner + performanceScanner only
│  └──────────┬───────────┘   │
│             │                │
│  ┌──────────▼───────────┐   │
│  │  Browser Runner       │   │  ← Puppeteer / Chromium
│  └──────────────────────┘   │
└─────────────────────────────┘
              │  headless Chromium
              ▼
       Target Web Page

Key design decisions:

Concern Decision
Transport stdio – required by the MCP spec for local server ↔ agent communication
Logging Always stderr – stdout is reserved for the JSON-RPC transport
Tool isolation Each domain (performance, accessibility …) lives in its own file
No external HTTP library Node ≥ 18 native fetch – keeps the dependency list minimal
Error handling All tool handlers return structured error text instead of throwing, so the agent always receives a readable response
Scope Performance-only – accessibility, SEO, security scanners exist but are not wired into cxa_scan_performance

Project Structure

mcp-cxa/
├── .env.example                   # Environment variable template
├── .gitignore
├── package.json
├── README.md                      # ← you are here
│
├── performance-samples/           # Reference data & API docs
│   ├── performance_result.json
│   └── performance-details.md
│
├── src/
│   ├── server.js                  # Entry point – bootstraps MCP server
│   ├── config/
│   │   └── index.js               # Centralised config (env-driven)
│   ├── tools/
│   │   ├── index.js               # Central tool registry
│   │   └── performanceTool.js     # Performance MCP tool definitions
│   ├── services/
│   │   └── performanceService.js  # Business logic / API calls
│   └── utils/
│       ├── logger.js              # Structured stderr logger
│       ├── httpClient.js          # fetch wrapper with timeout & error handling
│       └── formatters.js          # Raw payload → Markdown report
│
└── tests/
    ├── config/
    │   └── index.test.js
    ├── services/
    │   └── performanceService.test.js
    └── utils/
        ├── formatters.test.js
        └── logger.test.js

Available Tools

cxa_scan_performance

Runs a real browser-based performance scan for any URL and returns a rich Markdown dashboard.

Parameter Type Required Default Description
url string Fully-qualified URL to scan
region string Local Label stamped on the report

Returns: Rich Markdown performance dashboard including:

  • Score card with grades (A+–F) for load time, TTFB, FCP
  • ASCII visual load bars
  • Omni-channel table (6 profiles: Chrome, Edge, Firefox, Safari, Android Chrome, iOS Safari)
  • Mobile vs Desktop comparison
  • Actionable recommendations

Note: Accessibility, SEO, and security are not included in this tool's output.


Getting Started

Prerequisites

  • Node.js ≥ 18.0.0 (for native fetch and --test runner)
  • Chromium / Puppeteer (installed automatically via npm install)

Install

cd mcp-cxa
npm install

Configure

cp .env.example .env
# Edit .env if needed – no API key required

Configuration

All configuration is read from environment variables (see .env.example):

Variable Default Description
CXA_SCAN_TIMEOUT_MS 30000 Page load timeout per profile (ms)
CXA_HEADLESS true Set false to watch Chromium during dev
CXA_DEFAULT_REGION Local Region label stamped on results
CXA_LOG_LEVEL info debug / info / warn / error

No CXA_API_BASE_URL or CXA_API_TOKEN are needed – all scanning is self-contained.


Running the Server

# Production
npm start

# Development (auto-restart on file change – Node ≥ 18.11)
npm run dev

Note: The server communicates over stdio. You should not see any output on stdout; all log lines appear on stderr as newline-delimited JSON.


Testing

Tests use Node's built-in test runner (node:test) – no additional test framework required.

# Run all tests once
npm test

# Run tests in watch mode
npm run test:watch

Test coverage by module

Module Test file
src/config/index.js tests/config/index.test.js
src/utils/logger.js tests/utils/logger.test.js
src/utils/formatters.js tests/utils/formatters.test.js
src/services/performanceService.js tests/services/performanceService.test.js

The HTTP client and MCP tool wiring are tested indirectly through the service tests (the HTTP client is stubbed so no real network calls are made).


Adding New Tool Categories

The server is designed to grow. To add, say, an Accessibility tool:

  1. Create the service

    src/services/accessibilityService.js
    

    Export getAccessibilitySummary(projectId) and any other methods.

  2. Create the tool file

    src/tools/accessibilityTool.js
    

    Export registerAccessibilityTools(server) following the same pattern as performanceTool.js.

  3. Register it in the central registry

    // src/tools/index.js
    const { registerAccessibilityTools } = require('./accessibilityTool');
    // ...
    function registerAllTools(server) {
      registerPerformanceTools(server);
      registerAccessibilityTools(server);   // ← add this line
    }
    
  4. Add a formatter (optional) in src/utils/formatters.js.

  5. Write tests under tests/services/ and tests/utils/.


MCP Client Configuration

VS Code (GitHub Copilot)

Add the following to your VS Code settings.json or .vscode/mcp.json:

{
  "servers": {
    "cxa-mcp": {
      "type": "stdio",
      "command": "node",
      "args": ["${workspaceFolder}/mcp-cxa/src/server.js"],
      "env": {
        "CXA_LOG_LEVEL": "info"
      }
    }
  }
}

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "cxa-mcp": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-cxa/src/server.js"],
      "env": {
        "CXA_LOG_LEVEL": "info"
      }
    }
  }
}

Logging

All log entries are written to stderr as newline-delimited JSON:

{"timestamp":"2026-03-13T06:27:31.123Z","level":"INFO","message":"CXA MCP Server is running – listening on stdio"}
{"timestamp":"2026-03-13T06:27:32.456Z","level":"INFO","message":"Tool invoked: cxa_scan_performance","meta":{"url":"https://example.com","region":"Local"}}

Set CXA_LOG_LEVEL=debug to see every browser navigation event.


Sample Performance Payload

The backend returns a JSON object of the following shape (see performance-samples/performance_result.json):

{
  "url": "https://www.sammonsfinancialgroup.com/",
  "executionId": "464a1bd3-45c8-4390-a31a-5ef779e81ca1",
  "timestamp": "2026-03-13T06:27:31.820822Z",
  "browser": "Chrome",
  "region": "Virginia",
  "speedIndex": "0.02 s",
  "uiux": "",
  "sustainabilityScore": "",
  "accessibility": "",
  "seoScore": "",
  "security": "",
  "omniChannel": [
    { "Browser": "Windows 11 - Chrome", "loadTime": 1229, "version": "125" },
    { "Browser": "Android 14 - Chrome", "loadTime": 2058, "version": "14"  }
  ]
}

The formatter converts this into a structured Markdown table report that agents can render or summarise for end users.


API Endpoint Reference

Method Path Description
GET /test/reports/getSummaryDetails?projectId=<id> Fetch latest scan summary
POST /test/scan/trigger Trigger a new scan (extend when live)

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选