desearch-mcp-server 0.2.2 → 0.2.3
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/CHANGELOG.md +8 -0
- package/README.md +1 -1
- package/build/oauth/flow.d.ts +1 -1
- package/build/oauth/flow.d.ts.map +1 -1
- package/build/oauth/flow.js +40 -12
- package/build/oauth/page.d.ts.map +1 -1
- package/build/oauth/page.js +3 -2
- package/build/server.d.ts +1 -1
- package/build/server.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.3
|
|
4
|
+
|
|
5
|
+
The sign-in form works in a browser.
|
|
6
|
+
|
|
7
|
+
The page used `no-referrer`, so a browser posted `Origin: null` and no `Referer`. The server treated that as a cross-site submit even when `Sec-Fetch-Site` was `same-origin`. The form also omitted `response_type`, so the post redirected with `unsupported_response_type`. `Content-Security-Policy: form-action 'self'` can block the redirect to the client callback.
|
|
8
|
+
|
|
9
|
+
The form now includes hidden `response_type=code` plus `client_id`, `redirect_uri`, `state`, `code_challenge`, `code_challenge_method`, `scope`, and `resource`. The referrer policy is `same-origin`. A post with `Sec-Fetch-Site: same-origin` is accepted when `Origin` is missing or `null`. `cross-site` and `same-site` posts, and foreign origins, are still rejected. A post with no origin signal is still rejected. The page `form-action` allows the validated callback origin.
|
|
10
|
+
|
|
3
11
|
## 0.2.2
|
|
4
12
|
|
|
5
13
|
OAuth discovery and sign-in answer on the rewritten `/api/*` paths as well as the public paths.
|
package/README.md
CHANGED
|
@@ -475,7 +475,7 @@ Environment variables for the host:
|
|
|
475
475
|
|
|
476
476
|
The key check calls `GET /twitter/trends?woeid=1&count=1`. A real key is authenticated and then rejected as invalid input (HTTP 422), so the check does not run a full trends query. Only 422 counts as a valid key. `401` and `403` reject the key. Any other status, including a 2xx, is a verification error and is not treated as valid.
|
|
477
477
|
|
|
478
|
-
`POST /register` allows 10 requests an hour per IP. The sign-in key check allows 20 requests every 10 minutes per IP. A request past the limit returns 429 with `Retry-After`. On Vercel the address is the first `X-Forwarded-For` hop. The sign-in form accepts a same-origin `Origin` or `Referer`, and
|
|
478
|
+
`POST /register` allows 10 requests an hour per IP. The sign-in key check allows 20 requests every 10 minutes per IP. A request past the limit returns 429 with `Retry-After`. On Vercel the address is the first `X-Forwarded-For` hop. The sign-in page uses `Referrer-Policy: same-origin` and posts `response_type=code` with the other authorize fields. The form accepts a same-origin `Origin` or `Referer`, and accepts `Sec-Fetch-Site: same-origin` when `Origin` is missing or `null`. It rejects `Sec-Fetch-Site` `cross-site` and `same-site`, a foreign `Origin`, and a POST that has no origin signal.
|
|
479
479
|
|
|
480
480
|
### Use with Claude (custom connector)
|
|
481
481
|
|
package/build/oauth/flow.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function htmlResponse(status: number, html: string): Response;
|
|
1
|
+
export declare function htmlResponse(status: number, html: string, redirectUri?: string): Response;
|
|
2
2
|
export declare function oauthError(status: number, error: string, description: string): Response;
|
|
3
3
|
export declare function registerClient(request: Request): Promise<Response>;
|
|
4
4
|
export declare function showAuthorize(request: Request): Promise<Response>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../../oauth/flow.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../../oauth/flow.ts"],"names":[],"mappings":"AAuDA,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,QAAQ,CAQzF;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,QAAQ,CAQvF;AAyDD,wBAAsB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAqFxE;AAwFD,wBAAsB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAOvE;AAmCD,wBAAsB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CA0DzE;AAgED,wBAAsB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAmBvE;AAoDD,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAUhG"}
|
package/build/oauth/flow.js
CHANGED
|
@@ -9,12 +9,37 @@ const VERIFIER_PATTERN = /^[A-Za-z0-9\-._~]{43,128}$/;
|
|
|
9
9
|
const HTML_HEADERS = {
|
|
10
10
|
"Content-Type": "text/html; charset=utf-8",
|
|
11
11
|
"Cache-Control": "no-store",
|
|
12
|
-
"Referrer-Policy": "
|
|
12
|
+
"Referrer-Policy": "same-origin",
|
|
13
13
|
"X-Frame-Options": "DENY",
|
|
14
|
-
"Content-Security-Policy": "default-src 'none'; style-src 'unsafe-inline'; form-action 'self'; base-uri 'none'; frame-ancestors 'none'",
|
|
15
14
|
};
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
/**
|
|
16
|
+
* `form-action 'self'` blocks the 302 that follows a form POST in Chrome, so
|
|
17
|
+
* the sign-in page also allows the validated callback origin (claude.ai,
|
|
18
|
+
* chatgpt.com, or the loopback host and port).
|
|
19
|
+
*/
|
|
20
|
+
function contentSecurityPolicy(redirectUri) {
|
|
21
|
+
const targets = ["'self'"];
|
|
22
|
+
if (redirectUri && isAllowedRedirectUri(redirectUri)) {
|
|
23
|
+
try {
|
|
24
|
+
const origin = new URL(redirectUri).origin;
|
|
25
|
+
if (/^https?:\/\/[A-Za-z0-9.\[\]:-]+$/.test(origin)) {
|
|
26
|
+
targets.push(origin);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// The redirect was already rejected before a page is rendered.
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return `default-src 'none'; style-src 'unsafe-inline'; form-action ${targets.join(" ")}; base-uri 'none'; frame-ancestors 'none'`;
|
|
34
|
+
}
|
|
35
|
+
export function htmlResponse(status, html, redirectUri) {
|
|
36
|
+
return new Response(html, {
|
|
37
|
+
status,
|
|
38
|
+
headers: {
|
|
39
|
+
...HTML_HEADERS,
|
|
40
|
+
"Content-Security-Policy": contentSecurityPolicy(redirectUri),
|
|
41
|
+
},
|
|
42
|
+
});
|
|
18
43
|
}
|
|
19
44
|
export function oauthError(status, error, description) {
|
|
20
45
|
return new Response(JSON.stringify({ error, error_description: description }), {
|
|
@@ -209,16 +234,19 @@ export async function showAuthorize(request) {
|
|
|
209
234
|
if (context instanceof Response) {
|
|
210
235
|
return context;
|
|
211
236
|
}
|
|
212
|
-
return htmlResponse(200, authorizePage(context.fields));
|
|
237
|
+
return htmlResponse(200, authorizePage(context.fields), context.fields.redirectUri);
|
|
213
238
|
}
|
|
214
239
|
function authorizePostForbidden(request) {
|
|
215
240
|
const fetchSite = request.headers.get("sec-fetch-site")?.trim().toLowerCase() ?? "";
|
|
216
|
-
if (fetchSite === "cross-site") {
|
|
241
|
+
if (fetchSite === "cross-site" || fetchSite === "same-site") {
|
|
217
242
|
return htmlResponse(400, messagePage("Connect Desearch", "This sign-in form was sent from another site."));
|
|
218
243
|
}
|
|
219
244
|
const expected = publicOrigin(request);
|
|
220
|
-
const origin = request.headers.get("origin")?.trim();
|
|
221
|
-
|
|
245
|
+
const origin = request.headers.get("origin")?.trim() ?? "";
|
|
246
|
+
// `no-referrer` made browsers send the literal Origin "null". Treat that
|
|
247
|
+
// as a missing origin. A same-origin Sec-Fetch-Site is enough on its own.
|
|
248
|
+
const originMissing = origin.length === 0 || origin.toLowerCase() === "null";
|
|
249
|
+
if (!originMissing) {
|
|
222
250
|
if (origin.replace(/\/+$/, "") !== expected) {
|
|
223
251
|
return htmlResponse(400, messagePage("Connect Desearch", "This sign-in form was sent from another site."));
|
|
224
252
|
}
|
|
@@ -236,10 +264,10 @@ function authorizePostForbidden(request) {
|
|
|
236
264
|
}
|
|
237
265
|
return null;
|
|
238
266
|
}
|
|
239
|
-
if (
|
|
240
|
-
return
|
|
267
|
+
if (fetchSite === "same-origin") {
|
|
268
|
+
return null;
|
|
241
269
|
}
|
|
242
|
-
return
|
|
270
|
+
return htmlResponse(403, messagePage("Connect Desearch", "This sign-in form did not come from this site."));
|
|
243
271
|
}
|
|
244
272
|
export async function submitAuthorize(request) {
|
|
245
273
|
const forbidden = authorizePostForbidden(request);
|
|
@@ -274,7 +302,7 @@ export async function submitAuthorize(request) {
|
|
|
274
302
|
const apiKey = (form.get("api_key") ?? "").trim();
|
|
275
303
|
const checked = await checkDesearchApiKey(apiKey);
|
|
276
304
|
if (!checked.ok) {
|
|
277
|
-
return htmlResponse(400, authorizePage({ ...fields, error: checked.message }));
|
|
305
|
+
return htmlResponse(400, authorizePage({ ...fields, error: checked.message }), fields.redirectUri);
|
|
278
306
|
}
|
|
279
307
|
const code = randomToken(AUTH_CODE_PREFIX, 32);
|
|
280
308
|
const store = await getOAuthStore();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../oauth/page.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,mBAAmB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../oauth/page.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,mBAAmB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAmEjE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAqBlE"}
|
package/build/oauth/page.js
CHANGED
|
@@ -13,6 +13,7 @@ export function authorizePage(fields) {
|
|
|
13
13
|
? `<p class="error" role="alert">${escapeHtml(fields.error)}</p>`
|
|
14
14
|
: "";
|
|
15
15
|
const hidden = [
|
|
16
|
+
["response_type", "code"],
|
|
16
17
|
["client_id", fields.clientId],
|
|
17
18
|
["redirect_uri", fields.redirectUri],
|
|
18
19
|
["state", fields.state],
|
|
@@ -28,7 +29,7 @@ export function authorizePage(fields) {
|
|
|
28
29
|
<head>
|
|
29
30
|
<meta charset="utf-8">
|
|
30
31
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
31
|
-
<meta name="referrer" content="
|
|
32
|
+
<meta name="referrer" content="same-origin">
|
|
32
33
|
<meta name="robots" content="noindex">
|
|
33
34
|
<title>Connect Desearch</title>
|
|
34
35
|
<style>
|
|
@@ -74,7 +75,7 @@ export function messagePage(title, message) {
|
|
|
74
75
|
<head>
|
|
75
76
|
<meta charset="utf-8">
|
|
76
77
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
77
|
-
<meta name="referrer" content="
|
|
78
|
+
<meta name="referrer" content="same-origin">
|
|
78
79
|
<meta name="robots" content="noindex">
|
|
79
80
|
<title>${escapeHtml(title)}</title>
|
|
80
81
|
<style>
|
package/build/server.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { type PeopleClient } from "./people.js";
|
|
3
3
|
export declare const SERVER_NAME = "Desearch";
|
|
4
|
-
export declare const SERVER_VERSION = "0.2.
|
|
4
|
+
export declare const SERVER_VERSION = "0.2.3";
|
|
5
5
|
interface XSearchPayload {
|
|
6
6
|
query: string;
|
|
7
7
|
sort?: "Top" | "Latest";
|
package/build/server.js
CHANGED
|
@@ -5,7 +5,7 @@ import { z } from "zod";
|
|
|
5
5
|
import { PEOPLE_CONTROL_ACTIONS, PEOPLE_FILTER_CHANNELS, PEOPLE_PLATFORMS, PEOPLE_PROFILE_SORTS, PEOPLE_SEARCH_FILTERS, PEOPLE_TASK_STATUSES, controlPeopleTask, createPeopleClient, listPeopleProfiles, listPeopleTasks, readPeopleStatus, startPeopleSearch, } from "./people.js";
|
|
6
6
|
import { AI_SEARCH_TOOLS, WEB_LINK_TOOLS, toolIdSchema } from "./tool-sources.js";
|
|
7
7
|
export const SERVER_NAME = "Desearch";
|
|
8
|
-
export const SERVER_VERSION = "0.2.
|
|
8
|
+
export const SERVER_VERSION = "0.2.3";
|
|
9
9
|
// desearch-js 1.5 publishes a default class. Node16 resolution types that package
|
|
10
10
|
// as a module namespace, so the constructor is applied through a cast.
|
|
11
11
|
const Desearch = DesearchImport;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "desearch-mcp-server",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"mcpName": "io.github.Desearch-ai/mcp-desearch",
|
|
5
5
|
"description": "AI search (web, Reddit, Hacker News, arXiv, Wikipedia, and Twitter), X (Twitter) search, web search, page extraction, X data, and People Search (find people and creators on X, YouTube, LinkedIn, and TikTok) tools for AI agents.",
|
|
6
6
|
"license": "MIT",
|