Skip to main content
Glama
MCP Server Codebase Analyzer

MCP Server Codebase Analyzer

by kushalsai-01

MCP Server Codebase Analyzer

A production-grade MCP (Model Context Protocol) server that analyzes TypeScript codebases, detects code health issues, fetches system incidents, and generates actionable remediation plans. Supports dual transport (STDIO for local dev, SSE for cloud deployment). Built with ts-morph, Express, and Zod validation.


πŸš€ Features

Three Core Tools:

  1. analyze_codebase_health β€” Scans TypeScript repositories for:

    • Large files (potential refactoring candidates)

    • Missing explicit function types (weak typing)

    • Circular dependencies (architectural issues)

    • Uses ts-morph for AST-level analysis

  2. fetch_system_incidents β€” Returns structured incident data:

    • Mock incident data (perfect for testing/demos)

    • Configurable delays and failure modes

    • LLM-friendly JSON responses

  3. generate_remediation_plan β€” Creates actionable fix plans:

    • Root cause analysis from stack traces

    • Step-by-step remediation steps

    • Code suggestions and best practices

    • Risk level assessment

All tools return structured success/error envelopes designed for LLM consumption.

Related MCP server: butter-code-health

Architecture Overview

flowchart LR
    Client[McpClient] --> Runtime[RuntimeSelector]
    Runtime -->|stdio| Stdio[StdioTransportAdapter]
    Runtime -->|sse| Sse[SseTransportAdapter]
    Stdio --> Server[McpServer]
    Sse --> Server
    Server --> Registry[ToolRegistry]
    Registry --> ToolA[analyze_codebase_health]
    Registry --> ToolB[fetch_system_incidents]
    Registry --> ToolC[generate_remediation_plan]

Local Run (STDIO)

  1. Install dependencies:

    • npm install

  2. Start server:

    • npm run dev:stdio

  3. The server starts over stdin/stdout and is ready for local MCP clients.

Run with SSE (Express)

  1. Set environment:

    • TRANSPORT=sse

    • optional: AUTH_TOKEN=your-secret-token

  2. Start server:

    • npm run dev:sse

  3. Endpoints:

    • GET /events for SSE stream

    • POST /messages?sessionId=... for MCP JSON-RPC messages

Connect From Cursor

For local usage, register Nexus-Core as a stdio MCP server:

  • command: node

  • args: dist/index.js (after build) or tsx src/index.ts (dev)

  • env: TRANSPORT=stdio

For hosted usage, configure your MCP client to use the SSE endpoint:

  • stream URL: https://<host>/events

  • message URL: https://<host>/messages?sessionId=<session-id>

  • add Authorization: Bearer <AUTH_TOKEN> if token auth is enabled.

Example Prompts

  • "Analyze my repo"

  • "Fetch incidents"

  • "Fix this error"

Environment Variables

See .env.example for all supported settings. Important controls:

  • TRANSPORT: stdio or sse

  • TOOL_TIMEOUT_MS: hard timeout for each tool call

  • TS_MORPH_MAX_FILES, TS_MORPH_MAX_DEPTH: analysis guardrails

  • INCIDENT_API_TIMEOUT_MS, INCIDENT_API_RETRIES: external dependency controls

  • SSE_HEARTBEAT_MS, SSE_SESSION_TTL_MS: SSE session lifecycle

Production Deployment

Docker

  • Build image: docker build -t nexus-core .

  • Run container:

    • docker run -e TRANSPORT=sse -e PORT=8080 -p 8080:8080 nexus-core

Cloud Run

Use deploy.sh:

PROJECT_ID=<gcp-project> REGION=<region> SERVICE=nexus-core ./deploy.sh

This script:

  1. Builds container image

  2. Pushes to GCR

  3. Deploys to Cloud Run

Reliability and Error Model

  • All tool requests are validated with Zod.

  • No tool execution returns unhandled exceptions.

  • Errors use a standard envelope with:

    • code

    • message

    • retryable

    • suggestedAction

    • meta (requestId, toolName, timing)

Available Tools

3 tools
analyze_codebase_healthC

Analyzes repository health using ts-morph and reports large files, missing function types, and potential circular dependencies.

Inputs: maxFiles, repoPath, excludeGlobs, includeGlobs. Returns: issues, summary

fetch_system_incidentsC

Fetches incident telemetry from a mock external API, including realistic stack traces and failure simulation controls.

Inputs: limit, delayMs, service, failRate. Returns: incidents

generate_remediation_planB

Generates deterministic root-cause analysis and actionable remediation steps from an incident payload and source file content.

Inputs: incident (required), fileContent (required). Returns: fixSteps, riskLevel, rootCause, codeSuggestions

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 3 tools

    Disambiguation4/5

    The three tools occupy distinct stages of an incident-response workflow: static health scanning, incident retrieval, and remediation synthesis. There is mild conceptual overlap between analyze_codebase_health and generate_remediation_plan since both reason about source code, but the inputs (repo vs. incident payload + file content) and outputs (health report vs. remediation steps) make the boundary clear enough.

    Naming Consistency5/5

    All three names follow a strict verb_noun snake_case pattern (analyze_codebase_health, fetch_system_incidents, generate_remediation_plan) with unambiguous verbs indicating the action. No stylistic mixing or vague verbs.

    Tool Count3/5

    Three tools is thin for a server billed as a codebase analyzer; a user expecting exploration or querying will find only one analysis entry point. Each tool is substantive rather than trivial, but the surface feels narrow for the stated scope.

    Completeness3/5

    The pipeline has a notable gap: generate_remediation_plan requires source file content as input, yet no tool lists, reads, or locates files in the repository, so an agent must supply that content from outside the server. Incident handling also lacks any query/filter or status-update operations, leaving the lifecycle incomplete.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      Enables AI coding agents to interact with TypeScript projects through compiler-level code intelligence, providing tools for navigation, type information, diagnostics, refactoring, and semantic search.
      29
      152 npm
      5
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to analyze code health in TypeScript/JavaScript projects, providing tools to run analysis, start a dashboard, and get summaries.
      8 npm
      3
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Analyzes codebases to produce structured quality health reports with risk-scored modules based on git churn, test coverage, and test-to-source mapping, acting as an MCP server for AI coding agents and a standalone CLI.
      MIT
    • F
      license
      Not graded
      quality
      B
      maintenance
      Enables AI coding agents to query a live, type-aware, intent-aware cross-repo index of an organization's TypeScript services, answering semantic questions about functions, endpoints, types, and behavior across repositories. It also supports validation of cross-repo API mismatches and same-repo checks.
      6
      -