Skip to main content
Glama
MCP Best Practices Server

MCP Best Practices Server

by KeyserDSoze
README.md
# MCP Best Practices Server

[![Build and Deploy](https://github.com/yourusername/mcp-best-practices-server/actions/workflows/deploy.yml/badge.svg)](https://github.com/yourusername/mcp-best-practices-server/actions/workflows/deploy.yml)
[![npm version](https://badge.fury.io/js/mcp-best-practices-server.svg)](https://badge.fury.io/js/mcp-best-practices-server)

An MCP (Model Context Protocol) server that provides coding best practices, guidelines, and code review capabilities for multiple programming languages and frameworks. Compatible with VS Code, GitHub Copilot, and other MCP clients.

## ๐Ÿš€ Quick Start

### One-Click Installation for VS Code

Click this link to automatically install and configure the server in VS Code:

**[๐Ÿ“ฆ Install in VS Code](vscode:mcp/install?%7B%22name%22%3A%22mcp-best-practices-server%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22mcp-best-practices-server%22%5D%7D)**

### Manual Installation

#### Option 1: Global Installation

```bash
npm install -g mcp-best-practices-server
```

Then add to your `.vscode/mcp.json`:

```json
{
  "mcpServers": {
    "best-practices": {
      "command": "mcp-best-practices-server",
      "args": []
    }
  }
}
```

#### Option 2: Using npx (Recommended)

Add to your `.vscode/mcp.json`:

```json
{
  "mcpServers": {
    "best-practices": {
      "command": "npx",
      "args": ["mcp-best-practices-server"]
    }
  }
}
```

## โœจ Features

### ๐Ÿ”ง Tools

| Tool | Description | Parameters |
|------|-------------|------------|
| **get_best_practices** | Retrieve best practices for specific languages/frameworks | `language` (required), `framework` (optional), `category` (optional) |
| **search_best_practices** | Search through all available guidelines | `query` (required), `limit` (optional, default: 10) |
| **validate_code_pattern** | Analyze code snippets for best practice compliance | `code` (required), `language` (required), `context` (optional) |

### ๐Ÿ“š Resources

Browse and access best practice documents directly:

- **TypeScript** - Type safety, modern syntax, performance guidelines
- **JavaScript** - ES6+, async/await, error handling, security
- **React** - Component design, hooks, performance optimization
- **General Programming** - SOLID principles, testing, documentation

### ๐Ÿ’ฌ Prompts

| Prompt | Description | Parameters |
|--------|-------------|------------|
| **code_review** | Comprehensive code review based on best practices | `code`, `language`, `focus_areas` (optional) |
| **architecture_guidance** | Architectural recommendations for projects | `project_type`, `technologies`, `scale` (optional) |

## ๐ŸŽฏ Usage Examples

### In VS Code with GitHub Copilot

#### Get Language-Specific Best Practices

```
User: "Show me TypeScript best practices for error handling"
AI: *calls get_best_practices tool with language="typescript", category="error-handling"*
```

#### Search for Specific Guidelines

```
User: "How should I structure React components?"
AI: *calls search_best_practices tool with query="React component structure"*
```

#### Code Review and Validation

```
User: "Review this function for best practices"

function getUserData(id) {
  const data = fetch('/api/users/' + id).then(r => r.json());
  return data;
}

AI: *calls validate_code_pattern tool to analyze the code*
```

#### Use Built-in Prompts

```
User: "/mcp.best-practices.code_review"
AI: *Prompts for code, language, and focus areas, then provides comprehensive review*
```

### Available Best Practice Categories

- **Performance** - Optimization techniques, caching strategies, lazy loading
- **Security** - Input validation, authentication, authorization, XSS prevention
- **Testing** - Unit testing, integration testing, TDD, mocking
- **Architecture** - Design patterns, SOLID principles, code organization
- **Maintainability** - Code readability, documentation, refactoring

## ๐Ÿ“– Supported Languages and Frameworks

### Programming Languages
- **TypeScript** - Complete guidelines for modern TypeScript development
- **JavaScript** - ES6+ best practices, async patterns, performance
- **Python** - PEP 8, testing, packaging (coming soon)
- **Java** - Spring Boot, testing, performance (coming soon)

### Frameworks and Libraries
- **React** - Hooks, component patterns, performance optimization
- **Vue.js** - Composition API, reactive patterns (coming soon)
- **Express.js** - API design, middleware, security (coming soon)
- **Next.js** - SSR/SSG patterns, performance (coming soon)

## ๐Ÿ› ๏ธ Development

### Local Development

1. **Clone the repository**
   ```bash
   git clone https://github.com/yourusername/mcp-best-practices-server.git
   cd mcp-best-practices-server
   ```

2. **Install dependencies**
   ```bash
   npm install
   ```

3. **Build the project**
   ```bash
   npm run build
   ```

4. **Test locally**
   ```bash
   npm start
   ```

### Development Mode

For development with automatic restart:

```json
{
  "mcpServers": {
    "best-practices-dev": {
      "command": "node",
      "args": ["./dist/index.js"],
      "env": {
        "NODE_ENV": "development"
      },
      "dev": {
        "watch": ["src/**/*.ts", "best-practices/**/*.md"],
        "debug": {
          "type": "node",
          "request": "launch",
          "program": "./dist/index.js"
        }
      }
    }
  }
}
```

### Adding New Best Practices

1. Create markdown files in the `best-practices/` directory
2. Follow the naming convention: `{language}/{framework}/{category}.md`
3. Use clear headings and code examples
4. Include both good and bad examples with โœ…/โŒ indicators

Example structure:
```
best-practices/
โ”œโ”€โ”€ typescript/
โ”‚   โ”œโ”€โ”€ general.md
โ”‚   โ”œโ”€โ”€ react/
โ”‚   โ”‚   โ”œโ”€โ”€ hooks.md
โ”‚   โ”‚   โ””โ”€โ”€ performance.md
โ”‚   โ””โ”€โ”€ testing.md
โ”œโ”€โ”€ javascript/
โ”‚   โ”œโ”€โ”€ general.md
โ”‚   โ”œโ”€โ”€ async.md
โ”‚   โ””โ”€โ”€ security.md
โ””โ”€โ”€ general/
    โ”œโ”€โ”€ programming.md
    โ”œโ”€โ”€ testing.md
    โ””โ”€โ”€ architecture.md
```

## ๐Ÿงช Testing

```bash
# Run all tests
npm test

# Run with coverage
npm run test:coverage

# Run linting
npm run lint

# Fix linting issues
npm run lint:fix
```

## ๐Ÿ“š API Reference

### Tool Schemas

#### get_best_practices

```typescript
interface GetBestPracticesArgs {
  language: string;           // Required: programming language
  framework?: string;         // Optional: specific framework
  category?: string;          // Optional: category like 'performance', 'security'
}
```

#### search_best_practices

```typescript
interface SearchBestPracticesArgs {
  query: string;             // Required: search query
  limit?: number;            // Optional: max results (default: 10)
}
```

#### validate_code_pattern

```typescript
interface ValidateCodePatternArgs {
  code: string;              // Required: code to analyze
  language: string;          // Required: programming language
  context?: string;          // Optional: additional context
}
```

## ๐Ÿค Contributing

We welcome contributions! Here's how you can help:

1. **Add new best practices** - Submit markdown files for new languages/frameworks
2. **Improve existing content** - Enhance current best practice documents
3. **Fix bugs** - Report and fix issues in the server code
4. **Add features** - Implement new tools or capabilities

### Contribution Guidelines

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Write tests for new functionality
4. Ensure all tests pass (`npm test`)
5. Update documentation as needed
6. Commit changes (`git commit -m 'Add amazing feature'`)
7. Push to branch (`git push origin feature/amazing-feature`)
8. Open a Pull Request

## ๐Ÿ“„ License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## ๐Ÿ”— Related Projects

- [Model Context Protocol](https://spec.modelcontextprotocol.io/) - Official MCP specification
- [MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk) - Official TypeScript SDK
- [VS Code MCP Extension](https://code.visualstudio.com/docs/copilot/copilot-extensibility-overview) - VS Code MCP support

## ๐Ÿ“ž Support

- **Issues**: [GitHub Issues](https://github.com/yourusername/mcp-best-practices-server/issues)
- **Discussions**: [GitHub Discussions](https://github.com/yourusername/mcp-best-practices-server/discussions)
- **Documentation**: [GitHub Pages](https://yourusername.github.io/mcp-best-practices-server/)

## ๐ŸŒŸ Acknowledgments

- The MCP community for creating an amazing protocol
- Contributors who have shared their knowledge and best practices
- The VS Code team for excellent MCP integration

---

**Made with โค๏ธ for the developer community**

*Compatible with VS Code, GitHub Copilot, Claude Desktop, and other MCP clients*