search1api-mcp 0.12.0 → 0.14.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/README.md +10 -0
- package/build/api.js +2 -0
- package/build/client-channel.js +20 -0
- package/build/config.js +1 -0
- package/build/http.js +8 -2
- package/build/server.js +10 -3
- package/build/tools/dataset.js +62 -0
- package/build/tools/handlers.js +4 -1
- package/build/tools/index.js +51 -0
- package/build/types.js +18 -0
- package/package.json +1 -1
- package/server.json +2 -2
package/README.md
CHANGED
|
@@ -235,6 +235,15 @@ Find local businesses and places on Google Maps. Returns one page of up to 20 pl
|
|
|
235
235
|
| `page` | No | 1 | Google Maps page, 1-6; each page is a separate call |
|
|
236
236
|
| `max_results` | No | 20 | Places to return from the page (1-20); fewer places do not lower the price |
|
|
237
237
|
|
|
238
|
+
### query_dataset
|
|
239
|
+
Answer a question from a curated dataset of facts collected from many sources and cross-checked, instead of searching the open web. The first dataset is `gta6`, covering GTA 6 (Grand Theft Auto VI) gameplay. Each fact is a citable result: `title` is the fact, `url` its best source, and `metadata` holds its relevance, confidence, how many independent sources state it, whether sources disagree (with the competing claims) and all source links. When `found` is false the dataset has no answer. Costs 1 credit only when `found` is true.
|
|
240
|
+
|
|
241
|
+
| Parameter | Required | Default | Description |
|
|
242
|
+
|-----------|----------|---------|-------------|
|
|
243
|
+
| `dataset` | Yes | - | Dataset to query: `gta6` |
|
|
244
|
+
| `query` | Yes | - | The question in natural language, up to 500 characters; other languages are translated before matching |
|
|
245
|
+
| `max_results` | No | 5 | Facts to return (1-10) |
|
|
246
|
+
|
|
238
247
|
### deepcrawl
|
|
239
248
|
Read many pages of one site in a single task, such as a documentation section. Finds the site's URLs through its sitemap, keeps those that match the path rules, and returns up to `max_pages` pages as citable results: `title`, `url`, and the page's Markdown in `text`. The result also carries `stats` (discovered, matched, skipped, crawled, failed), `failed` (URLs that could not be read, with the reason), the API `message`, and `result_url`, a JSON file with every page in full. Costs 20 credits per started task, however many pages it reads.
|
|
240
249
|
|
|
@@ -263,6 +272,7 @@ Report a wrong, empty or incomplete result, an error you could not resolve, docu
|
|
|
263
272
|
## Version History
|
|
264
273
|
|
|
265
274
|
- v0.11.0: New `deepcrawl` tool to read up to 50 pages of one site in a single task (20 credits per task; checking a running task is free)
|
|
275
|
+
- v0.13.0: New `query_dataset` tool that answers from verified fact datasets, starting with GTA 6 gameplay (1 credit per answered question)
|
|
266
276
|
- v0.10.0: New `maps` tool for Google Maps place search (3 credits per page of up to 20 places)
|
|
267
277
|
- v0.7.0: New `ask` tool for agentic search. `search` adds the `bingcn`, `yandex`, and `grokipedia` engines and a `page` parameter; `search` and `news` accept `time_range: "week"` and pass `published_date`, GitHub, and Hacker News fields through in result `metadata`
|
|
268
278
|
|
package/build/api.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { API_KEY, API_CONFIG } from './config.js';
|
|
2
2
|
import { log } from './utils.js';
|
|
3
|
+
import { clientChannelHeaders } from './client-channel.js';
|
|
3
4
|
/**
|
|
4
5
|
* A non-2xx answer from the API. `status` and `body` let a caller tell, for
|
|
5
6
|
* example, a failed deepcrawl task (a task payload sent with HTTP 500) from
|
|
@@ -51,6 +52,7 @@ async function request(method, endpoint, data, apiKey) {
|
|
|
51
52
|
method,
|
|
52
53
|
headers: {
|
|
53
54
|
'Authorization': `Bearer ${key}`,
|
|
55
|
+
...clientChannelHeaders(),
|
|
54
56
|
...(method === 'POST' && { 'Content-Type': 'application/json' }),
|
|
55
57
|
},
|
|
56
58
|
...(method === 'POST' && { body: JSON.stringify(data) }),
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { PACKAGE_VERSION } from "./version.js";
|
|
3
|
+
const current = new AsyncLocalStorage();
|
|
4
|
+
export function withClientChannel(channel, run) {
|
|
5
|
+
return current.run(channel, run);
|
|
6
|
+
}
|
|
7
|
+
// Printable ASCII only, so the value is always a valid header.
|
|
8
|
+
function headerValue(value) {
|
|
9
|
+
return value.replace(/[^\x20-\x7e]/g, "").trim().slice(0, 100);
|
|
10
|
+
}
|
|
11
|
+
export function clientChannelHeaders() {
|
|
12
|
+
const channel = current.getStore();
|
|
13
|
+
if (!channel)
|
|
14
|
+
return {};
|
|
15
|
+
const app = channel.app ? headerValue(channel.app) : "";
|
|
16
|
+
return {
|
|
17
|
+
"X-Search1API-Client": `${channel.transport}/${PACKAGE_VERSION}`,
|
|
18
|
+
...(app ? { "X-Search1API-Client-App": app } : {}),
|
|
19
|
+
};
|
|
20
|
+
}
|
package/build/config.js
CHANGED
package/build/http.js
CHANGED
|
@@ -24,7 +24,10 @@ const MCP_RESOURCE_METADATA = "https://mcp.search1api.com/.well-known/oauth-prot
|
|
|
24
24
|
*/
|
|
25
25
|
export async function validateCredential(credential) {
|
|
26
26
|
const response = await fetch(`${API_BASE_URL}/usage`, {
|
|
27
|
-
headers: {
|
|
27
|
+
headers: {
|
|
28
|
+
Authorization: `Bearer ${credential}`,
|
|
29
|
+
"X-Search1API-Client": `mcp-remote/${PACKAGE_VERSION}`,
|
|
30
|
+
},
|
|
28
31
|
});
|
|
29
32
|
if (response.status === 401 || response.status === 403) {
|
|
30
33
|
return null;
|
|
@@ -135,7 +138,10 @@ export function createHttpApp(options = {}) {
|
|
|
135
138
|
const allowedOriginHostnames = options.allowedOriginHostnames ?? configuredAllowedOriginHostnames();
|
|
136
139
|
const validateHost = hostHeaderValidation(allowedHostnames);
|
|
137
140
|
const validateOrigin = originValidation(allowedOriginHostnames);
|
|
138
|
-
const mcpHandler = createMcpHandler(({ authInfo }) => createMcpServer(toolCredential(authInfo)
|
|
141
|
+
const mcpHandler = createMcpHandler(({ authInfo, requestInfo }) => createMcpServer(toolCredential(authInfo), {
|
|
142
|
+
transport: "mcp-remote",
|
|
143
|
+
userAgent: requestInfo?.headers.get("user-agent") ?? undefined,
|
|
144
|
+
}), {
|
|
139
145
|
legacy: "stateless",
|
|
140
146
|
onerror: (error) => log("MCP handler error:", error),
|
|
141
147
|
});
|
package/build/server.js
CHANGED
|
@@ -8,6 +8,7 @@ import { handleToolCall } from "./tools/handlers.js";
|
|
|
8
8
|
import { ALL_TOOLS } from "./tools/index.js";
|
|
9
9
|
import { MCP_APP_MIME_TYPE, SEARCH_UI_META, SEARCH_UI_URI, SEARCH_UI_COMPAT_URIS, readSearchUi, } from "./ui.js";
|
|
10
10
|
import { formatError, log } from "./utils.js";
|
|
11
|
+
import { withClientChannel } from "./client-channel.js";
|
|
11
12
|
import { PACKAGE_VERSION } from "./version.js";
|
|
12
13
|
import { SERVER_DESCRIPTION, SERVER_ICONS } from "./branding.js";
|
|
13
14
|
/** JSON-RPC error code this server uses for a missing or rejected credential. */
|
|
@@ -32,7 +33,9 @@ export function unauthenticatedCredential(message) {
|
|
|
32
33
|
* once per stateless legacy HTTP request, or once per stdio connection.
|
|
33
34
|
* All transports expose the same data tools and optional rendering tool.
|
|
34
35
|
*/
|
|
35
|
-
export function createMcpServer(credential
|
|
36
|
+
export function createMcpServer(credential, channel = {
|
|
37
|
+
transport: "mcp-local",
|
|
38
|
+
}) {
|
|
36
39
|
log("Creating Search1API MCP server");
|
|
37
40
|
const server = new McpServer({
|
|
38
41
|
name: "search1api",
|
|
@@ -41,7 +44,7 @@ export function createMcpServer(credential) {
|
|
|
41
44
|
icons: SERVER_ICONS,
|
|
42
45
|
websiteUrl: "https://s1.dev",
|
|
43
46
|
description: SERVER_DESCRIPTION,
|
|
44
|
-
}, { instructions: "Use search, news, ask, maps, crawl, deepcrawl, sitemap and trending to retrieve data. Call render_results with selected existing results only when the user wants to browse sources or a visual list helps. Rendering never repeats a search or consumes search credits; unsupported UI clients receive a readable text list." });
|
|
47
|
+
}, { instructions: "Use search, news, ask, maps, query_dataset, crawl, deepcrawl, sitemap and trending to retrieve data; query_dataset answers questions covered by a verified dataset (GTA 6 gameplay). Call render_results with selected existing results only when the user wants to browse sources or a visual list helps. Rendering never repeats a search or consumes search credits; unsupported UI clients receive a readable text list." });
|
|
45
48
|
for (const tool of ALL_TOOLS) {
|
|
46
49
|
const inputSchema = fromJsonSchema(tool.inputSchema);
|
|
47
50
|
const outputSchema = tool.outputSchema
|
|
@@ -58,7 +61,11 @@ export function createMcpServer(credential) {
|
|
|
58
61
|
try {
|
|
59
62
|
const bearerCredential = typeof credential === "function" ? credential() : credential;
|
|
60
63
|
log(`Tool call received: ${tool.name}`);
|
|
61
|
-
|
|
64
|
+
// clientInfo is per request on the 2026 era and per connection on
|
|
65
|
+
// stdio; a stateless legacy HTTP call has neither, so the MCP
|
|
66
|
+
// request's User-Agent stands in.
|
|
67
|
+
const app = server.server.getClientVersion()?.name ?? channel.userAgent;
|
|
68
|
+
return await withClientChannel({ transport: channel.transport, app }, () => handleToolCall(tool.name, args, bearerCredential));
|
|
62
69
|
}
|
|
63
70
|
catch (error) {
|
|
64
71
|
throw normalizeProtocolError(`handling tool call ${tool.name}`, error);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { isValidDatasetQueryArgs, } from '../types.js';
|
|
2
|
+
import { makeRequest } from '../api.js';
|
|
3
|
+
import { formatError } from '../utils.js';
|
|
4
|
+
import { API_CONFIG } from '../config.js';
|
|
5
|
+
import { INVALID_PARAMS, ProtocolError, } from "@modelcontextprotocol/server";
|
|
6
|
+
/**
|
|
7
|
+
* Implementation of the query_dataset tool: POST /dataset, with each fact
|
|
8
|
+
* returned as a citable result (title = fact, url = its best source).
|
|
9
|
+
*/
|
|
10
|
+
export async function handleQueryDataset(args, apiKey) {
|
|
11
|
+
if (!isValidDatasetQueryArgs(args)) {
|
|
12
|
+
throw new ProtocolError(INVALID_PARAMS, "Invalid query_dataset arguments");
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const response = await makeRequest(API_CONFIG.ENDPOINTS.DATASET, {
|
|
16
|
+
dataset: args.dataset,
|
|
17
|
+
query: args.query,
|
|
18
|
+
...(args.max_results !== undefined && { max_results: args.max_results }),
|
|
19
|
+
}, apiKey);
|
|
20
|
+
const results = response.results.map((fact) => ({
|
|
21
|
+
id: fact.id,
|
|
22
|
+
title: fact.fact,
|
|
23
|
+
...(fact.sources[0] && { url: fact.sources[0].url }),
|
|
24
|
+
text: fact.contested && fact.conflicting_claims.length > 0
|
|
25
|
+
? `${fact.fact} (contested; other sources say: ${fact.conflicting_claims.join(" / ")})`
|
|
26
|
+
: fact.fact,
|
|
27
|
+
metadata: {
|
|
28
|
+
question: fact.question,
|
|
29
|
+
relevance: fact.relevance,
|
|
30
|
+
confidence: fact.confidence,
|
|
31
|
+
corroborated_by: fact.corroborated_by,
|
|
32
|
+
contested: fact.contested,
|
|
33
|
+
conflicting_claims: fact.conflicting_claims,
|
|
34
|
+
sources: fact.sources,
|
|
35
|
+
attributes: fact.attributes,
|
|
36
|
+
updated_at: fact.updated_at,
|
|
37
|
+
},
|
|
38
|
+
}));
|
|
39
|
+
const structuredContent = {
|
|
40
|
+
dataset: response.dataset,
|
|
41
|
+
found: response.found,
|
|
42
|
+
...(response.query_en && { query_en: response.query_en }),
|
|
43
|
+
results,
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
structuredContent,
|
|
47
|
+
content: [{
|
|
48
|
+
type: "text",
|
|
49
|
+
text: JSON.stringify(structuredContent)
|
|
50
|
+
}]
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
return {
|
|
55
|
+
content: [{
|
|
56
|
+
type: "text",
|
|
57
|
+
text: `Dataset API error: ${formatError(error)}`
|
|
58
|
+
}],
|
|
59
|
+
isError: true
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
package/build/tools/handlers.js
CHANGED
|
@@ -8,8 +8,9 @@ import { handleTrending } from "./trending.js";
|
|
|
8
8
|
import { handleRenderResults } from "./render-results.js";
|
|
9
9
|
import { handleAsk } from "./ask.js";
|
|
10
10
|
import { handleMaps } from "./maps.js";
|
|
11
|
+
import { handleQueryDataset } from "./dataset.js";
|
|
11
12
|
import { handleDeepcrawl } from "./deepcrawl.js";
|
|
12
|
-
import { SEARCH_TOOL, CRAWL_TOOL, SITEMAP_TOOL, NEWS_TOOL, TRENDING_TOOL, ASK_TOOL, MAPS_TOOL, DEEPCRAWL_TOOL, RENDER_RESULTS_TOOL, } from "./index.js";
|
|
13
|
+
import { SEARCH_TOOL, CRAWL_TOOL, SITEMAP_TOOL, NEWS_TOOL, TRENDING_TOOL, ASK_TOOL, MAPS_TOOL, QUERY_DATASET_TOOL, DEEPCRAWL_TOOL, RENDER_RESULTS_TOOL, } from "./index.js";
|
|
13
14
|
/**
|
|
14
15
|
* Dispatch request based on tool name
|
|
15
16
|
* @param toolName Name of the tool
|
|
@@ -34,6 +35,8 @@ export async function handleToolCall(toolName, args, apiKey) {
|
|
|
34
35
|
return await handleAsk(args, apiKey);
|
|
35
36
|
case MAPS_TOOL.name:
|
|
36
37
|
return await handleMaps(args, apiKey);
|
|
38
|
+
case QUERY_DATASET_TOOL.name:
|
|
39
|
+
return await handleQueryDataset(args, apiKey);
|
|
37
40
|
case DEEPCRAWL_TOOL.name:
|
|
38
41
|
return await handleDeepcrawl(args, apiKey);
|
|
39
42
|
case RENDER_RESULTS_TOOL.name:
|
package/build/tools/index.js
CHANGED
|
@@ -427,6 +427,56 @@ export const MAPS_TOOL = {
|
|
|
427
427
|
required: ["results"],
|
|
428
428
|
},
|
|
429
429
|
};
|
|
430
|
+
// Verified dataset tool definition
|
|
431
|
+
export const QUERY_DATASET_TOOL = {
|
|
432
|
+
name: "query_dataset",
|
|
433
|
+
title: "Answer from a verified fact dataset",
|
|
434
|
+
description: "Answer a question from a curated dataset of facts that Search1API has collected from many sources and cross-checked, instead of searching the open web. Use it when the question falls in a listed dataset: gta6 covers GTA 6 (Grand Theft Auto VI) gameplay, such as missions, vehicles, weapons, money, collectibles, properties, controls, settings and performance, and bugs and fixes. Each result is one short fact with its relevance, a confidence score, how many independent sources state it, whether sources disagree (with the competing claims), and source links to cite. When found is false the dataset has no answer: say so or use search, and do not present the closest facts as the answer. Costs 1 credit only when found is true.",
|
|
435
|
+
...AUTHENTICATED_READ_ONLY_WEB,
|
|
436
|
+
inputSchema: {
|
|
437
|
+
type: "object",
|
|
438
|
+
properties: {
|
|
439
|
+
dataset: {
|
|
440
|
+
type: "string",
|
|
441
|
+
enum: ["gta6"],
|
|
442
|
+
description: "Dataset to query: gta6 for GTA 6 gameplay",
|
|
443
|
+
},
|
|
444
|
+
query: {
|
|
445
|
+
type: "string",
|
|
446
|
+
maxLength: 500,
|
|
447
|
+
description: "The player's question in natural language, with any platform or version in the question itself; non-English questions are translated before matching",
|
|
448
|
+
},
|
|
449
|
+
max_results: {
|
|
450
|
+
type: "integer",
|
|
451
|
+
minimum: 1,
|
|
452
|
+
maximum: 10,
|
|
453
|
+
description: "Maximum facts to return",
|
|
454
|
+
default: 5,
|
|
455
|
+
},
|
|
456
|
+
},
|
|
457
|
+
required: ["dataset", "query"],
|
|
458
|
+
},
|
|
459
|
+
outputSchema: {
|
|
460
|
+
type: "object",
|
|
461
|
+
properties: {
|
|
462
|
+
dataset: { type: "string" },
|
|
463
|
+
found: {
|
|
464
|
+
type: "boolean",
|
|
465
|
+
description: "Whether the best fact answers the question; when false the results are only the closest facts",
|
|
466
|
+
},
|
|
467
|
+
query_en: {
|
|
468
|
+
type: "string",
|
|
469
|
+
description: "English translation used for matching, for non-English questions",
|
|
470
|
+
},
|
|
471
|
+
results: {
|
|
472
|
+
type: "array",
|
|
473
|
+
description: "Facts ordered by relevance. title is the fact, url its best source, and metadata holds relevance, confidence, corroborated_by, contested, conflicting_claims, the answered question, all sources and dataset attributes",
|
|
474
|
+
items: CITABLE_RESULT_SCHEMA,
|
|
475
|
+
},
|
|
476
|
+
},
|
|
477
|
+
required: ["dataset", "found", "results"],
|
|
478
|
+
},
|
|
479
|
+
};
|
|
430
480
|
const DEEPCRAWL_PATH_RULES = {
|
|
431
481
|
type: "array",
|
|
432
482
|
maxItems: 20,
|
|
@@ -563,6 +613,7 @@ export const ALL_TOOLS = [
|
|
|
563
613
|
TRENDING_TOOL,
|
|
564
614
|
ASK_TOOL,
|
|
565
615
|
MAPS_TOOL,
|
|
616
|
+
QUERY_DATASET_TOOL,
|
|
566
617
|
DEEPCRAWL_TOOL,
|
|
567
618
|
RENDER_RESULTS_TOOL,
|
|
568
619
|
];
|
package/build/types.js
CHANGED
|
@@ -226,3 +226,21 @@ export function isValidDeepcrawlArgs(args) {
|
|
|
226
226
|
}
|
|
227
227
|
return true;
|
|
228
228
|
}
|
|
229
|
+
/** Datasets POST /dataset serves; extend together with the tool's enum. */
|
|
230
|
+
export const DATASETS = ['gta6'];
|
|
231
|
+
export function isValidDatasetQueryArgs(args) {
|
|
232
|
+
if (typeof args !== 'object' || args === null) {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
const { dataset, query, max_results } = args;
|
|
236
|
+
if (typeof dataset !== 'string' || !DATASETS.includes(dataset)) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
if (typeof query !== 'string' || query.trim().length === 0 || query.length > 500) {
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
if (max_results !== undefined && (!Number.isInteger(max_results) || max_results < 1 || max_results > 10)) {
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
return true;
|
|
246
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "search1api-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"mcpName": "io.github.superagents-lab/search1api",
|
|
5
5
|
"description": "A Model Context Protocol (MCP) server that provides search and crawl functionality using Search1API",
|
|
6
6
|
"private": false,
|
package/server.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"url": "https://github.com/superagents-lab/search1api-mcp",
|
|
17
17
|
"source": "github"
|
|
18
18
|
},
|
|
19
|
-
"version": "0.
|
|
19
|
+
"version": "0.14.0",
|
|
20
20
|
"remotes": [
|
|
21
21
|
{
|
|
22
22
|
"type": "streamable-http",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
{
|
|
28
28
|
"registryType": "npm",
|
|
29
29
|
"identifier": "search1api-mcp",
|
|
30
|
-
"version": "0.
|
|
30
|
+
"version": "0.14.0",
|
|
31
31
|
"transport": {
|
|
32
32
|
"type": "stdio"
|
|
33
33
|
},
|