coding-best-practices-mcp-server

anilpraneeth/coding-best-practices-mcp-server

3.2

If you are the rightful owner of coding-best-practices-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

The Coding Best Practices MCP Server is a comprehensive tool designed to enhance Python and AWS coding practices through automated linting, security analysis, and code quality recommendations.

Tools
4
Resources
0
Prompts
0

Coding Best Practices MCP Server

A comprehensive Model Context Protocol (MCP) server that provides Python and AWS coding best practices, automated linting, security analysis, and code quality recommendations.

Features

Python Best Practices

  • Comprehensive Linting: Run flake8, black, isort, mypy, and bandit on your Python code
  • Security Analysis: Detect security vulnerabilities using bandit and safety
  • Code Quality Analysis: Analyze code structure, complexity, and provide improvement suggestions
  • Dependency Checking: Scan for security vulnerabilities and outdated packages
  • Automated Fixes: Auto-format code with black and isort

AWS Best Practices

  • CloudFormation Linting: Validate CloudFormation templates for best practices and security
  • IAM Policy Analysis: Analyze IAM policies for security issues and overly permissive permissions
  • Cost Optimization: Identify cost optimization opportunities across AWS services
  • Security Audit: Perform comprehensive security audits of AWS resources
  • Infrastructure Templates: Generate best-practice CloudFormation and CDK templates

General Tools

  • Project Setup: Automatically configure new projects with best practices
  • Comprehensive Reports: Generate detailed analysis reports in multiple formats
  • Resource Guides: Access to best practices documentation and templates

Installation

From PyPI (Recommended)

pip install coding-best-practices-mcp

From Source

git clone https://github.com/coding-best-practices/mcp-server.git
cd mcp-server
pip install -e .

Quick Start

1. Install the MCP Server

pip install coding-best-practices-mcp

2. Configure Your MCP Client

Add the server to your MCP client configuration:

{
  "mcpServers": {
    "coding-best-practices": {
      "command": "coding-best-practices-mcp",
      "args": []
    }
  }
}

3. Start Using the Tools

Once configured, you can use the following tools in your MCP client:

Python Linting
# Lint a Python file
python_lint --file_path /path/to/your/file.py

# Lint with specific tools
python_lint --file_path /path/to/your/file.py --tools flake8,black,mypy

# Auto-fix issues
python_lint --file_path /path/to/your/file.py --fix
Security Analysis
# Security scan
python_security_scan --file_path /path/to/your/file.py --severity medium

# Check dependencies
python_dependency_check --requirements_file requirements.txt
AWS Analysis
# Lint CloudFormation template
aws_cloudformation_lint --template_path template.json

# Analyze IAM policy
aws_iam_analyzer --policy_file policy.json

# Cost optimization analysis
aws_cost_optimization --region us-east-1

# Security audit
aws_security_audit --region us-east-1

Available Tools

Python Tools

ToolDescriptionParameters
python_lintRun comprehensive Python lintingfile_path, tools, fix
python_security_scanSecurity analysis with banditfile_path, severity
python_code_qualityAnalyze code quality and structurefile_path, include_suggestions
python_dependency_checkCheck dependencies for vulnerabilitiesrequirements_file, check_updates

AWS Tools

ToolDescriptionParameters
aws_cloudformation_lintLint CloudFormation templatestemplate_path, check_security
aws_iam_analyzerAnalyze IAM policiespolicy_file, check_permissions
aws_cost_optimizationAnalyze cost optimization opportunitiesregion, service_types
aws_security_auditPerform security auditregion, include_compliance

General Tools

ToolDescriptionParameters
generate_best_practices_reportGenerate comprehensive reportproject_path, include_python, include_aws, output_format
setup_project_standardsSet up project with best practicesproject_path, language, include_pre_commit

Examples

Python Code Analysis

# Example Python code with issues
def example_function(x, y):
    # This line is too long and should be flagged by flake8
    result = x + y + x * y + x ** 2 + y ** 2 + x * y * 2 + x ** 3 + y ** 3
    return result

class ExampleClass:
    def __init__(self, name):
        self.name = name
        # Missing docstring
        pass

Running python_lint on this code will identify:

  • Line length violations
  • Missing docstrings
  • Style issues
  • Type hints recommendations

AWS CloudFormation Analysis

{
  "Resources": {
    "ExampleS3Bucket": {
      "Type": "AWS::S3::Bucket",
      "Properties": {
        "BucketName": "example-bucket-name"
      }
    },
    "ExampleSecurityGroup": {
      "Type": "AWS::EC2::SecurityGroup",
      "Properties": {
        "SecurityGroupIngress": [
          {
            "IpProtocol": "tcp",
            "FromPort": 22,
            "ToPort": 22,
            "CidrIp": "0.0.0.0/0"
          }
        ]
      }
    }
  }
}

Running aws_cloudformation_lint will identify:

  • Security group allowing SSH from anywhere
  • Missing encryption configuration
  • Missing public access block settings

Configuration

Python Configuration

The server uses standard Python tool configurations:

  • Black: Configured for 88 character line length
  • isort: Configured with black profile
  • flake8: Configured with appropriate ignores
  • mypy: Configured with strict mode
  • bandit: Configured for security scanning

AWS Configuration

For AWS tools to work, you need to configure AWS credentials:

# Using AWS CLI
aws configure

# Or set environment variables
export AWS_ACCESS_KEY_ID=your_access_key
export AWS_SECRET_ACCESS_KEY=your_secret_key
export AWS_DEFAULT_REGION=us-east-1

Development

Setting up Development Environment

git clone https://github.com/coding-best-practices/mcp-server.git
cd mcp-server
pip install -e ".[dev]"
pre-commit install

Running Tests

pytest

Code Quality

The project uses several tools to maintain code quality:

  • Black: Code formatting
  • isort: Import sorting
  • flake8: Linting
  • mypy: Type checking
  • pytest: Testing
  • pre-commit: Git hooks

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Run the quality checks
  6. Submit a pull request

License

This project is licensed under the MIT License - see the file for details.

Support

Changelog

v0.1.0

  • Initial release
  • Python linting and security analysis
  • AWS CloudFormation and IAM analysis
  • Cost optimization and security audit tools
  • Project setup automation
  • Comprehensive reporting

Roadmap

  • Support for additional languages (JavaScript, Go, Java)
  • Integration with CI/CD pipelines
  • Custom rule configuration
  • Team collaboration features
  • Metrics and analytics dashboard
  • Integration with popular IDEs