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:
-
Review MCP Configuration:
Carefully examine the
mcp.jsonfile located in your~/.cursor/directory. Ensure that the command and arguments for@21st-dev/magicare correctly specified.{ "mcpServers": { "@21st-dev/magic": { "command": "npx", "args": [ "-y", "@21st-dev/magic@latest", "API_KEY=\"xxxxxxxxxx\"" ] } } } -
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.jsonto remove the API key from theargsarray. The@21st-dev/magictool 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_KEYenvironment 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 CursorFor Windows, you would use the
setcommand in the command prompt or PowerShell. -
Verify
@21st-dev/magicInstallation:Ensure that the
@21st-dev/magicpackage is correctly installed globally or locally within your project.npm install -g @21st-dev/magic@latestor, if you prefer local installation:
npm install @21st-dev/magic@latest -
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/magicserver itself might have its own logs. Consult the documentation for@21st-dev/magicto find the location of these logs. -
Update Dependencies:
Ensure that you're using the latest versions of
@21st-dev/magicand Cursor. Outdated dependencies can sometimes lead to compatibility issues.
Related Considerations
- Firewall/Proxy: Ensure no firewall or proxy settings are interfering with the connection between Cursor and the MCP server.
- Resource Constraints: Verify that your system has sufficient resources (CPU, memory) to run both Cursor and the MCP server concurrently.
- MCP Server Stability: If the issue persists, investigate the stability of the
@21st-dev/magicMCP server itself. Contact the maintainers of the package for assistance if needed.