@agentsearchhq/agentsearch-mcp 1.1.0 → 1.1.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/.env.example +5 -14
- package/README.md +34 -105
- package/dist/client.d.ts +4 -6
- package/dist/client.js +15 -34
- package/dist/client.js.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/tools/render.js +1 -1
- package/dist/tools/render.js.map +1 -1
- package/dist/tools/search.js +9 -9
- package/dist/tools/search.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/manifest.json +10 -20
- package/package.json +2 -3
- package/server.json +8 -12
- package/smithery.yaml +6 -11
package/.env.example
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
# AgentSearch MCP configuration
|
|
2
|
-
# Copy to .env for local testing (never commit .env)
|
|
2
|
+
# Copy to .env for local testing (never commit .env).
|
|
3
|
+
# This server talks only to an AgentSearch-compatible API you run yourself.
|
|
3
4
|
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
AGENTSEARCH_MODE=direct
|
|
5
|
+
# Required. Base URL of that API, with no trailing slash. There is no default.
|
|
6
|
+
AGENTSEARCH_BASE_URL=
|
|
7
7
|
|
|
8
|
-
#
|
|
9
|
-
# Default: http://127.0.0.1:8000
|
|
10
|
-
AGENTSEARCH_BASE_URL=http://127.0.0.1:8000
|
|
11
|
-
|
|
12
|
-
# Optional Bearer token for direct mode Authorization header
|
|
13
|
-
# If the server returns 401 with the key, the client retries once without it
|
|
8
|
+
# Optional Bearer token. If the API returns 401 with the key, the client retries once without it.
|
|
14
9
|
AGENTSEARCH_API_KEY=
|
|
15
|
-
|
|
16
|
-
# Portal reference (used when AGENTSEARCH_MODE=portal):
|
|
17
|
-
# POST https://agent.pocket.network/v1/agentsearch-web-search-v1/v1/search
|
|
18
|
-
# body: {"query":"...","max_results":5}
|
package/README.md
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
# agentsearch-mcp
|
|
2
2
|
|
|
3
|
-
MCP (Model Context Protocol) server
|
|
3
|
+
MCP (Model Context Protocol) server for people running their own [AgentSearch](https://agentsearchhq.com/?utm_source=github&utm_medium=readme&utm_campaign=mcp)-compatible backend. It exposes web search, page extract, and JavaScript page rendering (headless browser) to Cursor, Claude Desktop, and other MCP hosts over **stdio**.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
`AGENTSEARCH_BASE_URL` is required and points at that API. There is no built-in default host.
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
`POST https://agent.pocket.network/v1/agentsearch-web-search-v1/v1/search`
|
|
9
|
-
body: `{ "query": "...", "max_results": 5 }`
|
|
10
|
-
- Direct search: `POST {AGENTSEARCH_BASE_URL}/v1/search` with the same body
|
|
11
|
-
- Direct extract: `POST {AGENTSEARCH_BASE_URL}/v1/extract`
|
|
12
|
-
- Direct render: `POST {AGENTSEARCH_BASE_URL}/v1/render` (headless Chromium; [OpenAPI spec](https://agentsearchhq.com/specs/render-openapi.json))
|
|
7
|
+
For pay-per-call access with no backend of your own, use Pocket's official MCP server instead:
|
|
13
8
|
|
|
14
|
-
|
|
9
|
+
```bash
|
|
10
|
+
npx -y @pocket-network/agentic-portal-mcp
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
That server calls `agentsearch-web-search-v1` and `agentsearch-web-extract-v1` at $0.005/call over x402. Details: https://agentsearchhq.com/?utm_source=github&utm_medium=readme&utm_campaign=mcp
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
This package calls your API directly:
|
|
16
|
+
|
|
17
|
+
- Search: `POST {AGENTSEARCH_BASE_URL}/v1/search` with body `{ "query": "...", "max_results": 5 }`
|
|
18
|
+
- Extract: `POST {AGENTSEARCH_BASE_URL}/v1/extract`
|
|
19
|
+
- Render: `POST {AGENTSEARCH_BASE_URL}/v1/render` (headless Chromium; [OpenAPI spec](https://agentsearchhq.com/specs/render-openapi.json))
|
|
17
20
|
|
|
18
21
|
---
|
|
19
22
|
|
|
@@ -21,11 +24,9 @@ Pocket explorer: [agentsearch-web-search-v1](https://explorer.pocket.network/ser
|
|
|
21
24
|
|
|
22
25
|
| Tool | Args | Description |
|
|
23
26
|
|------|------|-------------|
|
|
24
|
-
| `agentsearch_web_search` | `query` (string, required), `max_results` (number, optional, default 5, clamped 1–
|
|
25
|
-
| `agentsearch_extract` | `url` (absolute URL, required), `formats` (string[], optional), `max_chars` (positive integer, optional) | Page extract via `POST /v1/extract`.
|
|
26
|
-
| `agentsearch_render` | `url` (absolute http(s) URL, required); optional: `formats` (`markdown`\|`text`\|`html`\|`links`, default `["markdown"]`), `max_chars` (1–100000), `screenshot`, `screenshot_format` (`png`\|`jpeg`), `full_page`, `viewport` (`{width 320–1920, height 240–1600}`), `wait_until` (`domcontentloaded`\|`load`\|`networkidle`), `wait_for_selector`, `wait_ms` (0–1500), `block` (`image`\|`media`\|`font`\|`stylesheet`) | Renders a JavaScript-heavy page in headless Chromium via `POST /v1/render` and returns title, status, meta, and the rendered markdown/text/HTML/links (plus optional base64 screenshot).
|
|
27
|
-
|
|
28
|
-
On portal **HTTP 402**, the search tool returns a clear MCP error that **x402 payment is required** (or switch to `AGENTSEARCH_MODE=direct`). In portal mode, `agentsearch_extract` and `agentsearch_render` do not call the network; they return an MCP error telling you to switch to direct mode or use search.
|
|
27
|
+
| `agentsearch_web_search` | `query` (string, required), `max_results` (number, optional, default 5, clamped 1–5) | Web search. Returns pretty-printed JSON. Use for a query; use extract when you already have a URL. Read-only HTTP. |
|
|
28
|
+
| `agentsearch_extract` | `url` (absolute URL, required), `formats` (string[], optional), `max_chars` (positive integer, optional) | Page extract via `POST /v1/extract`. Use when you already have a URL. Read-only HTTP. |
|
|
29
|
+
| `agentsearch_render` | `url` (absolute http(s) URL, required); optional: `formats` (`markdown`\|`text`\|`html`\|`links`, default `["markdown"]`), `max_chars` (1–100000), `screenshot`, `screenshot_format` (`png`\|`jpeg`), `full_page`, `viewport` (`{width 320–1920, height 240–1600}`), `wait_until` (`domcontentloaded`\|`load`\|`networkidle`), `wait_for_selector`, `wait_ms` (0–1500), `block` (`image`\|`media`\|`font`\|`stylesheet`) | Renders a JavaScript-heavy page in headless Chromium via `POST /v1/render` and returns title, status, meta, and the rendered markdown/text/HTML/links (plus optional base64 screenshot). Use when extract returns empty/partial content for an SPA; prefer extract for static pages. Read-only HTTP. |
|
|
29
30
|
|
|
30
31
|
For `agentsearch_render`, target-site failures (DNS/TLS errors, timeouts, bot walls, robots.txt) come back as a normal result whose JSON has a non-null `error` object (`code`, `message`, `retryable`); bad input (400), oversize body (413), rate limits (429) and backend faults (500) are MCP errors. The backend enforces a ~4.2 s render deadline.
|
|
31
32
|
|
|
@@ -34,13 +35,11 @@ For `agentsearch_render`, target-site failures (DNS/TLS errors, timeouts, bot wa
|
|
|
34
35
|
## Requirements
|
|
35
36
|
|
|
36
37
|
- Node.js **20+**
|
|
37
|
-
-
|
|
38
|
+
- Your own AgentSearch-compatible API. Set `AGENTSEARCH_BASE_URL` to its base URL. The process exits at startup if that variable is missing.
|
|
38
39
|
|
|
39
40
|
---
|
|
40
41
|
|
|
41
|
-
## Install
|
|
42
|
-
|
|
43
|
-
Published package:
|
|
42
|
+
## Install
|
|
44
43
|
|
|
45
44
|
```bash
|
|
46
45
|
npx -y @agentsearchhq/agentsearch-mcp
|
|
@@ -56,7 +55,7 @@ npm install
|
|
|
56
55
|
npm run build
|
|
57
56
|
```
|
|
58
57
|
|
|
59
|
-
Scripts: `build` → `tsc`, `start` → `node dist/index.js`, `test` → build + `node --test test/*.mjs`, `prepare` → runs build
|
|
58
|
+
Scripts: `build` → `tsc`, `start` → `node dist/index.js`, `test` → build + `node --test test/*.mjs`, `prepare` → runs build.
|
|
60
59
|
|
|
61
60
|
Binary: `agentsearch-mcp` → `dist/index.js`
|
|
62
61
|
|
|
@@ -64,39 +63,19 @@ Binary: `agentsearch-mcp` → `dist/index.js`
|
|
|
64
63
|
|
|
65
64
|
## Environment variables
|
|
66
65
|
|
|
67
|
-
| Variable |
|
|
68
|
-
|
|
69
|
-
| `
|
|
70
|
-
| `
|
|
71
|
-
| `AGENTSEARCH_API_KEY` | _(empty)_ | Optional `Authorization: Bearer …` for direct; on **401** the client retries once **without** the key |
|
|
66
|
+
| Variable | Required | Notes |
|
|
67
|
+
|----------|----------|--------|
|
|
68
|
+
| `AGENTSEARCH_BASE_URL` | yes | Base URL of your API (no trailing slash). No default. |
|
|
69
|
+
| `AGENTSEARCH_API_KEY` | no | Optional `Authorization: Bearer …`. On **401** the client retries once **without** the key. |
|
|
72
70
|
|
|
73
71
|
See `.env.example`. Never commit a real `.env`.
|
|
74
72
|
|
|
75
73
|
---
|
|
76
74
|
|
|
77
|
-
## Cursor
|
|
75
|
+
## Cursor
|
|
78
76
|
|
|
79
77
|
**Project** (`.cursor/mcp.json`) or **user** (`~/.cursor/mcp.json` / Cursor Settings → MCP):
|
|
80
78
|
|
|
81
|
-
```json
|
|
82
|
-
{
|
|
83
|
-
"mcpServers": {
|
|
84
|
-
"agentsearch": {
|
|
85
|
-
"command": "node",
|
|
86
|
-
"args": [
|
|
87
|
-
"C:/Users/Holla/OneDrive/Desktop/AgentSearch/agentsearch-mcp/dist/index.js"
|
|
88
|
-
],
|
|
89
|
-
"env": {
|
|
90
|
-
"AGENTSEARCH_MODE": "direct",
|
|
91
|
-
"AGENTSEARCH_BASE_URL": "http://127.0.0.1:8000"
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
After `npm install && npm run build`, optionally use the bin:
|
|
99
|
-
|
|
100
79
|
```json
|
|
101
80
|
{
|
|
102
81
|
"mcpServers": {
|
|
@@ -104,22 +83,18 @@ After `npm install && npm run build`, optionally use the bin:
|
|
|
104
83
|
"command": "npx",
|
|
105
84
|
"args": ["-y", "@agentsearchhq/agentsearch-mcp"],
|
|
106
85
|
"env": {
|
|
107
|
-
"
|
|
108
|
-
"AGENTSEARCH_BASE_URL": "http://127.0.0.1:8000"
|
|
86
|
+
"AGENTSEARCH_BASE_URL": "https://your-agentsearch-host.example"
|
|
109
87
|
}
|
|
110
88
|
}
|
|
111
89
|
}
|
|
112
90
|
}
|
|
113
91
|
```
|
|
114
92
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
Optional API key (direct only):
|
|
93
|
+
Optional API key:
|
|
118
94
|
|
|
119
95
|
```json
|
|
120
96
|
"env": {
|
|
121
|
-
"
|
|
122
|
-
"AGENTSEARCH_BASE_URL": "http://127.0.0.1:8000",
|
|
97
|
+
"AGENTSEARCH_BASE_URL": "https://your-agentsearch-host.example",
|
|
123
98
|
"AGENTSEARCH_API_KEY": "your-key-here"
|
|
124
99
|
}
|
|
125
100
|
```
|
|
@@ -137,13 +112,10 @@ Edit Claude Desktop config (`claude_desktop_config.json`):
|
|
|
137
112
|
{
|
|
138
113
|
"mcpServers": {
|
|
139
114
|
"agentsearch": {
|
|
140
|
-
"command": "
|
|
141
|
-
"args": [
|
|
142
|
-
"C:/Users/Holla/OneDrive/Desktop/AgentSearch/agentsearch-mcp/dist/index.js"
|
|
143
|
-
],
|
|
115
|
+
"command": "npx",
|
|
116
|
+
"args": ["-y", "@agentsearchhq/agentsearch-mcp"],
|
|
144
117
|
"env": {
|
|
145
|
-
"
|
|
146
|
-
"AGENTSEARCH_BASE_URL": "http://127.0.0.1:8000"
|
|
118
|
+
"AGENTSEARCH_BASE_URL": "https://your-agentsearch-host.example"
|
|
147
119
|
}
|
|
148
120
|
}
|
|
149
121
|
}
|
|
@@ -154,58 +126,15 @@ Restart Claude Desktop after saving.
|
|
|
154
126
|
|
|
155
127
|
---
|
|
156
128
|
|
|
157
|
-
## Local run
|
|
129
|
+
## Local run
|
|
158
130
|
|
|
159
131
|
```bash
|
|
160
132
|
npm run build
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
# (process waits on stdin — Ctrl+C to stop)
|
|
133
|
+
AGENTSEARCH_BASE_URL=https://your-agentsearch-host.example node dist/index.js
|
|
134
|
+
# process waits on stdin — Ctrl+C to stop
|
|
164
135
|
```
|
|
165
136
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
## Publish (high level)
|
|
169
|
-
|
|
170
|
-
No paid promo — list the package so tools can discover it via registries and usage.
|
|
171
|
-
|
|
172
|
-
### npm
|
|
173
|
-
|
|
174
|
-
1. `npm login` (the `@agentsearchhq` org must allow the publisher)
|
|
175
|
-
2. Confirm `name` is `@agentsearchhq/agentsearch-mcp` and `version` matches `manifest.json` / `server.json` (currently `1.1.0`) in `package.json` (`publishConfig.access` is `public`)
|
|
176
|
-
3. `npm publish` (ensure `prepare`/`build` succeed; no secrets in the tarball)
|
|
177
|
-
|
|
178
|
-
### MCP Registry
|
|
179
|
-
|
|
180
|
-
1. Ensure `server.json` matches your npm package + stdio transport
|
|
181
|
-
2. Follow the [MCP Registry](https://github.com/modelcontextprotocol/registry) publish flow (authenticate publisher, submit server metadata)
|
|
182
|
-
3. Verify the listing resolves `@agentsearchhq/agentsearch-mcp` / stdio
|
|
183
|
-
|
|
184
|
-
### Smithery
|
|
185
|
-
|
|
186
|
-
Publish with the durable helper (preferred):
|
|
187
|
-
|
|
188
|
-
```bash
|
|
189
|
-
npm run smithery:publish
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
That runs `scripts/publish-smithery.mjs`, which ensures `agentsearch-mcp.mcpb` exists (`npm run mcpb:pack` if missing), idempotently patches the global Smithery CLI so the deploy payload always includes a tool `inputSchema` object when the MCPB omitted it, then runs `smithery mcp publish ./agentsearch-mcp.mcpb -n agentsearchhq/agentsearch-mcp`.
|
|
193
|
-
|
|
194
|
-
**MCPB note:** `manifest.json` must **omit** tool `inputSchema` — `mcpb validate` rejects it. The publish helper patches the CLI payload side instead.
|
|
195
|
-
|
|
196
|
-
Manual equivalent (after CLI is patched):
|
|
197
|
-
|
|
198
|
-
```bash
|
|
199
|
-
npm run mcpb:pack
|
|
200
|
-
smithery mcp publish ./agentsearch-mcp.mcpb -n agentsearchhq/agentsearch-mcp
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
`npm run mcpb:pack` compiles TypeScript to `dist/index.js`, installs production dependencies, then writes `agentsearch-mcp.mcpb`. Check the manifest with `npm run mcpb:validate`. `manifest.json` (MCPB 0.3) launches `node ${__dirname}/dist/index.js` and maps optional `AGENTSEARCH_MODE` (default `direct`), `AGENTSEARCH_BASE_URL` (default `http://127.0.0.1:8000`), and sensitive `AGENTSEARCH_API_KEY`. `smithery.yaml` remains as start-command metadata. Dry-run patch detection only: `node scripts/publish-smithery.mjs --dry-patch`.
|
|
204
|
-
|
|
205
|
-
### Glama
|
|
206
|
-
|
|
207
|
-
1. Submit the GitHub (or npm) package to [Glama](https://glama.ai) MCP directory
|
|
208
|
-
2. Link README + tools list; keep env docs in sync
|
|
137
|
+
If `AGENTSEARCH_BASE_URL` is unset, the process prints an error and exits.
|
|
209
138
|
|
|
210
139
|
---
|
|
211
140
|
|
package/dist/client.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* HTTP client for
|
|
3
|
-
*
|
|
2
|
+
* HTTP client for a self-hosted AgentSearch-compatible API
|
|
3
|
+
* (search, extract, and render).
|
|
4
4
|
*/
|
|
5
|
-
export type AgentSearchMode = "direct" | "portal";
|
|
6
5
|
export interface AgentSearchConfig {
|
|
7
|
-
mode: AgentSearchMode;
|
|
8
6
|
baseUrl: string;
|
|
9
7
|
apiKey?: string;
|
|
10
8
|
}
|
|
@@ -37,15 +35,15 @@ export interface RenderRequest {
|
|
|
37
35
|
wait_ms?: number;
|
|
38
36
|
block?: RenderBlockType[];
|
|
39
37
|
}
|
|
40
|
-
export declare const
|
|
38
|
+
export declare const MISSING_BASE_URL_MESSAGE = "AGENTSEARCH_BASE_URL is required. Set it to the base URL of your self-hosted AgentSearch-compatible API (no trailing slash). This package does not call the Pocket portal.";
|
|
41
39
|
export declare class AgentSearchHttpError extends Error {
|
|
42
40
|
readonly status: number;
|
|
43
41
|
readonly body: string;
|
|
44
|
-
readonly paymentRequired: boolean;
|
|
45
42
|
constructor(status: number, body: string);
|
|
46
43
|
}
|
|
47
44
|
export declare function loadConfig(): AgentSearchConfig;
|
|
48
45
|
export declare function webSearch(cfg: AgentSearchConfig, req: SearchRequest): Promise<unknown>;
|
|
49
46
|
export declare function extractPage(cfg: AgentSearchConfig, req: ExtractRequest): Promise<unknown>;
|
|
50
47
|
export declare function renderPage(cfg: AgentSearchConfig, req: RenderRequest): Promise<unknown>;
|
|
48
|
+
/** Backend allows at most 5 hits. Values outside 1–5 are clamped; default is 5. */
|
|
51
49
|
export declare function clampMaxResults(n: number | undefined, fallback?: number): number;
|
package/dist/client.js
CHANGED
|
@@ -1,38 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* HTTP client for
|
|
3
|
-
*
|
|
2
|
+
* HTTP client for a self-hosted AgentSearch-compatible API
|
|
3
|
+
* (search, extract, and render).
|
|
4
4
|
*/
|
|
5
|
-
export const
|
|
5
|
+
export const MISSING_BASE_URL_MESSAGE = "AGENTSEARCH_BASE_URL is required. Set it to the base URL of your self-hosted AgentSearch-compatible API (no trailing slash). This package does not call the Pocket portal.";
|
|
6
6
|
export class AgentSearchHttpError extends Error {
|
|
7
7
|
status;
|
|
8
8
|
body;
|
|
9
|
-
paymentRequired;
|
|
10
9
|
constructor(status, body) {
|
|
11
|
-
|
|
12
|
-
super(paymentRequired
|
|
13
|
-
? `AgentSearch portal returned 402 Payment Required (x402). Use AGENTSEARCH_MODE=direct with a local/self-hosted AgentSearch API, or complete portal payment.`
|
|
14
|
-
: `AgentSearch HTTP ${status}: ${body.slice(0, 500)}`);
|
|
10
|
+
super(`AgentSearch HTTP ${status}: ${body.slice(0, 500)}`);
|
|
15
11
|
this.name = "AgentSearchHttpError";
|
|
16
12
|
this.status = status;
|
|
17
13
|
this.body = body;
|
|
18
|
-
this.paymentRequired = paymentRequired;
|
|
19
14
|
}
|
|
20
15
|
}
|
|
21
|
-
const PORTAL_SEARCH_URL = "https://agent.pocket.network/v1/agentsearch-web-search-v1/v1/search";
|
|
22
16
|
export function loadConfig() {
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
17
|
+
const raw = process.env.AGENTSEARCH_BASE_URL?.trim() ?? "";
|
|
18
|
+
const baseUrl = raw.replace(/\/+$/, "");
|
|
19
|
+
if (!baseUrl) {
|
|
20
|
+
throw new Error(MISSING_BASE_URL_MESSAGE);
|
|
21
|
+
}
|
|
26
22
|
const apiKey = process.env.AGENTSEARCH_API_KEY?.trim() || undefined;
|
|
27
|
-
return {
|
|
23
|
+
return { baseUrl, apiKey };
|
|
28
24
|
}
|
|
29
25
|
function searchUrl(cfg) {
|
|
30
|
-
if (cfg.mode === "portal")
|
|
31
|
-
return PORTAL_SEARCH_URL;
|
|
32
26
|
return `${cfg.baseUrl}/v1/search`;
|
|
33
27
|
}
|
|
34
28
|
function extractUrl(cfg) {
|
|
35
|
-
// Extract is only defined for direct in this package; portal extract may differ.
|
|
36
29
|
return `${cfg.baseUrl}/v1/extract`;
|
|
37
30
|
}
|
|
38
31
|
function renderUrl(cfg) {
|
|
@@ -55,12 +48,9 @@ async function postJson(url, body, apiKey, opts) {
|
|
|
55
48
|
if (res.status === 401 &&
|
|
56
49
|
apiKey &&
|
|
57
50
|
opts?.retryWithoutKeyOn401 !== false) {
|
|
58
|
-
//
|
|
51
|
+
// Some deployments reject a present key; retry once without it.
|
|
59
52
|
return postJson(url, body, undefined, { retryWithoutKeyOn401: false });
|
|
60
53
|
}
|
|
61
|
-
if (res.status === 402) {
|
|
62
|
-
throw new AgentSearchHttpError(402, text);
|
|
63
|
-
}
|
|
64
54
|
if (!res.ok) {
|
|
65
55
|
throw new AgentSearchHttpError(res.status, text || res.statusText);
|
|
66
56
|
}
|
|
@@ -74,21 +64,15 @@ async function postJson(url, body, apiKey, opts) {
|
|
|
74
64
|
}
|
|
75
65
|
}
|
|
76
66
|
export async function webSearch(cfg, req) {
|
|
77
|
-
|
|
78
|
-
const key = cfg.mode === "direct" ? cfg.apiKey : undefined;
|
|
79
|
-
return postJson(url, { query: req.query, max_results: req.max_results }, key, { retryWithoutKeyOn401: cfg.mode === "direct" });
|
|
67
|
+
return postJson(searchUrl(cfg), { query: req.query, max_results: req.max_results }, cfg.apiKey, { retryWithoutKeyOn401: true });
|
|
80
68
|
}
|
|
81
69
|
export async function extractPage(cfg, req) {
|
|
82
|
-
if (cfg.mode === "portal") {
|
|
83
|
-
throw new Error("agentsearch_extract is only supported in AGENTSEARCH_MODE=direct (POST {BASE}/v1/extract). Switch to direct mode or call search only.");
|
|
84
|
-
}
|
|
85
|
-
const url = extractUrl(cfg);
|
|
86
70
|
const body = { url: req.url };
|
|
87
71
|
if (req.formats)
|
|
88
72
|
body.formats = req.formats;
|
|
89
73
|
if (req.max_chars !== undefined)
|
|
90
74
|
body.max_chars = req.max_chars;
|
|
91
|
-
return postJson(
|
|
75
|
+
return postJson(extractUrl(cfg), body, cfg.apiKey, { retryWithoutKeyOn401: true });
|
|
92
76
|
}
|
|
93
77
|
const RENDER_FIELDS = [
|
|
94
78
|
"formats",
|
|
@@ -103,10 +87,6 @@ const RENDER_FIELDS = [
|
|
|
103
87
|
"block",
|
|
104
88
|
];
|
|
105
89
|
export async function renderPage(cfg, req) {
|
|
106
|
-
if (cfg.mode === "portal") {
|
|
107
|
-
// Portal render endpoint is not live yet: fail before any network call.
|
|
108
|
-
throw new Error(RENDER_PORTAL_UNSUPPORTED_MESSAGE);
|
|
109
|
-
}
|
|
110
90
|
const body = { url: req.url };
|
|
111
91
|
for (const key of RENDER_FIELDS) {
|
|
112
92
|
if (req[key] !== undefined)
|
|
@@ -116,8 +96,9 @@ export async function renderPage(cfg, req) {
|
|
|
116
96
|
retryWithoutKeyOn401: true,
|
|
117
97
|
});
|
|
118
98
|
}
|
|
99
|
+
/** Backend allows at most 5 hits. Values outside 1–5 are clamped; default is 5. */
|
|
119
100
|
export function clampMaxResults(n, fallback = 5) {
|
|
120
101
|
const v = typeof n === "number" && Number.isFinite(n) ? Math.trunc(n) : fallback;
|
|
121
|
-
return Math.min(
|
|
102
|
+
return Math.min(5, Math.max(1, v));
|
|
122
103
|
}
|
|
123
104
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqCH,MAAM,CAAC,MAAM,wBAAwB,GACnC,4KAA4K,CAAC;AAE/K,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACpC,MAAM,CAAS;IACf,IAAI,CAAS;IAEtB,YAAY,MAAc,EAAE,IAAY;QACtC,KAAK,CAAC,oBAAoB,MAAM,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QAC3D,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,MAAM,UAAU,UAAU;IACxB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAC3D,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACxC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5C,CAAC;IACD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,IAAI,EAAE,IAAI,SAAS,CAAC;IACpE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;A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C,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE;QAChD,oBAAoB,EAAE,IAAI;KAC3B,CAAC,CAAC;AACL,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,eAAe,CAAC,CAAqB,EAAE,QAAQ,GAAG,CAAC;IACjE,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IACjF,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -12,10 +12,11 @@ async function main() {
|
|
|
12
12
|
const transport = new StdioServerTransport();
|
|
13
13
|
await server.connect(transport);
|
|
14
14
|
// stdout is reserved for MCP JSON-RPC; log to stderr only
|
|
15
|
-
console.error(`agentsearch-mcp listening on stdio (
|
|
15
|
+
console.error(`agentsearch-mcp listening on stdio (base=${cfg.baseUrl})`);
|
|
16
16
|
}
|
|
17
17
|
main().catch((err) => {
|
|
18
|
-
|
|
18
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
19
|
+
console.error(`agentsearch-mcp failed to start: ${message}`);
|
|
19
20
|
process.exit(1);
|
|
20
21
|
});
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,OAAO,EAAE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C,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/tools/render.js
CHANGED
|
@@ -5,7 +5,7 @@ export const RENDER_DESCRIPTION = [
|
|
|
5
5
|
"Render one absolute http(s) URL in headless Chromium through the AgentSearch Web Render API, so JavaScript runs before content is captured, and return the backend response as pretty-printed JSON text (a non-JSON body is wrapped as {raw: text}).",
|
|
6
6
|
"The response includes the final url, title, status_code, meta (render_ms, chars, truncated, js, lang …), warnings, error, and the rendered page body in each requested format: markdown (default), text, html, and/or links; plus an optional base64 screenshot.",
|
|
7
7
|
"Use this when the page is a JavaScript-heavy app (SPA, client-rendered docs or dashboards) where agentsearch_extract returns empty or partial content; for static pages prefer agentsearch_extract (cheaper and faster), and to find pages from a query use agentsearch_web_search.",
|
|
8
|
-
"
|
|
8
|
+
"Requires AGENTSEARCH_BASE_URL (there is no default). POSTs {AGENTSEARCH_BASE_URL}/v1/render. The process exits at startup when that variable is missing.",
|
|
9
9
|
"Read-only: it loads the page like a browser visit and does not click, submit, or change anything, but it uses the network, has a hard backend deadline of about 4.2 s, and can hit rate limits (HTTP 429).",
|
|
10
10
|
"Target-site failures (DNS, TLS, timeouts, bot walls, robots.txt) come back as a normal result with a non-null error object {code, message, retryable} and empty or partial content; invalid input or a disallowed URL (HTTP 400), an oversized request (413), rate limits (429), and backend faults (500) are MCP errors with the status and a truncated body.",
|
|
11
11
|
"When AGENTSEARCH_API_KEY is set it is sent as a Bearer token, and HTTP 401 is retried once without the key.",
|
package/dist/tools/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/tools/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEzD,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G,CAAC,CAAC,CAAC;iBACN,GAAG,CAAC,IAAI,CAAC;iBACT,QAAQ,EAAE;iBACV,QAAQ,CAAC,wDAAwD,CAAC;YACrE,KAAK,EAAE,CAAC;iBACL,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;iBACvD,QAAQ,EAAE;iBACV,QAAQ,CAAC,qEAAqE,CAAC;SACnF;KACF,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;QACb,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC;YACzB,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YACzC,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;aAC/D,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/dist/tools/search.js
CHANGED
|
@@ -25,20 +25,20 @@ export function errorContent(err) {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
const WEB_SEARCH_DESCRIPTION = [
|
|
28
|
-
"Search the web through AgentSearch and return the backend response as pretty-printed JSON text (a non-JSON body is wrapped as {raw: text}).",
|
|
28
|
+
"Search the web through your self-hosted AgentSearch API and return the backend response as pretty-printed JSON text (a non-JSON body is wrapped as {raw: text}).",
|
|
29
29
|
"Use this when you have a query and need hits rather than a page body; if you already have a URL, use agentsearch_extract instead (or agentsearch_render for JavaScript-heavy pages).",
|
|
30
|
-
"
|
|
30
|
+
"Requires AGENTSEARCH_BASE_URL (there is no default). POSTs {AGENTSEARCH_BASE_URL}/v1/search.",
|
|
31
31
|
"Read-only HTTP POST: not destructive, but it uses the network and can hit backend rate limits.",
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"Integers for max_results outside 1–
|
|
32
|
+
"When AGENTSEARCH_API_KEY is set it is sent as a Bearer token, and HTTP 401 is retried once without the key.",
|
|
33
|
+
"HTTP failures are MCP errors with the status and a truncated body.",
|
|
34
|
+
"Integers for max_results outside 1–5 are clamped (default 5), not rejected. The backend allows at most 5.",
|
|
35
35
|
].join(" ");
|
|
36
36
|
const EXTRACT_DESCRIPTION = [
|
|
37
|
-
"Extract the content of one absolute URL through AgentSearch and return the backend response as pretty-printed JSON text (a non-JSON body is wrapped as {raw: text}).",
|
|
37
|
+
"Extract the content of one absolute URL through your self-hosted AgentSearch API and return the backend response as pretty-printed JSON text (a non-JSON body is wrapped as {raw: text}).",
|
|
38
38
|
"Use this only when you already have the page URL and need its body; to find pages from a query, use agentsearch_web_search instead; if the page is a JavaScript app whose content only appears after scripts run, use agentsearch_render.",
|
|
39
|
-
"
|
|
39
|
+
"Requires AGENTSEARCH_BASE_URL (there is no default). POSTs {AGENTSEARCH_BASE_URL}/v1/extract.",
|
|
40
40
|
"Read-only HTTP POST: not destructive, but it fetches through AgentSearch and can hit network or backend rate limits.",
|
|
41
|
-
"When AGENTSEARCH_API_KEY is set it is sent as a Bearer token, and HTTP 401 is retried once without the key;
|
|
41
|
+
"When AGENTSEARCH_API_KEY is set it is sent as a Bearer token, and HTTP 401 is retried once without the key; any HTTP failure includes the status and a truncated body.",
|
|
42
42
|
'formats, when provided, is forwarded unchanged (for example "markdown" or "text") and is not limited to an enum; max_chars, when set, is a positive integer cap sent to the API rather than applied by this server.',
|
|
43
43
|
].join(" ");
|
|
44
44
|
export function registerSearchTools(server) {
|
|
@@ -54,7 +54,7 @@ export function registerSearchTools(server) {
|
|
|
54
54
|
.number()
|
|
55
55
|
.int()
|
|
56
56
|
.optional()
|
|
57
|
-
.describe("How many hits to request (1–
|
|
57
|
+
.describe("How many hits to request (1–5, default 5). Values outside that range are clamped."),
|
|
58
58
|
},
|
|
59
59
|
}, async ({ query, max_results }) => {
|
|
60
60
|
try {
|
package/dist/tools/search.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/tools/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,SAAS,EACT,WAAW,GACZ,MAAM,cAAc,CAAC;AAEtB,MAAM,UAAU,YAAY,CAAC,IAAa;IACxC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAY;IAIvC,IAAI,IAAY,CAAC;IACjB,IAAI,GAAG,YAAY,oBAAoB,EAAE,CAAC;QACxC,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC;IACrB,CAAC;SAAM,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;QAChC,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC;IACrB,CAAC;SAAM,CAAC;QACN,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IACD,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QACjC,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC;AAED,MAAM,sBAAsB,GAAG;IAC7B,
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/tools/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,SAAS,EACT,WAAW,GACZ,MAAM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AE,SAAS,EAAE,EAAE,EAAE;QACpC,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC;YACzB,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;YACjE,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC;qBACzB;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/manifest.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": "0.3",
|
|
3
3
|
"name": "agentsearch-mcp",
|
|
4
|
-
"display_name": "AgentSearch
|
|
5
|
-
"version": "1.1.
|
|
6
|
-
"description": "MCP server for AgentSearch web search, page extract, and JavaScript page rendering in headless Chromium
|
|
7
|
-
"long_description": "Stdio MCP server
|
|
4
|
+
"display_name": "AgentSearch (agentsearchhq.com)",
|
|
5
|
+
"version": "1.1.1",
|
|
6
|
+
"description": "MCP server for a self-hosted AgentSearch API: web search, page extract, and JavaScript page rendering in headless Chromium.",
|
|
7
|
+
"long_description": "Stdio MCP server for people running their own AgentSearch-compatible API. It calls web search, URL extract, and Web Render (headless Chromium for JavaScript-heavy pages, returning title plus rendered markdown, text, HTML, links, and an optional screenshot). AGENTSEARCH_BASE_URL is required. AGENTSEARCH_API_KEY is optional.",
|
|
8
8
|
"author": {
|
|
9
9
|
"name": "AgentSearch",
|
|
10
10
|
"url": "https://github.com/agentsearchhq-coder"
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
"mcp",
|
|
22
22
|
"agentsearch",
|
|
23
23
|
"web-search",
|
|
24
|
-
"pocket-network",
|
|
25
24
|
"render",
|
|
26
25
|
"headless-browser",
|
|
27
26
|
"javascript-rendering"
|
|
@@ -45,7 +44,6 @@
|
|
|
45
44
|
"${__dirname}/dist/index.js"
|
|
46
45
|
],
|
|
47
46
|
"env": {
|
|
48
|
-
"AGENTSEARCH_MODE": "${user_config.AGENTSEARCH_MODE}",
|
|
49
47
|
"AGENTSEARCH_BASE_URL": "${user_config.AGENTSEARCH_BASE_URL}",
|
|
50
48
|
"AGENTSEARCH_API_KEY": "${user_config.AGENTSEARCH_API_KEY}"
|
|
51
49
|
}
|
|
@@ -54,36 +52,28 @@
|
|
|
54
52
|
"tools": [
|
|
55
53
|
{
|
|
56
54
|
"name": "agentsearch_web_search",
|
|
57
|
-
"description": "Search the web via
|
|
55
|
+
"description": "Search the web via your self-hosted AgentSearch API and return JSON text. Use extract when you already have a URL. Read-only."
|
|
58
56
|
},
|
|
59
57
|
{
|
|
60
58
|
"name": "agentsearch_extract",
|
|
61
|
-
"description": "Extract one page from a URL
|
|
59
|
+
"description": "Extract one page from a URL. Use web search to find URLs. Read-only; returns JSON text."
|
|
62
60
|
},
|
|
63
61
|
{
|
|
64
62
|
"name": "agentsearch_render",
|
|
65
|
-
"description": "Render one URL in headless Chromium
|
|
63
|
+
"description": "Render one URL in headless Chromium and return title plus rendered markdown/text/HTML/links as JSON text. Use for JavaScript-heavy pages where extract comes back empty; prefer extract for static pages. Read-only."
|
|
66
64
|
}
|
|
67
65
|
],
|
|
68
66
|
"user_config": {
|
|
69
|
-
"AGENTSEARCH_MODE": {
|
|
70
|
-
"type": "string",
|
|
71
|
-
"title": "AgentSearch mode",
|
|
72
|
-
"description": "direct (local or self-hosted API) or portal (Pocket Network). Default direct.",
|
|
73
|
-
"default": "direct",
|
|
74
|
-
"required": false
|
|
75
|
-
},
|
|
76
67
|
"AGENTSEARCH_BASE_URL": {
|
|
77
68
|
"type": "string",
|
|
78
69
|
"title": "AgentSearch base URL",
|
|
79
|
-
"description": "
|
|
80
|
-
"
|
|
81
|
-
"required": false
|
|
70
|
+
"description": "Required base URL of your self-hosted AgentSearch API, without a trailing slash.",
|
|
71
|
+
"required": true
|
|
82
72
|
},
|
|
83
73
|
"AGENTSEARCH_API_KEY": {
|
|
84
74
|
"type": "string",
|
|
85
75
|
"title": "AgentSearch API key",
|
|
86
|
-
"description": "Optional Bearer token
|
|
76
|
+
"description": "Optional Bearer token. Leave blank if the API does not require a key.",
|
|
87
77
|
"sensitive": true,
|
|
88
78
|
"required": false
|
|
89
79
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentsearchhq/agentsearch-mcp",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"mcpName": "io.github.agentsearchhq-coder/agentsearch-mcp",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
|
-
"description": "MCP server for AgentSearch web search, page extract and JavaScript rendering
|
|
8
|
+
"description": "MCP server for a self-hosted AgentSearch API: web search, page extract, and JavaScript page rendering",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"main": "dist/index.js",
|
|
11
11
|
"bin": {
|
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
"model-context-protocol",
|
|
39
39
|
"agentsearch",
|
|
40
40
|
"web-search",
|
|
41
|
-
"pocket-network",
|
|
42
41
|
"render",
|
|
43
42
|
"headless-browser",
|
|
44
43
|
"javascript-rendering"
|
package/server.json
CHANGED
|
@@ -1,36 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
3
|
"name": "io.github.agentsearchhq-coder/agentsearch-mcp",
|
|
4
|
-
"
|
|
4
|
+
"title": "AgentSearch (agentsearchhq.com)",
|
|
5
|
+
"description": "AgentSearch web search, page extract and JS page render for agents. Self-hosted API via stdio.",
|
|
6
|
+
"websiteUrl": "https://agentsearchhq.com/?utm_source=mcp-registry&utm_medium=directory&utm_campaign=listing",
|
|
5
7
|
"repository": {
|
|
6
8
|
"url": "https://github.com/agentsearchhq-coder/agentsearch-mcp",
|
|
7
9
|
"source": "github"
|
|
8
10
|
},
|
|
9
|
-
"version": "1.1.
|
|
11
|
+
"version": "1.1.1",
|
|
10
12
|
"packages": [
|
|
11
13
|
{
|
|
12
14
|
"registryType": "npm",
|
|
13
15
|
"identifier": "@agentsearchhq/agentsearch-mcp",
|
|
14
|
-
"version": "1.1.
|
|
16
|
+
"version": "1.1.1",
|
|
15
17
|
"transport": {
|
|
16
18
|
"type": "stdio"
|
|
17
19
|
},
|
|
18
20
|
"environmentVariables": [
|
|
19
|
-
{
|
|
20
|
-
"name": "AGENTSEARCH_MODE",
|
|
21
|
-
"description": "direct | portal (default direct)",
|
|
22
|
-
"isRequired": false,
|
|
23
|
-
"format": "string"
|
|
24
|
-
},
|
|
25
21
|
{
|
|
26
22
|
"name": "AGENTSEARCH_BASE_URL",
|
|
27
|
-
"description": "Base URL
|
|
28
|
-
"isRequired":
|
|
23
|
+
"description": "Base URL of your AgentSearch API deployment (no trailing slash)",
|
|
24
|
+
"isRequired": true,
|
|
29
25
|
"format": "string"
|
|
30
26
|
},
|
|
31
27
|
{
|
|
32
28
|
"name": "AGENTSEARCH_API_KEY",
|
|
33
|
-
"description": "Optional Bearer token for
|
|
29
|
+
"description": "Optional Bearer token for your AgentSearch API",
|
|
34
30
|
"isRequired": false,
|
|
35
31
|
"isSecret": true,
|
|
36
32
|
"format": "string"
|
package/smithery.yaml
CHANGED
|
@@ -1,28 +1,23 @@
|
|
|
1
|
-
# Smithery
|
|
1
|
+
# Smithery start command for a self-hosted AgentSearch-compatible API.
|
|
2
2
|
startCommand:
|
|
3
3
|
type: stdio
|
|
4
4
|
configSchema:
|
|
5
5
|
type: object
|
|
6
|
+
required:
|
|
7
|
+
- agentsearchBaseUrl
|
|
6
8
|
properties:
|
|
7
|
-
agentsearchMode:
|
|
8
|
-
type: string
|
|
9
|
-
enum: [direct, portal]
|
|
10
|
-
default: direct
|
|
11
|
-
description: direct local API or Pocket portal
|
|
12
9
|
agentsearchBaseUrl:
|
|
13
10
|
type: string
|
|
14
|
-
|
|
15
|
-
description: Base URL for direct mode
|
|
11
|
+
description: Base URL of your self-hosted AgentSearch API (no trailing slash). Required.
|
|
16
12
|
agentsearchApiKey:
|
|
17
13
|
type: string
|
|
18
|
-
description: Optional Bearer token for
|
|
14
|
+
description: Optional Bearer token for your AgentSearch API
|
|
19
15
|
commandFunction: |-
|
|
20
16
|
(config) => ({
|
|
21
17
|
command: 'node',
|
|
22
18
|
args: ['dist/index.js'],
|
|
23
19
|
env: {
|
|
24
|
-
|
|
25
|
-
AGENTSEARCH_BASE_URL: config.agentsearchBaseUrl ?? 'http://127.0.0.1:8000',
|
|
20
|
+
AGENTSEARCH_BASE_URL: config.agentsearchBaseUrl,
|
|
26
21
|
...(config.agentsearchApiKey
|
|
27
22
|
? { AGENTSEARCH_API_KEY: config.agentsearchApiKey }
|
|
28
23
|
: {})
|