smart-web-mcp 0.4.4 → 0.5.1
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 +25 -0
- package/README.md +43 -24
- package/dist/browser-session.d.ts +46 -0
- package/dist/browser-session.js +215 -0
- package/dist/browser-session.js.map +1 -0
- package/dist/index.js +57 -2
- package/dist/index.js.map +1 -1
- package/dist/shared.d.ts +27 -2
- package/dist/shared.js +54 -10
- 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 +24 -6
- package/dist/smartfetch/provider-policy.js.map +1 -1
- package/dist/smartfetch/provider-types.d.ts +1 -0
- package/dist/smartfetch/providers/dcinside.js +1 -1
- package/dist/smartfetch/providers/dcinside.js.map +1 -1
- package/dist/smartfetch/providers/hackernews.d.ts +2 -0
- package/dist/smartfetch/providers/hackernews.js +154 -0
- package/dist/smartfetch/providers/hackernews.js.map +1 -0
- package/dist/smartfetch/providers/index.js +3 -1
- package/dist/smartfetch/providers/index.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/naver-cafe.d.ts +2 -0
- package/dist/smartfetch/providers/naver-cafe.js +163 -0
- package/dist/smartfetch/providers/naver-cafe.js.map +1 -0
- 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-internals.d.ts +13 -0
- package/dist/smartfetch-internals.js +19 -0
- package/dist/smartfetch-internals.js.map +1 -0
- package/dist/smartfetch.d.ts +11 -1
- package/dist/smartfetch.js +104 -124
- package/dist/smartfetch.js.map +1 -1
- package/dist/smartsearch.d.ts +12 -1
- package/dist/smartsearch.js +198 -24
- package/dist/smartsearch.js.map +1 -1
- package/package.json +11 -5
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,31 @@ The format is based on Keep a Changelog and this project uses SemVer.
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.5.1] - 2026-03-24
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- `smartfetch` now recognizes public Naver Cafe article links and pulls the readable body through Naver's shared-article JSON endpoint instead of returning the outer page shell
|
|
14
|
+
|
|
15
|
+
## [0.5.0] - 2026-03-23
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- `smartcrawl` for local browser-driven exploration of boards, docs sites, pagination, and scroll-heavy pages
|
|
20
|
+
- shared stealth browser session runtime used by both `smartcrawl` and `smartfetch`
|
|
21
|
+
- npm-managed `pre-commit` and `pre-push` hook installation for local TypeScript and full repo checks
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- configuration UX now centers on `SMART_WEB_PROFILE` with fine-grained env flags treated as advanced overrides
|
|
26
|
+
- README, examples, and getting-started docs now use one npm-first path instead of parallel npm/Bun setup tracks
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
|
|
30
|
+
- MCP registry metadata now keeps the advanced environment-variable overrides that the runtime still supports
|
|
31
|
+
- Playwright fetch now preserves HTML content for provider normalization instead of dropping back to plain text first
|
|
32
|
+
- DCInside parsing now handles recommendation boxes with additional classes
|
|
33
|
+
|
|
9
34
|
## [0.4.4] - 2026-03-21
|
|
10
35
|
|
|
11
36
|
### 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,46 @@
|
|
|
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
|
+
type TimedCache = {
|
|
41
|
+
value: any;
|
|
42
|
+
expiresAt: number;
|
|
43
|
+
};
|
|
44
|
+
export declare function TEST_setChromiumCache(value: TimedCache | undefined): void;
|
|
45
|
+
export declare function runBrowserSession(options: BrowserSessionOptions): Promise<BrowserPageResult>;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,215 @@
|
|
|
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
|
+
const FAILURE_CACHE_TTL_MS = 30_000;
|
|
4
|
+
let chromiumCache = undefined;
|
|
5
|
+
export function TEST_setChromiumCache(value) {
|
|
6
|
+
chromiumCache = value;
|
|
7
|
+
}
|
|
8
|
+
async function getChromium() {
|
|
9
|
+
if (chromiumCache !== undefined && Date.now() < chromiumCache.expiresAt)
|
|
10
|
+
return chromiumCache.value;
|
|
11
|
+
try {
|
|
12
|
+
const playwrightExtra = await import("playwright-extra");
|
|
13
|
+
const stealthModule = await import("puppeteer-extra-plugin-stealth");
|
|
14
|
+
const chromium = playwrightExtra.chromium;
|
|
15
|
+
const createStealthPlugin = stealthModule.default || stealthModule;
|
|
16
|
+
chromium.use(createStealthPlugin());
|
|
17
|
+
chromiumCache = { value: chromium, expiresAt: Number.POSITIVE_INFINITY };
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
chromiumCache = { value: false, expiresAt: Date.now() + FAILURE_CACHE_TTL_MS };
|
|
21
|
+
}
|
|
22
|
+
return chromiumCache.value;
|
|
23
|
+
}
|
|
24
|
+
async function launchBrowser(chromium) {
|
|
25
|
+
const attempts = [
|
|
26
|
+
{ channel: process.env.SMARTFETCH_CHROME_CHANNEL || "chrome", headless: true },
|
|
27
|
+
{ executablePath: process.env.SMARTFETCH_CHROME_PATH, headless: true },
|
|
28
|
+
{ headless: true },
|
|
29
|
+
];
|
|
30
|
+
let lastError = null;
|
|
31
|
+
for (const options of attempts) {
|
|
32
|
+
const launchOptions = { ...options };
|
|
33
|
+
if (launchOptions.executablePath === undefined)
|
|
34
|
+
delete launchOptions.executablePath;
|
|
35
|
+
try {
|
|
36
|
+
return await chromium.launch(launchOptions);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
lastError = error;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
throw lastError;
|
|
43
|
+
}
|
|
44
|
+
async function clickLoadMore(page) {
|
|
45
|
+
return page.evaluate(() => {
|
|
46
|
+
const pattern = /^(load more|show more|more posts|more results|view more|see more|더보기|더 보기|더 불러오기)$/i;
|
|
47
|
+
const nodes = Array.from(document.querySelectorAll("button, [role='button'], input[type='button'], input[type='submit'], a"));
|
|
48
|
+
for (const node of nodes) {
|
|
49
|
+
const element = node;
|
|
50
|
+
const text = (element.innerText || element.getAttribute("aria-label") || element.getAttribute("title") || "").replace(/\s+/g, " ").trim();
|
|
51
|
+
if (!text || !pattern.test(text))
|
|
52
|
+
continue;
|
|
53
|
+
if (node instanceof HTMLAnchorElement) {
|
|
54
|
+
const href = node.getAttribute("href") || "";
|
|
55
|
+
if (href && href !== "#" && !href.toLowerCase().startsWith("javascript:"))
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
const rect = element.getBoundingClientRect();
|
|
59
|
+
if (rect.width <= 0 || rect.height <= 0)
|
|
60
|
+
continue;
|
|
61
|
+
element.click();
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
async function drivePage(page, options) {
|
|
68
|
+
const scrollSteps = Math.max(0, Math.min(20, Math.floor(Number(options.scrollSteps || 0))));
|
|
69
|
+
const maxLoadMoreClicks = Math.max(0, Math.min(10, Math.floor(Number(options.maxLoadMoreClicks || 0))));
|
|
70
|
+
let completedScrollSteps = 0;
|
|
71
|
+
let loadMoreClicks = 0;
|
|
72
|
+
let stagnantRounds = 0;
|
|
73
|
+
let previousAnchorCount = await page.locator("a[href]").count().catch(() => 0);
|
|
74
|
+
let previousHeight = await page.evaluate(() => document.body?.scrollHeight || document.documentElement?.scrollHeight || 0);
|
|
75
|
+
for (let step = 0; step < scrollSteps; step++) {
|
|
76
|
+
let clicked = false;
|
|
77
|
+
if (loadMoreClicks < maxLoadMoreClicks) {
|
|
78
|
+
clicked = await clickLoadMore(page).catch(() => false);
|
|
79
|
+
if (clicked) {
|
|
80
|
+
loadMoreClicks += 1;
|
|
81
|
+
await page.waitForTimeout(700);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
await page.evaluate(() => window.scrollTo(0, document.body?.scrollHeight || document.documentElement?.scrollHeight || 0));
|
|
85
|
+
completedScrollSteps += 1;
|
|
86
|
+
await page.waitForTimeout(700);
|
|
87
|
+
await page.waitForLoadState("networkidle", { timeout: 1500 }).catch(() => { });
|
|
88
|
+
const currentAnchorCount = await page.locator("a[href]").count().catch(() => previousAnchorCount);
|
|
89
|
+
const currentHeight = await page.evaluate(() => document.body?.scrollHeight || document.documentElement?.scrollHeight || 0);
|
|
90
|
+
if (!clicked && currentAnchorCount <= previousAnchorCount && currentHeight <= previousHeight) {
|
|
91
|
+
stagnantRounds += 1;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
stagnantRounds = 0;
|
|
95
|
+
}
|
|
96
|
+
previousAnchorCount = currentAnchorCount;
|
|
97
|
+
previousHeight = currentHeight;
|
|
98
|
+
if (stagnantRounds >= 2)
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
return { scroll_steps: completedScrollSteps, load_more_clicks: loadMoreClicks };
|
|
102
|
+
}
|
|
103
|
+
async function extractAnchors(page, maxAnchors) {
|
|
104
|
+
return page.evaluate((maxItems) => {
|
|
105
|
+
const nodes = Array.from(document.querySelectorAll("a[href]")).slice(0, maxItems);
|
|
106
|
+
return nodes.map((node) => {
|
|
107
|
+
const element = node;
|
|
108
|
+
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");
|
|
109
|
+
const text = (element.innerText || element.getAttribute("aria-label") || element.getAttribute("title") || "").replace(/\s+/g, " ").trim();
|
|
110
|
+
const contextSource = closest?.innerText || element.innerText || element.textContent || "";
|
|
111
|
+
return {
|
|
112
|
+
href: element.href || "",
|
|
113
|
+
text,
|
|
114
|
+
context: contextSource.replace(/\s+/g, " ").trim().slice(0, 500),
|
|
115
|
+
rel: element.rel || "",
|
|
116
|
+
class_name: typeof element.className === "string" ? element.className : "",
|
|
117
|
+
aria_label: element.getAttribute("aria-label") || "",
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
}, maxAnchors);
|
|
121
|
+
}
|
|
122
|
+
export async function runBrowserSession(options) {
|
|
123
|
+
const chromium = await getChromium();
|
|
124
|
+
if (!chromium) {
|
|
125
|
+
return {
|
|
126
|
+
ok: false,
|
|
127
|
+
method: "playwright_stealth",
|
|
128
|
+
error: {
|
|
129
|
+
category: "unavailable",
|
|
130
|
+
code: "playwright_unavailable",
|
|
131
|
+
message: "Playwright browser runtime is unavailable",
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
const resolveOptions = {
|
|
136
|
+
timeoutMs: options.timeoutMs,
|
|
137
|
+
};
|
|
138
|
+
if (options.allowPrivateHosts !== undefined)
|
|
139
|
+
resolveOptions.allowPrivateHosts = options.allowPrivateHosts;
|
|
140
|
+
if (options.extraHeaders !== undefined)
|
|
141
|
+
resolveOptions.headers = options.extraHeaders;
|
|
142
|
+
const resolved = await resolveValidatedUrl(options.url, resolveOptions);
|
|
143
|
+
if (!resolved.ok) {
|
|
144
|
+
return {
|
|
145
|
+
ok: false,
|
|
146
|
+
method: "playwright_stealth",
|
|
147
|
+
error: {
|
|
148
|
+
category: "block",
|
|
149
|
+
code: resolved.reason,
|
|
150
|
+
message: resolved.message,
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
let browser = null;
|
|
155
|
+
let context = null;
|
|
156
|
+
let page = null;
|
|
157
|
+
try {
|
|
158
|
+
browser = await launchBrowser(chromium);
|
|
159
|
+
context = await browser.newContext({
|
|
160
|
+
userAgent: DEFAULT_USER_AGENT,
|
|
161
|
+
locale: "ko-KR",
|
|
162
|
+
extraHTTPHeaders: options.extraHeaders,
|
|
163
|
+
});
|
|
164
|
+
page = await context.newPage();
|
|
165
|
+
await page.goto(resolved.url, {
|
|
166
|
+
waitUntil: options.waitUntil || "networkidle",
|
|
167
|
+
timeout: options.timeoutMs,
|
|
168
|
+
});
|
|
169
|
+
const driven = await drivePage(page, options);
|
|
170
|
+
const html = await page.content();
|
|
171
|
+
const text = await page.evaluate(() => document.body?.innerText || "");
|
|
172
|
+
const title = asString(await page.title());
|
|
173
|
+
const finalUrl = asString(page.url());
|
|
174
|
+
const maxAnchors = Math.max(50, Math.min(2000, Math.floor(Number(options.maxAnchors || 400))));
|
|
175
|
+
const anchors = await extractAnchors(page, maxAnchors);
|
|
176
|
+
const links = dedupeUrls(anchors.map((anchor) => asString(anchor?.href)));
|
|
177
|
+
return {
|
|
178
|
+
ok: true,
|
|
179
|
+
method: "playwright_stealth",
|
|
180
|
+
url: options.url,
|
|
181
|
+
final_url: finalUrl || resolved.url,
|
|
182
|
+
title,
|
|
183
|
+
html,
|
|
184
|
+
text,
|
|
185
|
+
links,
|
|
186
|
+
anchors,
|
|
187
|
+
scroll_steps: driven.scroll_steps,
|
|
188
|
+
load_more_clicks: driven.load_more_clicks,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
193
|
+
return {
|
|
194
|
+
ok: false,
|
|
195
|
+
method: "playwright_stealth",
|
|
196
|
+
error: {
|
|
197
|
+
category: message.toLowerCase().includes("timeout") ? "timeout" : "unavailable",
|
|
198
|
+
code: "playwright_fetch_failed",
|
|
199
|
+
message,
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
finally {
|
|
204
|
+
if (page) {
|
|
205
|
+
await page.close().catch(() => { });
|
|
206
|
+
}
|
|
207
|
+
if (context) {
|
|
208
|
+
await context.close().catch(() => { });
|
|
209
|
+
}
|
|
210
|
+
if (browser) {
|
|
211
|
+
await browser.close().catch(() => { });
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
//# 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,MAAM,oBAAoB,GAAG,MAAM,CA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E,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,21 +16,75 @@ 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
|
-
target: z.enum(["auto", "generic", "reddit_post", "x_post", "dcinside_post", "youtube_video", "naver_blog", "tistory_post", "velog_post"]).optional().describe("Content type hint"),
|
|
87
|
+
target: z.enum(["auto", "generic", "reddit_post", "x_post", "dcinside_post", "youtube_video", "naver_blog", "tistory_post", "velog_post", "hackernews_post"]).optional().describe("Content type hint"),
|
|
33
88
|
timeout_ms: z.number().int().min(3000).max(120000).optional().describe("Fetch timeout in milliseconds"),
|
|
34
89
|
force_dynamic: z.boolean().optional().describe("Skip light fetches and go straight to Playwright"),
|
|
35
90
|
strict_schema: z.boolean().optional().describe("Return schema-safe fallback output when normalization breaks"),
|
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,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KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;QAC9D,GAAG,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC;QACvE,GAAG,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type Target = "auto" | "generic" | "reddit_post" | "x_post" | "dcinside_post" | "youtube_video" | "naver_blog" | "tistory_post" | "velog_post";
|
|
1
|
+
export type Target = "auto" | "generic" | "reddit_post" | "x_post" | "dcinside_post" | "youtube_video" | "naver_blog" | "naver_cafe_post" | "tistory_post" | "velog_post" | "hackernews_post";
|
|
2
2
|
export type ResolvedTarget = Exclude<Target, "auto">;
|
|
3
3
|
export type ErrorCategory = "timeout" | "block" | "parse_error" | "unavailable";
|
|
4
4
|
export type ToolError = {
|
|
@@ -11,6 +11,7 @@ export type AdapterResult = {
|
|
|
11
11
|
method: string;
|
|
12
12
|
content: string;
|
|
13
13
|
links: string[];
|
|
14
|
+
final_url?: string;
|
|
14
15
|
error?: ToolError;
|
|
15
16
|
};
|
|
16
17
|
export type SearchResult = {
|
|
@@ -19,12 +20,33 @@ export type SearchResult = {
|
|
|
19
20
|
snippet: string;
|
|
20
21
|
engine: string;
|
|
21
22
|
};
|
|
23
|
+
export type SearchHandoffItem = {
|
|
24
|
+
title: string;
|
|
25
|
+
url: string;
|
|
26
|
+
snippet: string;
|
|
27
|
+
kind: string;
|
|
28
|
+
score: number;
|
|
29
|
+
depth: number;
|
|
30
|
+
};
|
|
31
|
+
export type SearchHandoff = {
|
|
32
|
+
tool: "smartcrawl";
|
|
33
|
+
performed: boolean;
|
|
34
|
+
reason: string;
|
|
35
|
+
start_url: string;
|
|
36
|
+
query: string;
|
|
37
|
+
mode: "auto" | "board" | "docs";
|
|
38
|
+
items: SearchHandoffItem[];
|
|
39
|
+
pages_attempted: number;
|
|
40
|
+
pages_loaded: number;
|
|
41
|
+
errors: string[];
|
|
42
|
+
};
|
|
22
43
|
export type SearchResponse = {
|
|
23
44
|
engine: string;
|
|
24
45
|
query: string;
|
|
25
46
|
results: SearchResult[];
|
|
26
47
|
fallbacks_tried: string[];
|
|
27
48
|
notes: string[];
|
|
49
|
+
handoff?: SearchHandoff;
|
|
28
50
|
};
|
|
29
51
|
export type SmartfetchOutput = {
|
|
30
52
|
source: "smartfetch";
|
|
@@ -58,6 +80,7 @@ export type SmartfetchAsset = {
|
|
|
58
80
|
downloadable: boolean;
|
|
59
81
|
};
|
|
60
82
|
export type SmartfetchRenderFormat = "text" | "markdown";
|
|
83
|
+
export type SmartWebProfile = "balanced" | "private";
|
|
61
84
|
export declare function asString(value: unknown): string;
|
|
62
85
|
export declare function asNumber(value: unknown): number;
|
|
63
86
|
export declare function decodeHtml(value: string): string;
|
|
@@ -81,8 +104,9 @@ export declare function extractMetaDescription(html: string): string;
|
|
|
81
104
|
export declare function extractMetaProperty(html: string, property: string): string;
|
|
82
105
|
export declare function extractMetaName(html: string, name: string): string;
|
|
83
106
|
export declare function inferTarget(url: string, target: Target): ResolvedTarget;
|
|
107
|
+
export declare function smartWebProfile(): SmartWebProfile;
|
|
84
108
|
export declare function envFlag(name: string): boolean;
|
|
85
|
-
export declare function envEnabled(name: string, defaultValue: boolean): boolean;
|
|
109
|
+
export declare function envEnabled(name: string, defaultValue: boolean, profileDefaults?: Partial<Record<SmartWebProfile, boolean>>): boolean;
|
|
86
110
|
export declare function validateOutboundUrl(url: string, options?: {
|
|
87
111
|
allowPrivateHosts?: boolean;
|
|
88
112
|
}): Promise<{
|
|
@@ -112,6 +136,7 @@ export declare function isRedditUrl(url: string): boolean;
|
|
|
112
136
|
export declare function isDcinsideUrl(url: string): boolean;
|
|
113
137
|
export declare function isYouTubeUrl(url: string): boolean;
|
|
114
138
|
export declare function isNaverBlogUrl(url: string): boolean;
|
|
139
|
+
export declare function isNaverCafeUrl(url: string): boolean;
|
|
115
140
|
export declare function isTistoryUrl(url: string): boolean;
|
|
116
141
|
export declare function isVelogUrl(url: string): boolean;
|
|
117
142
|
export declare function needsDynamicCrawl(result: AdapterResult): boolean;
|