Skip to main content
Glama

generate_cursor_rules

Create .cursorrules files for Cursor AI by analyzing project stacks including programming languages, frameworks, and databases to configure AI coding assistance.

Instructions

Generates a .cursorrules file for Cursor AI based on the project stack.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectNameYesName of the project
languagesYesProgramming languages used (e.g., ['typescript', 'python'])
frameworksNoFrameworks used (e.g., ['react', 'fastapi'])
databasesNoDatabases used (e.g., ['postgresql', 'redis'])

Implementation Reference

  • The handler function that implements the core logic of the 'generate_cursor_rules' tool, generating a .cursorrules file content based on project name, languages, frameworks, and databases.
    export function generateCursorRulesHandler(args: any) {
        const { projectName, languages, frameworks = [], databases = [] } = args;
    
        const content = `# ${projectName} - Cursor Rules
    
    ## Project Overview
    This is a ${languages.join("/")} project${frameworks.length ? ` using ${frameworks.join(", ")}` : ""}.
    
    ## Code Style
    - Follow ${languages[0]} best practices and style guides
    - Use consistent naming conventions
    - Write self-documenting code with clear variable names
    - Keep functions small and focused (< 50 lines)
    
    ## Architecture
    - Separate concerns clearly (MVC, Clean Architecture, etc.)
    - Use dependency injection where applicable
    - Keep business logic separate from I/O
    
    ## Testing
    - Write unit tests for all business logic
    - Use integration tests for API endpoints
    - Aim for > 80% code coverage
    
    ## Error Handling
    - Use structured error handling
    - Log errors with appropriate context
    - Return meaningful error messages to users
    
    ## Security
    - Never commit secrets or API keys
    - Validate all user input
    - Use parameterized queries for databases
    ${databases.length ? `\n## Database (${databases.join(", ")})\n- Use connection pooling\n- Handle transactions properly\n- Avoid N+1 queries` : ""}
    
    ## Documentation
    - Document all public APIs
    - Keep README up to date
    - Use inline comments for complex logic only
    `;
    
        return {
            content: [{ type: "text", text: content }]
        };
    }
  • Zod-based input schema definition for the 'generate_cursor_rules' tool, specifying parameters like projectName, languages, frameworks, and databases.
    export const generateCursorRulesSchema = {
        name: "generate_cursor_rules",
        description: "Generates a .cursorrules file for Cursor AI based on the project stack.",
        inputSchema: z.object({
            projectName: z.string().describe("Name of the project"),
            languages: z.array(z.string()).describe("Programming languages used (e.g., ['typescript', 'python'])"),
            frameworks: z.array(z.string()).optional().describe("Frameworks used (e.g., ['react', 'fastapi'])"),
            databases: z.array(z.string()).optional().describe("Databases used (e.g., ['postgresql', 'redis'])")
        })
    };
  • src/index.ts:95-95 (registration)
    Registration of the 'generate_cursor_rules' tool in the toolRegistry Map used by the main stdio MCP server.
    ["generate_cursor_rules", { schema: generateCursorRulesSchema, handler: generateCursorRulesHandler }],
  • src/server.ts:106-106 (registration)
    Registration of the 'generate_cursor_rules' tool in the toolRegistry Map used by the HTTP MCP server.
    ["generate_cursor_rules", { schema: generateCursorRulesSchema, handler: generateCursorRulesHandler }],

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/millsydotdev/Code-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server