obscura-mcp-server 0.1.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.
- package/INSTALL.md +259 -0
- package/README.md +100 -0
- package/biome.json +27 -0
- package/bun.lock +265 -0
- package/dist/index.js +53111 -0
- package/package.json +43 -0
- package/src/formatters/clean.ts +97 -0
- package/src/formatters/html.ts +10 -0
- package/src/formatters/index.ts +23 -0
- package/src/formatters/markdown.ts +18 -0
- package/src/formatters/text.ts +23 -0
- package/src/index.ts +16 -0
- package/src/schemas/fetch.ts +7 -0
- package/src/schemas/query.ts +17 -0
- package/src/schemas/search.ts +7 -0
- package/src/tools/fetch/fetch.ts +52 -0
- package/src/tools/fetch/index.ts +43 -0
- package/src/tools/fetch/obscura.ts +45 -0
- package/src/tools/index.ts +39 -0
- package/src/tools/query/fetch.ts +140 -0
- package/src/tools/query/index.ts +66 -0
- package/src/tools/query/obscura.ts +103 -0
- package/src/tools/search/fetch.ts +78 -0
- package/src/tools/search/index.ts +43 -0
- package/src/tools/search/obscura.ts +74 -0
- package/src/types/fetch.ts +4 -0
- package/src/types/formatters.ts +2 -0
- package/src/types/query.ts +18 -0
- package/src/types/search.ts +10 -0
- package/src/utils/exec.ts +57 -0
- package/src/utils/obscura.ts +40 -0
- package/tsconfig.json +27 -0
package/INSTALL.md
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
# Installation Guide
|
|
2
|
+
|
|
3
|
+
This guide covers how to configure the Obscura MCP server with various AI clients.
|
|
4
|
+
|
|
5
|
+
## Installation Methods
|
|
6
|
+
|
|
7
|
+
### Method 1: Using bunx (recommended - no installation needed)
|
|
8
|
+
|
|
9
|
+
Once published to npm (coming soon):
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"mcpServers": {
|
|
14
|
+
"obscura": {
|
|
15
|
+
"command": "bunx",
|
|
16
|
+
"args": ["obscura-mcp-server"]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Method 2: Using npx
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"mcpServers": {
|
|
27
|
+
"obscura": {
|
|
28
|
+
"command": "npx",
|
|
29
|
+
"args": ["-y", "obscura-mcp-server"]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Method 3: Using global installation
|
|
36
|
+
|
|
37
|
+
First, install globally:
|
|
38
|
+
```bash
|
|
39
|
+
npm install -g obscura-mcp-server
|
|
40
|
+
# or
|
|
41
|
+
bun add -g obscura-mcp-server
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Then configure:
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"mcpServers": {
|
|
48
|
+
"obscura": {
|
|
49
|
+
"command": "obscura-mcp"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Method 4: Using local clone
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
git clone https://github.com/your-user/obscura-mcp-server
|
|
59
|
+
cd obscura-mcp-server
|
|
60
|
+
bun install
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"mcpServers": {
|
|
66
|
+
"obscura": {
|
|
67
|
+
"command": "bunx",
|
|
68
|
+
"args": ["run", "/path/to/obscura-mcp-server/src/index.ts"]
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Client Configuration
|
|
77
|
+
|
|
78
|
+
### VSCode
|
|
79
|
+
|
|
80
|
+
| OS | Path |
|
|
81
|
+
|----|------|
|
|
82
|
+
| macOS | `~/Library/Application Support/Code/User/settings.json` |
|
|
83
|
+
| Linux | `~/.config/Code/User/settings.json` |
|
|
84
|
+
| Windows | `%APPDATA%\Code\User\settings.json` |
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"mcp": {
|
|
89
|
+
"servers": {
|
|
90
|
+
"obscura": {
|
|
91
|
+
"command": "bunx",
|
|
92
|
+
"args": ["obscura-mcp-server"]
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Restart VSCode after editing.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
### Cursor
|
|
104
|
+
|
|
105
|
+
| OS | Path |
|
|
106
|
+
|----|------|
|
|
107
|
+
| macOS | `~/.cursor/mcp.json` |
|
|
108
|
+
| Linux | `~/.cursor/mcp.json` |
|
|
109
|
+
| Windows | `%USERPROFILE%\.cursor\mcp.json` |
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"mcpServers": {
|
|
114
|
+
"obscura": {
|
|
115
|
+
"type": "stdio",
|
|
116
|
+
"command": "bunx",
|
|
117
|
+
"args": ["obscura-mcp-server"]
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Or use workspace-relative path:
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"mcpServers": {
|
|
127
|
+
"obscura": {
|
|
128
|
+
"type": "stdio",
|
|
129
|
+
"command": "bun",
|
|
130
|
+
"args": ["run", "${workspaceFolder}/src/index.ts"]
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Cursor also supports UI configuration: Settings → Features → Model Context Protocol
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
### OpenCode
|
|
141
|
+
|
|
142
|
+
| OS | Path |
|
|
143
|
+
|----|------|
|
|
144
|
+
| macOS | `~/.config/opencode/opencode.json` |
|
|
145
|
+
| Linux | `~/.config/opencode/opencode.json` |
|
|
146
|
+
| Windows | `%APPDATA%\opencode\opencode.json` |
|
|
147
|
+
|
|
148
|
+
```json
|
|
149
|
+
{
|
|
150
|
+
"mcp": {
|
|
151
|
+
"obscura": {
|
|
152
|
+
"type": "local",
|
|
153
|
+
"command": ["bunx", "obscura-mcp-server"],
|
|
154
|
+
"environment": {
|
|
155
|
+
"OBSCURA_PATH": "/usr/local/bin/obscura"
|
|
156
|
+
},
|
|
157
|
+
"enabled": true
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
### Claude Code
|
|
166
|
+
|
|
167
|
+
| OS | Path |
|
|
168
|
+
|----|------|
|
|
169
|
+
| macOS | `~/Library/Application Support/Claude/claude_desktop_config.json` |
|
|
170
|
+
| Linux | `~/.config/Claude/claude_desktop_config.json` |
|
|
171
|
+
| Windows | `%APPDATA%\Claude\claude_desktop_config.json` |
|
|
172
|
+
|
|
173
|
+
```json
|
|
174
|
+
{
|
|
175
|
+
"mcpServers": {
|
|
176
|
+
"obscura": {
|
|
177
|
+
"command": "bunx",
|
|
178
|
+
"args": ["obscura-mcp-server"]
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Or via CLI:
|
|
185
|
+
```bash
|
|
186
|
+
claude mcp add obscura bunx obscura-mcp-server
|
|
187
|
+
claude mcp list
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
### Codex
|
|
193
|
+
|
|
194
|
+
| OS | Path |
|
|
195
|
+
|----|------|
|
|
196
|
+
| macOS | `~/.codex/config.json` |
|
|
197
|
+
| Linux | `~/.codex/config.json` |
|
|
198
|
+
| Windows | `%USERPROFILE%\.codex\config.json` |
|
|
199
|
+
|
|
200
|
+
```json
|
|
201
|
+
{
|
|
202
|
+
"mcpServers": {
|
|
203
|
+
"obscura": {
|
|
204
|
+
"command": "bunx",
|
|
205
|
+
"args": ["obscura-mcp-server"]
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
### Pi
|
|
214
|
+
|
|
215
|
+
Add to your MCP servers config:
|
|
216
|
+
To use MCP servers with Pi, you need to install the `pi-mcp-adapter` package and configure it to connect to the Obscura MCP server.
|
|
217
|
+
Link to package: https://pi.dev/packages/pi-mcp-adapter
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
pi install npm:pi-mcp-adapter
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Then configure the adapter to point to the Obscura MCP server:
|
|
224
|
+
|
|
225
|
+
```json
|
|
226
|
+
{
|
|
227
|
+
"mcpServers": {
|
|
228
|
+
"obscura": {
|
|
229
|
+
"command": "bunx",
|
|
230
|
+
"args": ["obscura-mcp-server"]
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Environment Variables
|
|
239
|
+
|
|
240
|
+
| Variable | Description | Default |
|
|
241
|
+
|----------|-------------|---------|
|
|
242
|
+
| `OBSCURA_PATH` | Path to Obscura binary | looks in PATH |
|
|
243
|
+
|
|
244
|
+
## Troubleshooting
|
|
245
|
+
|
|
246
|
+
### Server not starting
|
|
247
|
+
- Verify Bun is installed: `bun --version`
|
|
248
|
+
- Check the path to the project directory
|
|
249
|
+
- Run manually to see errors: `bun run start`
|
|
250
|
+
|
|
251
|
+
### Obscura not detected
|
|
252
|
+
- Install Obscura: https://github.com/h4ckf0r0day/obscura
|
|
253
|
+
- Set `OBSCURA_PATH` environment variable (optional if Obscura is not in PATH)
|
|
254
|
+
- The server falls back to native fetch if Obscura is unavailable
|
|
255
|
+
|
|
256
|
+
### Connection issues
|
|
257
|
+
- Ensure the server is running (stdio mode)
|
|
258
|
+
- Check client logs for JSON-RPC errors
|
|
259
|
+
- Try restarting the AI client after config changes
|
package/README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Obscura MCP Server
|
|
2
|
+
|
|
3
|
+
> A Model Context Protocol server for web scraping and automation using [Obscura](https://github.com/h4ckf0r0day/obscura)
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This MCP server provides tools for AI agents to interact with web pages. It uses **Obscura**, a headless browser engine written in Rust with V8 JavaScript support, built specifically for web scraping and AI agent automation.
|
|
8
|
+
|
|
9
|
+
When Obscura is unavailable, it gracefully falls back to native fetch APIs.
|
|
10
|
+
|
|
11
|
+
## Tools
|
|
12
|
+
|
|
13
|
+
### `fetch_page`
|
|
14
|
+
Fetch web content from a URL.
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{ "url": "https://example.com", "type": "markdown" }
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### `search`
|
|
21
|
+
Search the web and return results.
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{ "query": "rust headless browser", "limit": 5 }
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### `query`
|
|
28
|
+
Query a webpage using CSS selectors or text search.
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
{ "url": "https://example.com", "selector": "h1", "text": "title" }
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
> For client-specific configuration, see [INSTALL.md](./INSTALL.md).
|
|
35
|
+
|
|
36
|
+
## Requirements
|
|
37
|
+
|
|
38
|
+
- [Obscura](https://github.com/h4ckf0r0day/obscura) (optional, for enhanced capabilities)
|
|
39
|
+
- Node.js 18+ or Bun
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
See [INSTALL.md](./INSTALL.md) for setup with VSCode, Cursor, OpenCode, Claude Code, Codex, and Pi.
|
|
44
|
+
|
|
45
|
+
## Architecture
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
49
|
+
│ MCP Client │
|
|
50
|
+
│ (Claude Desktop) │
|
|
51
|
+
└─────────────────────────┬───────────────────────────────────┘
|
|
52
|
+
│ JSON-RPC
|
|
53
|
+
▼
|
|
54
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
55
|
+
│ Obscura MCP Server │
|
|
56
|
+
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
|
|
57
|
+
│ │ fetch │ │ search │ │ query │ ← Tools │
|
|
58
|
+
│ └───┬─────┘ └───┬─────┘ └───┬─────┘ │
|
|
59
|
+
│ │ │ │ │
|
|
60
|
+
│ ▼ ▼ ▼ │
|
|
61
|
+
│ ┌─────────────────────────────────────────────────────────┐│
|
|
62
|
+
│ │ checkObscura() ││
|
|
63
|
+
│ └────────────────────┬────────────────────────────────────┘│
|
|
64
|
+
│ │ │
|
|
65
|
+
│ ┌────────────┴────────────┐ │
|
|
66
|
+
│ ▼ ▼ │
|
|
67
|
+
│ ┌────────────┐ ┌────────────┐ │
|
|
68
|
+
│ │ Obscura │ │ Native │ │
|
|
69
|
+
│ │ (headless) │ │ fetch │ │
|
|
70
|
+
│ └────────────┘ └────────────┘ │
|
|
71
|
+
└─────────────────────────────────────────────────────────────┘
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Why Obscura?
|
|
75
|
+
|
|
76
|
+
| Feature | Obscura | Native Fetch |
|
|
77
|
+
|---------|---------|--------------|
|
|
78
|
+
| JavaScript execution | ✅ | ❌ |
|
|
79
|
+
| Cloudflare bypass | ✅ | ❌ |
|
|
80
|
+
| Stealth mode | ✅ | ❌ |
|
|
81
|
+
| Wait conditions | ✅ | ❌ |
|
|
82
|
+
| DOM manipulation | ✅ | ❌ |
|
|
83
|
+
| No dependencies | ❌ | ✅ |
|
|
84
|
+
|
|
85
|
+
## Development
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Run in development mode
|
|
89
|
+
bun run dev
|
|
90
|
+
|
|
91
|
+
# Type check
|
|
92
|
+
bun run check
|
|
93
|
+
|
|
94
|
+
# Lint and fix
|
|
95
|
+
bun run lint:fix
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## License
|
|
99
|
+
|
|
100
|
+
MIT
|
package/biome.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.4.13/schema.json",
|
|
3
|
+
"vcs": {
|
|
4
|
+
"enabled": true,
|
|
5
|
+
"clientKind": "git",
|
|
6
|
+
"useIgnoreFile": true
|
|
7
|
+
},
|
|
8
|
+
"formatter": {
|
|
9
|
+
"enabled": true,
|
|
10
|
+
"indentStyle": "space",
|
|
11
|
+
"indentWidth": 2,
|
|
12
|
+
"lineWidth": 100
|
|
13
|
+
},
|
|
14
|
+
"linter": {
|
|
15
|
+
"enabled": true,
|
|
16
|
+
"rules": {
|
|
17
|
+
"recommended": true
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"javascript": {
|
|
21
|
+
"formatter": {
|
|
22
|
+
"quoteStyle": "double",
|
|
23
|
+
"semicolons": "always",
|
|
24
|
+
"trailingCommas": "es5"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|