desearch-mcp-server 0.2.1 → 0.2.2

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.2
4
+
5
+ OAuth discovery and sign-in answer on the rewritten `/api/*` paths as well as the public paths.
6
+
7
+ Vercel rewrites `/.well-known/oauth-protected-resource`, `/.well-known/oauth-protected-resource/mcp`, `/.well-known/oauth-authorization-server`, `/.well-known/openid-configuration`, `/register`, `/authorize`, and `/token` to `/api/oauth-protected-resource`, `/api/oauth-protected-resource-mcp`, `/api/oauth-authorization-server`, `/api/openid-configuration`, `/api/oauth-register`, `/api/oauth-authorize`, and `/api/oauth-token`. A Node framework project serves `index.ts` and does not run the `api/*.js` wrappers, so those rewritten paths were 404. The handler now treats each rewritten path as the matching public route. Issuer, resource, and metadata URLs stay on the public paths.
8
+
3
9
  ## 0.2.1
4
10
 
5
11
  Remote MCP OAuth 2.1 and per-IP rate limits, on top of the 0.2.0 People Search tools. `search` and `fetch` are included for clients that look up a page by query and then read it.
package/README.md CHANGED
@@ -552,7 +552,7 @@ docker run --rm -e MCP_TRANSPORT=http -p 3000:3000 desearch-mcp
552
552
 
553
553
  ### Deploy on Vercel
554
554
 
555
- Vercel fits the MCP handler because each JSON-RPC call is one response. `vercel.json` builds the project, serves `POST /mcp`, and sets the function duration to 60 seconds. Hobby plans cap function duration lower than that, so AI Search tool calls need a plan that allows at least 60 seconds. `initialize` and `tools/list` are short either way.
555
+ Vercel fits the MCP handler because each JSON-RPC call is one response. `vercel.json` builds the project, serves `POST /mcp`, and sets the function duration to 60 seconds. The same file rewrites the public OAuth paths to `/api/*`. The server accepts those rewritten paths and the public paths, and the metadata documents still advertise the public paths. Hobby plans cap function duration lower than that, so AI Search tool calls need a plan that allows at least 60 seconds. `initialize` and `tools/list` are short either way.
556
556
 
557
557
  OAuth codes and tokens need shared storage. On Vercel set `OAUTH_STORE=redis`, `REDIS_URL`, `OAUTH_ENCRYPTION_KEY`, and `OAUTH_ISSUER=https://mcp.desearch.ai`. The server refuses OAuth when `OAUTH_ISSUER` is unset or `OAUTH_STORE` is not `redis`, because Vercel sets `VERCEL` on every function. `OAUTH_REQUIRE_AUTH_ON_INITIALIZE=true` is optional. Leave it unset unless a client treats public `initialize` as a reason to skip sign-in.
558
558
 
@@ -2,6 +2,7 @@ import { wwwAuthenticate } from "./metadata.js";
2
2
  export { resetOAuthForTests } from "./store.js";
3
3
  export { setApiKeyCheckerForTests, validateDesearchApiKey } from "./validate-key.js";
4
4
  export { wwwAuthenticate };
5
+ export declare function canonicalOAuthPath(pathname: string): string | null;
5
6
  export declare function isOAuthPath(pathname: string): boolean;
6
7
  export declare function isOAuthMaterial(value: string): boolean;
7
8
  export type RequestCredential = {
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../oauth/http.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0D,eAAe,EAAE,MAAM,eAAe,CAAC;AAKxG,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,CAAC;AAY3B,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAErD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAMtD;AAED,MAAM,MAAM,iBAAiB,GACvB;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,GACxB;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC;AAE9B;;;;GAIG;AACH,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA0B3F;AAuBD,wBAAsB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CA8DhF"}
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../oauth/http.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0D,eAAe,EAAE,MAAM,eAAe,CAAC;AAKxG,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,CAAC;AA6B3B,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMlE;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAErD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAMtD;AAED,MAAM,MAAM,iBAAiB,GACvB;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,GACxB;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC;AAE9B;;;;GAIG;AACH,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA0B3F;AAuBD,wBAAsB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CA8DhF"}
@@ -16,8 +16,31 @@ const OAUTH_PATHS = new Set([
16
16
  "/authorize",
17
17
  "/token",
18
18
  ]);
19
+ /**
20
+ * `vercel.json` rewrites the public OAuth paths to these destinations before
21
+ * the request reaches the process. The `api/*.js` wrappers map them back, but
22
+ * a Node framework project uses `index.ts` as the only entry and never runs
23
+ * those wrappers. Accept the rewritten paths here so both setups work.
24
+ * Metadata URLs still advertise the public paths.
25
+ */
26
+ const OAUTH_REWRITTEN_PATHS = {
27
+ "/api/oauth-protected-resource": "/.well-known/oauth-protected-resource",
28
+ "/api/oauth-protected-resource-mcp": "/.well-known/oauth-protected-resource/mcp",
29
+ "/api/oauth-authorization-server": "/.well-known/oauth-authorization-server",
30
+ "/api/openid-configuration": "/.well-known/openid-configuration",
31
+ "/api/oauth-register": "/register",
32
+ "/api/oauth-authorize": "/authorize",
33
+ "/api/oauth-token": "/token",
34
+ };
35
+ export function canonicalOAuthPath(pathname) {
36
+ const normalized = pathname.length > 1 ? pathname.replace(/\/+$/, "") : pathname;
37
+ if (OAUTH_PATHS.has(normalized)) {
38
+ return normalized;
39
+ }
40
+ return OAUTH_REWRITTEN_PATHS[normalized] ?? null;
41
+ }
19
42
  export function isOAuthPath(pathname) {
20
- return OAUTH_PATHS.has(pathname);
43
+ return canonicalOAuthPath(pathname) !== null;
21
44
  }
22
45
  export function isOAuthMaterial(value) {
23
46
  return (value.startsWith(ACCESS_TOKEN_PREFIX) ||
@@ -75,8 +98,8 @@ function methodNotAllowed(allow) {
75
98
  });
76
99
  }
77
100
  export async function handleOAuthHttp(request) {
78
- const pathname = new URL(request.url).pathname.replace(/\/+$/, "") || "/";
79
- if (!isOAuthPath(pathname)) {
101
+ const pathname = canonicalOAuthPath(new URL(request.url).pathname);
102
+ if (!pathname) {
80
103
  return null;
81
104
  }
82
105
  try {
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.1";
4
+ export declare const SERVER_VERSION = "0.2.2";
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.1";
8
+ export const SERVER_VERSION = "0.2.2";
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.1",
3
+ "version": "0.2.2",
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",