ferrum-mcp 1.0.0
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.
- checksums.yaml +7 -0
- data/.env.example +90 -0
- data/CHANGELOG.md +229 -0
- data/CONTRIBUTING.md +469 -0
- data/LICENSE +21 -0
- data/README.md +334 -0
- data/SECURITY.md +286 -0
- data/bin/ferrum-mcp +66 -0
- data/bin/lint +10 -0
- data/bin/serve +3 -0
- data/bin/test +4 -0
- data/docs/API_REFERENCE.md +1410 -0
- data/docs/CONFIGURATION.md +254 -0
- data/docs/DEPLOYMENT.md +846 -0
- data/docs/DOCKER.md +836 -0
- data/docs/DOCKER_BOTBROWSER.md +455 -0
- data/docs/GETTING_STARTED.md +249 -0
- data/docs/TROUBLESHOOTING.md +677 -0
- data/lib/ferrum_mcp/browser_manager.rb +101 -0
- data/lib/ferrum_mcp/cli/command_handler.rb +99 -0
- data/lib/ferrum_mcp/cli/server_runner.rb +166 -0
- data/lib/ferrum_mcp/configuration.rb +229 -0
- data/lib/ferrum_mcp/resource_manager.rb +223 -0
- data/lib/ferrum_mcp/server.rb +254 -0
- data/lib/ferrum_mcp/session.rb +227 -0
- data/lib/ferrum_mcp/session_manager.rb +183 -0
- data/lib/ferrum_mcp/tools/accept_cookies_tool.rb +458 -0
- data/lib/ferrum_mcp/tools/base_tool.rb +114 -0
- data/lib/ferrum_mcp/tools/clear_cookies_tool.rb +66 -0
- data/lib/ferrum_mcp/tools/click_tool.rb +218 -0
- data/lib/ferrum_mcp/tools/close_session_tool.rb +49 -0
- data/lib/ferrum_mcp/tools/create_session_tool.rb +146 -0
- data/lib/ferrum_mcp/tools/drag_and_drop_tool.rb +171 -0
- data/lib/ferrum_mcp/tools/evaluate_js_tool.rb +46 -0
- data/lib/ferrum_mcp/tools/execute_script_tool.rb +48 -0
- data/lib/ferrum_mcp/tools/fill_form_tool.rb +78 -0
- data/lib/ferrum_mcp/tools/find_by_text_tool.rb +153 -0
- data/lib/ferrum_mcp/tools/get_attribute_tool.rb +56 -0
- data/lib/ferrum_mcp/tools/get_cookies_tool.rb +70 -0
- data/lib/ferrum_mcp/tools/get_html_tool.rb +52 -0
- data/lib/ferrum_mcp/tools/get_session_info_tool.rb +40 -0
- data/lib/ferrum_mcp/tools/get_text_tool.rb +67 -0
- data/lib/ferrum_mcp/tools/get_title_tool.rb +42 -0
- data/lib/ferrum_mcp/tools/get_url_tool.rb +39 -0
- data/lib/ferrum_mcp/tools/go_back_tool.rb +49 -0
- data/lib/ferrum_mcp/tools/go_forward_tool.rb +49 -0
- data/lib/ferrum_mcp/tools/hover_tool.rb +76 -0
- data/lib/ferrum_mcp/tools/list_sessions_tool.rb +33 -0
- data/lib/ferrum_mcp/tools/navigate_tool.rb +59 -0
- data/lib/ferrum_mcp/tools/press_key_tool.rb +91 -0
- data/lib/ferrum_mcp/tools/query_shadow_dom_tool.rb +225 -0
- data/lib/ferrum_mcp/tools/refresh_tool.rb +49 -0
- data/lib/ferrum_mcp/tools/screenshot_tool.rb +121 -0
- data/lib/ferrum_mcp/tools/session_tool.rb +37 -0
- data/lib/ferrum_mcp/tools/set_cookie_tool.rb +77 -0
- data/lib/ferrum_mcp/tools/solve_captcha_tool.rb +528 -0
- data/lib/ferrum_mcp/transport/http_server.rb +93 -0
- data/lib/ferrum_mcp/transport/rate_limiter.rb +79 -0
- data/lib/ferrum_mcp/transport/stdio_server.rb +63 -0
- data/lib/ferrum_mcp/version.rb +5 -0
- data/lib/ferrum_mcp/whisper_service.rb +222 -0
- data/lib/ferrum_mcp.rb +35 -0
- metadata +248 -0
data/README.md
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
# FerrumMCP 🌐
|
|
2
|
+
|
|
3
|
+
[](https://github.com/Eth3rnit3/FerrumMCP/actions/workflows/ci.yml)
|
|
4
|
+
[](https://rubygems.org/gems/ferrum-mcp)
|
|
5
|
+
[](https://github.com/Eth3rnit3/FerrumMCP/actions/workflows/docker-publish.yml)
|
|
6
|
+
[](https://www.ruby-lang.org)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
[](https://hub.docker.com/r/eth3rnit3/ferrum-mcp)
|
|
9
|
+
|
|
10
|
+
> A browser automation server for the Model Context Protocol (MCP), enabling AI assistants to interact with web pages through a standardized interface.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 🚀 Quick Links
|
|
15
|
+
|
|
16
|
+
| Documentation | Description |
|
|
17
|
+
|---------------|-------------|
|
|
18
|
+
| [**Getting Started**](docs/GETTING_STARTED.md) | Installation, setup, and first steps |
|
|
19
|
+
| [**Docker Deployment**](docs/DOCKER.md) | Complete Docker guide with Claude Desktop integration |
|
|
20
|
+
| [**API Reference**](docs/API_REFERENCE.md) | Complete documentation of all 27+ tools |
|
|
21
|
+
| [**Configuration**](docs/CONFIGURATION.md) | Environment variables and advanced configuration |
|
|
22
|
+
| [**Troubleshooting**](docs/TROUBLESHOOTING.md) | Common issues and solutions |
|
|
23
|
+
| [**Deployment**](docs/DEPLOYMENT.md) | Production deployment guide |
|
|
24
|
+
| [**BotBrowser Integration**](docs/DOCKER_BOTBROWSER.md) | Anti-detection browser setup |
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 📖 Table of Contents
|
|
29
|
+
|
|
30
|
+
- [What is FerrumMCP?](#what-is-ferrummcp)
|
|
31
|
+
- [Features](#features)
|
|
32
|
+
- [Quick Start](#quick-start)
|
|
33
|
+
- [Documentation](#documentation)
|
|
34
|
+
- [Tools & Capabilities](#tools--capabilities)
|
|
35
|
+
- [Project Resources](#project-resources)
|
|
36
|
+
- [Contributing](#contributing)
|
|
37
|
+
- [License](#license)
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## What is FerrumMCP?
|
|
42
|
+
|
|
43
|
+
FerrumMCP is a **browser automation server** that implements the **Model Context Protocol (MCP)** by Anthropic. It provides AI assistants with the ability to navigate websites, interact with elements, extract content, and perform complex browser automation tasks through a simple, standardized interface.
|
|
44
|
+
|
|
45
|
+
**Key Benefits:**
|
|
46
|
+
- 🤖 **AI-Native Design**: Purpose-built for AI assistants like Claude
|
|
47
|
+
- 🔄 **Session-Based**: Multiple concurrent browser sessions with isolated configurations
|
|
48
|
+
- 🌐 **Multi-Browser**: Support for Chrome, Edge, Brave, and BotBrowser
|
|
49
|
+
- 🧩 **Smart Automation**: Cookie banner detection and CAPTCHA solving (⚠️ experimental)
|
|
50
|
+
- 📦 **Easy Deployment**: Docker, systemd, or Kubernetes ready
|
|
51
|
+
- 🔌 **Dual Transport**: HTTP and STDIO for maximum compatibility
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Features
|
|
56
|
+
|
|
57
|
+
### Core Capabilities
|
|
58
|
+
|
|
59
|
+
✅ **Session Management**
|
|
60
|
+
- Create/manage multiple browser sessions
|
|
61
|
+
- Automatic cleanup (30min idle timeout)
|
|
62
|
+
- Custom browser configurations per session
|
|
63
|
+
|
|
64
|
+
✅ **Navigation**
|
|
65
|
+
- URL navigation with network idle detection
|
|
66
|
+
- Browser history (back/forward)
|
|
67
|
+
- Page refresh
|
|
68
|
+
|
|
69
|
+
✅ **Interaction**
|
|
70
|
+
- Click, hover, drag-and-drop
|
|
71
|
+
- Form filling with typing delays
|
|
72
|
+
- Keyboard input simulation
|
|
73
|
+
- **Smart cookie banner acceptance** (8 strategies, multi-language)
|
|
74
|
+
- **AI-powered CAPTCHA solving** (Whisper integration - ⚠️ experimental, under development)
|
|
75
|
+
|
|
76
|
+
✅ **Extraction**
|
|
77
|
+
- Text and HTML content extraction
|
|
78
|
+
- Screenshot capture (base64)
|
|
79
|
+
- Page metadata (title, URL)
|
|
80
|
+
- XPath-based text search
|
|
81
|
+
|
|
82
|
+
✅ **Advanced**
|
|
83
|
+
- JavaScript execution and evaluation
|
|
84
|
+
- Cookie management (get/set/clear)
|
|
85
|
+
- Shadow DOM querying
|
|
86
|
+
- Element attribute retrieval
|
|
87
|
+
|
|
88
|
+
### Enterprise Features
|
|
89
|
+
|
|
90
|
+
🦾 **BotBrowser Integration**
|
|
91
|
+
- Anti-detection browser automation
|
|
92
|
+
- Fingerprint management with encrypted profiles
|
|
93
|
+
- **Note**: Requires valid trial/premium profiles (demo profiles cause session instability)
|
|
94
|
+
|
|
95
|
+
🔒 **Security** (v1.0+)
|
|
96
|
+
- Session limits
|
|
97
|
+
- Rate limiting
|
|
98
|
+
- Health check endpoint
|
|
99
|
+
- Non-root Docker user
|
|
100
|
+
|
|
101
|
+
📊 **Observability**
|
|
102
|
+
- File-based logging
|
|
103
|
+
- Health checks
|
|
104
|
+
- Metrics endpoint (planned)
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Quick Start
|
|
109
|
+
|
|
110
|
+
### Option 1: Docker (Recommended)
|
|
111
|
+
|
|
112
|
+
**Standard Image** (Chromium only):
|
|
113
|
+
```bash
|
|
114
|
+
docker pull eth3rnit3/ferrum-mcp:latest
|
|
115
|
+
docker run --security-opt seccomp=unconfined -p 3000:3000 eth3rnit3/ferrum-mcp:latest
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**BotBrowser Image** (Anti-detection):
|
|
119
|
+
```bash
|
|
120
|
+
docker pull eth3rnit3/ferrum-mcp:botbrowser
|
|
121
|
+
docker run --security-opt seccomp=unconfined -p 3000:3000 \
|
|
122
|
+
-v /path/to/bot_profiles:/profiles:ro \
|
|
123
|
+
-e "BROWSER_BOTBROWSER=botbrowser:/opt/botbrowser/chrome:BotBrowser:Anti-detection browser" \
|
|
124
|
+
-e "BOT_PROFILE_MACOS_1=/profiles/profile_1.enc:Profile 1:Trial profile 1" \
|
|
125
|
+
eth3rnit3/ferrum-mcp:botbrowser
|
|
126
|
+
```
|
|
127
|
+
### Option 2: Gem Installation
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
gem install ferrum-mcp
|
|
131
|
+
ferrum-mcp start
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Option 3: From Source
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
git clone https://github.com/Eth3rnit3/FerrumMCP.git
|
|
138
|
+
cd FerrumMCP
|
|
139
|
+
bundle install
|
|
140
|
+
ruby bin/ferrum-mcp
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**➡️ [Full installation guide](docs/GETTING_STARTED.md)**
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Documentation
|
|
148
|
+
|
|
149
|
+
### Getting Started
|
|
150
|
+
|
|
151
|
+
| Guide | Description |
|
|
152
|
+
|-------|-------------|
|
|
153
|
+
| [**Installation**](docs/GETTING_STARTED.md#quick-start) | Docker, gem, and source installation |
|
|
154
|
+
| [**Claude Desktop Setup**](docs/GETTING_STARTED.md#claude-desktop) | Integrate with Claude Desktop (STDIO) |
|
|
155
|
+
| [**First Session**](docs/GETTING_STARTED.md#usage-examples) | Create your first browser automation |
|
|
156
|
+
|
|
157
|
+
### Configuration
|
|
158
|
+
|
|
159
|
+
| Topic | Link |
|
|
160
|
+
|-------|------|
|
|
161
|
+
| **Environment Variables** | [Configuration Guide](docs/CONFIGURATION.md) |
|
|
162
|
+
| **Multi-Browser Setup** | [Multi-Browser Config](docs/CONFIGURATION.md#multi-browser-configuration) |
|
|
163
|
+
| **BotBrowser Integration** | [BotBrowser Guide](docs/DOCKER_BOTBROWSER.md) |
|
|
164
|
+
| **Resource Discovery** | [Resource Config](docs/CONFIGURATION.md#resource-discovery) |
|
|
165
|
+
|
|
166
|
+
### API Documentation
|
|
167
|
+
|
|
168
|
+
| Resource | Description |
|
|
169
|
+
|----------|-------------|
|
|
170
|
+
| [**API Reference**](docs/API_REFERENCE.md) | Complete tool documentation with examples |
|
|
171
|
+
| [**Session Management**](docs/API_REFERENCE.md#session-management) | Create, list, and manage browser sessions |
|
|
172
|
+
| [**Navigation Tools**](docs/API_REFERENCE.md#navigation-tools) | URL navigation and history |
|
|
173
|
+
| [**Interaction Tools**](docs/API_REFERENCE.md#interaction-tools) | Click, fill forms, solve CAPTCHAs |
|
|
174
|
+
| [**Extraction Tools**](docs/API_REFERENCE.md#extraction-tools) | Get content, screenshots, metadata |
|
|
175
|
+
| [**Advanced Tools**](docs/API_REFERENCE.md#advanced-tools) | JavaScript, cookies, Shadow DOM |
|
|
176
|
+
|
|
177
|
+
### Operations
|
|
178
|
+
|
|
179
|
+
| Guide | Description |
|
|
180
|
+
|-------|-------------|
|
|
181
|
+
| [**Troubleshooting**](docs/TROUBLESHOOTING.md) | Common issues and solutions |
|
|
182
|
+
| [**Deployment**](docs/DEPLOYMENT.md) | Docker, K8s, systemd deployment |
|
|
183
|
+
| [**Migration**](docs/MIGRATION.md) | Upgrade between versions |
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Tools & Capabilities
|
|
188
|
+
|
|
189
|
+
FerrumMCP provides **27+ browser automation tools** organized into 6 categories:
|
|
190
|
+
|
|
191
|
+
### 1. Session Management (4 tools)
|
|
192
|
+
- `create_session` - Create browser sessions with custom config
|
|
193
|
+
- `list_sessions` - List all active sessions
|
|
194
|
+
- `get_session_info` - Get detailed session information
|
|
195
|
+
- `close_session` - Manually close a session
|
|
196
|
+
|
|
197
|
+
### 2. Navigation (4 tools)
|
|
198
|
+
- `navigate` - Navigate to URLs
|
|
199
|
+
- `go_back` - Browser back button
|
|
200
|
+
- `go_forward` - Browser forward button
|
|
201
|
+
- `refresh` - Reload current page
|
|
202
|
+
|
|
203
|
+
### 3. Interaction (7 tools)
|
|
204
|
+
- `click` - Click elements
|
|
205
|
+
- `fill_form` - Fill form fields
|
|
206
|
+
- `press_key` - Keyboard input
|
|
207
|
+
- `hover` - Mouse hover
|
|
208
|
+
- `drag_and_drop` - Drag elements
|
|
209
|
+
- `accept_cookies` - **Smart cookie banner detection** (8 strategies)
|
|
210
|
+
- `solve_captcha` - **AI-powered CAPTCHA solving** (⚠️ experimental, under development)
|
|
211
|
+
|
|
212
|
+
### 4. Extraction (6 tools)
|
|
213
|
+
- `get_text` - Extract text content
|
|
214
|
+
- `get_html` - Get HTML content
|
|
215
|
+
- `screenshot` - Capture screenshots
|
|
216
|
+
- `get_title` - Get page title
|
|
217
|
+
- `get_url` - Get current URL
|
|
218
|
+
- `find_by_text` - XPath text search
|
|
219
|
+
|
|
220
|
+
### 5. Advanced (9 tools)
|
|
221
|
+
- `execute_script` - Run JavaScript
|
|
222
|
+
- `evaluate_js` - Evaluate JavaScript with return value
|
|
223
|
+
- `get_cookies` - Get browser cookies
|
|
224
|
+
- `set_cookie` - Set cookies
|
|
225
|
+
- `clear_cookies` - Clear cookies
|
|
226
|
+
- `get_attribute` - Get element attributes
|
|
227
|
+
- `query_shadow_dom` - Interact with Shadow DOM
|
|
228
|
+
|
|
229
|
+
### 6. MCP Resources (7 resources)
|
|
230
|
+
- `ferrum://browsers` - Discover configured browsers
|
|
231
|
+
- `ferrum://user-profiles` - Discover Chrome profiles
|
|
232
|
+
- `ferrum://bot-profiles` - Discover BotBrowser profiles
|
|
233
|
+
- `ferrum://capabilities` - Server capabilities
|
|
234
|
+
|
|
235
|
+
**➡️ [Complete API Reference](docs/API_REFERENCE.md)**
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## Project Resources
|
|
240
|
+
|
|
241
|
+
### Development
|
|
242
|
+
|
|
243
|
+
| Resource | Link |
|
|
244
|
+
|----------|------|
|
|
245
|
+
| **Contributing Guide** | [CONTRIBUTING.md](CONTRIBUTING.md) |
|
|
246
|
+
| **Security Policy** | [SECURITY.md](SECURITY.md) |
|
|
247
|
+
| **Changelog** | [CHANGELOG.md](CHANGELOG.md) |
|
|
248
|
+
| **AI Development Guide** | [CLAUDE.md](CLAUDE.md) |
|
|
249
|
+
|
|
250
|
+
### Community
|
|
251
|
+
|
|
252
|
+
| Platform | Link |
|
|
253
|
+
|----------|------|
|
|
254
|
+
| **GitHub Issues** | [Report bugs](https://github.com/Eth3rnit3/FerrumMCP/issues) |
|
|
255
|
+
| **GitHub Discussions** | [Ask questions](https://github.com/Eth3rnit3/FerrumMCP/discussions) |
|
|
256
|
+
| **Docker Hub** | [eth3rnit3/ferrum-mcp](https://hub.docker.com/r/eth3rnit3/ferrum-mcp) |
|
|
257
|
+
|
|
258
|
+
### Links
|
|
259
|
+
|
|
260
|
+
| Resource | URL |
|
|
261
|
+
|----------|-----|
|
|
262
|
+
| **Repository** | https://github.com/Eth3rnit3/FerrumMCP |
|
|
263
|
+
| **Documentation** | https://github.com/Eth3rnit3/FerrumMCP/tree/main/docs |
|
|
264
|
+
| **Releases** | https://github.com/Eth3rnit3/FerrumMCP/releases |
|
|
265
|
+
| **RubyGems** | https://rubygems.org/gems/ferrum-mcp |
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## Requirements
|
|
270
|
+
|
|
271
|
+
### System Requirements
|
|
272
|
+
- **Ruby**: 3.2 or higher
|
|
273
|
+
- **Browser**: Chrome, Chromium, Edge, or Brave
|
|
274
|
+
- **OS**: Linux, macOS, or Windows
|
|
275
|
+
|
|
276
|
+
### Optional Dependencies
|
|
277
|
+
- **whisper-cli**: For CAPTCHA solving
|
|
278
|
+
- **BotBrowser**: For anti-detection automation
|
|
279
|
+
- **Docker**: For containerized deployment
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## Contributing
|
|
284
|
+
|
|
285
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
286
|
+
|
|
287
|
+
**Quick contribution checklist:**
|
|
288
|
+
- 📖 Read [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
289
|
+
- 🐛 Use issue templates for bugs
|
|
290
|
+
- ✨ Use feature request template
|
|
291
|
+
- ✅ Run tests: `bundle exec rspec`
|
|
292
|
+
- 📝 Update documentation
|
|
293
|
+
- 🎨 Follow RuboCop style
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## Security
|
|
298
|
+
|
|
299
|
+
For security vulnerabilities, please email [eth3rnit3@gmail.com](mailto:eth3rnit3@gmail.com). See [SECURITY.md](SECURITY.md) for our security policy.
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## License
|
|
304
|
+
|
|
305
|
+
FerrumMCP is released under the [MIT License](LICENSE).
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
## Credits
|
|
310
|
+
|
|
311
|
+
Built with:
|
|
312
|
+
- [Ferrum](https://github.com/rubycdp/ferrum) - Ruby Chrome DevTools Protocol
|
|
313
|
+
- [Model Context Protocol](https://github.com/anthropics/mcp) by Anthropic
|
|
314
|
+
- [Whisper](https://github.com/ggerganov/whisper.cpp) for CAPTCHA solving
|
|
315
|
+
- [BotBrowser](https://botbrowser.com) for anti-detection (optional)
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
## Support
|
|
320
|
+
|
|
321
|
+
- 📚 **Documentation**: [docs/](docs/)
|
|
322
|
+
- 💬 **Discussions**: [GitHub Discussions](https://github.com/Eth3rnit3/FerrumMCP/discussions)
|
|
323
|
+
- 🐛 **Issues**: [GitHub Issues](https://github.com/Eth3rnit3/FerrumMCP/issues)
|
|
324
|
+
- 📧 **Email**: [eth3rnit3@gmail.com](mailto:eth3rnit3@gmail.com)
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
<p align="center">
|
|
329
|
+
<strong>Made with ❤️ by <a href="https://github.com/Eth3rnit3">Eth3rnit3</a></strong>
|
|
330
|
+
</p>
|
|
331
|
+
|
|
332
|
+
<p align="center">
|
|
333
|
+
<a href="#-quick-links">Back to Top</a>
|
|
334
|
+
</p>
|
data/SECURITY.md
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
We release patches for security vulnerabilities for the following versions:
|
|
6
|
+
|
|
7
|
+
| Version | Supported |
|
|
8
|
+
| ------- | ------------------ |
|
|
9
|
+
| 0.1.x | :white_check_mark: |
|
|
10
|
+
| < 0.1 | :x: |
|
|
11
|
+
|
|
12
|
+
## Security Model and Trust Assumptions
|
|
13
|
+
|
|
14
|
+
FerrumMCP is designed to operate in **trusted environments** with the following security assumptions:
|
|
15
|
+
|
|
16
|
+
### Trust Model
|
|
17
|
+
|
|
18
|
+
1. **Trusted Environment**: FerrumMCP assumes it runs in a controlled environment where all clients are trusted
|
|
19
|
+
2. **No Public Exposure**: The server should NOT be exposed to the public internet without additional security layers
|
|
20
|
+
3. **Trusted Input**: Tool inputs are assumed to come from trusted AI assistants, not untrusted users
|
|
21
|
+
4. **Local Network**: HTTP transport is intended for localhost or private network use only
|
|
22
|
+
|
|
23
|
+
### What FerrumMCP Does NOT Provide
|
|
24
|
+
|
|
25
|
+
- ❌ **Authentication**: No API keys, tokens, or user authentication
|
|
26
|
+
- ❌ **Authorization**: No role-based access control or permissions
|
|
27
|
+
- ❌ **Rate Limiting**: No built-in protection against DoS attacks
|
|
28
|
+
- ❌ **Input Sanitization**: Limited validation of user-provided selectors and scripts
|
|
29
|
+
- ❌ **Audit Logging**: No security event logging or monitoring
|
|
30
|
+
- ❌ **Encryption**: No TLS/SSL for HTTP transport (use reverse proxy if needed)
|
|
31
|
+
|
|
32
|
+
### Security Boundaries
|
|
33
|
+
|
|
34
|
+
FerrumMCP provides security at the following levels:
|
|
35
|
+
|
|
36
|
+
✅ **Browser Sandbox**: Relies on Chrome's built-in sandbox for isolation
|
|
37
|
+
✅ **Thread Safety**: Mutex-protected session management prevents race conditions
|
|
38
|
+
✅ **Session Isolation**: Each browser session is isolated from others
|
|
39
|
+
✅ **Dependency Pinning**: All gems use pessimistic version constraints
|
|
40
|
+
✅ **Input Validation**: Session IDs and basic parameters are validated
|
|
41
|
+
|
|
42
|
+
## Known Security Considerations
|
|
43
|
+
|
|
44
|
+
### 1. Arbitrary JavaScript Execution
|
|
45
|
+
|
|
46
|
+
**Tools affected**: `execute_script`, `evaluate_js`
|
|
47
|
+
|
|
48
|
+
**Risk**: These tools allow execution of arbitrary JavaScript in the browser context.
|
|
49
|
+
|
|
50
|
+
**Mitigation**:
|
|
51
|
+
- Only use in trusted environments
|
|
52
|
+
- Do not expose to untrusted users
|
|
53
|
+
- Consider disabling these tools if not needed
|
|
54
|
+
|
|
55
|
+
### 2. File System Access
|
|
56
|
+
|
|
57
|
+
**Tools affected**: `screenshot`, potential future download features
|
|
58
|
+
|
|
59
|
+
**Risk**: Screenshots are saved to disk and could fill storage or access sensitive paths.
|
|
60
|
+
|
|
61
|
+
**Mitigation**:
|
|
62
|
+
- Screenshots are temporary and base64-encoded
|
|
63
|
+
- No direct file path control by users
|
|
64
|
+
- Consider implementing storage quotas
|
|
65
|
+
|
|
66
|
+
### 3. Network Access
|
|
67
|
+
|
|
68
|
+
**Tools affected**: `navigate`, all browser operations
|
|
69
|
+
|
|
70
|
+
**Risk**: Browser can access arbitrary URLs including internal networks.
|
|
71
|
+
|
|
72
|
+
**Mitigation**:
|
|
73
|
+
- Use browser's built-in protections
|
|
74
|
+
- Consider firewall rules to restrict browser network access
|
|
75
|
+
- Monitor for suspicious navigation patterns
|
|
76
|
+
|
|
77
|
+
### 4. XPath Injection
|
|
78
|
+
|
|
79
|
+
**Tools affected**: `find_by_text`
|
|
80
|
+
|
|
81
|
+
**Risk**: User-provided text could manipulate XPath queries.
|
|
82
|
+
|
|
83
|
+
**Mitigation**:
|
|
84
|
+
- Partial escaping implemented for quotes
|
|
85
|
+
- Use CSS selectors when possible
|
|
86
|
+
- Full XPath sanitization planned for v1.1
|
|
87
|
+
|
|
88
|
+
### 5. Session Resource Exhaustion
|
|
89
|
+
|
|
90
|
+
**Risk**: Unlimited session creation could exhaust system resources (DoS).
|
|
91
|
+
|
|
92
|
+
**Current Status**: No hard limits enforced
|
|
93
|
+
**Planned**: `MAX_CONCURRENT_SESSIONS` configuration in v1.1
|
|
94
|
+
|
|
95
|
+
**Temporary Mitigation**:
|
|
96
|
+
- Sessions auto-close after 30 minutes idle
|
|
97
|
+
- Background cleanup every 5 minutes
|
|
98
|
+
- Monitor session count via `list_sessions`
|
|
99
|
+
|
|
100
|
+
### 6. Docker Root Execution
|
|
101
|
+
|
|
102
|
+
**Risk**: Docker container runs as root by default.
|
|
103
|
+
|
|
104
|
+
**Current Status**: No USER directive in Dockerfile
|
|
105
|
+
**Planned**: Non-root user in v1.1
|
|
106
|
+
|
|
107
|
+
**Temporary Mitigation**:
|
|
108
|
+
- Use Docker user namespaces
|
|
109
|
+
- Run with `--user` flag: `docker run --user 1000:1000 ...`
|
|
110
|
+
- Apply SELinux or AppArmor policies
|
|
111
|
+
|
|
112
|
+
### 7. Cookie and Credential Exposure
|
|
113
|
+
|
|
114
|
+
**Tools affected**: `get_cookies`, `set_cookie`
|
|
115
|
+
|
|
116
|
+
**Risk**: Cookies containing session tokens or credentials could be extracted.
|
|
117
|
+
|
|
118
|
+
**Mitigation**:
|
|
119
|
+
- Use httpOnly and secure flags when setting cookies
|
|
120
|
+
- Consider restricting cookie access to specific domains
|
|
121
|
+
- Avoid storing sensitive data in cookies
|
|
122
|
+
|
|
123
|
+
## Reporting a Vulnerability
|
|
124
|
+
|
|
125
|
+
We take security vulnerabilities seriously. If you discover a security issue, please follow responsible disclosure:
|
|
126
|
+
|
|
127
|
+
### How to Report
|
|
128
|
+
|
|
129
|
+
**Email**: [eth3rnit3@gmail.com](mailto:eth3rnit3@gmail.com)
|
|
130
|
+
|
|
131
|
+
**Subject**: `[SECURITY] FerrumMCP Vulnerability Report`
|
|
132
|
+
|
|
133
|
+
### What to Include
|
|
134
|
+
|
|
135
|
+
Please provide as much information as possible:
|
|
136
|
+
|
|
137
|
+
1. **Description**: Clear description of the vulnerability
|
|
138
|
+
2. **Impact**: What can an attacker do with this vulnerability?
|
|
139
|
+
3. **Affected Versions**: Which versions are affected?
|
|
140
|
+
4. **Reproduction Steps**: Detailed steps to reproduce the issue
|
|
141
|
+
5. **Proof of Concept**: Code or commands demonstrating the vulnerability (if applicable)
|
|
142
|
+
6. **Suggested Fix**: Any ideas for fixing the issue (optional)
|
|
143
|
+
|
|
144
|
+
### Example Report
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
Subject: [SECURITY] FerrumMCP Vulnerability Report
|
|
148
|
+
|
|
149
|
+
Description:
|
|
150
|
+
The execute_script tool does not validate JavaScript syntax, allowing
|
|
151
|
+
injection of malicious code that could access internal network services.
|
|
152
|
+
|
|
153
|
+
Impact:
|
|
154
|
+
An attacker could use the browser to scan internal networks or exfiltrate
|
|
155
|
+
data from internal services.
|
|
156
|
+
|
|
157
|
+
Affected Versions: 0.1.0
|
|
158
|
+
|
|
159
|
+
Reproduction Steps:
|
|
160
|
+
1. Create a session: create_session(headless: false)
|
|
161
|
+
2. Execute: execute_script("fetch('http://internal-server/secrets')", session_id)
|
|
162
|
+
3. Browser makes request to internal server
|
|
163
|
+
|
|
164
|
+
Suggested Fix:
|
|
165
|
+
Implement URL allowlist or blocklist for browser network access.
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Response Timeline
|
|
169
|
+
|
|
170
|
+
- **Initial Response**: Within 48 hours
|
|
171
|
+
- **Status Update**: Within 7 days
|
|
172
|
+
- **Fix Timeline**: Depends on severity
|
|
173
|
+
- **Critical**: Emergency patch within 7 days
|
|
174
|
+
- **High**: Patch within 30 days
|
|
175
|
+
- **Medium**: Patch in next minor release
|
|
176
|
+
- **Low**: Patch in next release
|
|
177
|
+
|
|
178
|
+
### Disclosure Policy
|
|
179
|
+
|
|
180
|
+
- **Coordination**: We will work with you to understand and fix the issue
|
|
181
|
+
- **Credit**: You will be credited in the security advisory (unless you prefer to remain anonymous)
|
|
182
|
+
- **Public Disclosure**: We will coordinate public disclosure timing with you
|
|
183
|
+
- **CVE Assignment**: We will request CVE assignment for confirmed vulnerabilities
|
|
184
|
+
- **Security Advisory**: Published on GitHub Security Advisories
|
|
185
|
+
|
|
186
|
+
### What Happens Next
|
|
187
|
+
|
|
188
|
+
1. **Acknowledgment**: We confirm receipt of your report
|
|
189
|
+
2. **Validation**: We validate and reproduce the vulnerability
|
|
190
|
+
3. **Assessment**: We assess severity using CVSS scoring
|
|
191
|
+
4. **Development**: We develop and test a fix
|
|
192
|
+
5. **Notification**: We notify you when fix is ready
|
|
193
|
+
6. **Release**: We release patched version
|
|
194
|
+
7. **Disclosure**: We publish security advisory with your credit
|
|
195
|
+
|
|
196
|
+
## Security Best Practices
|
|
197
|
+
|
|
198
|
+
If you're deploying FerrumMCP, follow these best practices:
|
|
199
|
+
|
|
200
|
+
### Network Security
|
|
201
|
+
|
|
202
|
+
✅ **Bind to localhost**: Use `MCP_SERVER_HOST=127.0.0.1` for local-only access
|
|
203
|
+
✅ **Use firewall**: Restrict access to port 3000
|
|
204
|
+
✅ **Reverse proxy**: Use nginx/Apache with TLS for remote access
|
|
205
|
+
✅ **VPN/SSH tunnel**: For remote access, use VPN or SSH tunneling
|
|
206
|
+
|
|
207
|
+
### Deployment Security
|
|
208
|
+
|
|
209
|
+
✅ **Minimal privileges**: Run as non-root user
|
|
210
|
+
✅ **Resource limits**: Set ulimits for memory and CPU
|
|
211
|
+
✅ **Read-only filesystem**: Mount system directories read-only in Docker
|
|
212
|
+
✅ **Secrets management**: Use environment variables, not config files
|
|
213
|
+
✅ **Update regularly**: Keep FerrumMCP and dependencies updated
|
|
214
|
+
|
|
215
|
+
### Monitoring
|
|
216
|
+
|
|
217
|
+
✅ **Session monitoring**: Track active sessions via `list_sessions`
|
|
218
|
+
✅ **Log monitoring**: Monitor `logs/ferrum_mcp.log` for errors
|
|
219
|
+
✅ **Resource monitoring**: Watch CPU, memory, and disk usage
|
|
220
|
+
✅ **Network monitoring**: Monitor browser network activity
|
|
221
|
+
|
|
222
|
+
### Configuration
|
|
223
|
+
|
|
224
|
+
✅ **Disable unused tools**: Remove tools you don't need from `TOOL_CLASSES`
|
|
225
|
+
✅ **Browser sandboxing**: Ensure Chrome sandbox is enabled
|
|
226
|
+
✅ **Timeouts**: Set appropriate `BROWSER_TIMEOUT` values
|
|
227
|
+
✅ **Headless mode**: Use `BROWSER_HEADLESS=true` in production
|
|
228
|
+
|
|
229
|
+
## Security Roadmap
|
|
230
|
+
|
|
231
|
+
Planned security improvements for future versions:
|
|
232
|
+
|
|
233
|
+
### v1.1 (Planned)
|
|
234
|
+
- [ ] Session limits (`MAX_CONCURRENT_SESSIONS`)
|
|
235
|
+
- [ ] Rate limiting for HTTP transport
|
|
236
|
+
- [ ] XPath input sanitization
|
|
237
|
+
- [ ] Non-root Docker user
|
|
238
|
+
- [ ] Health check endpoint with optional authentication
|
|
239
|
+
|
|
240
|
+
### v1.2 (Planned)
|
|
241
|
+
- [ ] Optional API key authentication
|
|
242
|
+
- [ ] Tool-level permissions system
|
|
243
|
+
- [ ] Audit logging for security events
|
|
244
|
+
- [ ] URL allowlist/blocklist for navigation
|
|
245
|
+
- [ ] Resource usage quotas
|
|
246
|
+
|
|
247
|
+
### v2.0 (Future)
|
|
248
|
+
- [ ] Role-based access control (RBAC)
|
|
249
|
+
- [ ] TLS/SSL for HTTP transport
|
|
250
|
+
- [ ] Session encryption at rest
|
|
251
|
+
- [ ] Security event webhooks
|
|
252
|
+
- [ ] Integration with SIEM systems
|
|
253
|
+
|
|
254
|
+
## Acknowledgments
|
|
255
|
+
|
|
256
|
+
We thank the following security researchers for responsible disclosure:
|
|
257
|
+
|
|
258
|
+
- *No vulnerabilities reported yet*
|
|
259
|
+
|
|
260
|
+
## Contact
|
|
261
|
+
|
|
262
|
+
For security-related questions or concerns:
|
|
263
|
+
|
|
264
|
+
- **Security Email**: [eth3rnit3@gmail.com](mailto:eth3rnit3@gmail.com)
|
|
265
|
+
- **GitHub Issues**: For non-security bugs only
|
|
266
|
+
- **GitHub Discussions**: For general questions
|
|
267
|
+
|
|
268
|
+
## Legal
|
|
269
|
+
|
|
270
|
+
By reporting a vulnerability, you agree to:
|
|
271
|
+
|
|
272
|
+
- Give us reasonable time to fix the issue before public disclosure
|
|
273
|
+
- Not exploit the vulnerability beyond proof of concept
|
|
274
|
+
- Not access, modify, or delete data belonging to others
|
|
275
|
+
|
|
276
|
+
We commit to:
|
|
277
|
+
|
|
278
|
+
- Acknowledge your report within 48 hours
|
|
279
|
+
- Keep you informed of our progress
|
|
280
|
+
- Credit you in the security advisory (if you wish)
|
|
281
|
+
- Not pursue legal action for responsible disclosure
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
**Last Updated**: 2024-11-22
|
|
286
|
+
**Version**: 1.0
|
data/bin/ferrum-mcp
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require 'optparse'
|
|
5
|
+
# Load main module first to enable eager loading in production
|
|
6
|
+
require_relative '../lib/ferrum_mcp'
|
|
7
|
+
require_relative '../lib/ferrum_mcp/cli/command_handler'
|
|
8
|
+
|
|
9
|
+
# Default options
|
|
10
|
+
options = {
|
|
11
|
+
transport: 'http',
|
|
12
|
+
host: ENV.fetch('MCP_SERVER_HOST', '0.0.0.0'),
|
|
13
|
+
port: ENV.fetch('MCP_SERVER_PORT', '3000').to_i,
|
|
14
|
+
log_level: ENV.fetch('LOG_LEVEL', 'info')
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
command = ARGV[0]
|
|
18
|
+
|
|
19
|
+
# Parse options for 'start' command
|
|
20
|
+
if command == 'start' || command.nil?
|
|
21
|
+
ARGV.shift if command == 'start'
|
|
22
|
+
|
|
23
|
+
OptionParser.new do |opts|
|
|
24
|
+
opts.banner = "Usage: ferrum-mcp start [options]"
|
|
25
|
+
opts.separator ""
|
|
26
|
+
opts.separator "Options:"
|
|
27
|
+
|
|
28
|
+
opts.on('-t', '--transport TYPE', [:http, :stdio],
|
|
29
|
+
'Transport type (http or stdio)',
|
|
30
|
+
" Default: #{options[:transport]}") do |t|
|
|
31
|
+
options[:transport] = t.to_s
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
opts.on('-H', '--host HOST',
|
|
35
|
+
'Server host (HTTP only)',
|
|
36
|
+
" Default: #{options[:host]}") do |h|
|
|
37
|
+
options[:host] = h
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
opts.on('-p', '--port PORT', Integer,
|
|
41
|
+
'Server port (HTTP only)',
|
|
42
|
+
" Default: #{options[:port]}") do |p|
|
|
43
|
+
options[:port] = p
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
opts.on('-l', '--log-level LEVEL', [:debug, :info, :warn, :error],
|
|
47
|
+
'Log level (debug, info, warn, error)',
|
|
48
|
+
" Default: #{options[:log_level]}") do |l|
|
|
49
|
+
options[:log_level] = l.to_s
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
opts.on('-h', '--help', 'Show this help message') do
|
|
53
|
+
puts opts
|
|
54
|
+
exit
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
opts.on('-v', '--version', 'Show version') do
|
|
58
|
+
require_relative '../lib/ferrum_mcp/version'
|
|
59
|
+
puts "FerrumMCP #{FerrumMCP::VERSION}"
|
|
60
|
+
exit
|
|
61
|
+
end
|
|
62
|
+
end.parse!
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Delegate to command handler
|
|
66
|
+
FerrumMCP::CLI::CommandHandler.handle(command, options)
|
data/bin/lint
ADDED
data/bin/serve
ADDED
data/bin/test
ADDED