smart-web-mcp 0.4.3 → 0.5.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/CHANGELOG.md +31 -0
- package/README.md +43 -23
- package/dist/browser-session.d.ts +41 -0
- package/dist/browser-session.js +206 -0
- package/dist/browser-session.js.map +1 -0
- package/dist/index.js +56 -1
- package/dist/index.js.map +1 -1
- package/dist/shared.d.ts +54 -1
- package/dist/shared.js +159 -5
- package/dist/shared.js.map +1 -1
- package/dist/smartcrawl.d.ts +67 -0
- package/dist/smartcrawl.js +393 -0
- package/dist/smartcrawl.js.map +1 -0
- package/dist/smartfetch/archive-fallback.js +2 -2
- package/dist/smartfetch/archive-fallback.js.map +1 -1
- package/dist/smartfetch/assets.d.ts +2 -0
- package/dist/smartfetch/assets.js +85 -0
- package/dist/smartfetch/assets.js.map +1 -0
- package/dist/smartfetch/provider-policy.js +39 -4
- package/dist/smartfetch/provider-policy.js.map +1 -1
- package/dist/smartfetch/providers/dcinside.js +1 -1
- package/dist/smartfetch/providers/dcinside.js.map +1 -1
- package/dist/smartfetch/providers/naver-blog.js +1 -1
- package/dist/smartfetch/providers/naver-blog.js.map +1 -1
- package/dist/smartfetch/providers/x.js +3 -3
- package/dist/smartfetch/providers/x.js.map +1 -1
- package/dist/smartfetch/providers/youtube.js +24 -4
- package/dist/smartfetch/providers/youtube.js.map +1 -1
- package/dist/smartfetch.d.ts +11 -1
- package/dist/smartfetch.js +142 -114
- package/dist/smartfetch.js.map +1 -1
- package/dist/smartsearch.d.ts +12 -1
- package/dist/smartsearch.js +144 -24
- package/dist/smartsearch.js.map +1 -1
- package/package.json +11 -5
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,37 @@ The format is based on Keep a Changelog and this project uses SemVer.
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.5.0] - 2026-03-23
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `smartcrawl` for local browser-driven exploration of boards, docs sites, pagination, and scroll-heavy pages
|
|
14
|
+
- shared stealth browser session runtime used by both `smartcrawl` and `smartfetch`
|
|
15
|
+
- npm-managed `pre-commit` and `pre-push` hook installation for local TypeScript and full repo checks
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- configuration UX now centers on `SMART_WEB_PROFILE` with fine-grained env flags treated as advanced overrides
|
|
20
|
+
- README, examples, and getting-started docs now use one npm-first path instead of parallel npm/Bun setup tracks
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- MCP registry metadata now keeps the advanced environment-variable overrides that the runtime still supports
|
|
25
|
+
- Playwright fetch now preserves HTML content for provider normalization instead of dropping back to plain text first
|
|
26
|
+
- DCInside parsing now handles recommendation boxes with additional classes
|
|
27
|
+
|
|
28
|
+
## [0.4.4] - 2026-03-21
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
|
|
32
|
+
- `smartfetch.assets` structured output with discovered media and attachment download URLs
|
|
33
|
+
- attachment/media rendering in markdown and text output
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
37
|
+
- provider fetch tests now cover redirect-to-private-host blocking
|
|
38
|
+
- YouTube results expose thumbnail-style asset metadata for downstream download flows
|
|
39
|
+
|
|
9
40
|
## [0.4.3] - 2026-03-21
|
|
10
41
|
|
|
11
42
|
### Added
|
package/README.md
CHANGED
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
# smart-web
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
One local MCP server for web search, page fetch, and site crawl.
|
|
6
6
|
|
|
7
|
-
`smart-web`
|
|
7
|
+
`smart-web` ships three tools in one stdio server:
|
|
8
|
+
|
|
9
|
+
- `smartsearch`: fallback web search with optional site-crawl handoff
|
|
10
|
+
- `smartfetch`: browser-aware fetch with target-specific normalization
|
|
11
|
+
- `smartcrawl`: site exploration for docs, boards, pagination, and scroll-heavy pages
|
|
8
12
|
|
|
9
13
|
- npm: `https://www.npmjs.com/package/smart-web-mcp`
|
|
10
14
|
- MCP Registry: `io.github.rich-jojo/smart-web`
|
|
@@ -16,11 +20,7 @@ A web MCP that works.
|
|
|
16
20
|
npx -y smart-web-mcp
|
|
17
21
|
```
|
|
18
22
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
bunx smart-web-mcp
|
|
23
|
-
```
|
|
23
|
+
`npm` is the canonical package-manager path for this repo and package.
|
|
24
24
|
|
|
25
25
|
## Quick start
|
|
26
26
|
|
|
@@ -45,28 +45,48 @@ OpenCode:
|
|
|
45
45
|
}
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
##
|
|
48
|
+
## Configuration
|
|
49
|
+
|
|
50
|
+
Most users only need these variables:
|
|
51
|
+
|
|
52
|
+
- `SMART_WEB_PROFILE=balanced`: default behavior
|
|
53
|
+
- `SMART_WEB_PROFILE=private`: disables relay-style providers and public search helpers by default
|
|
54
|
+
- `SEARXNG_BASE_URL=https://search.example.com`: self-hosted private fallback search
|
|
55
|
+
- `EXA_API_KEY` and `BRAVE_SEARCH_API_KEY`: optional paid search tiers
|
|
56
|
+
|
|
57
|
+
Everything else is still supported, but treated as an advanced override rather than the main setup path.
|
|
49
58
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
- `
|
|
53
|
-
-
|
|
59
|
+
## Smoke test
|
|
60
|
+
|
|
61
|
+
- ask `smartsearch` for `site:velog.io react useeffect cleanup`
|
|
62
|
+
- ask `smartfetch` to fetch a normal article URL
|
|
63
|
+
- ask `smartcrawl` to explore a docs site or forum you actually use
|
|
54
64
|
|
|
55
65
|
## Docs
|
|
56
66
|
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
67
|
+
- [Getting started](docs/getting-started.md)
|
|
68
|
+
- [Configuration](docs/configuration.md)
|
|
69
|
+
- [Crawling](docs/crawling.md)
|
|
70
|
+
- [Providers](docs/providers.md)
|
|
71
|
+
- [Architecture](docs/architecture.md)
|
|
72
|
+
- [Contributing](CONTRIBUTING.md)
|
|
73
|
+
- [CHANGELOG](CHANGELOG.md)
|
|
74
|
+
|
|
75
|
+
## Examples
|
|
76
|
+
|
|
77
|
+
- [Claude Code](examples/claude.mcp.json)
|
|
78
|
+
- [OpenCode](examples/opencode.json)
|
|
79
|
+
|
|
80
|
+
These examples use `/absolute/path/to/...` placeholders for local checkouts.
|
|
64
81
|
|
|
65
|
-
##
|
|
82
|
+
## Development
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npm install
|
|
86
|
+
npm run check
|
|
87
|
+
```
|
|
66
88
|
|
|
67
|
-
|
|
68
|
-
- MCP Registry metadata is published
|
|
69
|
-
- GitHub Actions verify package, registry metadata, and MCP wiring
|
|
89
|
+
`npm install` also installs local git hooks for fast TypeScript checks on commit and the full verification suite on push.
|
|
70
90
|
|
|
71
91
|
## License
|
|
72
92
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ToolError } from "./shared.js";
|
|
2
|
+
type BrowserWaitUntil = "domcontentloaded" | "networkidle";
|
|
3
|
+
export type BrowserAnchor = {
|
|
4
|
+
href: string;
|
|
5
|
+
text: string;
|
|
6
|
+
context: string;
|
|
7
|
+
rel: string;
|
|
8
|
+
class_name: string;
|
|
9
|
+
aria_label: string;
|
|
10
|
+
};
|
|
11
|
+
export type BrowserPageSnapshot = {
|
|
12
|
+
ok: true;
|
|
13
|
+
method: "playwright_stealth";
|
|
14
|
+
url: string;
|
|
15
|
+
final_url: string;
|
|
16
|
+
title: string;
|
|
17
|
+
html: string;
|
|
18
|
+
text: string;
|
|
19
|
+
links: string[];
|
|
20
|
+
anchors: BrowserAnchor[];
|
|
21
|
+
scroll_steps: number;
|
|
22
|
+
load_more_clicks: number;
|
|
23
|
+
};
|
|
24
|
+
type BrowserPageFailure = {
|
|
25
|
+
ok: false;
|
|
26
|
+
method: "playwright_stealth";
|
|
27
|
+
error: ToolError;
|
|
28
|
+
};
|
|
29
|
+
export type BrowserPageResult = BrowserPageSnapshot | BrowserPageFailure;
|
|
30
|
+
export type BrowserSessionOptions = {
|
|
31
|
+
url: string;
|
|
32
|
+
timeoutMs: number;
|
|
33
|
+
allowPrivateHosts?: boolean;
|
|
34
|
+
waitUntil?: BrowserWaitUntil;
|
|
35
|
+
extraHeaders?: Record<string, string>;
|
|
36
|
+
scrollSteps?: number;
|
|
37
|
+
maxLoadMoreClicks?: number;
|
|
38
|
+
maxAnchors?: number;
|
|
39
|
+
};
|
|
40
|
+
export declare function runBrowserSession(options: BrowserSessionOptions): Promise<BrowserPageResult>;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { asString, dedupeUrls, resolveValidatedUrl } from "./shared.js";
|
|
2
|
+
const DEFAULT_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36";
|
|
3
|
+
let chromiumCache = undefined;
|
|
4
|
+
async function getChromium() {
|
|
5
|
+
if (chromiumCache !== undefined)
|
|
6
|
+
return chromiumCache;
|
|
7
|
+
try {
|
|
8
|
+
const playwrightExtra = await import("playwright-extra");
|
|
9
|
+
const stealthModule = await import("puppeteer-extra-plugin-stealth");
|
|
10
|
+
const chromium = playwrightExtra.chromium;
|
|
11
|
+
const createStealthPlugin = stealthModule.default || stealthModule;
|
|
12
|
+
chromium.use(createStealthPlugin());
|
|
13
|
+
chromiumCache = chromium;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
chromiumCache = false;
|
|
17
|
+
}
|
|
18
|
+
return chromiumCache;
|
|
19
|
+
}
|
|
20
|
+
async function launchBrowser(chromium) {
|
|
21
|
+
const attempts = [
|
|
22
|
+
{ channel: process.env.SMARTFETCH_CHROME_CHANNEL || "chrome", headless: true },
|
|
23
|
+
{ executablePath: process.env.SMARTFETCH_CHROME_PATH, headless: true },
|
|
24
|
+
{ headless: true },
|
|
25
|
+
];
|
|
26
|
+
let lastError = null;
|
|
27
|
+
for (const options of attempts) {
|
|
28
|
+
const launchOptions = { ...options };
|
|
29
|
+
if (launchOptions.executablePath === undefined)
|
|
30
|
+
delete launchOptions.executablePath;
|
|
31
|
+
try {
|
|
32
|
+
return await chromium.launch(launchOptions);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
lastError = error;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
throw lastError;
|
|
39
|
+
}
|
|
40
|
+
async function clickLoadMore(page) {
|
|
41
|
+
return page.evaluate(() => {
|
|
42
|
+
const pattern = /^(load more|show more|more posts|more results|view more|see more|더보기|더 보기|더 불러오기)$/i;
|
|
43
|
+
const nodes = Array.from(document.querySelectorAll("button, [role='button'], input[type='button'], input[type='submit'], a"));
|
|
44
|
+
for (const node of nodes) {
|
|
45
|
+
const element = node;
|
|
46
|
+
const text = (element.innerText || element.getAttribute("aria-label") || element.getAttribute("title") || "").replace(/\s+/g, " ").trim();
|
|
47
|
+
if (!text || !pattern.test(text))
|
|
48
|
+
continue;
|
|
49
|
+
if (node instanceof HTMLAnchorElement) {
|
|
50
|
+
const href = node.getAttribute("href") || "";
|
|
51
|
+
if (href && href !== "#" && !href.toLowerCase().startsWith("javascript:"))
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const rect = element.getBoundingClientRect();
|
|
55
|
+
if (rect.width <= 0 || rect.height <= 0)
|
|
56
|
+
continue;
|
|
57
|
+
element.click();
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
async function drivePage(page, options) {
|
|
64
|
+
const scrollSteps = Math.max(0, Math.min(20, Math.floor(Number(options.scrollSteps || 0))));
|
|
65
|
+
const maxLoadMoreClicks = Math.max(0, Math.min(10, Math.floor(Number(options.maxLoadMoreClicks || 0))));
|
|
66
|
+
let completedScrollSteps = 0;
|
|
67
|
+
let loadMoreClicks = 0;
|
|
68
|
+
let stagnantRounds = 0;
|
|
69
|
+
let previousAnchorCount = await page.locator("a[href]").count().catch(() => 0);
|
|
70
|
+
let previousHeight = await page.evaluate(() => document.body?.scrollHeight || document.documentElement?.scrollHeight || 0);
|
|
71
|
+
for (let step = 0; step < scrollSteps; step++) {
|
|
72
|
+
let clicked = false;
|
|
73
|
+
if (loadMoreClicks < maxLoadMoreClicks) {
|
|
74
|
+
clicked = await clickLoadMore(page).catch(() => false);
|
|
75
|
+
if (clicked) {
|
|
76
|
+
loadMoreClicks += 1;
|
|
77
|
+
await page.waitForTimeout(700);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
await page.evaluate(() => window.scrollTo(0, document.body?.scrollHeight || document.documentElement?.scrollHeight || 0));
|
|
81
|
+
completedScrollSteps += 1;
|
|
82
|
+
await page.waitForTimeout(700);
|
|
83
|
+
await page.waitForLoadState("networkidle", { timeout: 1500 }).catch(() => { });
|
|
84
|
+
const currentAnchorCount = await page.locator("a[href]").count().catch(() => previousAnchorCount);
|
|
85
|
+
const currentHeight = await page.evaluate(() => document.body?.scrollHeight || document.documentElement?.scrollHeight || 0);
|
|
86
|
+
if (!clicked && currentAnchorCount <= previousAnchorCount && currentHeight <= previousHeight) {
|
|
87
|
+
stagnantRounds += 1;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
stagnantRounds = 0;
|
|
91
|
+
}
|
|
92
|
+
previousAnchorCount = currentAnchorCount;
|
|
93
|
+
previousHeight = currentHeight;
|
|
94
|
+
if (stagnantRounds >= 2)
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
return { scroll_steps: completedScrollSteps, load_more_clicks: loadMoreClicks };
|
|
98
|
+
}
|
|
99
|
+
async function extractAnchors(page, maxAnchors) {
|
|
100
|
+
return page.evaluate((maxItems) => {
|
|
101
|
+
const nodes = Array.from(document.querySelectorAll("a[href]")).slice(0, maxItems);
|
|
102
|
+
return nodes.map((node) => {
|
|
103
|
+
const element = node;
|
|
104
|
+
const closest = element.closest("article, li, tr, section, main, .topic-list-item, .topic-body, .topic-post, .athing, .titleline, [role='article'], .feed-item, .timeline-item, .post, .storylink");
|
|
105
|
+
const text = (element.innerText || element.getAttribute("aria-label") || element.getAttribute("title") || "").replace(/\s+/g, " ").trim();
|
|
106
|
+
const contextSource = closest?.innerText || element.innerText || element.textContent || "";
|
|
107
|
+
return {
|
|
108
|
+
href: element.href || "",
|
|
109
|
+
text,
|
|
110
|
+
context: contextSource.replace(/\s+/g, " ").trim().slice(0, 500),
|
|
111
|
+
rel: element.rel || "",
|
|
112
|
+
class_name: typeof element.className === "string" ? element.className : "",
|
|
113
|
+
aria_label: element.getAttribute("aria-label") || "",
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
}, maxAnchors);
|
|
117
|
+
}
|
|
118
|
+
export async function runBrowserSession(options) {
|
|
119
|
+
const chromium = await getChromium();
|
|
120
|
+
if (!chromium) {
|
|
121
|
+
return {
|
|
122
|
+
ok: false,
|
|
123
|
+
method: "playwright_stealth",
|
|
124
|
+
error: {
|
|
125
|
+
category: "unavailable",
|
|
126
|
+
code: "playwright_unavailable",
|
|
127
|
+
message: "Playwright browser runtime is unavailable",
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
const resolveOptions = {
|
|
132
|
+
timeoutMs: options.timeoutMs,
|
|
133
|
+
};
|
|
134
|
+
if (options.allowPrivateHosts !== undefined)
|
|
135
|
+
resolveOptions.allowPrivateHosts = options.allowPrivateHosts;
|
|
136
|
+
if (options.extraHeaders !== undefined)
|
|
137
|
+
resolveOptions.headers = options.extraHeaders;
|
|
138
|
+
const resolved = await resolveValidatedUrl(options.url, resolveOptions);
|
|
139
|
+
if (!resolved.ok) {
|
|
140
|
+
return {
|
|
141
|
+
ok: false,
|
|
142
|
+
method: "playwright_stealth",
|
|
143
|
+
error: {
|
|
144
|
+
category: "block",
|
|
145
|
+
code: resolved.reason,
|
|
146
|
+
message: resolved.message,
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
let browser = null;
|
|
151
|
+
try {
|
|
152
|
+
browser = await launchBrowser(chromium);
|
|
153
|
+
const context = await browser.newContext({
|
|
154
|
+
userAgent: DEFAULT_USER_AGENT,
|
|
155
|
+
locale: "ko-KR",
|
|
156
|
+
extraHTTPHeaders: options.extraHeaders,
|
|
157
|
+
});
|
|
158
|
+
const page = await context.newPage();
|
|
159
|
+
await page.goto(resolved.url, {
|
|
160
|
+
waitUntil: options.waitUntil || "networkidle",
|
|
161
|
+
timeout: options.timeoutMs,
|
|
162
|
+
});
|
|
163
|
+
const driven = await drivePage(page, options);
|
|
164
|
+
const html = await page.content();
|
|
165
|
+
const text = await page.evaluate(() => document.body?.innerText || "");
|
|
166
|
+
const title = asString(await page.title());
|
|
167
|
+
const finalUrl = asString(page.url());
|
|
168
|
+
const maxAnchors = Math.max(50, Math.min(2000, Math.floor(Number(options.maxAnchors || 400))));
|
|
169
|
+
const anchors = await extractAnchors(page, maxAnchors);
|
|
170
|
+
const links = dedupeUrls(anchors.map((anchor) => asString(anchor?.href)));
|
|
171
|
+
await context.close();
|
|
172
|
+
await browser.close();
|
|
173
|
+
browser = null;
|
|
174
|
+
return {
|
|
175
|
+
ok: true,
|
|
176
|
+
method: "playwright_stealth",
|
|
177
|
+
url: options.url,
|
|
178
|
+
final_url: finalUrl || resolved.url,
|
|
179
|
+
title,
|
|
180
|
+
html,
|
|
181
|
+
text,
|
|
182
|
+
links,
|
|
183
|
+
anchors,
|
|
184
|
+
scroll_steps: driven.scroll_steps,
|
|
185
|
+
load_more_clicks: driven.load_more_clicks,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
190
|
+
return {
|
|
191
|
+
ok: false,
|
|
192
|
+
method: "playwright_stealth",
|
|
193
|
+
error: {
|
|
194
|
+
category: message.toLowerCase().includes("timeout") ? "timeout" : "unavailable",
|
|
195
|
+
code: "playwright_fetch_failed",
|
|
196
|
+
message,
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
finally {
|
|
201
|
+
if (browser) {
|
|
202
|
+
await browser.close().catch(() => { });
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=browser-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-session.js","sourceRoot":"","sources":["../src/browser-session.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEvE,MAAM,kBAAkB,GAAG,iHAAiH,CAAA;AA8C5I,IAAI,aAAa,GAAQ,SAAS,CAAA;AAElC,KAAK,UAAU,WAAW;IACxB,IAAI,aAAa,KAAK,SAAS;QAAE,OAAO,aAAa,CAAA;IACrD,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAA;QACxD,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,gCAAgC,CAAC,CAAA;QACpE,MAAM,QAAQ,GAAI,eAAuB,CAAC,QAAQ,CAAA;QAClD,MAAM,mBAAmB,GAAI,aAAqB,CAAC,OAAO,IAAI,aAAa,CAAA;QAC3E,QAAQ,CAAC,GAAG,CAAC,mBAAmB,EAAE,CAAC,CAAA;QACnC,aAAa,GAAG,QAAQ,CAAA;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,aAAa,GAAG,KAAK,CAAA;IACvB,CAAC;IACD,OAAO,aAAa,CAAA;AACtB,CAAC;AAED,KAAK,UAAU,aAAa,CAAC,QAAa;IACxC,MAAM,QAAQ,GAAG;QACf,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,yB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AAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QACvC,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { readFileSync } from "node:fs";
|
|
|
3
3
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
4
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
5
|
import { z } from "zod";
|
|
6
|
+
import { renderSmartcrawl, runSmartcrawl } from "./smartcrawl.js";
|
|
6
7
|
import { runSmartfetch, renderSmartfetch } from "./smartfetch.js";
|
|
7
8
|
import { runSmartsearch, renderSmartsearch } from "./smartsearch.js";
|
|
8
9
|
const packageVersion = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
@@ -15,18 +16,72 @@ server.tool("smartsearch", "Search the web with fallback engines. Uses Exa, then
|
|
|
15
16
|
numResults: z.number().int().min(1).max(20).optional().describe("Number of search results to return"),
|
|
16
17
|
type: z.enum(["auto", "fast", "deep"]).optional().describe("Search depth hint"),
|
|
17
18
|
contextMaxCharacters: z.number().int().min(1000).max(20000).optional().describe("Maximum snippet/context size hint"),
|
|
18
|
-
|
|
19
|
+
site_crawl: z.boolean().optional().describe("After search, hand off into smartcrawl when a crawl_url or site: operator is available"),
|
|
20
|
+
crawl_url: z.string().optional().describe("Optional starting URL for the smartcrawl handoff"),
|
|
21
|
+
crawl_mode: z.enum(["auto", "board", "docs"]).optional().describe("Traversal hint for the smartcrawl handoff"),
|
|
22
|
+
crawl_limit: z.number().int().min(1).max(50).optional().describe("Maximum ranked crawl results to return in the handoff summary"),
|
|
23
|
+
crawl_max_pages: z.number().int().min(1).max(20).optional().describe("Maximum number of pages to visit during the crawl handoff"),
|
|
24
|
+
crawl_max_depth: z.number().int().min(0).max(3).optional().describe("Maximum recursive depth for the crawl handoff"),
|
|
25
|
+
crawl_timeout_ms: z.number().int().min(3000).max(120000).optional().describe("Per-page timeout for the crawl handoff"),
|
|
26
|
+
}, async ({ query, numResults, type, contextMaxCharacters, site_crawl, crawl_url, crawl_mode, crawl_limit, crawl_max_pages, crawl_max_depth, crawl_timeout_ms }) => {
|
|
19
27
|
const output = await runSmartsearch({
|
|
20
28
|
query,
|
|
21
29
|
...(numResults === undefined ? {} : { numResults }),
|
|
22
30
|
...(type === undefined ? {} : { searchType: type }),
|
|
23
31
|
...(contextMaxCharacters === undefined ? {} : { contextMaxCharacters }),
|
|
32
|
+
...(site_crawl === undefined ? {} : { siteCrawl: site_crawl }),
|
|
33
|
+
...(crawl_url === undefined ? {} : { crawlUrl: crawl_url }),
|
|
34
|
+
...(crawl_mode === undefined ? {} : { crawlMode: crawl_mode }),
|
|
35
|
+
...(crawl_limit === undefined ? {} : { crawlLimit: crawl_limit }),
|
|
36
|
+
...(crawl_max_pages === undefined ? {} : { crawlMaxPages: crawl_max_pages }),
|
|
37
|
+
...(crawl_max_depth === undefined ? {} : { crawlMaxDepth: crawl_max_depth }),
|
|
38
|
+
...(crawl_timeout_ms === undefined ? {} : { crawlTimeoutMs: crawl_timeout_ms }),
|
|
24
39
|
});
|
|
25
40
|
return {
|
|
26
41
|
structuredContent: output,
|
|
27
42
|
content: [{ type: "text", text: renderSmartsearch(output) }],
|
|
28
43
|
};
|
|
29
44
|
});
|
|
45
|
+
server.tool("smartcrawl", "Explore a specific site with a browser, pagination, and scroll-aware traversal to gather relevant pages or posts.", {
|
|
46
|
+
url: z.string().min(1).describe("Starting URL to explore"),
|
|
47
|
+
query: z.string().optional().describe("Optional topic filter used to rank crawl results"),
|
|
48
|
+
mode: z.enum(["auto", "board", "docs"]).optional().describe("Traversal hint for boards, docs sites, or automatic detection"),
|
|
49
|
+
limit: z.number().int().min(1).max(50).optional().describe("Maximum number of ranked results to return"),
|
|
50
|
+
max_pages: z.number().int().min(1).max(20).optional().describe("Maximum number of pages to visit during exploration"),
|
|
51
|
+
max_depth: z.number().int().min(0).max(3).optional().describe("Maximum recursive depth from the starting URL"),
|
|
52
|
+
include_patterns: z.array(z.string().min(1)).max(20).optional().describe("Optional regex or substring patterns for URLs to keep"),
|
|
53
|
+
exclude_patterns: z.array(z.string().min(1)).max(20).optional().describe("Optional regex or substring patterns for URLs to skip"),
|
|
54
|
+
same_origin_only: z.boolean().optional().describe("Restrict traversal to the starting origin while still surfacing external item links"),
|
|
55
|
+
follow_pagination: z.boolean().optional().describe("Follow next or more-style pagination links during exploration"),
|
|
56
|
+
scroll_steps: z.number().int().min(0).max(12).optional().describe("How many scroll attempts to use for scroll-driven pages"),
|
|
57
|
+
timeout_ms: z.number().int().min(3000).max(120000).optional().describe("Crawl timeout budget per page"),
|
|
58
|
+
format: z.enum(["json", "text", "markdown"]).optional().describe("Text rendering format for the human-readable content"),
|
|
59
|
+
}, async ({ url, query, mode, limit, max_pages, max_depth, include_patterns, exclude_patterns, same_origin_only, follow_pagination, scroll_steps, timeout_ms, format, }) => {
|
|
60
|
+
const output = await runSmartcrawl({
|
|
61
|
+
url,
|
|
62
|
+
...(query === undefined ? {} : { query }),
|
|
63
|
+
...(mode === undefined ? {} : { mode }),
|
|
64
|
+
...(limit === undefined ? {} : { limit }),
|
|
65
|
+
...(max_pages === undefined ? {} : { maxPages: max_pages }),
|
|
66
|
+
...(max_depth === undefined ? {} : { maxDepth: max_depth }),
|
|
67
|
+
...(include_patterns === undefined ? {} : { includePatterns: include_patterns }),
|
|
68
|
+
...(exclude_patterns === undefined ? {} : { excludePatterns: exclude_patterns }),
|
|
69
|
+
...(same_origin_only === undefined ? {} : { sameOriginOnly: same_origin_only }),
|
|
70
|
+
...(follow_pagination === undefined ? {} : { followPagination: follow_pagination }),
|
|
71
|
+
...(scroll_steps === undefined ? {} : { scrollSteps: scroll_steps }),
|
|
72
|
+
...(timeout_ms === undefined ? {} : { timeoutMs: timeout_ms }),
|
|
73
|
+
});
|
|
74
|
+
const requestedFormat = format || "json";
|
|
75
|
+
return {
|
|
76
|
+
structuredContent: output,
|
|
77
|
+
content: [
|
|
78
|
+
{
|
|
79
|
+
type: "text",
|
|
80
|
+
text: requestedFormat === "json" ? JSON.stringify(output, null, 2) : renderSmartcrawl(output, requestedFormat),
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
};
|
|
84
|
+
});
|
|
30
85
|
server.tool("smartfetch", "Fetch a URL with browser-aware fallbacks. Uses impit first, then stealth Playwright when the page looks JS-rendered or blocked.", {
|
|
31
86
|
url: z.string().min(1).describe("Target URL to fetch"),
|
|
32
87
|
target: z.enum(["auto", "generic", "reddit_post", "x_post", "dcinside_post", "youtube_video", "naver_blog", "tistory_post", "velog_post"]).optional().describe("Content type hint"),
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACjE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEpE,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,OAAiB,CAAA;AAEtH,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;IAC3B,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,cAAc;CACxB,CAAC,CAAA;AAEF,MAAM,CAAC,IAAI,CACT,aAAa,EACb,6GAA6G,EAC7G;IACE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAA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AC,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC;KACxE,CAAC,CAAA;IAEF,MAAM,eAAe,GAAG,MAAM,IAAI,MAAM,CAAA;IACxC,OAAO;QACL,iBAAiB,EAAE,MAAM;QACzB,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,eAAe,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,EAAE,eAAe,CAAC;aAC/G;SACF;KACF,CAAA;AACH,CAAC,CACF,CAAA;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAA;IAC5C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;AACjC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
package/dist/shared.d.ts
CHANGED
|
@@ -19,12 +19,33 @@ export type SearchResult = {
|
|
|
19
19
|
snippet: string;
|
|
20
20
|
engine: string;
|
|
21
21
|
};
|
|
22
|
+
export type SearchHandoffItem = {
|
|
23
|
+
title: string;
|
|
24
|
+
url: string;
|
|
25
|
+
snippet: string;
|
|
26
|
+
kind: string;
|
|
27
|
+
score: number;
|
|
28
|
+
depth: number;
|
|
29
|
+
};
|
|
30
|
+
export type SearchHandoff = {
|
|
31
|
+
tool: "smartcrawl";
|
|
32
|
+
performed: boolean;
|
|
33
|
+
reason: string;
|
|
34
|
+
start_url: string;
|
|
35
|
+
query: string;
|
|
36
|
+
mode: "auto" | "board" | "docs";
|
|
37
|
+
items: SearchHandoffItem[];
|
|
38
|
+
pages_attempted: number;
|
|
39
|
+
pages_loaded: number;
|
|
40
|
+
errors: string[];
|
|
41
|
+
};
|
|
22
42
|
export type SearchResponse = {
|
|
23
43
|
engine: string;
|
|
24
44
|
query: string;
|
|
25
45
|
results: SearchResult[];
|
|
26
46
|
fallbacks_tried: string[];
|
|
27
47
|
notes: string[];
|
|
48
|
+
handoff?: SearchHandoff;
|
|
28
49
|
};
|
|
29
50
|
export type SmartfetchOutput = {
|
|
30
51
|
source: "smartfetch";
|
|
@@ -37,6 +58,7 @@ export type SmartfetchOutput = {
|
|
|
37
58
|
post: Record<string, unknown> | null;
|
|
38
59
|
thread: Record<string, unknown>[];
|
|
39
60
|
comments: Record<string, unknown>[];
|
|
61
|
+
assets: SmartfetchAsset[];
|
|
40
62
|
outbound_links: string[];
|
|
41
63
|
evidence: {
|
|
42
64
|
impit_attempted: boolean;
|
|
@@ -46,7 +68,18 @@ export type SmartfetchOutput = {
|
|
|
46
68
|
generated_at: string;
|
|
47
69
|
};
|
|
48
70
|
};
|
|
71
|
+
export type SmartfetchAssetKind = "image" | "video" | "audio" | "document" | "archive" | "attachment" | "other";
|
|
72
|
+
export type SmartfetchAsset = {
|
|
73
|
+
url: string;
|
|
74
|
+
download_url: string;
|
|
75
|
+
kind: SmartfetchAssetKind;
|
|
76
|
+
file_name: string;
|
|
77
|
+
mime_type: string;
|
|
78
|
+
source: string;
|
|
79
|
+
downloadable: boolean;
|
|
80
|
+
};
|
|
49
81
|
export type SmartfetchRenderFormat = "text" | "markdown";
|
|
82
|
+
export type SmartWebProfile = "balanced" | "private";
|
|
50
83
|
export declare function asString(value: unknown): string;
|
|
51
84
|
export declare function asNumber(value: unknown): number;
|
|
52
85
|
export declare function decodeHtml(value: string): string;
|
|
@@ -56,6 +89,12 @@ export declare function dedupeUrls(values: string[]): string[];
|
|
|
56
89
|
export declare function cleanLinks(values: string[]): string[];
|
|
57
90
|
export declare function extractUrls(value: string): string[];
|
|
58
91
|
export declare function extractAnchorHrefs(value: string): string[];
|
|
92
|
+
export declare function absolutizeUrl(input: string, baseUrl: string): string;
|
|
93
|
+
export declare function extractTagAttribute(html: string, tag: string, attribute: string, baseUrl: string): string[];
|
|
94
|
+
export declare function extractMetaContentValues(html: string, names: string[], baseUrl: string): string[];
|
|
95
|
+
export declare function fileNameFromUrl(url: string): string;
|
|
96
|
+
export declare function inferMimeType(url: string): string;
|
|
97
|
+
export declare function inferAssetKind(url: string, mimeType?: string): SmartfetchAssetKind;
|
|
59
98
|
export declare function uniqueResults(results: SearchResult[]): SearchResult[];
|
|
60
99
|
export declare function resolveDuckDuckGoUrl(input: string): string;
|
|
61
100
|
export declare function capture(value: string, regex: RegExp): string;
|
|
@@ -64,8 +103,9 @@ export declare function extractMetaDescription(html: string): string;
|
|
|
64
103
|
export declare function extractMetaProperty(html: string, property: string): string;
|
|
65
104
|
export declare function extractMetaName(html: string, name: string): string;
|
|
66
105
|
export declare function inferTarget(url: string, target: Target): ResolvedTarget;
|
|
106
|
+
export declare function smartWebProfile(): SmartWebProfile;
|
|
67
107
|
export declare function envFlag(name: string): boolean;
|
|
68
|
-
export declare function envEnabled(name: string, defaultValue: boolean): boolean;
|
|
108
|
+
export declare function envEnabled(name: string, defaultValue: boolean, profileDefaults?: Partial<Record<SmartWebProfile, boolean>>): boolean;
|
|
69
109
|
export declare function validateOutboundUrl(url: string, options?: {
|
|
70
110
|
allowPrivateHosts?: boolean;
|
|
71
111
|
}): Promise<{
|
|
@@ -77,6 +117,19 @@ export declare function validateOutboundUrl(url: string, options?: {
|
|
|
77
117
|
reason?: never;
|
|
78
118
|
message?: never;
|
|
79
119
|
}>;
|
|
120
|
+
export declare function resolveValidatedUrl(url: string, options?: {
|
|
121
|
+
allowPrivateHosts?: boolean;
|
|
122
|
+
timeoutMs?: number;
|
|
123
|
+
maxRedirects?: number;
|
|
124
|
+
headers?: HeadersInit;
|
|
125
|
+
}): Promise<{
|
|
126
|
+
ok: false;
|
|
127
|
+
reason: string;
|
|
128
|
+
message: string;
|
|
129
|
+
} | {
|
|
130
|
+
ok: true;
|
|
131
|
+
url: string;
|
|
132
|
+
}>;
|
|
80
133
|
export declare function isXUrl(url: string): boolean;
|
|
81
134
|
export declare function isRedditUrl(url: string): boolean;
|
|
82
135
|
export declare function isDcinsideUrl(url: string): boolean;
|