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

View original issue on GitHub  ·  Variant 2

Cursor MCP Server Shows "No tools available" for `@21st-dev/magic`

When configuring Cursor's MCP (Managed Code Provider) servers, the `@21st-dev/magic` tool is not being recognized, resulting in the "No tools available" message within the Cursor interface. Despite a seemingly correct configuration in the ~/.cursor/mcp.json file, Cursor fails to identify and utilize the tool's capabilities.

The core problem lies in how the `@21st-dev/magic` MCP server is being launched and how it communicates with Cursor. The provided MCP logs indicate a failure to establish a stable connection, leading to the "Connection closed" error. The "No server info found" error further suggests that Cursor is unable to properly initialize and maintain a connection with the `@21st-dev/magic` server.

Root Cause Analysis

While the exact root cause requires further investigation, several potential issues could be contributing to the problem:

Solution

Here's a step-by-step approach to troubleshoot and resolve the issue:

  1. Environment Variable Configuration: Modify the mcp.json configuration to use an environment variable for the API key. First, set the environment variable in your shell (e.g., export MAGIC_API_KEY="xxxxxxxxxx"). Then, update the mcp.json file:
  2. {
      "mcpServers": {
        "@21st-dev/magic": {
          "command": "npx",
          "args": [
            "-y",
            "@21st-dev/magic@latest"
          ],
          "env": {
            "API_KEY": "$MAGIC_API_KEY"
          }
        }
      }
    }
  3. Pin a Specific Version: Replace @latest with a specific, known-working version of `@21st-dev/magic`. This helps isolate version incompatibility issues:
  4. {
      "mcpServers": {
        "@21st-dev/magic": {
          "command": "npx",
          "args": [
            "-y",
            "@21st-dev/magic@1.2.3"
          ],
          "env": {
            "API_KEY": "$MAGIC_API_KEY"
          }
        }
      }
    }
  5. Verify MCP Compliance: Ensure that `@21st-dev/magic` correctly implements the MCP protocol, including proper handling of ListOfferings requests and the establishment of a persistent connection. Refer to Cursor's MCP documentation or examples for guidance.
  6. Examine `@21st-dev/magic` Output: Modify the command and args to redirect the output of `@21st-dev/magic` to a file. This can provide valuable debugging information:
  7. {
      "mcpServers": {
        "@21st-dev/magic": {
          "command": "bash",
          "args": [
            "-c",
            "npx -y @21st-dev/magic@latest API_KEY=\"$MAGIC_API_KEY\" > /tmp/magic_mcp.log 2>&1"
          ]
        }
      }
    }

    Then, examine the contents of /tmp/magic_mcp.log for any error messages or unexpected behavior.

  8. Restart Cursor: After making any changes to mcp.json, restart Cursor to ensure the new configuration is loaded.

Practical Tips and Considerations