@reaatech/mcp-server-doctor-core
Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.
Core types, utilities, grading benchmarks, and constants for MCP server diagnostics. This package is the single source of truth for all domain shapes used throughout the @reaatech/mcp-server-doctor-* ecosystem.
Installation
npm install @reaatech/mcp-server-doctor-core
# or
pnpm add @reaatech/mcp-server-doctor-core
Feature Overview
Domain types — DiagnosticReport, CheckResult, DiagnosticOptions, LatencyMetrics, and more
Zod schemas — runtime validation for diagnostic reports and domain objects
Grading system — A–F grade computation with configurable latency, error-rate, concurrency, and payload thresholds
Utility functions — generateUUID, percentile, calculateStats, retry, sleep, URL sanitization, and more
Version resolution — programmatic version access from package.json
Zero runtime dependencies beyond zod — lightweight and tree-shakeable
Dual ESM/CJS output — works with import and require
Quick Start
import {
type CheckResult,
type DiagnosticReport,
CheckCategory,
Severity,
gradeCompliance,
gradeLatency,
generateUUID,
calculateStats,
} from "@reaatech/mcp-server-doctor-core" ;
// Grade a check by warning count
const grade = gradeCompliance ( true , 2 ); // → "B"
// Grade raw latency (p99 in ms)
const latencyGrade = gradeLatency ( 4200 ); // → "B"
// Compute percentile stats from raw samples
const stats = calculateStats ([ 100 , 200 , 150 , 300 , 250 ]);
console. log (stats.p99); // → 300
Exports
Types
Export Description CheckResultSingle diagnostic check outcome (name, category, grade, message, metrics, remediation) DiagnosticReportFull diagnostic report (id, endpoint, overallGrade, checks[], tools[], latency) DiagnosticOptionsConfiguration for a diagnostic run (transport, auth, timeout, concurrency) DiagnosticContextRuntime context passed to each check (endpoint, options, requestId) ToolDefinitionMCP tool descriptor (name, description, inputSchema) LatencyMetricsPercentile statistics (p50, p90, p99, min, max, mean, samples) ToolLatencyMetricsPer-tool latency breakdown (toolName, latency, samples)
Enums
Export Description CheckCategoryTRANSPORT, SCHEMA, LATENCY, AUTH, PAYLOAD, ERROR_FORMAT, TIMEOUT, CONCURRENCYSeverityCRITICAL, WARNING, INFOGradeA | B | C | D | F
Grading
Export Description gradeCompliance(passed, warnings)Grade A–F by warning count (0→A, 1-2→B, 3-5→C, 6-9→D, 10+→F) gradeLatency(p99Ms)Grade by p99 latency (≤1s→A, ≤3s→B, ≤5s→C, ≤10s→D, >10s→F) gradeErrorRate(rate)Grade by error rate (≤1%→A, ≤5%→B, ≤10%→C, ≤20%→D, >20%→F) gradeConcurrency(maxConcurrent)Grade by concurrent capacity (≥50→A, ≥25→B, ≥10→C, ≥5→D, <5→F) gradePayload(bytes)Grade by max payload (≥5MB→A, ≥1MB→B, ≥500KB→C, ≥100KB→D, <100KB→F) worstGrade(...grades)Returns the lowest (worst) grade from a set computeOverallGrade({checks, latency})Composite grade across all checks + raw latency gradeToNumber(grade)Convert A→4, B→3, …, F→0
Utilities
Export Description generateUUID()Generate a v4 UUID now()Current ISO 8601 timestamp measureTimeAsync(fn)Execute fn and return { result, durationMs } sleep(ms)Promise-based delay retry(fn, options)Retry with exponential backoff percentile(sortedValues, p)Compute p-th percentile (0–100) calculateStats(values)Full stats object: p50, p90, p99, min, max, mean, samples isValidURL(str)Check if string is a parseable URL isPrivateURL(str)Detect localhost / private IP ranges sanitizeUrl(str)Redact query params / credentials from URL for logging
Constants
Export Value Description MCP_PROTOCOL_VERSION2024-11-05Advertised protocol version DEFAULT_TIMEOUT_MS30000Default request timeout DEFAULT_CONCURRENCY10Default concurrency level CONCURRENCY_LEVELS[5, 10, 25, 50]Stress-test concurrency levels WARMUP_ROUNDS3Latency warmup rounds MEASUREMENT_ROUNDS20Latency measurement rounds MIN_PAYLOAD_BYTES1024Binary search lower bound MAX_PAYLOAD_BYTES5242880Binary search upper bound (5 MB)
Related Packages
License
MIT