What is Zero-configuration AI context generation system that analyzes any codebase instantly through CLI, MCP, or HTTP interfaces.?
The PAIML MCP Agent Toolkit (pmat) is a zero-configuration AI context generation system that analyzes any codebase instantly through CLI, MCP, or HTTP interfaces. Built by Pragmatic AI Labs with extreme quality standards and zero tolerance for technical debt, it provides deep context analysis, complexity metrics, dead code detection, and technical debt detection, among other features. The toolkit supports multiple programming languages and integrates seamlessly with CI/CD pipelines.
Documentation
PAIML MCP Agent Toolkit (pmat)
Zero-configuration AI context generation system that analyzes any codebase instantly through CLI, MCP, or HTTP interfaces. Built by Pragmatic AI Labs with extreme quality standards and zero tolerance for technical debt.
Toyota Way Success: Achieved 97% complexity reduction in stubs.rs through complete modular refactoring (v0.29.5). Project maintains zero tolerance standards: 0 SATD comments, 0 failing doctests, 0 failing property tests, 72+ comprehensive property tests, and proper separation of concerns across all components. Latest refactoring created dedicated modules (language_analyzer.rs, defect_formatter.rs, dead_code_formatter.rs) eliminating 549 lines of duplicated code while maintaining full functionality β
π Installation
Install pmat using one of the following methods:
From Crates.io (Recommended):
cargo install pmat
With the Quick Install Script (Linux only):
curl -sSfL https://raw.githubusercontent.com/paiml/paiml-mcp-agent-toolkit/master/scripts/install.sh | sh
macOS users: Please use cargo install pmat instead. Pre-built binaries are only available for Linux.
From Source:
git clone https://github.com/paiml/paiml-mcp-agent-toolkit
cd paiml-mcp-agent-toolkit
cargo build --release
From GitHub Releases:
Pre-built binaries for Linux are available on the releases page. macOS and Windows users should use cargo install pmat.
Requirements
Rust: 1.80.0 or later
Git: For repository analysis
π Getting Started# Quick Start
pmat context
# Get complexity metrics for top 10 files
pmat analyze complexity --top-files 10
# Analyze specific files with include patterns
pmat analyze complexity --include "src/*.rs" --format json
# Test with validated examples (try these!)
cargo run --example complexity_demo
pmat analyze complexity --include "server/examples/complexity_*.rs"
# Find technical debt
pmat analyze satd
# Run comprehensive quality checks
pmat quality-gate --strict
Using as a Library
Add to your Cargo.toml:
[dependencies]
pmat = "0.31.0"
Basic usage:
use pmat::{
services::code_analysis::CodeAnalysisService,
types::ProjectPath,
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let service = CodeAnalysisService::new();
let path = ProjectPath::new(".");
// Generate context
let context = service.generate_context(path, None).await?;
println!("Project context: {}", context);
// Analyze complexity
let complexity = service.analyze_complexity(path, Some(10)).await?;
println!("Complexity results: {:?}", complexity);
Ok(())
}
Key Features# π Code Analysis
Deep Context Analysis - Comprehensive AST-based code analysis with defect prediction
Complexity Analysis - Accurate McCabe cyclomatic and cognitive complexity metrics with AST-based precision
The MCP server can now be run using the pmcp Rust SDK for better type safety and async support:
// Run the MCP server with pmcp SDK
cargo run --example mcp_server_pmcp
// Or use as a library
use pmat::mcp_pmcp::{handlers::*, PmcpServer};
use pmcp::{Server, ServerBuilder};
let server = ServerBuilder::new("pmat-mcp", "1.0.0")
.with_tool("analyze_complexity", "Analyze code complexity",
Box::new(AnalyzeComplexityTool))
.with_tool("analyze_satd", "Detect technical debt",
Box::new(AnalyzeSatdTool))
// ... add more tools
.build();
// Handle connections
server.handle_connection(stream).await?;
The pmcp SDK provides:
Type-safe tool definitions with proper async handling
Built-in JSON-RPC 2.0 protocol implementation
Automatic request/response serialization
Connection lifecycle management
Error handling and logging
Available MCP tools:
generate_template - Generate project files from templates
See examples/ci_integration.rs for more CI/CD patterns including GitLab CI, Jenkins, and pre-commit hooks.
Recent Updates# π v0.29.6 - Critical Bug Fixes
Fixed Quality Gate Bug: Quality gate dead code detection now correctly analyzes code instead of always reporting violations
Fixed Include Patterns: --include patterns now properly work with test directories (e.g., --include "tests/**/*.rs")
Fixed Clippy Warning: Replaced deprecated map_or with is_some_and for cleaner code
π v0.28.14 - Toyota Way Kaizen Success
Massive Complexity Reduction: Core handle_refactor_auto function complexity reduced from 136 β 21 (84% reduction)
Zero Quality Violations: Project now maintains 0 lint violations, 0 max complexity, 0 SATD comments
Toyota Way Implementation: Applied Kaizen (continuous improvement), Genchi Genbutsu (go and see), Jidoka (quality at source), and Poka-Yoke (error-proofing) principles
Code Size Optimization: Net reduction of 3,401 lines while improving functionality and maintainability
Comprehensive Testing: Added extensive property tests, doctests, and unit tests for all refactored components
Zero Compromise: No hacks, shortcuts, or technical debt introduced during refactoring
π¦ v0.28.9 - CI/CD Integration & Exit Codes
CI/CD Support: All analyze commands now support --fail-on-violation flag
Exit Codes: Commands exit with code 1 when violations exceed thresholds
Configurable Thresholds: Added --max-percentage for dead-code analysis
For systems with low swap space, we provide a configuration tool:
make config-swap # Configure 8GB swap (requires sudo)
make clear-swap # Clear swap memory between heavy operations
π§ͺ Testing
The project uses a distributed test architecture for fast feedback:
make test-unit # <10s - Core logic tests
make test-services # <30s - Service integration
make test-protocols # <45s - Protocol validation
make test-e2e # <120s - Full system tests
make test-performance # Performance regression
# Run all tests in parallel
make test-all
# Coverage analysis
make coverage-stratified
π€ Contributing
We welcome contributions! Please see our Contributing Guide for details.
Quick Start for Contributors
git clone https://github.com/paiml/paiml-mcp-agent-toolkit
cd paiml-mcp-agent-toolkit
# Install dependencies
make install-deps
# Run tests
make test-fast # Quick validation
make test-all # Complete test suite
# Check code quality
make lint # Run extreme quality lints
make coverage # Generate coverage report
Development Workflow
Fork the repository
Create a feature branch (git checkout -b feature/amazing-feature)
Make your changes following our Zero Tolerance Quality Standards
Run quality checks before committing:
make lint # Check code quality
make test # Run all tests (fast, doctests, property tests, examples)
Submit a pull request with a clear description of changes
Note: The make test command runs comprehensive testing including: