list_ports
Retrieve all ports monitored by Shodan for internet-connected devices, aiding in cybersecurity research and threat intelligence analysis.
Instructions
List all ports that Shodan crawls on the Internet
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:1614-1632 (handler)MCP tool handler for 'list_ports': calls shodanClient.listPorts() and formats the response as text content.case "list_ports": { try { const ports = await shodanClient.listPorts(); return { content: [{ type: "text", text: JSON.stringify(ports, null, 2) }] }; } catch (error) { if (error instanceof McpError) { throw error; } throw new McpError( ErrorCode.InternalError, `Error listing ports: ${(error as Error).message}` ); } }
- src/index.ts:420-433 (helper)Core implementation of listPorts in ShodanClient: makes API call to /shodan/ports and returns { ports: data }.async listPorts(): Promise<any> { try { const response = await this.axiosInstance.get("/shodan/ports"); return { ports: response.data }; } catch (error: unknown) { if (axios.isAxiosError(error)) { throw new McpError( ErrorCode.InternalError, `Shodan API error: ${error.response?.data?.error || error.message}` ); } throw error; } }
- src/index.ts:1056-1062 (registration)Tool registration in ListToolsRequestSchema handler: defines name, description, and empty inputSchema for 'list_ports'.name: "list_ports", description: "List all ports that Shodan crawls on the Internet", inputSchema: { type: "object", properties: {} } },
- src/index.ts:1056-1062 (schema)Input schema for list_ports tool: empty object schema (no parameters required).name: "list_ports", description: "List all ports that Shodan crawls on the Internet", inputSchema: { type: "object", properties: {} } },