TsComplexityMcp
Analyzes TypeScript functions to calculate their complexity, allowing agents to detect and reduce overly complex functions (e.g. keeping complexity at or below a set threshold such as 12).
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@TsComplexityMcpWhat's the complexity of this function? function f(x){if(x)return 1;return 0;}"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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.

Installation
Requirements
TypeScript.
Node.js version 20 or higher.
npm.
Git.
Install the server
Examine the Node.js version. Enter this command:
node --versionMake sure that the version is 20 or higher.
Clone the repository. Enter this command:
git clone https://github.com/JohnMarzulli/TsComplexityMcp.gitGo to the repository directory. Enter this command:
cd TsComplexityMcpInstall the dependencies. Enter this command:
npm installBuild the server. Enter this command:
npm run buildDo the tests. Enter this command:
npm testMake sure that no tests fail.
Add the server to an MCP client
Find the full path of the server file. Enter this command in the repository directory:
echo "$PWD/dist/server.js"Open the MCP configuration file of your MCP client.
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
mcpServerskey, use this example:{ "mcpServers": { "ts-complexity": { "command": "node", "args": ["</full/path/to>/TsComplexityMcp/dist/server.js"] } } }Save the configuration file.
Start the server. In Visual Studio Code, do these steps:
Open the Command Palette.
Select MCP: List Servers.
Select ts-complexity.
Select Start Server.
Make sure that the tool
analyze_typescript_complexityis 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 toolanalyze_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.
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Source of exactly one TypeScript function. |
TDQS
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.
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.
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.
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.
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.
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 tool update
v0.1.0- First observed
analyze_typescript_complexity
TDQS
Scored across 1 tool
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.
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.
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.
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
Related MCP Connectors
Stateless TS/JS compiler facts for agents: references, imports, impact. No repo index or OAuth.
Coding agents in multi-service codebases routinely rebuild existing helpers, trust stale type definitions, and modify API contracts without knowing who consumes them. Carrick solves this by indexing your entire TypeScript ecosystem across service and repository boundaries. By integrating deeply with the TypeScript compiler, Carrick traces every route, type, and cross-service call while recording function behaviour so agents search by intent rather than name. Delivered via MCP for AI agents and LSP for IDEs, Carrick ensures models see existing endpoints and utilities before generating new code. The scanner is source-available and runs from your CLI or CI pipeline.
A TypeScript MCP server for Home Assistant, enabling programmatic management of entities, automati…
AI-powered codebase analysis — call graphs, security, dead code, complexity. 150+ tools.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceAn MCP server for static Big-O time complexity analysis using tree-sitter AST parsing. Supports JavaScript, TypeScript, Python, Java, Kotlin, and Dart.3MIT
- AlicenseNot gradedqualityCmaintenanceAST-aware TypeScript/JavaScript codebase exploration for AI agents, providing high-precision symbol resolution, reference finding, and structural analysis via MCP tools.205 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables to extract TypeScript methods, functions, and their relevant imports and class properties for code analysis, refactoring, and documentation.MIT
- AlicenseAqualityDmaintenanceProvides deep structural analysis of TypeScript and JavaScript code via the TypeScript Compiler API, offering 20 tools for functions, types, call graphs, code quality, dead code detection, and IDE integration.20280 npmMIT