Skip to main content
Glama
JohnMarzulli

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.

NameRequiredDescriptionDefault
codeYesSource of exactly one TypeScript function.

TDQS

A3.7/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations exist, so the description carries the full disclosure burden. It does useful work by specifying the return payload shape and the 1-based, snippet-relative line numbering, but says nothing about failure modes, unsupported syntax, or size limits — significant gaps for an unannotated tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two tight sentences with zero filler; the primary purpose leads, and the return contract follows immediately. Every clause carries information an agent would otherwise have to infer.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Because no output schema exists, the description rightly documents the return object and line-numbering convention, which is the highest-value missing structured data. Error handling and metric definition remain unspecified, but for a single-input pure computation this is close to sufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Single parameter with 100% schema coverage, so baseline is 4. The description reinforces the schema's key constraint ('exactly one TypeScript function') rather than repeating it blindly, though it adds no syntax or format detail beyond that.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Names a specific verb and resource ('Scores the complexity of a single TypeScript function') and identifies the underlying engine (tsmetrics-core). The only residual vagueness is which complexity metric is produced, but the scope is unambiguous and there are no siblings to confuse.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is implied by the scope: feed it exactly one function's source. It never states when to reach for this versus other analysis approaches, nor what happens with invalid TypeScript or multi-function input. With no siblings the omission is tolerable but the guidance is only inferred.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

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

  1. 1 tool updatev0.1.0
    • First observedanalyze_typescript_complexity

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.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers