Cursor MCP Servers settings shows "No tools available" for @21st-dev/magic

View original issue on GitHub  ·  Variant 1

Cursor MCP Servers Showing "No tools available" for @21st-dev/magic

You might encounter an issue where Cursor, when configured with the Magic Code Provider (MCP) server @21st-dev/magic, displays "No tools available" in the MCP Servers settings. This indicates that Cursor is unable to properly communicate with and retrieve tool information from your specified Magic MCP server.

Root Cause Analysis

Based on the provided information, the root cause appears to stem from issues in establishing and maintaining a stable connection between Cursor and the @21st-dev/magic MCP server. The logs reveal that Cursor attempts to start a new stdio process using the provided command but encounters errors such as "Connection closed" and "No server info found." This suggests that the server process might be crashing or terminating unexpectedly, preventing Cursor from successfully listing the available tools.

Specifically, the error messages indicate a problem with the command execution. The command includes setting an API key directly in the command line, which might lead to issues with how the @21st-dev/magic tool parses or handles this information. Additionally, the npx command and its arguments might not be correctly configured to initiate and maintain a stable server process.

Solution

To resolve this issue, consider the following steps:

  1. Review MCP Configuration:

    Carefully examine the mcp.json file located in your ~/.cursor/ directory. Ensure that the command and arguments for @21st-dev/magic are correctly specified.

    {
      "mcpServers": {
        "@21st-dev/magic": {
          "command": "npx",
          "args": [
            "-y",
            "@21st-dev/magic@latest",
            "API_KEY=\"xxxxxxxxxx\""
          ]
        }
      }
    }
    
  2. Securely Pass the API Key:

    Avoid passing the API key directly as a command-line argument. Instead, consider setting it as an environment variable. Modify your mcp.json to remove the API key from the args array. The @21st-dev/magic tool should be designed to pick up the API key from the environment.

    {
      "mcpServers": {
        "@21st-dev/magic": {
          "command": "npx",
          "args": [
            "-y",
            "@21st-dev/magic@latest"
          ]
        }
      }
    }
    

    Then, set the API_KEY environment variable before launching Cursor. How you do this depends on your operating system and shell. For example, in a Unix-like environment (Linux, macOS) using bash, you could use:

    export API_KEY="xxxxxxxxxx"
    cursor # Or however you launch Cursor
    

    For Windows, you would use the set command in the command prompt or PowerShell.

  3. Verify @21st-dev/magic Installation:

    Ensure that the @21st-dev/magic package is correctly installed globally or locally within your project.

    npm install -g @21st-dev/magic@latest
    

    or, if you prefer local installation:

    npm install @21st-dev/magic@latest
    
  4. Check MCP Server Logs:

    Examine the MCP server logs for any detailed error messages or exceptions that might provide further insights into the connection issues. The Cursor logs provide some information, but the @21st-dev/magic server itself might have its own logs. Consult the documentation for @21st-dev/magic to find the location of these logs.

  5. Update Dependencies:

    Ensure that you're using the latest versions of @21st-dev/magic and Cursor. Outdated dependencies can sometimes lead to compatibility issues.

Related Considerations