smart-web-mcp 0.4.4 → 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 +19 -0
- package/README.md +43 -24
- 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 +24 -1
- package/dist/shared.js +16 -8
- 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/provider-policy.js +2 -2
- 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 +20 -4
- package/dist/smartfetch/providers/youtube.js.map +1 -1
- package/dist/smartfetch.d.ts +11 -1
- package/dist/smartfetch.js +75 -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,25 @@ 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
|
+
|
|
9
28
|
## [0.4.4] - 2026-03-21
|
|
10
29
|
|
|
11
30
|
### 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,29 +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
|
-
- `smartfetch
|
|
54
|
-
-
|
|
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
|
|
55
64
|
|
|
56
65
|
## Docs
|
|
57
66
|
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
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.
|
|
65
81
|
|
|
66
|
-
##
|
|
82
|
+
## Development
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npm install
|
|
86
|
+
npm run check
|
|
87
|
+
```
|
|
67
88
|
|
|
68
|
-
|
|
69
|
-
- MCP Registry metadata is published
|
|
70
|
-
- 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.
|
|
71
90
|
|
|
72
91
|
## License
|
|
73
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 @@
|
|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rB,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA;QACrB,OAAO,GAAG,IAAI,CAAA;QACd,OAAO;YACL,EAAE,EAAE,IAAI;YACR,MAAM,EAAE,oBAAoB;YAC5B,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,SAAS,EAAE,QAAQ,IAAI,QAAQ,CAAC,GAAG;YACnC,KAAK;YACL,IAAI;YACJ,IAAI;YACJ,KAAK;YACL,OAAO;YACP,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;SAC1C,CAAA;IACH,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACtE,OAAO;YACL,EAAE,EAAE,KAAK;YACT,MAAM,EAAE,oBAAoB;YAC5B,KAAK,EAAE;gBACL,QAAQ,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa;gBAC/E,IAAI,EAAE,yBAAyB;gBAC/B,OAAO;aACR;SACF,CAAA;IACH,CAAC;YAAS,CAAC;QACT,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,OAAO,CAAC,KAAK,EAAE,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,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC;IACrD,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;IACrG,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,C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AAC;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";
|
|
@@ -58,6 +79,7 @@ export type SmartfetchAsset = {
|
|
|
58
79
|
downloadable: boolean;
|
|
59
80
|
};
|
|
60
81
|
export type SmartfetchRenderFormat = "text" | "markdown";
|
|
82
|
+
export type SmartWebProfile = "balanced" | "private";
|
|
61
83
|
export declare function asString(value: unknown): string;
|
|
62
84
|
export declare function asNumber(value: unknown): number;
|
|
63
85
|
export declare function decodeHtml(value: string): string;
|
|
@@ -81,8 +103,9 @@ export declare function extractMetaDescription(html: string): string;
|
|
|
81
103
|
export declare function extractMetaProperty(html: string, property: string): string;
|
|
82
104
|
export declare function extractMetaName(html: string, name: string): string;
|
|
83
105
|
export declare function inferTarget(url: string, target: Target): ResolvedTarget;
|
|
106
|
+
export declare function smartWebProfile(): SmartWebProfile;
|
|
84
107
|
export declare function envFlag(name: string): boolean;
|
|
85
|
-
export declare function envEnabled(name: string, defaultValue: boolean): boolean;
|
|
108
|
+
export declare function envEnabled(name: string, defaultValue: boolean, profileDefaults?: Partial<Record<SmartWebProfile, boolean>>): boolean;
|
|
86
109
|
export declare function validateOutboundUrl(url: string, options?: {
|
|
87
110
|
allowPrivateHosts?: boolean;
|
|
88
111
|
}): Promise<{
|
package/dist/shared.js
CHANGED
|
@@ -245,7 +245,7 @@ export function inferTarget(url, target) {
|
|
|
245
245
|
return "velog_post";
|
|
246
246
|
}
|
|
247
247
|
catch {
|
|
248
|
-
//
|
|
248
|
+
// Defer invalid URL reporting to the fetch path so callers get one consistent error.
|
|
249
249
|
}
|
|
250
250
|
return "generic";
|
|
251
251
|
}
|
|
@@ -267,13 +267,21 @@ function truthyEnv(value) {
|
|
|
267
267
|
function falsyEnv(value) {
|
|
268
268
|
return /^(0|false|no|off)$/i.test(String(value || "").trim());
|
|
269
269
|
}
|
|
270
|
+
export function smartWebProfile() {
|
|
271
|
+
const value = String(process.env.SMART_WEB_PROFILE || "").trim().toLowerCase();
|
|
272
|
+
if (["private", "local", "local-only", "strict"].includes(value))
|
|
273
|
+
return "private";
|
|
274
|
+
return "balanced";
|
|
275
|
+
}
|
|
270
276
|
export function envFlag(name) {
|
|
271
277
|
return truthyEnv(process.env[name]);
|
|
272
278
|
}
|
|
273
|
-
export function envEnabled(name, defaultValue) {
|
|
279
|
+
export function envEnabled(name, defaultValue, profileDefaults) {
|
|
274
280
|
const value = process.env[name];
|
|
275
|
-
if (value === undefined || String(value).trim() === "")
|
|
276
|
-
|
|
281
|
+
if (value === undefined || String(value).trim() === "") {
|
|
282
|
+
const profileDefault = profileDefaults?.[smartWebProfile()];
|
|
283
|
+
return profileDefault !== undefined ? profileDefault : defaultValue;
|
|
284
|
+
}
|
|
277
285
|
if (truthyEnv(value))
|
|
278
286
|
return true;
|
|
279
287
|
if (falsyEnv(value))
|
|
@@ -310,7 +318,7 @@ export async function validateOutboundUrl(url, options) {
|
|
|
310
318
|
}
|
|
311
319
|
}
|
|
312
320
|
catch {
|
|
313
|
-
//
|
|
321
|
+
// DNS failures are reported by the fetch attempt itself.
|
|
314
322
|
}
|
|
315
323
|
return { ok: true };
|
|
316
324
|
}
|
|
@@ -346,7 +354,7 @@ export async function resolveValidatedUrl(url, options) {
|
|
|
346
354
|
await response.body?.cancel();
|
|
347
355
|
}
|
|
348
356
|
catch {
|
|
349
|
-
//
|
|
357
|
+
// Ignore best-effort stream cleanup failures.
|
|
350
358
|
}
|
|
351
359
|
return { ok: true, url: currentUrl };
|
|
352
360
|
}
|
|
@@ -355,7 +363,7 @@ export async function resolveValidatedUrl(url, options) {
|
|
|
355
363
|
await response.body?.cancel();
|
|
356
364
|
}
|
|
357
365
|
catch {
|
|
358
|
-
//
|
|
366
|
+
// Ignore best-effort stream cleanup failures.
|
|
359
367
|
}
|
|
360
368
|
return { ok: false, reason: "too_many_redirects", message: `Too many redirects while resolving URL: ${url}` };
|
|
361
369
|
}
|
|
@@ -364,7 +372,7 @@ export async function resolveValidatedUrl(url, options) {
|
|
|
364
372
|
await response.body?.cancel();
|
|
365
373
|
}
|
|
366
374
|
catch {
|
|
367
|
-
//
|
|
375
|
+
// Ignore best-effort stream cleanup failures.
|
|
368
376
|
}
|
|
369
377
|
if (!location) {
|
|
370
378
|
return { ok: false, reason: "redirect_missing_location", message: "Redirect response did not include a Location header" };
|