search1api-mcp 0.6.0 → 0.7.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
@@ -1,6 +1,6 @@
1
1
  # Search1API MCP Server
2
2
 
3
- [![smithery badge](https://smithery.ai/badge/superagents-lab/search1api-mcp)](https://smithery.ai/servers/superagents-lab/search1api-mcp)
3
+ [![Smithery](https://img.shields.io/badge/Smithery-listed-6C5CE7)](https://smithery.ai/servers/superagents-lab/search1api-mcp)
4
4
  [![Glama](https://img.shields.io/badge/Glama-listed-6C5CE7)](https://glama.ai/mcp/servers/superagents-lab/search1api-mcp)
5
5
 
6
6
  [中文文档](./README_zh.md)
@@ -11,7 +11,7 @@ The official MCP server for [Search1API](https://s1.dev/?utm_source=mcp) — web
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
13
  - Existing integrations can continue to use an API key from the [Search1API dashboard](https://dashboard.search1api.com).
14
- - Tool calls always require a credential. Tool discovery (`initialize`, `tools/list`) is answered without one, so clients and directories can inspect the server before signing in.
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)
17
17
 
@@ -146,22 +146,23 @@ omit `Origin` and do not require an entry.
146
146
  ## Tools
147
147
 
148
148
  ### search
149
- Search the web using Search1API. Results include a citable
150
- `id`/`title`/`url` structure. Pass a result URL to `crawl` when you need the
151
- full page.
149
+ Search the web using Search1API. Results include a citable `id`/`title`/`url` structure. Pass a result URL to `crawl` when you need the full page.
152
150
 
153
151
  | Parameter | Required | Default | Description |
154
152
  |-----------|----------|---------|-------------|
155
153
  | `query` | Yes | - | Search query |
156
154
  | `max_results` | No | 10 | Number of results |
157
- | `search_service` | No | google | google, bing, duckduckgo, yahoo, x, reddit, github, youtube, arxiv, wechat, bilibili, imdb, wikipedia |
155
+ | `search_service` | No | google | google, bing, bingcn, duckduckgo, yahoo, yandex, x, reddit, github, youtube, arxiv, wechat, bilibili, imdb, wikipedia, grokipedia |
156
+ | `page` | No | 1 | Results page (1-100); only bing, bingcn, baidu, and grokipedia paginate |
158
157
  | `crawl_results` | No | 0 | Number of top results to crawl for full content; each successful crawl adds 1 credit to the base 1-credit search request |
159
158
  | `include_sites` | No | [] | Sites to include |
160
159
  | `exclude_sites` | No | [] | Sites to exclude |
161
- | `time_range` | No | - | day, month, year |
160
+ | `time_range` | No | - | day, week, month, year |
161
+
162
+ Results carry `published_date` in `metadata` when the engine exposes one; `github` results add `kind`, `stars`, `language`, and `num_comments`.
162
163
 
163
164
  ### news
164
- Search for news articles.
165
+ Search for news articles. `hackernews` results link to the discussion thread and add `story_url`, `points`, and `num_comments` to `metadata`.
165
166
 
166
167
  | Parameter | Required | Default | Description |
167
168
  |-----------|----------|---------|-------------|
@@ -171,7 +172,7 @@ Search for news articles.
171
172
  | `crawl_results` | No | 0 | Number of top results to crawl for full content; each successful crawl adds 1 credit to the base 1-credit news request |
172
173
  | `include_sites` | No | [] | Sites to include |
173
174
  | `exclude_sites` | No | [] | Sites to exclude |
174
- | `time_range` | No | - | day, month, year |
175
+ | `time_range` | No | - | day, week, month, year |
175
176
 
176
177
  ### crawl
177
178
  Extract content from a URL.
@@ -195,8 +196,18 @@ Get trending topics from popular platforms.
195
196
  | `search_service` | Yes | - | github, hackernews |
196
197
  | `max_results` | No | 10 | Number of items |
197
198
 
199
+ ### ask
200
+ Agentic search: describe the need in natural language and Search1API picks up to five engines and a time window, drops off-topic results, and returns at most 10 citable results ranked by relevance. The result also carries `intent` (keywords, engines, and window used) and `errors` (engines that failed while others completed). Costs 5 credits per completed request; use `search` when you already know the engine.
201
+
202
+ | Parameter | Required | Description |
203
+ |-----------|----------|-------------|
204
+ | `query` | Yes | The request in natural language, up to 500 characters |
205
+
198
206
  ## Version History
199
207
 
208
+ - 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`
209
+
210
+ - v0.6.1: Bug fix — MCP discovery (`initialize`, `tools/list`, `resources/*`, `prompts/list`, `server/discover`) requires a credential again. Serving it anonymously made clients that equate "tools listed" with "signed in" show a connected state with no way to trigger the OAuth flow; the 401 challenge now answers every unauthenticated request, restoring OAuth sign-in at connect time. Directory visibility is unchanged via the static server card and registry metadata
200
211
  - v0.6.0: MCP discovery (`initialize`, `tools/list`, `resources/*`, `prompts/list`, `server/discover`) is served without a credential so clients and directories can enumerate tools before signing in; tool calls still require OAuth or an API key. Stdio mode starts without `SEARCH1API_KEY` and serves tool metadata, refusing only at call time. Malformed requests answer as JSON-RPC instead of an HTML error page
201
212
  - v0.5.4: OAuth issuer moved to `clerk.s1.dev` and is configurable with `OAUTH_AUTHORIZATION_SERVER`; MCP server card published at `/.well-known/mcp/server-card.json`; OAuth discovery documents now send cache headers
202
213
  - v0.5.3: OAuth resource and tool metadata no longer require OIDC session scopes; Smithery and Glama registry badges added
package/build/config.js CHANGED
@@ -41,7 +41,8 @@ export const API_CONFIG = {
41
41
  CRAWL: '/crawl',
42
42
  SITEMAP: '/sitemap',
43
43
  NEWS: '/news',
44
- TRENDING: '/trending'
44
+ TRENDING: '/trending',
45
+ ASK: '/ask'
45
46
  }
46
47
  };
47
48
  // Export API key
package/build/http.js CHANGED
@@ -12,27 +12,10 @@ const API_BASE_URL = process.env.SEARCH1API_API_URL || "https://api.search1api.c
12
12
  const DEFAULT_AUTHORIZATION_SERVER = "https://clerk.s1.dev";
13
13
  const OAUTH_DISCOVERY_CACHE_CONTROL = "public, max-age=60, s-maxage=60";
14
14
  const MCP_RESOURCE = "https://mcp.search1api.com/mcp";
15
+ // Public by design: the OpenAI Platform reads it to verify that we own this
16
+ // host before listing the plugin.
17
+ const OPENAI_APPS_CHALLENGE_TOKEN = "edGbvSAg00ELU99x45v2SjrDPJNLa1gPwjuvlflUJnM";
15
18
  const MCP_RESOURCE_METADATA = "https://mcp.search1api.com/.well-known/oauth-protected-resource/mcp";
16
- /**
17
- * JSON-RPC methods that only return static server metadata.
18
- *
19
- * The tool and resource descriptors are already published in the repository
20
- * manifests, the server card, and the MCP registry, so answering them for an
21
- * anonymous caller discloses nothing new and lets directory scanners enumerate
22
- * the server without first completing an OAuth exchange. Every method that
23
- * spends credits or reaches the Search1API backend is deliberately absent.
24
- */
25
- const PUBLIC_MCP_METHODS = new Set([
26
- "initialize",
27
- "notifications/initialized",
28
- "ping",
29
- "server/discover",
30
- "tools/list",
31
- "prompts/list",
32
- "resources/list",
33
- "resources/templates/list",
34
- "resources/read",
35
- ]);
36
19
  /**
37
20
  * Validate both Clerk OAuth tokens and legacy Search1API API keys at the API.
38
21
  */
@@ -66,8 +49,11 @@ export async function validateCredential(credential) {
66
49
  * A single v2 handler serves the 2026-07-28 protocol and the SDK's default
67
50
  * stateless 2025 fallback. Every presented credential is validated per
68
51
  * exchange, so no credential or principal is retained in a server-side MCP
69
- * session. An exchange that presents no credential at all reaches only the
70
- * metadata methods in PUBLIC_MCP_METHODS.
52
+ * session. Every exchange requires a credential: the 401 + WWW-Authenticate
53
+ * challenge on the first unauthenticated request is what spec-compliant
54
+ * clients treat as the trigger to start the OAuth flow, and serving
55
+ * discovery anonymously would leave clients that equate "tools listed" with
56
+ * "signed in" stuck connected but unable to authorize.
71
57
  */
72
58
  export function createHttpApp(options = {}) {
73
59
  const app = express();
@@ -103,14 +89,17 @@ export function createHttpApp(options = {}) {
103
89
  }
104
90
  res.redirect(301, target.toString());
105
91
  });
106
- // /mcp is a transport endpoint whose only anonymous answers are static
107
- // descriptors, so search engines gain nothing from walking this host. Keep
108
- // the OAuth discovery documents reachable for agents.
92
+ // /mcp is a transport endpoint that answers nothing without a credential,
93
+ // so search engines gain nothing from walking this host. Keep the OAuth
94
+ // discovery documents reachable for agents.
109
95
  app.get("/robots.txt", (_req, res) => {
110
96
  res
111
97
  .type("text/plain")
112
98
  .send(["User-agent: *", "Disallow: /", "Allow: /.well-known/", ""].join("\n"));
113
99
  });
100
+ app.get("/.well-known/openai-apps-challenge", (_req, res) => {
101
+ res.type("text/plain").send(OPENAI_APPS_CHALLENGE_TOKEN);
102
+ });
114
103
  // OIDC scopes such as openid and offline_access belong to the client/AS
115
104
  // exchange; this resource does not require any resource-specific scope.
116
105
  const protectedResourceMetadata = {
@@ -129,9 +118,10 @@ export function createHttpApp(options = {}) {
129
118
  .json(protectedResourceMetadata);
130
119
  });
131
120
  // A single static document for directories that read one URL rather than
132
- // speak MCP. /mcp now answers tools/list anonymously too, so this card is a
133
- // convenience rather than the only pre-connection description. It is built
134
- // from ALL_TOOLS, so neither surface can drift from the real tool set.
121
+ // speak MCP. The transport endpoint challenges every unauthenticated
122
+ // request so clients trigger OAuth at connect time, which makes this card
123
+ // the only pre-connection description of the tool set. It is built from
124
+ // ALL_TOOLS, so it cannot drift from the real tool set.
135
125
  app.get("/.well-known/mcp/server-card.json", (_req, res) => {
136
126
  res
137
127
  .set("Cache-Control", OAUTH_DISCOVERY_CACHE_CONTROL)
@@ -139,14 +129,14 @@ export function createHttpApp(options = {}) {
139
129
  .json({
140
130
  name: "Search1API",
141
131
  version: PACKAGE_VERSION,
142
- description: "Remote MCP server for Search1API. Exposes live web search, news, page reading, sitemap discovery, and trending topics as tools for AI agents.",
132
+ description: "Remote MCP server for Search1API. Exposes live web search, agentic search, news, page reading, sitemap discovery, and trending topics as tools for AI agents.",
143
133
  serverUrl: MCP_RESOURCE,
144
134
  tools: ALL_TOOLS.map((tool) => ({
145
135
  name: tool.name,
146
136
  title: tool.title,
147
137
  description: tool.description,
148
138
  inputSchema: tool.inputSchema,
149
- annotations: tool.annotations,
139
+ annotations: { ...tool.annotations, title: tool.title },
150
140
  })),
151
141
  serverInfo: {
152
142
  name: "Search1API",
@@ -182,7 +172,7 @@ export function createHttpApp(options = {}) {
182
172
  });
183
173
  app.use(express.json());
184
174
  app.all("/mcp", async (req, res) => {
185
- const outcome = await authenticateMcpRequest(req, res, credentialValidator, isPublicDiscovery(req));
175
+ const outcome = await authenticateMcpRequest(req, res, credentialValidator);
186
176
  if (outcome.status === "handled") {
187
177
  return;
188
178
  }
@@ -315,10 +305,11 @@ function challenge(res, message, error) {
315
305
  /**
316
306
  * Resolve the credential a tool handler is allowed to spend.
317
307
  *
318
- * Anonymous exchanges only ever reach metadata methods, so no tool handler
319
- * should observe one. Should a future routing change let a call through, fail
320
- * loudly here rather than let makeRequest fall back to the operator's own
321
- * SEARCH1API_KEY and bill an unauthenticated caller to us.
308
+ * Unauthenticated exchanges are answered 401 by authenticateMcpRequest and
309
+ * never reach the MCP handler, so no tool handler should observe one. Should a
310
+ * future routing change let a call through, fail loudly here rather than let
311
+ * makeRequest fall back to the operator's own SEARCH1API_KEY and bill an
312
+ * unauthenticated caller to us.
322
313
  */
323
314
  function toolCredential(authInfo) {
324
315
  if (authInfo?.token) {
@@ -326,48 +317,13 @@ function toolCredential(authInfo) {
326
317
  }
327
318
  return unauthenticatedCredential("Authentication is required to call Search1API tools.");
328
319
  }
329
- /**
330
- * Collect every JSON-RPC method named by one HTTP exchange.
331
- *
332
- * The 2026-07-28 transport routes on the mcp-method header while the body
333
- * repeats the method, and a legacy batch names one per array entry; all of them
334
- * have to be public for the exchange to be. Returns null when any part of the
335
- * request names no method, so an unrecognised shape falls through to the
336
- * authenticated path instead of being mistaken for discovery.
337
- */
338
- function requestedMcpMethods(req) {
339
- const methods = [];
340
- const headerMethod = req.headers["mcp-method"];
341
- if (typeof headerMethod === "string" && headerMethod.trim()) {
342
- methods.push(headerMethod.trim());
343
- }
344
- const entries = Array.isArray(req.body) ? req.body : [req.body];
345
- for (const entry of entries) {
346
- if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
347
- return null;
348
- }
349
- const method = entry.method;
350
- if (typeof method !== "string" || !method) {
351
- return null;
352
- }
353
- methods.push(method);
354
- }
355
- return methods.length > 0 ? methods : null;
356
- }
357
- /** Whether this exchange may be served without any credential at all. */
358
- function isPublicDiscovery(req) {
359
- if (req.method !== "POST") {
360
- return false;
361
- }
362
- const methods = requestedMcpMethods(req);
363
- return (methods !== null && methods.every((method) => PUBLIC_MCP_METHODS.has(method)));
364
- }
365
- async function authenticateMcpRequest(req, res, credentialValidator, allowAnonymous) {
320
+ async function authenticateMcpRequest(req, res, credentialValidator) {
366
321
  const credential = extractCredential(req);
367
322
  if (!credential) {
368
- if (allowAnonymous) {
369
- return { status: "anonymous" };
370
- }
323
+ // The 401 + WWW-Authenticate challenge is the standardized trigger for
324
+ // the client-side OAuth flow; serving any method without a credential
325
+ // would leave clients that treat a successful connect as "signed in"
326
+ // with no way to start authorizing.
371
327
  challenge(res, "Authentication is required. Use OAuth 2.1 discovery or provide a Search1API API key as a Bearer token.");
372
328
  return { status: "handled" };
373
329
  }
package/build/server.js CHANGED
@@ -41,7 +41,7 @@ export function createMcpServer(credential) {
41
41
  description: tool.description,
42
42
  inputSchema,
43
43
  ...(outputSchema ? { outputSchema } : {}),
44
- annotations: tool.annotations,
44
+ annotations: { ...tool.annotations, title: tool.title },
45
45
  _meta: tool._meta,
46
46
  }, async (args) => {
47
47
  try {
@@ -0,0 +1,49 @@
1
+ import { isValidAskArgs } 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 ask tool
8
+ */
9
+ export async function handleAsk(args, apiKey) {
10
+ if (!isValidAskArgs(args)) {
11
+ throw new ProtocolError(INVALID_PARAMS, "Invalid ask arguments");
12
+ }
13
+ try {
14
+ // The endpoint accepts only `query`; the decision model chooses the rest.
15
+ const response = await makeRequest(API_CONFIG.ENDPOINTS.ASK, { query: args.query }, apiKey);
16
+ const results = response.results.map((result) => ({
17
+ id: result.link,
18
+ title: result.title,
19
+ url: result.link,
20
+ text: result.snippet,
21
+ metadata: {
22
+ source: result.source,
23
+ relevance: result.relevance,
24
+ ...(result.published_date ? { published_date: result.published_date } : {}),
25
+ },
26
+ }));
27
+ const structuredContent = {
28
+ intent: response.intent,
29
+ results,
30
+ errors: response.errors ?? [],
31
+ };
32
+ return {
33
+ structuredContent,
34
+ content: [{
35
+ type: "text",
36
+ text: JSON.stringify(structuredContent)
37
+ }]
38
+ };
39
+ }
40
+ catch (error) {
41
+ return {
42
+ content: [{
43
+ type: "text",
44
+ text: `Ask API error: ${formatError(error)}`
45
+ }],
46
+ isError: true
47
+ };
48
+ }
49
+ }
@@ -5,7 +5,8 @@ import { handleCrawl } from "./crawl.js";
5
5
  import { handleSitemap } from "./sitemap.js";
6
6
  import { handleNews } from "./news.js";
7
7
  import { handleTrending } from "./trending.js";
8
- import { SEARCH_TOOL, CRAWL_TOOL, SITEMAP_TOOL, NEWS_TOOL, TRENDING_TOOL, } from "./index.js";
8
+ import { handleAsk } from "./ask.js";
9
+ import { SEARCH_TOOL, CRAWL_TOOL, SITEMAP_TOOL, NEWS_TOOL, TRENDING_TOOL, ASK_TOOL, } from "./index.js";
9
10
  /**
10
11
  * Dispatch request based on tool name
11
12
  * @param toolName Name of the tool
@@ -26,6 +27,8 @@ export async function handleToolCall(toolName, args, apiKey) {
26
27
  return await handleNews(args, apiKey);
27
28
  case TRENDING_TOOL.name:
28
29
  return await handleTrending(args, apiKey);
30
+ case ASK_TOOL.name:
31
+ return await handleAsk(args, apiKey);
29
32
  default:
30
33
  log(`Unknown tool: ${toolName}`);
31
34
  throw new ProtocolError(INVALID_PARAMS, `Unknown tool: ${toolName}`);
@@ -63,7 +63,7 @@ const SEARCH_OUTPUT_SCHEMA = {
63
63
  export const SEARCH_TOOL = {
64
64
  name: "search",
65
65
  title: "Search the web",
66
- description: "Search the live public web when the user needs current information, sources, or research. Returns citable results with id, title, URL, and text. Pass a result URL to crawl to retrieve the full page.",
66
+ description: "Search the live public web when the user needs current information, sources, or research. Returns citable results with id, title, URL, and text. Each result includes a URL that can be read in full.",
67
67
  ...AUTHENTICATED_READ_ONLY_WEB,
68
68
  inputSchema: {
69
69
  type: "object",
@@ -83,7 +83,14 @@ export const SEARCH_TOOL = {
83
83
  type: "string",
84
84
  description: "Search engine to use; choose one only when it matches the user's source intent",
85
85
  default: "google",
86
- enum: ["google", "bing", "duckduckgo", "yahoo", "x", "reddit", "github", "youtube", "arxiv", "wechat", "bilibili", "imdb", "wikipedia"],
86
+ enum: ["google", "bing", "bingcn", "duckduckgo", "yahoo", "yandex", "x", "reddit", "github", "youtube", "arxiv", "wechat", "bilibili", "imdb", "wikipedia", "grokipedia"],
87
+ },
88
+ page: {
89
+ type: "number",
90
+ minimum: 1,
91
+ maximum: 100,
92
+ description: "Results page to fetch; only bing, bingcn, baidu, and grokipedia paginate, other engines ignore it",
93
+ default: 1,
87
94
  },
88
95
  crawl_results: {
89
96
  type: "number",
@@ -110,7 +117,7 @@ export const SEARCH_TOOL = {
110
117
  time_range: {
111
118
  type: "string",
112
119
  description: "Optional recency window for time-sensitive searches",
113
- enum: ["day", "month", "year"],
120
+ enum: ["day", "week", "month", "year"],
114
121
  },
115
122
  },
116
123
  required: ["query"],
@@ -168,7 +175,7 @@ export const NEWS_TOOL = {
168
175
  time_range: {
169
176
  type: "string",
170
177
  description: "Optional recency window; use day for breaking news",
171
- enum: ["day", "month", "year"],
178
+ enum: ["day", "week", "month", "year"],
172
179
  },
173
180
  },
174
181
  required: ["query"],
@@ -275,10 +282,64 @@ export const TRENDING_TOOL = {
275
282
  required: ["results"],
276
283
  },
277
284
  };
285
+ // Ask tool definition
286
+ export const ASK_TOOL = {
287
+ name: "ask",
288
+ title: "Ask across the right sources",
289
+ description: "Describe what you are looking for in natural language when you do not know which source to search. Search1API picks up to five engines (web, Hacker News, Reddit, GitHub, X, arXiv, Wikipedia, and more), infers a time window from phrases such as \"this week\", and returns at most 10 relevant results ranked by relevance. Costs 5 credits; use search when you already know the engine.",
290
+ ...AUTHENTICATED_READ_ONLY_WEB,
291
+ inputSchema: {
292
+ type: "object",
293
+ properties: {
294
+ query: {
295
+ type: "string",
296
+ maxLength: 500,
297
+ description: "The request in natural language; platform hints (\"on Reddit\", \"papers\") and time hints (\"this week\") steer the search",
298
+ },
299
+ },
300
+ required: ["query"],
301
+ },
302
+ outputSchema: {
303
+ type: "object",
304
+ properties: {
305
+ intent: {
306
+ type: "object",
307
+ description: "Keywords, engines, and time window that were used",
308
+ properties: {
309
+ search_query: { type: "string" },
310
+ sources: { type: "array", items: { type: "string" } },
311
+ time_range: {
312
+ type: ["string", "null"],
313
+ enum: ["day", "week", "month", "year", null],
314
+ },
315
+ },
316
+ required: ["search_query", "sources", "time_range"],
317
+ },
318
+ results: {
319
+ type: "array",
320
+ items: CITABLE_RESULT_SCHEMA,
321
+ },
322
+ errors: {
323
+ type: "array",
324
+ description: "Engines that failed while others completed",
325
+ items: {
326
+ type: "object",
327
+ properties: {
328
+ source: { type: "string" },
329
+ message: { type: "string" },
330
+ },
331
+ required: ["source", "message"],
332
+ },
333
+ },
334
+ },
335
+ required: ["intent", "results", "errors"],
336
+ },
337
+ };
278
338
  export const ALL_TOOLS = [
279
339
  SEARCH_TOOL,
280
340
  NEWS_TOOL,
281
341
  CRAWL_TOOL,
282
342
  SITEMAP_TOOL,
283
343
  TRENDING_TOOL,
344
+ ASK_TOOL,
284
345
  ];
@@ -2,6 +2,7 @@ import { isValidNewsArgs } from '../types.js';
2
2
  import { makeRequest } from '../api.js';
3
3
  import { formatError, log } from '../utils.js';
4
4
  import { API_CONFIG } from '../config.js';
5
+ import { resultMetadata } from './search.js';
5
6
  import { INVALID_PARAMS, ProtocolError, } from "@modelcontextprotocol/server";
6
7
  /**
7
8
  * Implementation of the news search tool
@@ -18,10 +19,7 @@ export async function handleNews(args, apiKey) {
18
19
  title: result.title,
19
20
  url: result.link,
20
21
  text: result.content || result.snippet,
21
- metadata: {
22
- snippet: result.snippet,
23
- ...(result.content ? { has_full_content: true } : {}),
24
- },
22
+ metadata: resultMetadata(result),
25
23
  }));
26
24
  const structuredContent = { results };
27
25
  return {
@@ -3,6 +3,28 @@ import { makeRequest } from '../api.js';
3
3
  import { formatError } from '../utils.js';
4
4
  import { API_CONFIG } from '../config.js';
5
5
  import { INVALID_PARAMS, ProtocolError, } from "@modelcontextprotocol/server";
6
+ // Source fields the API adds for some engines (dates, GitHub and Hacker News
7
+ // details). Only fields the result actually carries are copied.
8
+ const OPTIONAL_RESULT_FIELDS = [
9
+ "published_date",
10
+ "kind",
11
+ "stars",
12
+ "language",
13
+ "num_comments",
14
+ "points",
15
+ "story_url",
16
+ ];
17
+ export function resultMetadata(result) {
18
+ const metadata = { snippet: result.snippet };
19
+ if (result.content)
20
+ metadata.has_full_content = true;
21
+ for (const field of OPTIONAL_RESULT_FIELDS) {
22
+ if (result[field] !== undefined && result[field] !== "") {
23
+ metadata[field] = result[field];
24
+ }
25
+ }
26
+ return metadata;
27
+ }
6
28
  /**
7
29
  * Implementation of the search tool
8
30
  */
@@ -17,10 +39,7 @@ export async function handleSearch(args, apiKey) {
17
39
  title: result.title,
18
40
  url: result.link,
19
41
  text: result.content || result.snippet,
20
- metadata: {
21
- snippet: result.snippet,
22
- ...(result.content ? { has_full_content: true } : {}),
23
- },
42
+ metadata: resultMetadata(result),
24
43
  }));
25
44
  const structuredContent = { results };
26
45
  return {
package/build/types.js CHANGED
@@ -2,8 +2,10 @@ export var SearchService;
2
2
  (function (SearchService) {
3
3
  SearchService["GOOGLE"] = "google";
4
4
  SearchService["BING"] = "bing";
5
+ SearchService["BINGCN"] = "bingcn";
5
6
  SearchService["DUCKDUCKGO"] = "duckduckgo";
6
7
  SearchService["YAHOO"] = "yahoo";
8
+ SearchService["YANDEX"] = "yandex";
7
9
  SearchService["GITHUB"] = "github";
8
10
  SearchService["YOUTUBE"] = "youtube";
9
11
  SearchService["X"] = "x";
@@ -13,6 +15,7 @@ export var SearchService;
13
15
  SearchService["BILIBILI"] = "bilibili";
14
16
  SearchService["IMDB"] = "imdb";
15
17
  SearchService["WIKIPEDIA"] = "wikipedia";
18
+ SearchService["GROKIPEDIA"] = "grokipedia";
16
19
  })(SearchService || (SearchService = {}));
17
20
  export var NewsService;
18
21
  (function (NewsService) {
@@ -25,6 +28,7 @@ export var NewsService;
25
28
  export var TimeRange;
26
29
  (function (TimeRange) {
27
30
  TimeRange["DAY"] = "day";
31
+ TimeRange["WEEK"] = "week";
28
32
  TimeRange["MONTH"] = "month";
29
33
  TimeRange["YEAR"] = "year";
30
34
  })(TimeRange || (TimeRange = {}));
@@ -32,13 +36,16 @@ export function isValidSearchArgs(args) {
32
36
  if (typeof args !== 'object' || args === null) {
33
37
  return false;
34
38
  }
35
- const { query, max_results, search_service, crawl_results, include_sites, exclude_sites, time_range } = args;
39
+ const { query, max_results, page, search_service, crawl_results, include_sites, exclude_sites, time_range } = args;
36
40
  if (typeof query !== 'string' || query.trim().length === 0) {
37
41
  return false;
38
42
  }
39
43
  if (max_results !== undefined && (typeof max_results !== 'number' || max_results < 1 || max_results > 50)) {
40
44
  return false;
41
45
  }
46
+ if (page !== undefined && (!Number.isInteger(page) || page < 1 || page > 100)) {
47
+ return false;
48
+ }
42
49
  if (search_service !== undefined) {
43
50
  const validServices = Object.values(SearchService);
44
51
  if (!validServices.includes(search_service)) {
@@ -138,3 +145,10 @@ export function isValidTrendingArgs(args) {
138
145
  }
139
146
  return true;
140
147
  }
148
+ export function isValidAskArgs(args) {
149
+ if (typeof args !== 'object' || args === null) {
150
+ return false;
151
+ }
152
+ const { query } = args;
153
+ return typeof query === 'string' && query.trim().length > 0 && query.length <= 500;
154
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "search1api-mcp",
3
- "version": "0.6.0",
3
+ "version": "0.7.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
@@ -2,12 +2,12 @@
2
2
  "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
3
  "name": "io.github.superagents-lab/search1api",
4
4
  "title": "Search1API",
5
- "description": "Web search, news, page retrieval, sitemaps, and trending topics through Search1API.",
5
+ "description": "Web search, agentic search, news, page retrieval, sitemaps, and trending topics through Search1API.",
6
6
  "repository": {
7
7
  "url": "https://github.com/superagents-lab/search1api-mcp",
8
8
  "source": "github"
9
9
  },
10
- "version": "0.6.0",
10
+ "version": "0.7.0",
11
11
  "remotes": [
12
12
  {
13
13
  "type": "streamable-http",
@@ -18,7 +18,7 @@
18
18
  {
19
19
  "registryType": "npm",
20
20
  "identifier": "search1api-mcp",
21
- "version": "0.6.0",
21
+ "version": "0.7.0",
22
22
  "transport": {
23
23
  "type": "stdio"
24
24
  },