Skip to main content
Glama
TsComplexityMcp

TsComplexityMcp

by JohnMarzulli

TsComplexityMcp

TsComplexityMcp is an MCP server. It calculates the complexity of one TypeScript function.

Use this server to prevent code that is too complex.

This server is an MCP interface for the tsmetrics-core package by Tamas Kiss: https://github.com/kisstkondoros/tsmetrics-core.

Adding a rule in your AGENTS.md file to limit complexity to 12 or lower. Ask your LLM to reduce complexity.

alt text

Installation

Requirements

  • TypeScript.

  • Node.js version 20 or higher.

  • npm.

  • Git.

Install the server

  1. Examine the Node.js version. Enter this command:

    node --version

    Make sure that the version is 20 or higher.

  2. Clone the repository. Enter this command:

    git clone https://github.com/JohnMarzulli/TsComplexityMcp.git
  3. Go to the repository directory. Enter this command:

    cd TsComplexityMcp
  4. Install the dependencies. Enter this command:

    npm install
  5. Build the server. Enter this command:

    npm run build
  6. Do the tests. Enter this command:

    npm test

    Make sure that no tests fail.

Add the server to an MCP client

  1. Find the full path of the server file. Enter this command in the repository directory:

    echo "$PWD/dist/server.js"
  2. Open the MCP configuration file of your MCP client.

  3. Add the server to the configuration file. Use the full path from step 1.

    For Visual Studio Code, use the file ~/.config/Code/User/mcp.json:

    {
      "servers": {
        "ts-complexity": {
          "type": "stdio",
          "command": "node",
          "args": ["</full/path/to>/TsComplexityMcp/dist/server.js"]
        }
      }
    }

    For MCP clients that use the mcpServers key, use this example:

    {
      "mcpServers": {
        "ts-complexity": {
          "command": "node",
          "args": ["</full/path/to>/TsComplexityMcp/dist/server.js"]
        }
      }
    }
  4. Save the configuration file.

  5. Start the server. In Visual Studio Code, do these steps:

    1. Open the Command Palette.

    2. Select MCP: List Servers.

    3. Select ts-complexity.

    4. Select Start Server.

  6. Make sure that the tool analyze_typescript_complexity is in the list of tools.

NOTE: The MCP client starts the server process. Do not start dist/server.js in a terminal.

Available Tools

1 tool
analyze_typescript_complexityA

Scores the complexity of a single TypeScript function with tsmetrics-core. Returns JSON { total, details: [{ startLine, endLine, complexity, description }] }; lines are 1-based within the snippet.

Inputs: code (required).

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 1 tool

    Disambiguation5/5

    There is only one tool, so there is no possibility of confusing it with another. Its purpose—scoring the complexity of a single TypeScript function—is stated unambiguously in the name and description.

    Naming Consistency5/5

    The single name analyze_typescript_complexity follows a clear verb_noun convention in snake_case with a descriptive qualifier. With only one tool there is no opportunity for inconsistency, and the format is readable and predictable.

    Tool Count3/5

    The server appears to be a narrowly scoped complexity analyzer, so a small surface is defensible, but one tool is thin for a useful MCP surface. Adding batch or file-level analysis variants would round it out without bloating it.

    Completeness3/5

    The surface covers snippet-level function complexity only; there is no way to analyze a whole file, a directory, or multiple functions in one call, which are natural extensions of the stated domain. Agents working on real codebases will hit a dead end after the single-function case.

    Related MCP Connectors

    Related MCP Servers