This MCP server provides a WebSocket interface for interacting with the Shodan API, allowing you to query information about internet-connected devices, vulnerabilities, and perform related tasks like DNS lookups and CVE information retrieval.
First, clone the repository and install the dependencies:
# Clone the repository
git clone https://github.com/yourusername/shodan-mcp-server.git
cd shodan-mcp-server
# Install dependencies
npm install
Before running the server, you need to set your Shodan API key as an environment variable:
export SHODAN_API_KEY=your_api_key_here # Unix/Linux/macOS
$env:SHODAN_API_KEY="your_api_key_here" # Windows PowerShell
Start the server using npm:
npm start
If you prefer Docker, you can build and run the container:
# Build the image
npm run build
# Run the container
docker run -e SHODAN_API_KEY=your_api_key_here -p 3000:3000 shodan-mcp-server
By default, the server starts on port 3000. To use a different port, set the PORT
environment variable.
The server implements the Model Context Protocol (MCP) over WebSocket. You can use the following tools:
Retrieve detailed information about an IP address:
{
"tool": "host_info",
"params": {
"ip": "8.8.8.8"
}
}
Search the Shodan database using their query syntax:
{
"tool": "search",
"params": {
"query": "nginx country:\"US\"",
"page": 1,
"limit": 10
}
}
Resolve domain names to IP addresses:
{
"tool": "dns_lookup",
"params": {
"domain": "example.com"
}
}
Get details about specific CVE vulnerabilities:
{
"tool": "cve_info",
"params": {
"cveId": "CVE-2021-44228"
}
}
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.