Skip to main content

A Model Context Protocol server for development rules and best practices

Project description

Rules MCP Server

A Model Context Protocol (MCP) server that provides development rules and best practices from markdown files. Similar to Context7's approach, this server dynamically loads rules from markdown files in the rules/ directory.

Features

  • Simple API: Only two tools - get_rules and list_rules
  • Dynamic Loading: Automatically loads any .md files from the rules/ directory
  • File Watching: Automatically reloads rules when files change (optional)
  • Metadata Support: Extracts metadata from markdown files for better organization

Installation

From PyPI (Recommended)

pip install rules-mcp-server

From Source

git clone https://github.com/yourusername/rules-mcp-server.git
cd rules-mcp-server
pip install -e .

Prerequisites

  • Python 3.8+
  • pip

Usage

With Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "rules": {
      "command": "rules-mcp-server"
    }
  }
}

With Cursor

Add to your ~/.cursor/mcp.json:

{
  "mcpServers": {
    "rules": {
      "command": "rules-mcp-server"
    }
  }
}

Alternative: Using Python Module

{
  "mcpServers": {
    "rules": {
      "command": "python",
      "args": ["-m", "rules_mcp_server"]
    }
  }
}

Local Development

# After installation
rules-mcp-server

# Or run directly
python server.py

Available Tools

get_rules(domain: str)

Get rules and best practices for a specific domain.

Example:

get_rules("react") - Get React development rules
get_rules("security") - Get security best practices

list_rules()

List all available rule domains with descriptions.

Example:

list_rules() - Shows all available rule domains

Adding Rules

Simply add markdown files to the rules/ directory. The filename (without .md) becomes the domain name.

Rule File Format

# Domain Name Rules

## Metadata
- Version: 1.0
- Last Updated: 2025-01-26
- Description: Brief description of the rules

## Your Rules Content

Add your rules, best practices, examples, etc. here.
The server will automatically load this file and make it available
via get_rules("filename").

Example Rule File (rules/typescript.md)

# TypeScript Rules

## Metadata
- Version: 1.0
- Last Updated: 2025-01-26
- Description: TypeScript development best practices

## Type Safety

### Strict Mode
- Always enable strict mode in tsconfig.json
- Use explicit types for function parameters
- Avoid using `any` type

### Interfaces vs Types
- Use interfaces for object shapes
- Use type aliases for unions and primitives

Configuration

Environment variables:

  • RULES_DIRECTORY: Path to rules directory (default: ./rules)
  • WATCH_FILES: Enable file watching (default: true)
  • LOG_LEVEL: Logging level (default: INFO)

File Structure

rules-mcp-server/
├── rules/                  # Your rule markdown files
│   ├── react.md
│   ├── security.md
│   ├── typescript.md
│   └── ...
├── src/                    # Server source code
├── server.py              # Main server entry point
├── requirements.txt       # Python dependencies
└── README.md             # This file

Contributing

  1. Add your rule files to the rules/ directory
  2. Follow the markdown format with metadata section
  3. Test with your MCP client
  4. Commit and push to your repository

The server will automatically detect and load new rule files!

Publishing to PyPI

Build the Package

python build.py

Test Installation

python test_install.py

Upload to PyPI

# Test PyPI first
twine upload --repository testpypi dist/*

# Then real PyPI
twine upload dist/*

Development

Setup Development Environment

git clone https://github.com/yourusername/rules-mcp-server.git
cd rules-mcp-server
pip install -e .

Run Tests

python test_install.py

Build Package

python build.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rules_mcp_server-1.0.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rules_mcp_server-1.0.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file rules_mcp_server-1.0.0.tar.gz.

File metadata

  • Download URL: rules_mcp_server-1.0.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for rules_mcp_server-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ede93ba59ce05698390cc422b655d574c933fdc25155787aa7c222185a1176b2
MD5 3fbdbe157fbc8d8de91a8e2f39991bb3
BLAKE2b-256 28899f8892dca5121e9f0118d730e3b5debff036a097fcc0d5b9ebd5a7b931c3

See more details on using hashes here.

File details

Details for the file rules_mcp_server-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rules_mcp_server-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d325b65de921e9e07935e056fcac2211d1adf62d7275d5149431b29ff9b97b7a
MD5 01681c50ec09bff72e08192eb5273b7a
BLAKE2b-256 bfcae3132b97d06bce1607d847b99dd5c1b6c8cc2fa33f21c62a0c1bdd849e75

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page