search1api-mcp 0.6.1 → 0.7.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/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)
@@ -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,17 @@ 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
+
200
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
201
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
202
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
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,6 +12,9 @@ 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
19
  /**
17
20
  * Validate both Clerk OAuth tokens and legacy Search1API API keys at the API.
@@ -94,6 +97,9 @@ export function createHttpApp(options = {}) {
94
97
  .type("text/plain")
95
98
  .send(["User-agent: *", "Disallow: /", "Allow: /.well-known/", ""].join("\n"));
96
99
  });
100
+ app.get("/.well-known/openai-apps-challenge", (_req, res) => {
101
+ res.type("text/plain").send(OPENAI_APPS_CHALLENGE_TOKEN);
102
+ });
97
103
  // OIDC scopes such as openid and offline_access belong to the client/AS
98
104
  // exchange; this resource does not require any resource-specific scope.
99
105
  const protectedResourceMetadata = {
@@ -123,14 +129,14 @@ export function createHttpApp(options = {}) {
123
129
  .json({
124
130
  name: "Search1API",
125
131
  version: PACKAGE_VERSION,
126
- 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.",
127
133
  serverUrl: MCP_RESOURCE,
128
134
  tools: ALL_TOOLS.map((tool) => ({
129
135
  name: tool.name,
130
136
  title: tool.title,
131
137
  description: tool.description,
132
138
  inputSchema: tool.inputSchema,
133
- annotations: tool.annotations,
139
+ annotations: { ...tool.annotations, title: tool.title },
134
140
  })),
135
141
  serverInfo: {
136
142
  name: "Search1API",
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,18 @@ 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
+ export function resultMetadata(result) {
7
+ const metadata = {
8
+ ...result.metadata,
9
+ snippet: result.snippet,
10
+ };
11
+ if (result.content)
12
+ metadata.has_full_content = true;
13
+ if (result.published_date) {
14
+ metadata.published_date = result.published_date;
15
+ }
16
+ return metadata;
17
+ }
6
18
  /**
7
19
  * Implementation of the search tool
8
20
  */
@@ -17,10 +29,7 @@ export async function handleSearch(args, apiKey) {
17
29
  title: result.title,
18
30
  url: result.link,
19
31
  text: result.content || result.snippet,
20
- metadata: {
21
- snippet: result.snippet,
22
- ...(result.content ? { has_full_content: true } : {}),
23
- },
32
+ metadata: resultMetadata(result),
24
33
  }));
25
34
  const structuredContent = { results };
26
35
  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.1",
3
+ "version": "0.7.1",
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.1",
10
+ "version": "0.7.1",
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.1",
21
+ "version": "0.7.1",
22
22
  "transport": {
23
23
  "type": "stdio"
24
24
  },