search1api-mcp 0.11.0 → 0.13.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 CHANGED
@@ -10,7 +10,7 @@ The official MCP server for [Search1API](https://s1.dev/?utm_source=mcp) — web
10
10
  ## Authentication
11
11
 
12
12
  - OAuth-aware clients can connect to the Remote MCP URL directly, then sign in and approve access in the browser.
13
- - Existing integrations can continue to use an API key from the [Search1API dashboard](https://dashboard.search1api.com).
13
+ - Existing integrations can continue to use an API key from the [Search1API dashboard](https://app.s1.dev).
14
14
  - Every MCP request — including tool discovery (`initialize`, `tools/list`) — requires a credential. Unauthenticated requests draw the OAuth challenge, which is how clients trigger sign-in; pre-connect inspection is served by the static [server card](https://mcp.search1api.com/.well-known/mcp/server-card.json) instead.
15
15
 
16
16
  ## Quick Start (Remote MCP)
@@ -153,6 +153,8 @@ If you prefer to run the server locally, use Node.js 20 or newer with npx — no
153
153
  }
154
154
  ```
155
155
 
156
+ To send requests through another Search1API-compatible address, such as a New API gateway with the Search1API plugin, set `SEARCH1API_API_URL` to that base URL (for example `https://your-gateway.example.com/search1api`) and `SEARCH1API_KEY` to the key that address accepts.
157
+
156
158
  For self-hosted HTTP deployments behind a proxy, add any internal hostnames
157
159
  that reach the Node.js process to the comma-separated `MCP_ALLOWED_HOSTS`
158
160
  environment variable. `mcp.search1api.com` and localhost addresses are allowed
@@ -233,6 +235,15 @@ Find local businesses and places on Google Maps. Returns one page of up to 20 pl
233
235
  | `page` | No | 1 | Google Maps page, 1-6; each page is a separate call |
234
236
  | `max_results` | No | 20 | Places to return from the page (1-20); fewer places do not lower the price |
235
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
+
236
247
  ### deepcrawl
237
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.
238
249
 
@@ -261,6 +272,7 @@ Report a wrong, empty or incomplete result, an error you could not resolve, docu
261
272
  ## Version History
262
273
 
263
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)
264
276
  - v0.10.0: New `maps` tool for Google Maps place search (3 credits per page of up to 20 places)
265
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`
266
278
 
package/build/config.js CHANGED
@@ -33,8 +33,12 @@ else {
33
33
  log('API key located successfully.');
34
34
  }
35
35
  // API configuration
36
+ // SEARCH1API_API_URL points the tools at another Search1API-compatible base
37
+ // URL, such as a New API gateway with the Search1API plugin
38
+ // (https://your-gateway.example.com/search1api). The remote server reads the
39
+ // same variable.
36
40
  export const API_CONFIG = {
37
- BASE_URL: 'https://api.search1api.com',
41
+ BASE_URL: (process.env.SEARCH1API_API_URL?.trim() || 'https://api.search1api.com').replace(/\/+$/, ''),
38
42
  DEFAULT_QUERY: 'latest news in the world',
39
43
  ENDPOINTS: {
40
44
  SEARCH: '/search',
@@ -44,6 +48,7 @@ export const API_CONFIG = {
44
48
  TRENDING: '/trending',
45
49
  ASK: '/ask',
46
50
  MAPS: '/maps',
51
+ DATASET: '/dataset',
47
52
  DEEPCRAWL: '/deepcrawl',
48
53
  DEEPCRAWL_STATUS: '/deepcrawl/status'
49
54
  }
package/build/http.js CHANGED
@@ -46,41 +46,71 @@ export async function validateCredential(credential) {
46
46
  }
47
47
  return { credential, principal };
48
48
  }
49
- // A rejected credential stays rejected for this long before it is checked
50
- // again. Clients holding a dead token keep retrying (one ping every few
51
- // seconds, indefinitely), and without the cache each retry costs a /usage
52
- // call that the API counts as a 401. Matches the gateway's own cache of
53
- // failed token validation.
49
+ // How long a validation result is reused before the credential is checked
50
+ // again. Every MCP exchange carries the credential, and connected clients keep
51
+ // exchanging even when idle (re-discovery, reconnects, SSE attempts), so
52
+ // checking each one turned the API's /usage into its busiest endpoint: about
53
+ // 33k checks a day against about 1k tool calls. A minute collapses a client's
54
+ // bursts and most of its idle polling.
55
+ //
56
+ // Rejections: clients holding a dead token keep retrying (one ping every few
57
+ // seconds, indefinitely); matches the gateway's own cache of failed tokens.
58
+ // Acceptances: a revoked key, a disabled account or an expired OAuth token
59
+ // can still open a connection for up to this long. Tool calls are unaffected:
60
+ // the API authenticates and bills every one of them itself.
61
+ const ACCEPTED_CREDENTIAL_TTL_MS = 60_000;
54
62
  const REJECTED_CREDENTIAL_TTL_MS = 60_000;
55
- const REJECTED_CREDENTIAL_MAX_ENTRIES = 10_000;
63
+ const CREDENTIAL_CACHE_MAX_ENTRIES = 10_000;
56
64
  /**
57
- * Remember credentials the API rejected so repeat attempts are refused
58
- * locally. Only rejections are cached: accepted credentials are still checked
59
- * on every exchange, and validation outages (thrown errors) are not cached.
65
+ * Reuse validation results for a short time, keyed by the credential's hash.
66
+ *
67
+ * Both outcomes are cached, each for its own TTL. Validation outages (thrown
68
+ * errors) are never cached. Concurrent checks of the same credential share a
69
+ * single upstream call, since a client's exchanges often arrive together.
60
70
  */
61
- export function cacheRejectedCredentials(validator, { ttlMs = REJECTED_CREDENTIAL_TTL_MS, maxEntries = REJECTED_CREDENTIAL_MAX_ENTRIES, now = Date.now, } = {}) {
62
- const rejectedUntil = new Map();
71
+ export function cacheCredentialValidation(validator, { acceptedTtlMs = ACCEPTED_CREDENTIAL_TTL_MS, rejectedTtlMs = REJECTED_CREDENTIAL_TTL_MS, maxEntries = CREDENTIAL_CACHE_MAX_ENTRIES, now = Date.now, } = {}) {
72
+ const cache = new Map();
73
+ const inFlight = new Map();
74
+ const remember = (key, principal) => {
75
+ const ttlMs = principal === null ? rejectedTtlMs : acceptedTtlMs;
76
+ if (ttlMs <= 0) {
77
+ return;
78
+ }
79
+ cache.delete(key);
80
+ // Map keeps insertion order, so the first key is the oldest entry.
81
+ if (cache.size >= maxEntries) {
82
+ const oldest = cache.keys().next().value;
83
+ if (oldest !== undefined) {
84
+ cache.delete(oldest);
85
+ }
86
+ }
87
+ cache.set(key, { expiresAt: now() + ttlMs, principal });
88
+ };
63
89
  return async (credential) => {
64
90
  const key = createHash("sha256").update(credential).digest("hex");
65
- const expiresAt = rejectedUntil.get(key);
66
- if (expiresAt !== undefined) {
67
- if (expiresAt > now()) {
68
- return null;
91
+ const cached = cache.get(key);
92
+ if (cached !== undefined) {
93
+ if (cached.expiresAt > now()) {
94
+ return cached.principal === null
95
+ ? null
96
+ : { credential, principal: cached.principal };
69
97
  }
70
- rejectedUntil.delete(key);
98
+ cache.delete(key);
71
99
  }
72
- const authenticated = await validator(credential);
73
- if (!authenticated) {
74
- // Map keeps insertion order, so the first key is the oldest entry.
75
- if (rejectedUntil.size >= maxEntries) {
76
- const oldest = rejectedUntil.keys().next().value;
77
- if (oldest !== undefined) {
78
- rejectedUntil.delete(oldest);
79
- }
80
- }
81
- rejectedUntil.set(key, now() + ttlMs);
100
+ const pending = inFlight.get(key);
101
+ if (pending) {
102
+ return pending;
82
103
  }
83
- return authenticated;
104
+ const check = validator(credential)
105
+ .then((authenticated) => {
106
+ remember(key, authenticated?.principal ?? null);
107
+ return authenticated;
108
+ })
109
+ .finally(() => {
110
+ inFlight.delete(key);
111
+ });
112
+ inFlight.set(key, check);
113
+ return check;
84
114
  };
85
115
  }
86
116
  /**
@@ -88,8 +118,8 @@ export function cacheRejectedCredentials(validator, { ttlMs = REJECTED_CREDENTIA
88
118
  *
89
119
  * A single v2 handler serves the 2026-07-28 protocol and the SDK's default
90
120
  * stateless 2025 fallback. Every presented credential is validated per
91
- * exchange, so no credential or principal is retained in a server-side MCP
92
- * session. Every exchange requires a credential: the 401 + WWW-Authenticate
121
+ * exchange (through a one-minute result cache), so no credential or principal
122
+ * is retained in a server-side MCP session. Every exchange requires a credential: the 401 + WWW-Authenticate
93
123
  * challenge on the first unauthenticated request is what spec-compliant
94
124
  * clients treat as the trigger to start the OAuth flow, and serving
95
125
  * discovery anonymously would leave clients that equate "tools listed" with
@@ -97,7 +127,7 @@ export function cacheRejectedCredentials(validator, { ttlMs = REJECTED_CREDENTIA
97
127
  */
98
128
  export function createHttpApp(options = {}) {
99
129
  const app = express();
100
- const credentialValidator = cacheRejectedCredentials(options.validateCredential ?? validateCredential);
130
+ const credentialValidator = cacheCredentialValidation(options.validateCredential ?? validateCredential);
101
131
  const authorizationServer = normalizeAuthorizationServer(options.authorizationServer ??
102
132
  process.env.OAUTH_AUTHORIZATION_SERVER ??
103
133
  DEFAULT_AUTHORIZATION_SERVER);
package/build/server.js CHANGED
@@ -41,7 +41,7 @@ export function createMcpServer(credential) {
41
41
  icons: SERVER_ICONS,
42
42
  websiteUrl: "https://s1.dev",
43
43
  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." });
44
+ }, { 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
45
  for (const tool of ALL_TOOLS) {
46
46
  const inputSchema = fromJsonSchema(tool.inputSchema);
47
47
  const outputSchema = tool.outputSchema
@@ -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
+ }
@@ -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:
@@ -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.11.0",
3
+ "version": "0.13.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.11.0",
19
+ "version": "0.13.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.11.0",
30
+ "version": "0.13.0",
31
31
  "transport": {
32
32
  "type": "stdio"
33
33
  },