@burtthecoder/mcp-shodan 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +197 -176
  3. package/build/index.js +93 -9
  4. package/package.json +1 -1
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Burt
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Burt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,176 +1,197 @@
1
- # Shodan MCP Server
2
-
3
- A Model Context Protocol (MCP) server for querying the [Shodan API](https://shodan.io) and [Shodan CVEDB](https://cvedb.shodan.io). This server provides tools for IP lookups, device searches, DNS lookups, vulnerability queries, CPE lookups, and more. It is designed to integrate seamlessly with MCP-compatible applications like [Claude Desktop](https://claude.ai).
4
-
5
- ## Features
6
-
7
- - **IP Lookup**: Retrieve detailed information about an IP address
8
- - **Search**: Search for devices on Shodan matching specific queries
9
- - **Ports**: Get a list of ports that Shodan is scanning
10
- - **Vulnerabilities**: Fetch detailed information about CVEs using Shodan's CVEDB
11
- - **CPE Lookup**: Search for Common Platform Enumeration (CPE) entries by product name
12
- - **DNS Lookup**: Resolve hostnames to IP addresses
13
-
14
- ## Tools
15
-
16
- ### 1. IP Lookup Tool
17
- - Name: `ip_lookup`
18
- - Description: Retrieve detailed information about an IP address
19
- - Parameters:
20
- * `ip` (required): IP address to lookup
21
-
22
- ### 2. Search Tool
23
- - Name: `search`
24
- - Description: Search for devices on Shodan
25
- - Parameters:
26
- * `query` (required): Shodan search query
27
- * `max_results` (optional, default: 10): Number of results to return
28
-
29
- ### 3. Vulnerabilities Tool
30
- - Name: `vulnerabilities`
31
- - Description: Fetch detailed information about CVEs using Shodan's CVEDB
32
- - Parameters:
33
- * `cve` (required): CVE identifier in format CVE-YYYY-NNNNN (e.g., CVE-2021-44228)
34
- - Returns:
35
- * CVE details including:
36
- - CVSS v2 and v3 scores
37
- - EPSS score and ranking
38
- - KEV status
39
- - Proposed action
40
- - Ransomware campaign information
41
- - Affected products (CPEs)
42
- - References
43
-
44
- ### 4. CPE Lookup Tool
45
- - Name: `cpe_lookup`
46
- - Description: Search for Common Platform Enumeration (CPE) entries by product name
47
- - Parameters:
48
- * `product` (required): Name of the product to search for
49
- * `count` (optional, default: false): If true, returns only the count of matching CPEs
50
- * `skip` (optional, default: 0): Number of CPEs to skip (for pagination)
51
- * `limit` (optional, default: 1000): Maximum number of CPEs to return
52
- - Returns:
53
- * When count is true: Total number of matching CPEs
54
- * When count is false: List of CPEs with pagination details
55
-
56
- ### 5. DNS Lookup Tool
57
- - Name: `dns_lookup`
58
- - Description: Resolve hostnames to IP addresses
59
- - Parameters:
60
- * `hostnames` (required): Array of hostnames to resolve
61
-
62
- ## Requirements
63
-
64
- - Node.js (v18 or later)
65
- - A valid [Shodan API Key](https://account.shodan.io/)
66
-
67
- ## Setup Guide
68
-
69
- ### 1. Installation
70
-
71
- ```bash
72
- git clone <repository_url>
73
- cd mcp-shodan
74
- npm install
75
- ```
76
-
77
- ### 2. Configuration
78
-
79
- Create a `.env` file in the root directory:
80
- ```
81
- SHODAN_API_KEY=your_shodan_api_key
82
- ```
83
-
84
- ### 3. Build and Run
85
-
86
- ```bash
87
- npm run build
88
- npm start
89
- ```
90
-
91
- ### 4. Configure Claude Desktop
92
-
93
- There are two ways to configure the Shodan MCP server in Claude Desktop:
94
-
95
- #### Option 1: Direct Node Execution (Local Development)
96
- ```json
97
- {
98
- "mcpServers": {
99
- "shodan-mcp": {
100
- "command": "node",
101
- "args": ["path/to/mcp-shodan/build/index.js"],
102
- "env": {
103
- "SHODAN_API_KEY": "your_shodan_api_key",
104
- "DEBUG": "*"
105
- }
106
- }
107
- }
108
- }
109
- ```
110
-
111
- #### Option 2: NPX Installation (Recommended for Users)
112
- ```json
113
- {
114
- "mcpServers": {
115
- "shodan-mcp": {
116
- "command": "npm",
117
- "args": ["exec", "@burtthecoder/mcp-shodan"],
118
- "env": {
119
- "SHODAN_API_KEY": "your_shodan_api_key",
120
- "DEBUG": "*"
121
- }
122
- }
123
- }
124
- }
125
- ```
126
-
127
- The npm exec method automatically downloads and runs the latest version of the package from npm.
128
-
129
- Configuration file location:
130
-
131
- Windows: %APPDATA%\Claude\claude_desktop_config.json
132
- macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
133
-
134
- ## Usage
135
-
136
- 1. Start the MCP server:
137
- ```bash
138
- npm start
139
- ```
140
-
141
- 2. Launch Claude Desktop and ensure the Shodan MCP server is detected
142
- 3. Use any of the available tools through the Claude interface
143
-
144
- ## Development
145
-
146
- To run in development mode with hot reloading:
147
- ```bash
148
- npm run dev
149
- ```
150
-
151
- ## Error Handling
152
-
153
- The server includes comprehensive error handling for:
154
- - Invalid API keys
155
- - Rate limiting
156
- - Network errors
157
- - Invalid input parameters
158
- - Invalid CVE formats
159
- - Invalid CPE lookup parameters
160
-
161
- ## Version History
162
-
163
- - v1.0.6: Added CVEDB integration for enhanced CVE lookups and CPE search functionality
164
- - v1.0.0: Initial release with core functionality
165
-
166
- ## Contributing
167
-
168
- 1. Fork the repository
169
- 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
170
- 3. Commit your changes (`git commit -m 'Add amazing feature'`)
171
- 4. Push to the branch (`git push origin feature/amazing-feature`)
172
- 5. Open a Pull Request
173
-
174
- ## License
175
-
176
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
1
+ # Shodan MCP Server
2
+
3
+ A Model Context Protocol (MCP) server for querying the [Shodan API](https://shodan.io) and [Shodan CVEDB](https://cvedb.shodan.io). This server provides tools for IP lookups, device searches, DNS lookups, vulnerability queries, CPE lookups, and more. It is designed to integrate seamlessly with MCP-compatible applications like [Claude Desktop](https://claude.ai).
4
+
5
+ ## Quick Start (Recommended)
6
+
7
+ 1. Install the server globally via npm:
8
+ ```bash
9
+ npm install -g @burtthecoder/mcp-shodan
10
+ ```
11
+
12
+ 2. Add to your Claude Desktop configuration file:
13
+ ```json
14
+ {
15
+ "mcpServers": {
16
+ "shodan": {
17
+ "command": "mcp-shodan",
18
+ "env": {
19
+ "SHODAN_API_KEY": "your-shodan-api-key"
20
+ }
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ Configuration file location:
27
+ - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
28
+ - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
29
+
30
+ 3. Restart Claude Desktop
31
+
32
+ ## Alternative Setup (From Source)
33
+
34
+ If you prefer to run from source or need to modify the code:
35
+
36
+ 1. Clone and build:
37
+ ```bash
38
+ git clone https://github.com/BurtTheCoder/mcp-shodan.git
39
+ cd mcp-shodan
40
+ npm install
41
+ npm run build
42
+ ```
43
+
44
+ 2. Add to your Claude Desktop configuration:
45
+ ```json
46
+ {
47
+ "mcpServers": {
48
+ "shodan": {
49
+ "command": "node",
50
+ "args": ["/absolute/path/to/mcp-shodan/build/index.js"],
51
+ "env": {
52
+ "SHODAN_API_KEY": "your-shodan-api-key"
53
+ }
54
+ }
55
+ }
56
+ }
57
+ ```
58
+
59
+ ## Features
60
+
61
+ - **IP Lookup**: Retrieve detailed information about an IP address
62
+ - **Search**: Search for devices on Shodan matching specific queries
63
+ - **Ports**: Get a list of ports that Shodan is scanning
64
+ - **CVE Lookup**: Fetch detailed information about specific CVEs using Shodan's CVEDB
65
+ - **CPE Lookup**: Search for Common Platform Enumeration (CPE) entries by product name
66
+ - **CVEs by Product**: Search for all CVEs affecting a specific product or CPE
67
+ - **DNS Lookup**: Resolve hostnames to IP addresses
68
+
69
+ ## Tools
70
+
71
+ ### 1. IP Lookup Tool
72
+ - Name: `ip_lookup`
73
+ - Description: Retrieve detailed information about an IP address
74
+ - Parameters:
75
+ * `ip` (required): IP address to lookup
76
+
77
+ ### 2. Search Tool
78
+ - Name: `search`
79
+ - Description: Search for devices on Shodan
80
+ - Parameters:
81
+ * `query` (required): Shodan search query
82
+ * `max_results` (optional, default: 10): Number of results to return
83
+
84
+ ### 3. CVE Lookup Tool
85
+ - Name: `cve_lookup`
86
+ - Description: Fetch detailed information about CVEs using Shodan's CVEDB
87
+ - Parameters:
88
+ * `cve` (required): CVE identifier in format CVE-YYYY-NNNNN (e.g., CVE-2021-44228)
89
+ - Returns:
90
+ * CVE details including:
91
+ - CVSS v2 and v3 scores
92
+ - EPSS score and ranking
93
+ - KEV status
94
+ - Proposed action
95
+ - Ransomware campaign information
96
+ - Affected products (CPEs)
97
+ - References
98
+
99
+ ### 4. CPE Lookup Tool
100
+ - Name: `cpe_lookup`
101
+ - Description: Search for Common Platform Enumeration (CPE) entries by product name
102
+ - Parameters:
103
+ * `product` (required): Name of the product to search for
104
+ * `count` (optional, default: false): If true, returns only the count of matching CPEs
105
+ * `skip` (optional, default: 0): Number of CPEs to skip (for pagination)
106
+ * `limit` (optional, default: 1000): Maximum number of CPEs to return
107
+ - Returns:
108
+ * When count is true: Total number of matching CPEs
109
+ * When count is false: List of CPEs with pagination details
110
+
111
+ ### 5. CVEs by Product Tool
112
+ - Name: `cves_by_product`
113
+ - Description: Search for CVEs affecting a specific product or CPE
114
+ - Parameters:
115
+ * `cpe23` (optional): CPE 2.3 identifier (format: cpe:2.3:part:vendor:product:version)
116
+ * `product` (optional): Name of the product to search for CVEs
117
+ * `count` (optional, default: false): If true, returns only the count of matching CVEs
118
+ * `is_kev` (optional, default: false): If true, returns only CVEs with KEV flag set
119
+ * `sort_by_epss` (optional, default: false): If true, sorts CVEs by EPSS score
120
+ * `skip` (optional, default: 0): Number of CVEs to skip (for pagination)
121
+ * `limit` (optional, default: 1000): Maximum number of CVEs to return
122
+ * `start_date` (optional): Start date for filtering CVEs (format: YYYY-MM-DDTHH:MM:SS)
123
+ * `end_date` (optional): End date for filtering CVEs (format: YYYY-MM-DDTHH:MM:SS)
124
+ - Notes:
125
+ * Must provide either cpe23 or product, but not both
126
+ * Date filtering uses published time of CVEs
127
+ - Returns:
128
+ * When count is true: Total number of matching CVEs
129
+ * When count is false: List of CVEs with pagination details and query parameters
130
+
131
+ ### 6. DNS Lookup Tool
132
+ - Name: `dns_lookup`
133
+ - Description: Resolve hostnames to IP addresses
134
+ - Parameters:
135
+ * `hostnames` (required): Array of hostnames to resolve
136
+
137
+ ## Requirements
138
+
139
+ - Node.js (v18 or later)
140
+ - A valid [Shodan API Key](https://account.shodan.io/)
141
+
142
+ ## Troubleshooting
143
+
144
+ ### API Key Issues
145
+
146
+ If you see API key related errors:
147
+
148
+ 1. Verify your API key:
149
+ - Should be a valid Shodan API key
150
+ - No extra spaces or quotes around the key
151
+ - Must be from your Shodan account settings
152
+ 2. After any configuration changes:
153
+ - Save the config file
154
+ - Restart Claude Desktop
155
+
156
+ ### Module Loading Issues
157
+
158
+ If you see module loading errors:
159
+ 1. For global installation: Use the simple configuration shown in Quick Start
160
+ 2. For source installation: Ensure you're using Node.js v18 or later
161
+
162
+ ## Development
163
+
164
+ To run in development mode with hot reloading:
165
+ ```bash
166
+ npm run dev
167
+ ```
168
+
169
+ ## Error Handling
170
+
171
+ The server includes comprehensive error handling for:
172
+ - Invalid API keys
173
+ - Rate limiting
174
+ - Network errors
175
+ - Invalid input parameters
176
+ - Invalid CVE formats
177
+ - Invalid CPE lookup parameters
178
+ - Invalid date formats
179
+ - Mutually exclusive parameter validation
180
+
181
+ ## Version History
182
+
183
+ - v1.0.7: Added CVEs by Product search functionality and renamed vulnerabilities tool to cve_lookup
184
+ - v1.0.6: Added CVEDB integration for enhanced CVE lookups and CPE search functionality
185
+ - v1.0.0: Initial release with core functionality
186
+
187
+ ## Contributing
188
+
189
+ 1. Fork the repository
190
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
191
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
192
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
193
+ 5. Open a Pull Request
194
+
195
+ ## License
196
+
197
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
package/build/index.js CHANGED
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env node
2
1
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
2
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
3
  import { CallToolRequestSchema, ListToolsRequestSchema, InitializeRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
@@ -41,7 +40,7 @@ const SearchArgsSchema = z.object({
41
40
  .default(10)
42
41
  .describe("Maximum results to return."),
43
42
  });
44
- const VulnerabilitiesArgsSchema = z.object({
43
+ const CVELookupArgsSchema = z.object({
45
44
  cve: z.string()
46
45
  .regex(/^CVE-\d{4}-\d{4,}$/i, "Must be a valid CVE ID format (e.g., CVE-2021-44228)")
47
46
  .describe("The CVE identifier to query (format: CVE-YYYY-NNNNN)."),
@@ -55,6 +54,17 @@ const CpeLookupArgsSchema = z.object({
55
54
  skip: z.number().optional().default(0).describe("Number of CPEs to skip (for pagination)."),
56
55
  limit: z.number().optional().default(1000).describe("Maximum number of CPEs to return (max 1000)."),
57
56
  });
57
+ const CVEsByProductArgsSchema = z.object({
58
+ cpe23: z.string().optional().describe("The CPE version 2.3 identifier (format: cpe:2.3:part:vendor:product:version)."),
59
+ product: z.string().optional().describe("The name of the product to search for CVEs."),
60
+ count: z.boolean().optional().default(false).describe("If true, returns only the count of matching CVEs."),
61
+ is_kev: z.boolean().optional().default(false).describe("If true, returns only CVEs with the KEV flag set."),
62
+ sort_by_epss: z.boolean().optional().default(false).describe("If true, sorts CVEs by EPSS score in descending order."),
63
+ skip: z.number().optional().default(0).describe("Number of CVEs to skip (for pagination)."),
64
+ limit: z.number().optional().default(1000).describe("Maximum number of CVEs to return (max 1000)."),
65
+ start_date: z.string().optional().describe("Start date for filtering CVEs (format: YYYY-MM-DDTHH:MM:SS)."),
66
+ end_date: z.string().optional().describe("End date for filtering CVEs (format: YYYY-MM-DDTHH:MM:SS).")
67
+ }).refine(data => !(data.cpe23 && data.product), { message: "Cannot specify both cpe23 and product. Use only one." }).refine(data => data.cpe23 || data.product, { message: "Must specify either cpe23 or product." });
58
68
  // Helper Function to Query Shodan API
59
69
  async function queryShodan(endpoint, params) {
60
70
  try {
@@ -101,6 +111,20 @@ async function queryCPEDB(params) {
101
111
  throw new Error(`CVEDB API error: ${error.message}`);
102
112
  }
103
113
  }
114
+ // Helper Function for CVEs by product/CPE lookups using CVEDB
115
+ async function queryCVEsByProduct(params) {
116
+ try {
117
+ logToFile(`Querying CVEDB for CVEs with params: ${JSON.stringify(params)}`);
118
+ const response = await axios.get(`${CVEDB_API_URL}/cves`, { params });
119
+ return response.data;
120
+ }
121
+ catch (error) {
122
+ if (error.response?.status === 422) {
123
+ throw new Error(`Invalid parameters: ${error.response.data?.detail || error.message}`);
124
+ }
125
+ throw new Error(`CVEDB API error: ${error.message}`);
126
+ }
127
+ }
104
128
  // Server Setup
105
129
  const server = new Server({
106
130
  name: "shodan-mcp",
@@ -126,7 +150,7 @@ server.setRequestHandler(InitializeRequestSchema, async (request) => {
126
150
  name: "shodan-mcp",
127
151
  version: "1.0.0",
128
152
  },
129
- instructions: "This server provides tools for querying Shodan, including IP lookups, searches, vulnerabilities, and CPE lookups.",
153
+ instructions: "This server provides tools for querying Shodan, including IP lookups, searches, CVE lookups, CPE lookups, and CVE searches by product/CPE.",
130
154
  };
131
155
  });
132
156
  // Register Tools
@@ -143,9 +167,9 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
143
167
  inputSchema: zodToJsonSchema(SearchArgsSchema),
144
168
  },
145
169
  {
146
- name: "vulnerabilities",
170
+ name: "cve_lookup",
147
171
  description: "Retrieve vulnerability information for a CVE. Use format: CVE-YYYY-NNNNN (e.g., CVE-2021-44228)",
148
- inputSchema: zodToJsonSchema(VulnerabilitiesArgsSchema),
172
+ inputSchema: zodToJsonSchema(CVELookupArgsSchema),
149
173
  },
150
174
  {
151
175
  name: "dns_lookup",
@@ -157,6 +181,11 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
157
181
  description: "Search for Common Platform Enumeration (CPE) entries by product name.",
158
182
  inputSchema: zodToJsonSchema(CpeLookupArgsSchema),
159
183
  },
184
+ {
185
+ name: "cves_by_product",
186
+ description: "Search for CVEs affecting a specific product or CPE. Provide either product name or CPE 2.3 identifier.",
187
+ inputSchema: zodToJsonSchema(CVEsByProductArgsSchema),
188
+ },
160
189
  ];
161
190
  logToFile("Registered tools.");
162
191
  return { tools };
@@ -200,12 +229,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
200
229
  ],
201
230
  };
202
231
  }
203
- case "vulnerabilities": {
204
- const parsedVulnArgs = VulnerabilitiesArgsSchema.safeParse(args);
205
- if (!parsedVulnArgs.success) {
232
+ case "cve_lookup": {
233
+ const parsedCveArgs = CVELookupArgsSchema.safeParse(args);
234
+ if (!parsedCveArgs.success) {
206
235
  throw new Error("Invalid CVE format. Please use format: CVE-YYYY-NNNNN (e.g., CVE-2021-44228)");
207
236
  }
208
- const cveId = parsedVulnArgs.data.cve.toUpperCase();
237
+ const cveId = parsedCveArgs.data.cve.toUpperCase();
209
238
  logToFile(`Looking up CVE: ${cveId}`);
210
239
  try {
211
240
  const result = await queryCVEDB(cveId);
@@ -308,6 +337,61 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
308
337
  };
309
338
  }
310
339
  }
340
+ case "cves_by_product": {
341
+ const parsedArgs = CVEsByProductArgsSchema.safeParse(args);
342
+ if (!parsedArgs.success) {
343
+ throw new Error("Invalid arguments. Must provide either cpe23 or product name, but not both.");
344
+ }
345
+ try {
346
+ const result = await queryCVEsByProduct({
347
+ cpe23: parsedArgs.data.cpe23,
348
+ product: parsedArgs.data.product,
349
+ count: parsedArgs.data.count,
350
+ is_kev: parsedArgs.data.is_kev,
351
+ sort_by_epss: parsedArgs.data.sort_by_epss,
352
+ skip: parsedArgs.data.skip,
353
+ limit: parsedArgs.data.limit,
354
+ start_date: parsedArgs.data.start_date,
355
+ end_date: parsedArgs.data.end_date
356
+ });
357
+ // Format the response based on whether it's a count request or full CVE list
358
+ const formattedResult = parsedArgs.data.count
359
+ ? { total_cves: result.total }
360
+ : {
361
+ cves: result.cves,
362
+ skip: parsedArgs.data.skip,
363
+ limit: parsedArgs.data.limit,
364
+ total_returned: result.cves.length,
365
+ query_params: {
366
+ cpe23: parsedArgs.data.cpe23,
367
+ product: parsedArgs.data.product,
368
+ is_kev: parsedArgs.data.is_kev,
369
+ sort_by_epss: parsedArgs.data.sort_by_epss,
370
+ start_date: parsedArgs.data.start_date,
371
+ end_date: parsedArgs.data.end_date
372
+ }
373
+ };
374
+ return {
375
+ content: [
376
+ {
377
+ type: "text",
378
+ text: JSON.stringify(formattedResult, null, 2),
379
+ },
380
+ ],
381
+ };
382
+ }
383
+ catch (error) {
384
+ return {
385
+ content: [
386
+ {
387
+ type: "text",
388
+ text: error.message,
389
+ },
390
+ ],
391
+ isError: true,
392
+ };
393
+ }
394
+ }
311
395
  default:
312
396
  throw new Error(`Unknown tool: ${name}`);
313
397
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@burtthecoder/mcp-shodan",
4
- "version": "1.0.7",
4
+ "version": "1.0.9",
5
5
  "description": "A Model Context Protocol server for Shodan API queries.",
6
6
  "main": "./build/index.js",
7
7
  "bin": {