Skip to content

Commit

Permalink
Add Github Action and update README
Browse files Browse the repository at this point in the history
  • Loading branch information
BurtTheCoder committed Dec 13, 2024
1 parent 41069e4 commit 605c156
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 97 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Publish to NPM

on:
push:
branches:
- main
release:
types: [created]

jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'

- name: Configure Git
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
- name: Install dependencies
run: npm ci

- name: Bump version
if: github.event_name == 'push' && !contains(github.event.head_commit.message, '[skip ci]')
run: |
npm version patch -m "Bump version to %s [skip ci]"
git push
git push --tags
- name: Build
run: npm run build

- name: Publish to NPM
if: success()
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
28 changes: 4 additions & 24 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,31 +1,11 @@
# Source
# Source files (since we publish the build)
src/

# Development configs
# Development files
.github/
tsconfig.json
.gitignore
.env*
.vscode/

# Logs
*.log
server.log

# Tests
test/
__tests__/
*.test.ts
*.spec.ts

# Development files
.editorconfig
.eslintrc*
.prettierrc*
.github/
docs/

# Dependencies
node_modules/

# Don't ignore
# Don't ignore the build directory
!build/
139 changes: 68 additions & 71 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,60 @@

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).

## Quick Start (Recommended)

1. Install the server globally via npm:
```bash
npm install -g @burtthecoder/mcp-shodan
```

2. Add to your Claude Desktop configuration file:
```json
{
"mcpServers": {
"shodan": {
"command": "mcp-shodan",
"env": {
"SHODAN_API_KEY": "your-shodan-api-key"
}
}
}
}
```

Configuration file location:
- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`

3. Restart Claude Desktop

## Alternative Setup (From Source)

If you prefer to run from source or need to modify the code:

1. Clone and build:
```bash
git clone https://github.com/BurtTheCoder/mcp-shodan.git
cd mcp-shodan
npm install
npm run build
```

2. Add to your Claude Desktop configuration:
```json
{
"mcpServers": {
"shodan": {
"command": "node",
"args": ["/absolute/path/to/mcp-shodan/build/index.js"],
"env": {
"SHODAN_API_KEY": "your-shodan-api-key"
}
}
}
}
```

## Features

- **IP Lookup**: Retrieve detailed information about an IP address
Expand Down Expand Up @@ -85,82 +139,25 @@ A Model Context Protocol (MCP) server for querying the [Shodan API](https://shod
- Node.js (v18 or later)
- A valid [Shodan API Key](https://account.shodan.io/)

## Setup Guide

### 1. Installation

```bash
git clone <repository_url>
cd mcp-shodan
npm install
```

### 2. Configuration

Create a `.env` file in the root directory:
```
SHODAN_API_KEY=your_shodan_api_key
```

### 3. Build and Run
## Troubleshooting

```bash
npm run build
npm start
```
### API Key Issues

### 4. Configure Claude Desktop
If you see API key related errors:

There are two ways to configure the Shodan MCP server in Claude Desktop:
1. Verify your API key:
- Should be a valid Shodan API key
- No extra spaces or quotes around the key
- Must be from your Shodan account settings
2. After any configuration changes:
- Save the config file
- Restart Claude Desktop

#### Option 1: Direct Node Execution (Local Development)
```json
{
"mcpServers": {
"shodan-mcp": {
"command": "node",
"args": ["path/to/mcp-shodan/build/index.js"],
"env": {
"SHODAN_API_KEY": "your_shodan_api_key",
"DEBUG": "*"
}
}
}
}
```

#### Option 2: NPX Installation (Recommended for Users)
```json
{
"mcpServers": {
"shodan-mcp": {
"command": "npm",
"args": ["exec", "@burtthecoder/mcp-shodan"],
"env": {
"SHODAN_API_KEY": "your_shodan_api_key",
"DEBUG": "*"
}
}
}
}
```

The npm exec method automatically downloads and runs the latest version of the package from npm.

Configuration file location:

Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

## Usage

1. Start the MCP server:
```bash
npm start
```
### Module Loading Issues

2. Launch Claude Desktop and ensure the Shodan MCP server is detected
3. Use any of the available tools through the Claude interface
If you see module loading errors:
1. For global installation: Use the simple configuration shown in Quick Start
2. For source installation: Ensure you're using Node.js v18 or later

## Development

Expand Down
2 changes: 0 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env node

import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import {
Expand Down

0 comments on commit 605c156

Please sign in to comment.