search1api-mcp 0.13.0 → 0.15.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 +6 -1
- package/build/api.js +2 -0
- package/build/client-channel.js +20 -0
- package/build/feedback.js +4 -2
- package/build/http.js +8 -2
- package/build/server.js +9 -2
- package/package.json +2 -2
- package/server.json +2 -2
package/README.md
CHANGED
|
@@ -259,13 +259,18 @@ The tool waits up to about 45 seconds. If the crawl is still running, it returns
|
|
|
259
259
|
| `task_id` | No | - | `task_id` of a crawl that was still running; only checks its status, and the other parameters are ignored |
|
|
260
260
|
|
|
261
261
|
### send_feedback
|
|
262
|
-
Report a wrong, empty or incomplete result, an error you could not resolve, documentation that did not match behavior, or a missing capability to the Search1API team. Free; it spends no credits. When the server has a Search1API credential, the report is linked to that account so the team can follow up. Do not include credentials or private data.
|
|
262
|
+
Report a wrong, empty or incomplete result, an error you could not resolve, documentation that did not match behavior, or a missing capability to the Search1API team. Free; it spends no credits. When the server has a Search1API credential, the report is linked to that account, with the account's email, so the team can follow up. Do not include credentials or private data.
|
|
263
263
|
|
|
264
264
|
| Parameter | Required | Description |
|
|
265
265
|
|-----------|----------|-------------|
|
|
266
266
|
| `message` | Yes | What went wrong or what was missing, up to 4000 characters |
|
|
267
|
+
| `outcome` | Yes | How the task ended: `blocked` (could not finish), `worked_around` (finished another way), `friction` (finished after retries or guessing) |
|
|
267
268
|
| `intent` | No | What you were trying to accomplish |
|
|
269
|
+
| `expected` | No | What you expected to happen |
|
|
270
|
+
| `actual` | No | What happened instead: the calls made, in order, and the error text |
|
|
271
|
+
| `tool` | No | Name of the tool that had the problem |
|
|
268
272
|
| `category` | No | bug, feature_request, docs, other |
|
|
273
|
+
| `suggestion` | No | What would have helped |
|
|
269
274
|
| `request_id` | No | Request id of the call that had the problem |
|
|
270
275
|
| `model` | No | Your model name |
|
|
271
276
|
|
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/feedback.js
CHANGED
|
@@ -2,7 +2,8 @@ import { API_CONFIG } from "./config.js";
|
|
|
2
2
|
import { log } from "./utils.js";
|
|
3
3
|
/**
|
|
4
4
|
* Look up the signed Agentback identity of the Search1API user behind
|
|
5
|
-
* `apiKey`, so their feedback shows up under their account
|
|
5
|
+
* `apiKey`, so their feedback shows up under their account, with their email
|
|
6
|
+
* when the gateway has one so the report can be answered. Returns undefined
|
|
6
7
|
* when there is no key or the lookup fails; the report is then sent without an
|
|
7
8
|
* account rather than not at all.
|
|
8
9
|
*/
|
|
@@ -19,9 +20,10 @@ export async function feedbackIdentity(apiKey) {
|
|
|
19
20
|
return undefined;
|
|
20
21
|
}
|
|
21
22
|
const body = (await response.json());
|
|
23
|
+
const email = typeof body.email === "string" && body.email ? body.email : undefined;
|
|
22
24
|
return typeof body.account === "string" &&
|
|
23
25
|
typeof body.signature === "string"
|
|
24
|
-
? { account: body.account, signature: body.signature }
|
|
26
|
+
? { account: body.account, signature: body.signature, email }
|
|
25
27
|
: undefined;
|
|
26
28
|
}
|
|
27
29
|
catch {
|
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",
|
|
@@ -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);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "search1api-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.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,
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@modelcontextprotocol/node": "^2.0.0",
|
|
34
34
|
"@modelcontextprotocol/server": "^2.3.1",
|
|
35
|
-
"agentback": "^0.
|
|
35
|
+
"agentback": "^0.7.0",
|
|
36
36
|
"dotenv": "^16.6.1",
|
|
37
37
|
"express": "^4.22.2",
|
|
38
38
|
"zod": "^4.6.7"
|
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.15.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.15.0",
|
|
31
31
|
"transport": {
|
|
32
32
|
"type": "stdio"
|
|
33
33
|
},
|