search1api-mcp 0.8.0 → 0.9.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 +13 -4
- package/build/branding.js +2 -0
- package/build/config.js +3 -0
- package/build/feedback.js +31 -0
- package/build/http.js +111 -5
- package/build/server.js +28 -2
- package/build/setup-page.js +50 -0
- package/build/tools/index.js +32 -22
- package/build/tools/render-results.js +11 -11
- package/docs/mcp-ui.md +1 -1
- package/package.json +8 -4
- package/server.json +2 -2
package/README.md
CHANGED
|
@@ -56,11 +56,9 @@ After changing the URL, reconnect or refresh the connector's tool definitions; c
|
|
|
56
56
|
|
|
57
57
|
### Claude.ai (Web)
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
Install Search1API from the [Claude directory](https://claude.ai/directory/search1api), click **Connect**, and sign in with your Search1API account.
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
https://mcp.search1api.com/mcp?apiKey=YOUR_SEARCH1API_KEY
|
|
63
|
-
```
|
|
61
|
+
Avoid adding `https://mcp.search1api.com/mcp` through **Add custom connector**: that creates a separate custom connector, which Claude names after the URL's host (`mcp.search1api.com`) unless you type a name.
|
|
64
62
|
|
|
65
63
|
### Cursor
|
|
66
64
|
|
|
@@ -213,6 +211,17 @@ Agentic search: describe the need in natural language and Search1API picks up to
|
|
|
213
211
|
|-----------|----------|-------------|
|
|
214
212
|
| `query` | Yes | The request in natural language, up to 500 characters |
|
|
215
213
|
|
|
214
|
+
### send_feedback
|
|
215
|
+
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.
|
|
216
|
+
|
|
217
|
+
| Parameter | Required | Description |
|
|
218
|
+
|-----------|----------|-------------|
|
|
219
|
+
| `message` | Yes | What went wrong or what was missing, up to 4000 characters |
|
|
220
|
+
| `intent` | No | What you were trying to accomplish |
|
|
221
|
+
| `category` | No | bug, feature_request, docs, other |
|
|
222
|
+
| `request_id` | No | Request id of the call that had the problem |
|
|
223
|
+
| `model` | No | Your model name |
|
|
224
|
+
|
|
216
225
|
## Version History
|
|
217
226
|
|
|
218
227
|
- 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`
|
package/build/branding.js
CHANGED
|
@@ -9,3 +9,5 @@ export const SERVER_ICONS = [
|
|
|
9
9
|
sizes: ["512x512"],
|
|
10
10
|
},
|
|
11
11
|
];
|
|
12
|
+
// Same wording as server.json, advertised in the MCP handshake serverInfo.
|
|
13
|
+
export const SERVER_DESCRIPTION = "Web search, agentic search, news, page retrieval, sitemaps, and trending topics through Search1API.";
|
package/build/config.js
CHANGED
|
@@ -45,5 +45,8 @@ export const API_CONFIG = {
|
|
|
45
45
|
ASK: '/ask'
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
+
// Agentback project public key for the send_feedback tool. It can only submit
|
|
49
|
+
// feedback, so it ships with the package like any other public client key.
|
|
50
|
+
export const AGENTBACK_PROJECT_KEY = 'af_97385a84ecf95968db2403eb6ef165ddcd8ee6716c1b2ceb72f1a35a69e52b8e';
|
|
48
51
|
// Export API key
|
|
49
52
|
export { API_KEY };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { API_CONFIG } from "./config.js";
|
|
2
|
+
import { log } from "./utils.js";
|
|
3
|
+
/**
|
|
4
|
+
* Look up the signed Agentback identity of the Search1API user behind
|
|
5
|
+
* `apiKey`, so their feedback shows up under their account. Returns undefined
|
|
6
|
+
* when there is no key or the lookup fails; the report is then sent without an
|
|
7
|
+
* account rather than not at all.
|
|
8
|
+
*/
|
|
9
|
+
export async function feedbackIdentity(apiKey) {
|
|
10
|
+
if (!apiKey)
|
|
11
|
+
return undefined;
|
|
12
|
+
try {
|
|
13
|
+
const response = await fetch(`${API_CONFIG.BASE_URL}/feedback/identity`, {
|
|
14
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
15
|
+
signal: AbortSignal.timeout(3000),
|
|
16
|
+
});
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
log(`Feedback identity lookup returned HTTP ${response.status}`);
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const body = (await response.json());
|
|
22
|
+
return typeof body.account === "string" &&
|
|
23
|
+
typeof body.signature === "string"
|
|
24
|
+
? { account: body.account, signature: body.signature }
|
|
25
|
+
: undefined;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
log("Feedback identity lookup failed");
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
}
|
package/build/http.js
CHANGED
|
@@ -6,12 +6,14 @@ import { createMcpHandler, INTERNAL_ERROR, PARSE_ERROR, } from "@modelcontextpro
|
|
|
6
6
|
import express from "express";
|
|
7
7
|
import { createMcpServer, unauthenticatedCredential, UNAUTHENTICATED, } from "./server.js";
|
|
8
8
|
import { ALL_TOOLS } from "./tools/index.js";
|
|
9
|
+
import { renderSetupPage } from "./setup-page.js";
|
|
9
10
|
import { PACKAGE_VERSION } from "./version.js";
|
|
10
11
|
import { SERVER_ICON_FILE, SERVER_ICON_PATH, SERVER_ICONS } from "./branding.js";
|
|
11
12
|
import { log } from "./utils.js";
|
|
12
13
|
const API_BASE_URL = process.env.SEARCH1API_API_URL || "https://api.search1api.com";
|
|
13
14
|
const DEFAULT_AUTHORIZATION_SERVER = "https://clerk.s1.dev";
|
|
14
15
|
const OAUTH_DISCOVERY_CACHE_CONTROL = "public, max-age=60, s-maxage=60";
|
|
16
|
+
const OAUTH_SCOPES = ["offline_access"];
|
|
15
17
|
const MCP_RESOURCE = "https://mcp.search1api.com/mcp";
|
|
16
18
|
// Public by design: the OpenAI Platform reads it to verify that we own this
|
|
17
19
|
// host before listing the plugin.
|
|
@@ -44,6 +46,43 @@ export async function validateCredential(credential) {
|
|
|
44
46
|
}
|
|
45
47
|
return { credential, principal };
|
|
46
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.
|
|
54
|
+
const REJECTED_CREDENTIAL_TTL_MS = 60_000;
|
|
55
|
+
const REJECTED_CREDENTIAL_MAX_ENTRIES = 10_000;
|
|
56
|
+
/**
|
|
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.
|
|
60
|
+
*/
|
|
61
|
+
export function cacheRejectedCredentials(validator, { ttlMs = REJECTED_CREDENTIAL_TTL_MS, maxEntries = REJECTED_CREDENTIAL_MAX_ENTRIES, now = Date.now, } = {}) {
|
|
62
|
+
const rejectedUntil = new Map();
|
|
63
|
+
return async (credential) => {
|
|
64
|
+
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;
|
|
69
|
+
}
|
|
70
|
+
rejectedUntil.delete(key);
|
|
71
|
+
}
|
|
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);
|
|
82
|
+
}
|
|
83
|
+
return authenticated;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
47
86
|
/**
|
|
48
87
|
* Build the HTTP application without starting a listener.
|
|
49
88
|
*
|
|
@@ -58,7 +97,7 @@ export async function validateCredential(credential) {
|
|
|
58
97
|
*/
|
|
59
98
|
export function createHttpApp(options = {}) {
|
|
60
99
|
const app = express();
|
|
61
|
-
const credentialValidator = options.validateCredential ?? validateCredential;
|
|
100
|
+
const credentialValidator = cacheRejectedCredentials(options.validateCredential ?? validateCredential);
|
|
62
101
|
const authorizationServer = normalizeAuthorizationServer(options.authorizationServer ??
|
|
63
102
|
process.env.OAUTH_AUTHORIZATION_SERVER ??
|
|
64
103
|
DEFAULT_AUTHORIZATION_SERVER);
|
|
@@ -73,6 +112,37 @@ export function createHttpApp(options = {}) {
|
|
|
73
112
|
const nodeHandler = toNodeHandler(mcpHandler, {
|
|
74
113
|
onerror: (error) => log("MCP Node adapter error:", error),
|
|
75
114
|
});
|
|
115
|
+
// Refusals (Host/Origin checks, rejected credentials, protocol errors) are
|
|
116
|
+
// otherwise silent, which leaves a failing directory scanner undiagnosable.
|
|
117
|
+
// The bare 401 challenge that starts OAuth discovery is routine and only
|
|
118
|
+
// logged when it opens a connection (initialize or server/discover), so each
|
|
119
|
+
// client's connect attempt shows up once with its outcome.
|
|
120
|
+
app.use("/mcp", (req, res, next) => {
|
|
121
|
+
res.on("finish", () => {
|
|
122
|
+
const hasCredential = extractCredential(req) !== undefined;
|
|
123
|
+
const body = req.body && typeof req.body === "object" ? req.body : undefined;
|
|
124
|
+
const rpcMethod = body && "method" in body ? String(body.method) : undefined;
|
|
125
|
+
const opensConnection = rpcMethod === "initialize" || rpcMethod === "server/discover";
|
|
126
|
+
const refused = res.statusCode >= 400 && !(res.statusCode === 401 && !hasCredential);
|
|
127
|
+
if (!refused && !opensConnection) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const clientInfo = body?.params?.clientInfo ??
|
|
131
|
+
body?.params?._meta?.["io.modelcontextprotocol/clientInfo"];
|
|
132
|
+
log(`${refused ? "MCP request refused" : "MCP connection"}: ${req.method} ${res.statusCode}`, JSON.stringify({
|
|
133
|
+
rpcMethod,
|
|
134
|
+
client: typeof clientInfo?.name === "string" ? clientInfo.name : undefined,
|
|
135
|
+
credential: hasCredential,
|
|
136
|
+
origin: req.headers.origin,
|
|
137
|
+
host: req.headers.host,
|
|
138
|
+
protocolVersion: req.headers["mcp-protocol-version"],
|
|
139
|
+
accept: req.headers.accept,
|
|
140
|
+
contentType: req.headers["content-type"],
|
|
141
|
+
userAgent: req.headers["user-agent"],
|
|
142
|
+
}));
|
|
143
|
+
});
|
|
144
|
+
next();
|
|
145
|
+
});
|
|
76
146
|
app.use((req, res, next) => {
|
|
77
147
|
if (!validateHost(req, res)) {
|
|
78
148
|
return;
|
|
@@ -81,6 +151,8 @@ export function createHttpApp(options = {}) {
|
|
|
81
151
|
});
|
|
82
152
|
// The service root points to the MCP product page. Keep
|
|
83
153
|
// query parameters so bookmarked campaign/support links remain attributable.
|
|
154
|
+
// Answer 200 rather than redirecting: this origin is the declared widget
|
|
155
|
+
// domain, and directory checks treat a redirect as an unreachable domain.
|
|
84
156
|
app.get("/", (req, res) => {
|
|
85
157
|
const target = new URL("https://s1.dev/mcp-server");
|
|
86
158
|
for (const [key, value] of Object.entries(req.query)) {
|
|
@@ -88,7 +160,17 @@ export function createHttpApp(options = {}) {
|
|
|
88
160
|
target.searchParams.append(key, value);
|
|
89
161
|
}
|
|
90
162
|
}
|
|
91
|
-
|
|
163
|
+
// URLSearchParams percent-encodes quotes and angle brackets; only & needs escaping.
|
|
164
|
+
const href = target.toString().replaceAll("&", "&");
|
|
165
|
+
res
|
|
166
|
+
.status(200)
|
|
167
|
+
.set("Link", '<https://s1.dev/mcp-server>; rel="canonical"')
|
|
168
|
+
.type("html")
|
|
169
|
+
.send(`<!doctype html><html lang="en"><head><meta charset="utf-8">` +
|
|
170
|
+
`<title>Search1API MCP Server</title>` +
|
|
171
|
+
`<link rel="canonical" href="https://s1.dev/mcp-server">` +
|
|
172
|
+
`<meta http-equiv="refresh" content="0; url=${href}">` +
|
|
173
|
+
`</head><body><p>Search1API MCP Server. Continue to <a href="${href}">s1.dev/mcp-server</a>.</p></body></html>`);
|
|
92
174
|
});
|
|
93
175
|
// /mcp is a transport endpoint that answers nothing without a credential,
|
|
94
176
|
// so search engines gain nothing from walking this host. Keep the OAuth
|
|
@@ -108,11 +190,16 @@ export function createHttpApp(options = {}) {
|
|
|
108
190
|
.type("image/png")
|
|
109
191
|
.sendFile(SERVER_ICON_FILE);
|
|
110
192
|
});
|
|
111
|
-
//
|
|
112
|
-
//
|
|
193
|
+
// The resource needs no scope of its own, but clients that find no scope
|
|
194
|
+
// here fall back to every scope the authorization server lists, including
|
|
195
|
+
// Clerk's public_metadata and private_metadata, which dynamically registered
|
|
196
|
+
// clients may not request. Search1API checks no scope on the token, and
|
|
197
|
+
// offline_access alone is in every dynamic client's grant, including clients
|
|
198
|
+
// registered before openid joined Clerk's defaults.
|
|
113
199
|
const protectedResourceMetadata = {
|
|
114
200
|
resource: MCP_RESOURCE,
|
|
115
201
|
authorization_servers: [authorizationServer],
|
|
202
|
+
scopes_supported: OAUTH_SCOPES,
|
|
116
203
|
bearer_methods_supported: ["header"],
|
|
117
204
|
resource_documentation: "https://s1.dev/auth.md",
|
|
118
205
|
};
|
|
@@ -180,6 +267,25 @@ export function createHttpApp(options = {}) {
|
|
|
180
267
|
}
|
|
181
268
|
next();
|
|
182
269
|
});
|
|
270
|
+
// A person opening the MCP URL in a browser gets setup instructions instead
|
|
271
|
+
// of a bare 401. MCP clients POST, or GET with text/event-stream, and still
|
|
272
|
+
// draw the challenge that starts OAuth; a presented credential always goes
|
|
273
|
+
// through to the transport.
|
|
274
|
+
app.get("/mcp", (req, res, next) => {
|
|
275
|
+
const accept = req.headers.accept ?? "";
|
|
276
|
+
if (extractCredential(req) !== undefined ||
|
|
277
|
+
accept.includes("text/event-stream") ||
|
|
278
|
+
!accept.includes("text/html")) {
|
|
279
|
+
next();
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
res
|
|
283
|
+
.status(200)
|
|
284
|
+
.set("Cache-Control", "public, max-age=300")
|
|
285
|
+
.set("Vary", "Accept, Authorization")
|
|
286
|
+
.type("html")
|
|
287
|
+
.send(renderSetupPage());
|
|
288
|
+
});
|
|
183
289
|
app.use(express.json());
|
|
184
290
|
app.all("/mcp", async (req, res) => {
|
|
185
291
|
const outcome = await authenticateMcpRequest(req, res, credentialValidator);
|
|
@@ -305,7 +411,7 @@ function extractCredential(req) {
|
|
|
305
411
|
}
|
|
306
412
|
function challenge(res, message, error) {
|
|
307
413
|
const errorParameter = error ? `, error="${error}"` : "";
|
|
308
|
-
res.set("WWW-Authenticate", `Bearer resource_metadata="${MCP_RESOURCE_METADATA}"${errorParameter}`);
|
|
414
|
+
res.set("WWW-Authenticate", `Bearer resource_metadata="${MCP_RESOURCE_METADATA}", scope="${OAUTH_SCOPES.join(" ")}"${errorParameter}`);
|
|
309
415
|
res.status(401).json({
|
|
310
416
|
jsonrpc: "2.0",
|
|
311
417
|
error: { code: UNAUTHENTICATED, message },
|
package/build/server.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { INTERNAL_ERROR, McpServer, ProtocolError, fromJsonSchema, } from "@modelcontextprotocol/server";
|
|
2
|
+
import { Agentback } from "agentback";
|
|
3
|
+
import { attachToMcp } from "agentback/mcp";
|
|
4
|
+
import { AGENTBACK_PROJECT_KEY } from "./config.js";
|
|
5
|
+
import { feedbackIdentity } from "./feedback.js";
|
|
2
6
|
import { handleReadResource, RESOURCES } from "./resources.js";
|
|
3
7
|
import { handleToolCall } from "./tools/handlers.js";
|
|
4
8
|
import { ALL_TOOLS } from "./tools/index.js";
|
|
5
9
|
import { MCP_APP_MIME_TYPE, SEARCH_UI_META, SEARCH_UI_URI, SEARCH_UI_COMPAT_URIS, readSearchUi, } from "./ui.js";
|
|
6
10
|
import { formatError, log } from "./utils.js";
|
|
7
11
|
import { PACKAGE_VERSION } from "./version.js";
|
|
8
|
-
import { SERVER_ICONS } from "./branding.js";
|
|
12
|
+
import { SERVER_DESCRIPTION, SERVER_ICONS } from "./branding.js";
|
|
9
13
|
/** JSON-RPC error code this server uses for a missing or rejected credential. */
|
|
10
14
|
export const UNAUTHENTICATED = -32001;
|
|
11
15
|
/**
|
|
@@ -30,7 +34,14 @@ export function unauthenticatedCredential(message) {
|
|
|
30
34
|
*/
|
|
31
35
|
export function createMcpServer(credential) {
|
|
32
36
|
log("Creating Search1API MCP server");
|
|
33
|
-
const server = new McpServer({
|
|
37
|
+
const server = new McpServer({
|
|
38
|
+
name: "search1api",
|
|
39
|
+
title: "Search1API",
|
|
40
|
+
version: PACKAGE_VERSION,
|
|
41
|
+
icons: SERVER_ICONS,
|
|
42
|
+
websiteUrl: "https://s1.dev",
|
|
43
|
+
description: SERVER_DESCRIPTION,
|
|
44
|
+
}, { instructions: "Use search, news, ask, crawl, 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." });
|
|
34
45
|
for (const tool of ALL_TOOLS) {
|
|
35
46
|
const inputSchema = fromJsonSchema(tool.inputSchema);
|
|
36
47
|
const outputSchema = tool.outputSchema
|
|
@@ -54,6 +65,12 @@ export function createMcpServer(credential) {
|
|
|
54
65
|
}
|
|
55
66
|
});
|
|
56
67
|
}
|
|
68
|
+
// Lets agents report wrong results, unresolved errors or missing
|
|
69
|
+
// capabilities. Reporting is free and spends no Search1API credit.
|
|
70
|
+
attachToMcp(server, new Agentback({ projectKey: AGENTBACK_PROJECT_KEY }), {
|
|
71
|
+
product: "Search1API",
|
|
72
|
+
identify: () => feedbackIdentity(resolveCredential(credential)),
|
|
73
|
+
});
|
|
57
74
|
for (const resource of RESOURCES) {
|
|
58
75
|
server.registerResource(resource.name, resource.uri, {
|
|
59
76
|
description: resource.description,
|
|
@@ -104,6 +121,15 @@ export function createMcpServer(credential) {
|
|
|
104
121
|
}
|
|
105
122
|
return server;
|
|
106
123
|
}
|
|
124
|
+
// Unlike tool calls, feedback goes out without a credential when none resolves.
|
|
125
|
+
function resolveCredential(credential) {
|
|
126
|
+
try {
|
|
127
|
+
return typeof credential === "function" ? credential() : credential;
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
107
133
|
function normalizeProtocolError(context, error) {
|
|
108
134
|
log(`Error ${context}:`, error);
|
|
109
135
|
if (error instanceof ProtocolError) {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ALL_TOOLS } from "./tools/index.js";
|
|
2
|
+
const MCP_URL = "https://mcp.search1api.com/mcp";
|
|
3
|
+
function escapeHtml(value) {
|
|
4
|
+
return value
|
|
5
|
+
.replaceAll("&", "&")
|
|
6
|
+
.replaceAll("<", "<")
|
|
7
|
+
.replaceAll(">", ">")
|
|
8
|
+
.replaceAll('"', """);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Human-readable setup instructions served when a browser opens the MCP URL.
|
|
12
|
+
* MCP clients never see this page: they POST, or GET with text/event-stream,
|
|
13
|
+
* and still receive the 401 challenge that starts OAuth.
|
|
14
|
+
*/
|
|
15
|
+
export function renderSetupPage() {
|
|
16
|
+
const tools = ALL_TOOLS.map((tool) => `<li><code>${escapeHtml(tool.name)}</code> ${escapeHtml(tool.title ?? "")}</li>`).join("");
|
|
17
|
+
const cursorConfig = escapeHtml(JSON.stringify({ mcpServers: { search1api: { url: MCP_URL } } }, null, 2));
|
|
18
|
+
return `<!doctype html>
|
|
19
|
+
<html lang="en">
|
|
20
|
+
<head>
|
|
21
|
+
<meta charset="utf-8">
|
|
22
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
23
|
+
<title>Search1API MCP Server: setup</title>
|
|
24
|
+
<link rel="canonical" href="https://s1.dev/mcp-server">
|
|
25
|
+
<style>
|
|
26
|
+
body{font:16px/1.6 system-ui,sans-serif;max-width:720px;margin:0 auto;padding:24px 16px;color:#111;background:#fff}
|
|
27
|
+
pre,code{font-family:ui-monospace,monospace;font-size:14px}
|
|
28
|
+
pre{background:#f4f4f5;padding:12px;border-radius:8px;overflow-x:auto}
|
|
29
|
+
a{color:#1d4ed8}
|
|
30
|
+
@media (prefers-color-scheme:dark){body{color:#eee;background:#111}pre{background:#222}a{color:#93c5fd}}
|
|
31
|
+
</style>
|
|
32
|
+
</head>
|
|
33
|
+
<body>
|
|
34
|
+
<h1>Search1API MCP Server</h1>
|
|
35
|
+
<p>This is a remote MCP endpoint for AI clients, not a web page. Add this URL to your MCP client:</p>
|
|
36
|
+
<pre>${MCP_URL}</pre>
|
|
37
|
+
<h2>Sign in</h2>
|
|
38
|
+
<p>Connect without a key and your client will open the Search1API sign-in (OAuth). Or send an API key from <a href="https://app.s1.dev">your dashboard</a> as <code>Authorization: Bearer YOUR_SEARCH1API_KEY</code>.</p>
|
|
39
|
+
<h2>Clients</h2>
|
|
40
|
+
<p><strong>Claude.ai</strong>: install Search1API from the <a href="https://claude.ai/directory/search1api">Claude directory</a> and click Connect.</p>
|
|
41
|
+
<p><strong>Claude Code</strong>:</p>
|
|
42
|
+
<pre>claude mcp add --transport http search1api ${MCP_URL}</pre>
|
|
43
|
+
<p><strong>Cursor, Windsurf, Claude Desktop and other clients</strong> (mcp.json):</p>
|
|
44
|
+
<pre>${cursorConfig}</pre>
|
|
45
|
+
<h2>Tools</h2>
|
|
46
|
+
<ul>${tools}</ul>
|
|
47
|
+
<p>Full guide: <a href="https://s1.dev/mcp-server">s1.dev/mcp-server</a></p>
|
|
48
|
+
</body>
|
|
49
|
+
</html>`;
|
|
50
|
+
}
|
package/build/tools/index.js
CHANGED
|
@@ -20,6 +20,8 @@ const AUTHENTICATED_READ_ONLY_WEB = {
|
|
|
20
20
|
annotations: {
|
|
21
21
|
readOnlyHint: true,
|
|
22
22
|
destructiveHint: false,
|
|
23
|
+
// Every call is billed in credits, so a repeat is not free of effects.
|
|
24
|
+
idempotentHint: false,
|
|
23
25
|
openWorldHint: true,
|
|
24
26
|
},
|
|
25
27
|
};
|
|
@@ -56,6 +58,7 @@ const SEARCH_OUTPUT_SCHEMA = {
|
|
|
56
58
|
properties: {
|
|
57
59
|
results: {
|
|
58
60
|
type: "array",
|
|
61
|
+
description: "Matching sources, most relevant first; read any url in full with crawl",
|
|
59
62
|
items: CITABLE_RESULT_SCHEMA,
|
|
60
63
|
},
|
|
61
64
|
},
|
|
@@ -78,7 +81,7 @@ export const SEARCH_TOOL = {
|
|
|
78
81
|
type: "number",
|
|
79
82
|
minimum: 1,
|
|
80
83
|
maximum: 50,
|
|
81
|
-
description: "
|
|
84
|
+
description: "How many sources the answer needs; a handful suits most questions, more suits a broad survey",
|
|
82
85
|
default: 10,
|
|
83
86
|
},
|
|
84
87
|
search_service: {
|
|
@@ -91,13 +94,13 @@ export const SEARCH_TOOL = {
|
|
|
91
94
|
type: "number",
|
|
92
95
|
minimum: 1,
|
|
93
96
|
maximum: 100,
|
|
94
|
-
description: "
|
|
97
|
+
description: "Which page of results to fetch when the first page was not enough; only bing, bingcn, and grokipedia paginate, other engines ignore it",
|
|
95
98
|
default: 1,
|
|
96
99
|
},
|
|
97
100
|
crawl_results: {
|
|
98
101
|
type: "number",
|
|
99
102
|
minimum: 0,
|
|
100
|
-
description: "
|
|
103
|
+
description: "How many top results to also read in full, so their text holds the whole page instead of a snippet. Each successful page retrieval adds 1 credit to the base 1-credit search request",
|
|
101
104
|
default: 0,
|
|
102
105
|
},
|
|
103
106
|
include_sites: {
|
|
@@ -118,7 +121,7 @@ export const SEARCH_TOOL = {
|
|
|
118
121
|
},
|
|
119
122
|
time_range: {
|
|
120
123
|
type: "string",
|
|
121
|
-
description: "
|
|
124
|
+
description: "Restrict results to those published recently, for time-sensitive questions; leave unset for evergreen topics",
|
|
122
125
|
enum: ["day", "week", "month", "year"],
|
|
123
126
|
},
|
|
124
127
|
},
|
|
@@ -148,12 +151,12 @@ export const NEWS_TOOL = {
|
|
|
148
151
|
type: "number",
|
|
149
152
|
minimum: 1,
|
|
150
153
|
maximum: 50,
|
|
151
|
-
description: "
|
|
154
|
+
description: "How many articles the answer needs; a handful suits most questions, more suits broad coverage",
|
|
152
155
|
default: 10,
|
|
153
156
|
},
|
|
154
157
|
search_service: {
|
|
155
158
|
type: "string",
|
|
156
|
-
description: "News
|
|
159
|
+
description: "News engine to use; hackernews returns Hacker News discussions instead of publisher articles",
|
|
157
160
|
default: "bing",
|
|
158
161
|
enum: ["google", "bing", "duckduckgo", "yahoo", "hackernews"],
|
|
159
162
|
},
|
|
@@ -181,7 +184,7 @@ export const NEWS_TOOL = {
|
|
|
181
184
|
},
|
|
182
185
|
time_range: {
|
|
183
186
|
type: "string",
|
|
184
|
-
description: "
|
|
187
|
+
description: "Only return articles published within this window; use day for breaking news",
|
|
185
188
|
enum: ["day", "week", "month", "year"],
|
|
186
189
|
},
|
|
187
190
|
},
|
|
@@ -198,7 +201,7 @@ export const NEWS_TOOL = {
|
|
|
198
201
|
export const CRAWL_TOOL = {
|
|
199
202
|
name: "crawl",
|
|
200
203
|
title: "Read a web page",
|
|
201
|
-
description: "
|
|
204
|
+
description: "Read a public web page supplied by the user or returned by search. Returns its title, URL, and main content as text, so you can answer from the full page instead of a snippet.",
|
|
202
205
|
...AUTHENTICATED_READ_ONLY_WEB,
|
|
203
206
|
inputSchema: {
|
|
204
207
|
type: "object",
|
|
@@ -206,7 +209,7 @@ export const CRAWL_TOOL = {
|
|
|
206
209
|
url: {
|
|
207
210
|
type: "string",
|
|
208
211
|
format: "uri",
|
|
209
|
-
description: "
|
|
212
|
+
description: "Address of the page to read, such as a link the user shared or a URL from search results",
|
|
210
213
|
},
|
|
211
214
|
},
|
|
212
215
|
required: ["url"],
|
|
@@ -214,7 +217,10 @@ export const CRAWL_TOOL = {
|
|
|
214
217
|
outputSchema: {
|
|
215
218
|
type: "object",
|
|
216
219
|
properties: {
|
|
217
|
-
result:
|
|
220
|
+
result: {
|
|
221
|
+
...CITABLE_RESULT_SCHEMA,
|
|
222
|
+
description: "The page that was read; text holds its main content",
|
|
223
|
+
},
|
|
218
224
|
},
|
|
219
225
|
required: ["result"],
|
|
220
226
|
},
|
|
@@ -223,7 +229,7 @@ export const CRAWL_TOOL = {
|
|
|
223
229
|
export const SITEMAP_TOOL = {
|
|
224
230
|
name: "sitemap",
|
|
225
231
|
title: "Discover links on a site",
|
|
226
|
-
description: "Discover related public links from a page or domain when the user wants to explore a site's structure or available pages.",
|
|
232
|
+
description: "Discover related public links from a page or domain when the user wants to explore a site's structure or available pages. Returns a list of absolute URLs found on that site, which can then be read with crawl.",
|
|
227
233
|
...AUTHENTICATED_READ_ONLY_WEB,
|
|
228
234
|
inputSchema: {
|
|
229
235
|
type: "object",
|
|
@@ -241,6 +247,7 @@ export const SITEMAP_TOOL = {
|
|
|
241
247
|
properties: {
|
|
242
248
|
links: {
|
|
243
249
|
type: "array",
|
|
250
|
+
description: "Absolute URLs discovered on the site, without titles or page content",
|
|
244
251
|
items: {
|
|
245
252
|
type: "string",
|
|
246
253
|
format: "uri",
|
|
@@ -254,14 +261,14 @@ export const SITEMAP_TOOL = {
|
|
|
254
261
|
export const TRENDING_TOOL = {
|
|
255
262
|
name: "trending",
|
|
256
263
|
title: "Explore trending topics",
|
|
257
|
-
description: "List currently trending repositories or stories from GitHub or Hacker News when the user asks what is popular now.",
|
|
264
|
+
description: "List currently trending repositories or stories from GitHub or Hacker News when the user asks what is popular now. Returns each item's title, URL, and a short description when the platform provides one.",
|
|
258
265
|
...AUTHENTICATED_READ_ONLY_WEB,
|
|
259
266
|
inputSchema: {
|
|
260
267
|
type: "object",
|
|
261
268
|
properties: {
|
|
262
269
|
search_service: {
|
|
263
270
|
type: "string",
|
|
264
|
-
description: "
|
|
271
|
+
description: "Where to look: GitHub for popular open-source repositories, Hacker News for stories developers are discussing",
|
|
265
272
|
enum: ["github", "hackernews"],
|
|
266
273
|
default: "github",
|
|
267
274
|
},
|
|
@@ -269,7 +276,7 @@ export const TRENDING_TOOL = {
|
|
|
269
276
|
type: "number",
|
|
270
277
|
minimum: 1,
|
|
271
278
|
maximum: 50,
|
|
272
|
-
description: "
|
|
279
|
+
description: "How many trending items the answer needs, from the top of the list",
|
|
273
280
|
default: 10,
|
|
274
281
|
},
|
|
275
282
|
},
|
|
@@ -280,12 +287,13 @@ export const TRENDING_TOOL = {
|
|
|
280
287
|
properties: {
|
|
281
288
|
results: {
|
|
282
289
|
type: "array",
|
|
290
|
+
description: "Trending items reported by the platform",
|
|
283
291
|
items: {
|
|
284
292
|
type: "object",
|
|
285
293
|
properties: {
|
|
286
|
-
title: { type: "string" },
|
|
287
|
-
url: { type: "string", format: "uri" },
|
|
288
|
-
description: { type: "string" },
|
|
294
|
+
title: { type: "string", description: "Repository name or story headline" },
|
|
295
|
+
url: { type: "string", format: "uri", description: "Link to the repository or story" },
|
|
296
|
+
description: { type: "string", description: "Repository summary or story context, when available" },
|
|
289
297
|
},
|
|
290
298
|
required: ["title", "url"],
|
|
291
299
|
},
|
|
@@ -297,8 +305,8 @@ export const TRENDING_TOOL = {
|
|
|
297
305
|
// Ask tool definition
|
|
298
306
|
export const ASK_TOOL = {
|
|
299
307
|
name: "ask",
|
|
300
|
-
title: "Ask across
|
|
301
|
-
description: "
|
|
308
|
+
title: "Ask across sources",
|
|
309
|
+
description: "Search several sources at once from a natural-language request when the right engine is unclear. Search1API picks up to five engines (web, Hacker News, Reddit, GitHub, X, arXiv, Wikipedia, and more) and a time window from the wording, then returns up to 10 citable results ranked by relevance, plus the intent it used and any engines that failed. Costs 5 credits per call; use search when you already know the engine.",
|
|
302
310
|
...AUTHENTICATED_READ_ONLY_WEB,
|
|
303
311
|
inputSchema: {
|
|
304
312
|
type: "object",
|
|
@@ -306,7 +314,7 @@ export const ASK_TOOL = {
|
|
|
306
314
|
query: {
|
|
307
315
|
type: "string",
|
|
308
316
|
maxLength: 500,
|
|
309
|
-
description: "
|
|
317
|
+
description: "What the user is looking for, in their own words; naming a platform (\"on Reddit\", \"papers\") or a period (\"this week\") steers which engines and time window are used",
|
|
310
318
|
},
|
|
311
319
|
},
|
|
312
320
|
required: ["query"],
|
|
@@ -318,10 +326,11 @@ export const ASK_TOOL = {
|
|
|
318
326
|
type: "object",
|
|
319
327
|
description: "Keywords, engines, and time window that were used",
|
|
320
328
|
properties: {
|
|
321
|
-
search_query: { type: "string" },
|
|
322
|
-
sources: { type: "array", items: { type: "string" } },
|
|
329
|
+
search_query: { type: "string", description: "Keywords sent to the engines" },
|
|
330
|
+
sources: { type: "array", items: { type: "string" }, description: "Engines that were searched" },
|
|
323
331
|
time_range: {
|
|
324
332
|
type: ["string", "null"],
|
|
333
|
+
description: "Recency window inferred from the request, or null for any time",
|
|
325
334
|
enum: ["day", "week", "month", "year", null],
|
|
326
335
|
},
|
|
327
336
|
},
|
|
@@ -329,6 +338,7 @@ export const ASK_TOOL = {
|
|
|
329
338
|
},
|
|
330
339
|
results: {
|
|
331
340
|
type: "array",
|
|
341
|
+
description: "Up to 10 sources across the chosen engines, most relevant first",
|
|
332
342
|
items: CITABLE_RESULT_SCHEMA,
|
|
333
343
|
},
|
|
334
344
|
errors: {
|
|
@@ -7,7 +7,7 @@ export const RENDER_INPUT_SCHEMA = {
|
|
|
7
7
|
"type": "string",
|
|
8
8
|
"minLength": 1,
|
|
9
9
|
"maxLength": 120,
|
|
10
|
-
"description": "
|
|
10
|
+
"description": "Heading shown above the cards, such as the research topic"
|
|
11
11
|
},
|
|
12
12
|
"results": {
|
|
13
13
|
"type": "array",
|
|
@@ -21,30 +21,30 @@ export const RENDER_INPUT_SCHEMA = {
|
|
|
21
21
|
"type": "string",
|
|
22
22
|
"minLength": 1,
|
|
23
23
|
"maxLength": 2048,
|
|
24
|
-
"description": "
|
|
24
|
+
"description": "The id from the original search result; the server falls back to the URL when there is none"
|
|
25
25
|
},
|
|
26
26
|
"title": {
|
|
27
27
|
"type": "string",
|
|
28
28
|
"minLength": 1,
|
|
29
29
|
"maxLength": 300,
|
|
30
|
-
"description": "
|
|
30
|
+
"description": "Source title exactly as the search returned it; never invent or rewrite it"
|
|
31
31
|
},
|
|
32
32
|
"url": {
|
|
33
33
|
"type": "string",
|
|
34
34
|
"format": "uri",
|
|
35
35
|
"pattern": "^https?://",
|
|
36
36
|
"maxLength": 2048,
|
|
37
|
-
"description": "
|
|
37
|
+
"description": "Link to the source as the search returned it, never one carrying credentials"
|
|
38
38
|
},
|
|
39
39
|
"text": {
|
|
40
40
|
"type": "string",
|
|
41
41
|
"maxLength": 2000,
|
|
42
|
-
"description": "
|
|
42
|
+
"description": "Snippet or faithful excerpt from the source, not a full page or a model-written answer"
|
|
43
43
|
},
|
|
44
44
|
"metadata": {
|
|
45
45
|
"type": "object",
|
|
46
46
|
"additionalProperties": true,
|
|
47
|
-
"description": "
|
|
47
|
+
"description": "Metadata from the original result, such as the publication date; never credentials or UI details"
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"required": [
|
|
@@ -86,30 +86,30 @@ export const RENDER_OUTPUT_SCHEMA = {
|
|
|
86
86
|
"type": "string",
|
|
87
87
|
"minLength": 1,
|
|
88
88
|
"maxLength": 2048,
|
|
89
|
-
"description": "
|
|
89
|
+
"description": "The id from the original search result; the server falls back to the URL when there is none"
|
|
90
90
|
},
|
|
91
91
|
"title": {
|
|
92
92
|
"type": "string",
|
|
93
93
|
"minLength": 1,
|
|
94
94
|
"maxLength": 300,
|
|
95
|
-
"description": "
|
|
95
|
+
"description": "Source title exactly as the search returned it; never invent or rewrite it"
|
|
96
96
|
},
|
|
97
97
|
"url": {
|
|
98
98
|
"type": "string",
|
|
99
99
|
"format": "uri",
|
|
100
100
|
"pattern": "^https?://",
|
|
101
101
|
"maxLength": 2048,
|
|
102
|
-
"description": "
|
|
102
|
+
"description": "Link to the source as the search returned it, never one carrying credentials"
|
|
103
103
|
},
|
|
104
104
|
"text": {
|
|
105
105
|
"type": "string",
|
|
106
106
|
"maxLength": 2000,
|
|
107
|
-
"description": "
|
|
107
|
+
"description": "Snippet or faithful excerpt from the source, not a full page or a model-written answer"
|
|
108
108
|
},
|
|
109
109
|
"metadata": {
|
|
110
110
|
"type": "object",
|
|
111
111
|
"additionalProperties": true,
|
|
112
|
-
"description": "
|
|
112
|
+
"description": "Metadata from the original result, such as the publication date; never credentials or UI details"
|
|
113
113
|
}
|
|
114
114
|
},
|
|
115
115
|
"required": [
|
package/docs/mcp-ui.md
CHANGED
|
@@ -65,6 +65,6 @@ The search cards are adapted from [Rare UI](https://rareui.com), copyright 2026
|
|
|
65
65
|
|
|
66
66
|
The HTTP deployment builds the UI together with the server. Deploying the remote service makes on-demand rendering available at the default URL without publishing a new npm package. Source cards are linked only to `render_results`.
|
|
67
67
|
|
|
68
|
-
The npm package and local stdio clients update only when a new package version is published and installed. This remote-only rollout does not publish an npm version. A future npm release must choose a new package version
|
|
68
|
+
The npm package and local stdio clients update only when a new package version is published and installed. This remote-only rollout does not publish an npm version. A future npm release must choose a new package version with `npm version`, which copies it into `server.json`, `lhm.plugin.json`, `plugin.json` and `.cursor-plugin/plugin.json`; after editing `package.json` by hand, run `npm run sync:versions`. `npm test` fails while any of these manifests is behind.
|
|
69
69
|
|
|
70
70
|
Public directory submission and production OAuth acceptance are separate from building and deploying the service. Verify the publisher domain, reviewer access and policy coverage before submitting an app.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "search1api-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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,
|
|
@@ -25,13 +25,17 @@
|
|
|
25
25
|
"watch": "tsc --watch",
|
|
26
26
|
"inspector": "npx @modelcontextprotocol/inspector build/index.js",
|
|
27
27
|
"start:http": "node build/http.js",
|
|
28
|
-
"sync:manifest": "npm run build && node scripts/sync-lobe-manifest.mjs"
|
|
28
|
+
"sync:manifest": "npm run build && node scripts/sync-lobe-manifest.mjs",
|
|
29
|
+
"sync:versions": "node scripts/sync-versions.mjs",
|
|
30
|
+
"version": "node scripts/sync-versions.mjs && git add server.json lhm.plugin.json plugin.json .cursor-plugin/plugin.json"
|
|
29
31
|
},
|
|
30
32
|
"dependencies": {
|
|
31
33
|
"@modelcontextprotocol/node": "^2.0.0",
|
|
32
|
-
"@modelcontextprotocol/server": "^2.
|
|
34
|
+
"@modelcontextprotocol/server": "^2.3.1",
|
|
35
|
+
"agentback": "^0.2.0",
|
|
33
36
|
"dotenv": "^16.6.1",
|
|
34
|
-
"express": "^4.22.2"
|
|
37
|
+
"express": "^4.22.2",
|
|
38
|
+
"zod": "^4.6.7"
|
|
35
39
|
},
|
|
36
40
|
"devDependencies": {
|
|
37
41
|
"@modelcontextprotocol/client": "^2.0.0",
|
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.9.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.9.0",
|
|
31
31
|
"transport": {
|
|
32
32
|
"type": "stdio"
|
|
33
33
|
},
|