Code Quality & Metrics Tools (QLTY)
Relevant source files
The following files were used as context for generating this wiki page:
The Code Quality & Metrics Tools (QLTY) module provides a robust suite of Model Context Protocol (MCP) tools designed to automate linting, formatting, and the calculation of technical metrics within the codebase. It acts as a bridge between the qlty CLI and AI agents, allowing for automated code audits and improvements.
Sources: servers/qlty/server.py:1-12, servers/qlty/README.md:1-5
System Architecture
The QLTY system operates as an MCP server that wraps the local qlty binary. It exposes specialized tools for analyzing code quality, identifying "code smells," and applying automated fixes. The architecture follows a wrapper pattern where Python-based MCP handlers translate tool calls into CLI commands executed via subprocesses.
Data Flow and Component Interaction
The following diagram illustrates how a user request for a code quality check flows from the MCP Client through the QLTY Server to the underlying CLI tool.
The QLTY server locates the qlty binary by searching common installation paths such as ~/.qlty/bin/qlty, ~/.local/bin/qlty, and the system PATH.
Sources: servers/qlty/server.py:27-50, servers/qlty/server.py:168-245
Core Tools and Capabilities
The QLTY module provides six primary tools through its MCP interface. These tools allow agents to initialize the environment, list capabilities, and perform deep analysis of the source code.
| Tool Name | Description | Key Parameters |
|---|---|---|
qlty_check | Runs linters and identifies issues. Supports auto-fixing. | paths, all, fix, level, json_output |
qlty_fmt | Auto-formats files using configured formatters. | paths, all, cwd |
qlty_metrics | Calculates complexity, duplication, and maintainability. | paths, all, sort, json_output |
qlty_smells | Identifies duplication and complexity hotspots. | paths, all, json_output |
qlty_init | Initializes qlty in a repo (creates .qlty/qlty.toml). | yes, cwd |
qlty_plugins_list | Lists all available qlty plugins. | cwd |
Sources: servers/qlty/server.py:84-165, servers/qlty/README.md:7-14
Implementation Detail: Tool Execution Logic
Every tool call follows a consistent pattern of argument mapping. For instance, the qlty_check tool maps its MCP boolean arguments (like fix) to CLI flags (like --fix).
if name == "qlty_check":
args = ["check"]
if arguments.get("all"):
args.append("--all")
if arguments.get("fix"):
args.append("--fix")
if arguments.get("level"):
args.extend(["--level", arguments["level"]])
if arguments.get("json_output", True):
args.append("--json")
Sources: servers/qlty/server.py:171-183
Quality Metrics & Smells
The system can generate quantitative data about the codebase to assist in refactoring decisions.
Metrics Calculation
The qlty_metrics tool calculates several dimensions of code health. Users can sort these results to find the most problematic files based on:
- Complexity: Measures cyclomatic complexity.
- Duplication: Identifies code clones or repetitive logic.
- Maintainability: A composite index indicating how easily the code can be updated.
Sources: servers/qlty/server.py:133-138, scripts/qlty_check.py:53-54
Code Smells Identification
The qlty_smells tool specifically targets "hotspots" in the code—files that are both complex and frequently changed, or segments with high duplication. This tool typically returns JSON-formatted results for programmatic parsing by AI agents.
Sources: servers/qlty/server.py:151-155, scripts/qlty_check.py:46-47
Workflow Integration
QLTY is integrated into the broader "Continuous Claude" ecosystem through global installation scripts and specialized Python workflow scripts.
Installation and Configuration
The install-global.sh script automates the retrieval and setup of the qlty toolkit. It uses curl -fsSL https://qlty.sh/install.sh to install the binary and then registers the MCP server in the global mcp_config.json.
{
"mcpServers": {
"qlty": {
"command": "python",
"args": ["${HOME}/.claude/servers/qlty/server.py"]
}
}
}
Sources: install-global.sh:176-188, install-global.sh:454-458, mcp_config.json:20-23
Script-Based Workflow
While the MCP server provides the raw tools, the scripts/qlty_check.py file offers a high-level CLI interface for executing these workflows manually or via runtime.harness.
Summary
The QLTY module provides a comprehensive toolset for maintaining high code standards within the Continuous Claude project. By wrapping the qlty CLI as an MCP server, it enables AI agents to autonomously detect issues, measure technical debt via metrics, and apply automated formatting or linting fixes, significantly reducing the manual overhead of code maintenance.
Sources: servers/qlty/README.md:1-14, servers/qlty/server.py:1-20