desearch-mcp-server 0.1.3 → 0.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0
4
+
5
+ People Search tools. Release this version only after People Search is live on `api.desearch.ai`; until then the new tools return the API's HTTP error.
6
+
7
+ People Search finds X profiles, YouTube creators, LinkedIn members, or TikTok creators who match a plain-language description. desearch-js 1.5 has no People Search methods, so `people.ts` calls the `/desearch/people/*` routes directly with the same key header.
8
+
9
+ | Tool | Route | Billed |
10
+ | --- | --- | --- |
11
+ | `people-search` | `POST /desearch/people/search/{x,youtube,linkedin,tiktok}` | Yes. Reserves `count` people at the platform's per-person price and settles to the people delivered (minimum per search; nothing when it finds no one). |
12
+ | `people-search-status` | `GET /desearch/people/tasks/{id}` and `GET /desearch/people/tasks/{id}/results` | No |
13
+ | `people-search-control` | `POST /desearch/people/tasks/{id}/pause`, `/resume`, `/cancel` | No |
14
+ | `people-search-tasks` | `GET /desearch/people/tasks` | No |
15
+ | `people-profiles` | `GET /desearch/people/profiles` | No |
16
+
17
+ - `people-search` takes each platform's filters as top-level arguments and rejects a filter that does not apply to the chosen platform before the billed call. `idempotency_key` is sent as `Idempotency-Key`, so a retry returns the first task instead of starting a second search.
18
+ - `people-search-status` returns compact people (name, handle, url, platform, audience, location, score, why they matched, contacts, links) and a `next_cursor` that returns only people found since the previous call.
19
+ - Every people tool returns a `next` line that says what to call next.
20
+ - People tools reject unknown arguments, so a misspelled or nested filter is not dropped from a billed search.
21
+ - The `/export` CSV and JSON Lines routes are not tools.
22
+
23
+ ### Tool annotations
24
+
25
+ The 15 existing tools keep `readOnlyHint: true`, `destructiveHint: false`, `openWorldHint: true`. So do `people-search-status`, `people-search-tasks`, and `people-profiles`.
26
+
27
+ - `people-search`: `readOnlyHint: false`, `destructiveHint: false`, `idempotentHint: false`. It creates a billed task.
28
+ - `people-search-control`: `readOnlyHint: false`, `destructiveHint: true` (cancel cannot be undone), `idempotentHint: true`.
29
+
30
+ ## 0.1.4
31
+
32
+ `ai-search` tools enum drops `youtube`. Allowed ids are `web`, `twitter`, `arxiv`, `wikipedia`, `hackernews`, and `reddit`.
33
+
3
34
  ## 0.1.3
4
35
 
5
36
  Tool copy no longer states unsourced speed or latency.
package/README.md CHANGED
@@ -1,14 +1,63 @@
1
1
  # Desearch MCP Server
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/desearch-mcp-server.svg)](https://www.npmjs.com/package/desearch-mcp-server)
4
+ [![GitHub stars](https://img.shields.io/github/stars/Desearch-ai/mcp-desearch?style=social)](https://github.com/Desearch-ai/mcp-desearch/stargazers)
4
5
 
5
- AI search, X search and web search for AI agents, plus page extraction and X data tools. Bring your own Desearch API key.
6
+ If Desearch is useful, a [star](https://github.com/Desearch-ai/mcp-desearch/stargazers) helps others find it.
7
+
8
+ Remote: `https://mcp.desearch.ai/mcp` with header `Authorization: Bearer <DESEARCH_API_KEY>`.
9
+
10
+ Local: `npx -y desearch-mcp-server` with env `DESEARCH_API_KEY`.
11
+
12
+ [Get a key](https://console.desearch.ai/api-keys).
13
+
14
+ ## Find Desearch on
15
+
16
+ - [Official MCP Registry](https://registry.modelcontextprotocol.io/v0/servers?search=io.github.Desearch-ai/mcp-desearch)
17
+ - [Smithery](https://smithery.ai/servers/desearch/desearch)
18
+ - [Glama](https://glama.ai/mcp/servers/Desearch-ai/mcp-desearch)
19
+ - [VoltAgent official MCP servers](https://github.com/VoltAgent/official-mcp-servers#search-and-research)
20
+ - [Gemini CLI extensions](https://geminicli.com/extensions/)
21
+ - [Raycast MCP Registry](https://www.raycast.com/raycast/model-context-protocol-registry)
22
+
23
+ ## Demo
24
+
25
+ Prompt: Search the web for latest news on AI.
26
+
27
+ `web-search` takes `query` (required) and `start` (optional pagination offset: 0, 10, 20, ...).
28
+
29
+ ```json
30
+ {
31
+ "name": "web-search",
32
+ "arguments": {
33
+ "query": "latest news on AI"
34
+ }
35
+ }
36
+ ```
37
+
38
+ Example output:
39
+
40
+ ```json
41
+ {
42
+ "data": [
43
+ {
44
+ "title": "Example result",
45
+ "link": "https://example.com/page",
46
+ "snippet": "Short preview text."
47
+ }
48
+ ]
49
+ }
50
+ ```
51
+
52
+ The tool returns that JSON as pretty-printed text: `{ "content": [{ "type": "text", "text": "<json above>" }] }`.
53
+
54
+ AI search, X search and web search for AI agents, plus page extraction, X data tools, and People Search (find people and creators on X, YouTube, LinkedIn, and TikTok). Bring your own Desearch API key.
6
55
 
7
56
  ## Tools
8
57
 
9
58
  The Desearch MCP server includes the following tools:
10
59
 
11
- - **AI Search** (`ai-search`): Performs AI Twitter and web searches with relevant links and summary. `tools` uses short source ids (`web`, `twitter`, `arxiv`, `wikipedia`, `youtube`, `hackernews`, `reddit`). Older labels such as `Web Search` are still accepted and sent to the API as the short id. Default is `["web", "twitter"]`.
60
+ - **AI Search** (`ai-search`): Performs AI Twitter and web searches with relevant links and summary. `tools` uses short source ids (`web`, `twitter`, `arxiv`, `wikipedia`, `hackernews`, `reddit`). Older labels such as `Web Search`, `ArXiv Search`, `Wikipedia Search`, `Hacker News Search`, and `Reddit Search` are still accepted and sent as the short id. `youtube` is not accepted. Default is `["web", "twitter"]`.
12
61
  - **X Search** (`x-search`): Tweet search on X. Arguments: `query` (required), `count` (optional, default 20). Sort stays Top. Optional filters: `user`, `start_date`, `end_date` (YYYY-MM-DD), `lang`, `verified`, `blue_verified`, `is_quote`, `is_video`, `is_image`, `min_retweets`, `min_replies`, `min_likes`.
13
62
  - **Web Search** (`web-search`): SERP-style web search. Arguments: `query` (required), `start` (optional pagination offset).
14
63
  - **Web Links Search** (`web-links-search`): Web link search. Arguments: `prompt` (required), `tools` (optional, only `web`, default `["web"]`; `Web Search` is accepted and rewritten to `web`), `count` (optional, 10–200). The links/web API rejects other sources, so they are not in the enum.
@@ -23,8 +72,108 @@ The Desearch MCP server includes the following tools:
23
72
  - **X User Replies** (`x-user-replies`): Posts and replies by a user. Arguments: `user` (required), `count` (optional, 1–100), `query` (optional).
24
73
  - **X Post Replies** (`x-post-replies`): Replies to a post. Arguments: `post_id` (required), `count` (optional, 1–100), `query` (optional).
25
74
  - **X Trends** (`x-trends`): Trending topics for a location. Arguments: `woeid` (required), `count` (optional, 30–100).
75
+ - **People Search** (`people-search`): Start a search for people who match a plain-language description. **Billed.** Arguments: `platform` (required: `x`, `youtube`, `linkedin`, or `tiktok`), `query` (required, 3–1000 characters), `count` (optional, 5–200, API default 25), `min_score` (optional, 0–100), `exclude` (optional handles), `idempotency_key` (optional), and that platform's filters (below). Returns the `task_id`, status, and `reserved_cost_usd`.
76
+ - **People Search Status** (`people-search-status`): A task's status, progress, and cost, plus a page of the people found so far. Arguments: `task_id` (required), `cursor` (optional, `next_cursor` from the previous call), `limit` (optional, 1–100, default 25), `include_people` (optional, default `true`). Free.
77
+ - **Control People Search** (`people-search-control`): Pause, resume, or cancel a task. Arguments: `task_id` (required), `action` (required: `pause`, `resume`, or `cancel`). Free.
78
+ - **List People Search Tasks** (`people-search-tasks`): Your searches, newest first. Arguments: `platform` (optional), `status` (optional list, for example `["running", "paused"]`), `limit` (optional, 1–100), `cursor` (optional). Free.
79
+ - **List People Found** (`people-profiles`): Everyone your searches found on one platform, one entry per person, with the search that found them. Arguments: `platform` (required), `q` (optional text in name, handle, bio, or location), `sort` (optional: `score`, `recent`, or `audience`), `limit` (optional, 1–200, default 25), `cursor` (optional), and the filters `has` (channels every person must have: `email`, `website`, `x`, `linkedin`, `instagram`, `youtube`, `tiktok`), `min_audience`, `max_audience`, `min_score`, `location`, `verified`. Free.
80
+
81
+ The full SDK method → endpoint → MCP tool map is in [docs/API_MCP_PARITY.md](docs/API_MCP_PARITY.md). Every public `desearch-js` 1.5 method is a tool. `latestTweets` was removed from the SDK (`GET /twitter/latest` in 1.0.1) and is not exposed. People Search is not in `desearch-js` 1.5; its tools call the `/desearch/people/*` routes directly, and the parity doc lists them too.
82
+
83
+ ### People Search
84
+
85
+ People Search finds X profiles, YouTube creators, LinkedIn members, or TikTok creators who match a plain-language description. Each person comes back with a fit score, one line on why they matched, their audience (followers, or subscribers on YouTube), location, and the public contacts and links the search found.
86
+
87
+ A search is a background task:
88
+
89
+ 1. `people-search` starts it and returns a `task_id` at once. It is the only billed People Search call. It reserves `count` people at the platform's per-person price (`reserved_cost_usd`). When the search ends you pay only for the people it delivered (a per-search minimum applies when it finds anyone; a search that finds no one is free), and the rest of the reservation is returned. Send the same `idempotency_key` to retry a call without starting, or paying for, a second search.
90
+ 2. The search usually runs for 1 to 5 minutes. `people-search-status` returns its status, progress, cost, and the people found so far. People arrive while it runs: pass `next_cursor` back as `cursor` to get only the new ones. When `done` is `true` and `has_more` is `false`, you have everyone it found.
91
+ 3. `people-search-control` pauses, resumes, or cancels it. A cancelled search bills only the people it already delivered.
92
+
93
+ People found stay readable for 30 days after a search ends. `people-profiles` lists them per platform across all your searches, with filters such as `has: ["email"]`.
26
94
 
27
- The full SDK method → endpoint → MCP tool map is in [docs/API_MCP_PARITY.md](docs/API_MCP_PARITY.md). Every public `desearch-js` 1.5 method is a tool. `latestTweets` was removed from the SDK (`GET /twitter/latest` in 1.0.1) and is not exposed.
95
+ Search filters depend on the platform. A filter that does not apply is rejected before the billed call.
96
+
97
+ | Platform | Filters |
98
+ | --- | --- |
99
+ | `x` | `min_followers`, `max_followers`, `verified_only`, `countries`, `keywords`, `exclude_keywords` |
100
+ | `youtube` | `min_subscribers`, `max_subscribers`, `countries`, `require_contact`, `keywords`, `exclude_keywords` |
101
+ | `linkedin` | `min_followers`, `max_followers`, `countries`, `keywords`, `exclude_keywords` |
102
+ | `tiktok` | `min_followers`, `max_followers`, `require_contact`, `keywords`, `exclude_keywords` |
103
+
104
+ `require_contact` keeps only creators with a public email (on TikTok, in the bio). `keywords` and `exclude_keywords` take up to 20 words each.
105
+
106
+ Prompt: find 10 TikTok skincare creators with a public email.
107
+
108
+ ```json
109
+ {
110
+ "name": "people-search",
111
+ "arguments": {
112
+ "platform": "tiktok",
113
+ "query": "Skincare creators who review skincare products",
114
+ "count": 10,
115
+ "require_contact": true
116
+ }
117
+ }
118
+ ```
119
+
120
+ Example output:
121
+
122
+ ```json
123
+ {
124
+ "task_id": "3f1c2b9e-8d4a-4c1e-9b7a-2e5f6a7b8c9d",
125
+ "platform": "tiktok",
126
+ "status": "queued",
127
+ "done": false,
128
+ "query": "Skincare creators who review skincare products",
129
+ "count": 10,
130
+ "result_count": 0,
131
+ "reserved_cost_usd": 0.5,
132
+ "created_at": "2026-10-17T10:00:00Z",
133
+ "cost_usd": 0.5,
134
+ "currency": "USD",
135
+ "next": "Searches usually take 1 to 5 minutes. Poll people-search-status with this task_id every 15 to 30 seconds; people appear while it runs."
136
+ }
137
+ ```
138
+
139
+ Then poll with `{"task_id": "3f1c2b9e-8d4a-4c1e-9b7a-2e5f6a7b8c9d"}` on `people-search-status`:
140
+
141
+ ```json
142
+ {
143
+ "task_id": "3f1c2b9e-8d4a-4c1e-9b7a-2e5f6a7b8c9d",
144
+ "platform": "tiktok",
145
+ "status": "running",
146
+ "stage": "processing",
147
+ "done": false,
148
+ "query": "Skincare creators who review skincare products",
149
+ "count": 10,
150
+ "result_count": 4,
151
+ "progress": { "round": 1, "candidates_processed": 40, "qualified": 4 },
152
+ "reserved_cost_usd": 0.5,
153
+ "created_at": "2026-10-17T10:00:00Z",
154
+ "people": [
155
+ {
156
+ "id": "tiktok:example_creator",
157
+ "platform": "tiktok",
158
+ "handle": "example_creator",
159
+ "name": "Example Creator",
160
+ "url": "https://www.tiktok.com/@example_creator",
161
+ "audience": 48200,
162
+ "location": "United States",
163
+ "score": 88,
164
+ "why": "Reviews sunscreens and moisturizers every week.",
165
+ "contacts": [{ "type": "email", "value": "creator@example.com" }],
166
+ "links": [{ "type": "instagram", "url": "https://instagram.com/example_creator" }],
167
+ "evidence_url": "https://www.tiktok.com/@example_creator/video/1"
168
+ }
169
+ ],
170
+ "next_cursor": "4",
171
+ "has_more": false,
172
+ "next": "Still searching. Wait 15 to 30 seconds, then call people-search-status again with cursor \"4\" to get only the people found since this call."
173
+ }
174
+ ```
175
+
176
+ The output above is shortened to one person. CSV and JSON Lines downloads (`/export` routes) are not MCP tools; call the API directly for a file.
28
177
 
29
178
  ## Prerequisites 📋
30
179
 
@@ -37,7 +186,7 @@ The full SDK method → endpoint → MCP tool map is in [docs/API_MCP_PARITY.md]
37
186
 
38
187
  ### NPM Installation
39
188
 
40
- The package name is `desearch-mcp-server`. The first npm publish of this tree is `0.1.2` (the registry still has `0.0.1`). See [CHANGELOG.md](CHANGELOG.md) for the 0.0.1 → 0.1.2 migration. The stdio entry is the `desearch-mcp-server` bin (`build/index.js`), which requires `DESEARCH_API_KEY`.
189
+ The package name is `desearch-mcp-server`. The current version is on [npm](https://www.npmjs.com/package/desearch-mcp-server). See [CHANGELOG.md](CHANGELOG.md) for release notes. The stdio entry is the `desearch-mcp-server` bin (`build/index.js`), which requires `DESEARCH_API_KEY`.
41
190
 
42
191
  ```bash
43
192
  npm install -g desearch-mcp-server
@@ -67,6 +216,16 @@ Cursor or Claude can start that bin directly:
67
216
 
68
217
  `command: "desearch-mcp-server"` (no `args`) is the same entry after the global install above.
69
218
 
219
+ ### Gemini CLI
220
+
221
+ Install the extension from this repository. Gemini CLI asks for your Desearch API key (stored as a sensitive setting) and connects to the hosted server `https://mcp.desearch.ai/mcp`:
222
+
223
+ ```bash
224
+ gemini extensions install https://github.com/Desearch-ai/mcp-desearch
225
+ ```
226
+
227
+ To change the key later, run `gemini extensions config desearch`. AI agents such as Cline can follow [llms-install.md](llms-install.md) to set up the server.
228
+
70
229
  ### Using Smithery
71
230
 
72
231
  To install the Desearch MCP server for Claude Desktop automatically via [Smithery](https://smithery.ai/servers/desearch/desearch):
@@ -0,0 +1,125 @@
1
+ /**
2
+ * People Search on the Desearch API (`/desearch/people/*`).
3
+ *
4
+ * desearch-js 1.5 has no People Search methods, so this module calls the routes
5
+ * directly with the same base URL, `Authorization: <key>` header, and
6
+ * `HTTP <status>: <detail>` error text that desearch-js uses.
7
+ *
8
+ * - `POST /desearch/people/search/{platform}` starts a background search and is billed:
9
+ * it reserves `count` people at the route price and settles to what it delivers.
10
+ * - Every other route (tasks, results, pause/resume/cancel, profiles) is free.
11
+ */
12
+ export declare const PEOPLE_API_BASE_URL = "https://api.desearch.ai";
13
+ export declare const PEOPLE_PLATFORMS: readonly ["x", "youtube", "linkedin", "tiktok"];
14
+ export type PeoplePlatform = (typeof PEOPLE_PLATFORMS)[number];
15
+ export declare const PEOPLE_TASK_STATUSES: readonly ["queued", "running", "pausing", "paused", "cancelling", "completed", "partial", "failed", "cancelled", "expired"];
16
+ /** Statuses after which a task does not change again. */
17
+ export declare const PEOPLE_ENDED_STATUSES: ReadonlySet<string>;
18
+ /** `has` channels on `GET /desearch/people/profiles` (src/utils/people_filters.py). */
19
+ export declare const PEOPLE_FILTER_CHANNELS: readonly ["email", "website", "x", "linkedin", "instagram", "youtube", "tiktok"];
20
+ export declare const PEOPLE_PROFILE_SORTS: readonly ["score", "recent", "audience"];
21
+ export declare const PEOPLE_CONTROL_ACTIONS: readonly ["pause", "resume", "cancel"];
22
+ export type PeopleControlAction = (typeof PEOPLE_CONTROL_ACTIONS)[number];
23
+ /**
24
+ * Search filters each platform accepts inside the request `filters` object.
25
+ * The API forbids extra keys, so a filter that is not listed for a platform
26
+ * is rejected before the billed call instead of returning HTTP 422.
27
+ */
28
+ export declare const PEOPLE_SEARCH_FILTERS: {
29
+ readonly x: readonly ["min_followers", "max_followers", "verified_only", "countries", "keywords", "exclude_keywords"];
30
+ readonly youtube: readonly ["min_subscribers", "max_subscribers", "countries", "require_contact", "keywords", "exclude_keywords"];
31
+ readonly linkedin: readonly ["min_followers", "max_followers", "countries", "keywords", "exclude_keywords"];
32
+ readonly tiktok: readonly ["min_followers", "max_followers", "require_contact", "keywords", "exclude_keywords"];
33
+ };
34
+ export declare const PEOPLE_SEARCH_FILTER_NAMES: readonly ["min_followers", "max_followers", "min_subscribers", "max_subscribers", "verified_only", "require_contact", "countries", "keywords", "exclude_keywords"];
35
+ export interface PeopleSearchArgs {
36
+ platform: PeoplePlatform;
37
+ query: string;
38
+ count?: number;
39
+ min_score?: number;
40
+ exclude?: string[];
41
+ idempotency_key?: string;
42
+ min_followers?: number;
43
+ max_followers?: number;
44
+ min_subscribers?: number;
45
+ max_subscribers?: number;
46
+ verified_only?: boolean;
47
+ require_contact?: boolean;
48
+ countries?: string[];
49
+ keywords?: string[];
50
+ exclude_keywords?: string[];
51
+ }
52
+ export interface PeopleApiResponse {
53
+ status: number;
54
+ data: unknown;
55
+ }
56
+ type QueryValue = string | number | boolean | undefined;
57
+ export interface PeopleClient {
58
+ startSearch(platform: PeoplePlatform, body: Record<string, unknown>, idempotencyKey?: string): Promise<PeopleApiResponse>;
59
+ getTask(taskId: string): Promise<unknown>;
60
+ getResults(taskId: string, params: {
61
+ cursor?: string;
62
+ limit?: number;
63
+ }): Promise<unknown>;
64
+ controlTask(taskId: string, action: PeopleControlAction): Promise<unknown>;
65
+ listTasks(params: Record<string, QueryValue>): Promise<unknown>;
66
+ listProfiles(params: Record<string, QueryValue>): Promise<unknown>;
67
+ }
68
+ export declare function createPeopleClient(apiKey: string, baseUrl?: string): PeopleClient;
69
+ /**
70
+ * Request body for `POST /desearch/people/search/{platform}`.
71
+ * Throws when a filter does not apply to the platform, so no billed call is made.
72
+ */
73
+ export declare function peopleSearchBody(args: PeopleSearchArgs): Record<string, unknown>;
74
+ /**
75
+ * One person as an agent needs it: who they are, how big their audience is,
76
+ * how well they fit and why, and how to reach them.
77
+ */
78
+ export declare function compactPerson(person: unknown): Record<string, unknown>;
79
+ /** Task fields an agent polls on. `progress` is the worker's counters, passed through. */
80
+ export declare function compactTask(task: unknown, options?: {
81
+ progress?: boolean;
82
+ }): Record<string, unknown>;
83
+ /**
84
+ * One sentence on what to do next, so an agent does not have to infer it from the status.
85
+ * `nextCursor` is the results cursor when the caller just read a page of people.
86
+ */
87
+ export declare function peopleNextStep(status: string | undefined, nextCursor?: string, hasMore?: boolean): string;
88
+ /** `people-search`: start a billed background search and return the task to poll. */
89
+ export declare function startPeopleSearch(client: PeopleClient, args: PeopleSearchArgs): Promise<Record<string, unknown>>;
90
+ /** `people-search-status`: task status and progress, plus a page of people when there are any. */
91
+ export declare function readPeopleStatus(client: PeopleClient, args: {
92
+ task_id: string;
93
+ cursor?: string;
94
+ limit?: number;
95
+ include_people?: boolean;
96
+ }): Promise<Record<string, unknown>>;
97
+ /** `people-search-control`: pause, resume, or cancel a task. */
98
+ export declare function controlPeopleTask(client: PeopleClient, args: {
99
+ task_id: string;
100
+ action: PeopleControlAction;
101
+ }): Promise<Record<string, unknown>>;
102
+ /** `people-search-tasks`: the caller's tasks, newest first. */
103
+ export declare function listPeopleTasks(client: PeopleClient, args: {
104
+ platform?: PeoplePlatform;
105
+ status?: string[];
106
+ limit?: number;
107
+ cursor?: string;
108
+ }): Promise<Record<string, unknown>>;
109
+ export interface PeopleProfilesArgs {
110
+ platform: PeoplePlatform;
111
+ q?: string;
112
+ sort?: (typeof PEOPLE_PROFILE_SORTS)[number];
113
+ limit?: number;
114
+ cursor?: string;
115
+ has?: string[];
116
+ min_audience?: number;
117
+ max_audience?: number;
118
+ min_score?: number;
119
+ location?: string;
120
+ verified?: boolean;
121
+ }
122
+ /** `people-profiles`: everyone the caller's searches found on one platform. */
123
+ export declare function listPeopleProfiles(client: PeopleClient, args: PeopleProfilesArgs): Promise<Record<string, unknown>>;
124
+ export {};
125
+ //# sourceMappingURL=people.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"people.d.ts","sourceRoot":"","sources":["../people.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,mBAAmB,4BAA4B,CAAC;AAE7D,eAAO,MAAM,gBAAgB,iDAAkD,CAAC;AAChF,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE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AK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,+EAA+E;AAC/E,wBAAsB,kBAAkB,CACpC,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,kBAAkB,GACzB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAqBlC"}
@@ -0,0 +1,402 @@
1
+ import { fetch } from "undici";
2
+ /**
3
+ * People Search on the Desearch API (`/desearch/people/*`).
4
+ *
5
+ * desearch-js 1.5 has no People Search methods, so this module calls the routes
6
+ * directly with the same base URL, `Authorization: <key>` header, and
7
+ * `HTTP <status>: <detail>` error text that desearch-js uses.
8
+ *
9
+ * - `POST /desearch/people/search/{platform}` starts a background search and is billed:
10
+ * it reserves `count` people at the route price and settles to what it delivers.
11
+ * - Every other route (tasks, results, pause/resume/cancel, profiles) is free.
12
+ */
13
+ export const PEOPLE_API_BASE_URL = "https://api.desearch.ai";
14
+ export const PEOPLE_PLATFORMS = ["x", "youtube", "linkedin", "tiktok"];
15
+ export const PEOPLE_TASK_STATUSES = [
16
+ "queued",
17
+ "running",
18
+ "pausing",
19
+ "paused",
20
+ "cancelling",
21
+ "completed",
22
+ "partial",
23
+ "failed",
24
+ "cancelled",
25
+ "expired",
26
+ ];
27
+ /** Statuses after which a task does not change again. */
28
+ export const PEOPLE_ENDED_STATUSES = new Set([
29
+ "completed",
30
+ "partial",
31
+ "failed",
32
+ "cancelled",
33
+ "expired",
34
+ ]);
35
+ /** `has` channels on `GET /desearch/people/profiles` (src/utils/people_filters.py). */
36
+ export const PEOPLE_FILTER_CHANNELS = [
37
+ "email",
38
+ "website",
39
+ "x",
40
+ "linkedin",
41
+ "instagram",
42
+ "youtube",
43
+ "tiktok",
44
+ ];
45
+ export const PEOPLE_PROFILE_SORTS = ["score", "recent", "audience"];
46
+ export const PEOPLE_CONTROL_ACTIONS = ["pause", "resume", "cancel"];
47
+ /**
48
+ * Search filters each platform accepts inside the request `filters` object.
49
+ * The API forbids extra keys, so a filter that is not listed for a platform
50
+ * is rejected before the billed call instead of returning HTTP 422.
51
+ */
52
+ export const PEOPLE_SEARCH_FILTERS = {
53
+ x: ["min_followers", "max_followers", "verified_only", "countries", "keywords", "exclude_keywords"],
54
+ youtube: [
55
+ "min_subscribers",
56
+ "max_subscribers",
57
+ "countries",
58
+ "require_contact",
59
+ "keywords",
60
+ "exclude_keywords",
61
+ ],
62
+ linkedin: ["min_followers", "max_followers", "countries", "keywords", "exclude_keywords"],
63
+ tiktok: ["min_followers", "max_followers", "require_contact", "keywords", "exclude_keywords"],
64
+ };
65
+ export const PEOPLE_SEARCH_FILTER_NAMES = [
66
+ "min_followers",
67
+ "max_followers",
68
+ "min_subscribers",
69
+ "max_subscribers",
70
+ "verified_only",
71
+ "require_contact",
72
+ "countries",
73
+ "keywords",
74
+ "exclude_keywords",
75
+ ];
76
+ function isPlainObject(value) {
77
+ return typeof value === "object" && value !== null && !Array.isArray(value);
78
+ }
79
+ function errorDetail(data, text) {
80
+ if (isPlainObject(data) && data.detail !== undefined) {
81
+ const detail = typeof data.detail === "string" ? data.detail : JSON.stringify(data.detail);
82
+ const task = isPlainObject(data.task) ? data.task : undefined;
83
+ return typeof task?.status === "string" ? `${detail} Task status: ${task.status}.` : detail;
84
+ }
85
+ return text.length > 500 ? `${text.slice(0, 500)}...` : text;
86
+ }
87
+ function withQuery(path, params) {
88
+ const search = new URLSearchParams();
89
+ for (const [key, value] of Object.entries(params)) {
90
+ if (value !== undefined) {
91
+ search.append(key, String(value));
92
+ }
93
+ }
94
+ const qs = search.toString();
95
+ return qs ? `${path}?${qs}` : path;
96
+ }
97
+ export function createPeopleClient(apiKey, baseUrl = PEOPLE_API_BASE_URL) {
98
+ async function call(method, path, options = {}) {
99
+ const headers = { Authorization: apiKey, ...options.headers };
100
+ if (options.body) {
101
+ headers["Content-Type"] = "application/json";
102
+ }
103
+ let response;
104
+ let text;
105
+ try {
106
+ response = await fetch(`${baseUrl}${path}`, {
107
+ method,
108
+ headers,
109
+ body: options.body ? JSON.stringify(options.body) : undefined,
110
+ });
111
+ text = await response.text();
112
+ }
113
+ catch (error) {
114
+ throw new Error(`Unexpected Error: ${error instanceof Error ? error.message : String(error)}`);
115
+ }
116
+ let data = text;
117
+ if (text) {
118
+ try {
119
+ data = JSON.parse(text);
120
+ }
121
+ catch {
122
+ // Not JSON: keep the text.
123
+ }
124
+ }
125
+ if (!response.ok) {
126
+ throw new Error(`HTTP ${response.status}: ${errorDetail(data, text)}`);
127
+ }
128
+ return { status: response.status, data };
129
+ }
130
+ const taskPath = (taskId) => `/desearch/people/tasks/${encodeURIComponent(taskId)}`;
131
+ return {
132
+ startSearch(platform, body, idempotencyKey) {
133
+ return call("POST", `/desearch/people/search/${platform}`, {
134
+ body,
135
+ headers: idempotencyKey ? { "Idempotency-Key": idempotencyKey } : undefined,
136
+ });
137
+ },
138
+ async getTask(taskId) {
139
+ return (await call("GET", taskPath(taskId))).data;
140
+ },
141
+ async getResults(taskId, params) {
142
+ return (await call("GET", withQuery(`${taskPath(taskId)}/results`, params))).data;
143
+ },
144
+ async controlTask(taskId, action) {
145
+ return (await call("POST", `${taskPath(taskId)}/${action}`)).data;
146
+ },
147
+ async listTasks(params) {
148
+ return (await call("GET", withQuery("/desearch/people/tasks", params))).data;
149
+ },
150
+ async listProfiles(params) {
151
+ return (await call("GET", withQuery("/desearch/people/profiles", params))).data;
152
+ },
153
+ };
154
+ }
155
+ /**
156
+ * Request body for `POST /desearch/people/search/{platform}`.
157
+ * Throws when a filter does not apply to the platform, so no billed call is made.
158
+ */
159
+ export function peopleSearchBody(args) {
160
+ const allowed = PEOPLE_SEARCH_FILTERS[args.platform];
161
+ const filters = {};
162
+ const rejected = [];
163
+ for (const name of PEOPLE_SEARCH_FILTER_NAMES) {
164
+ const value = args[name];
165
+ if (value === undefined) {
166
+ continue;
167
+ }
168
+ if (!allowed.includes(name)) {
169
+ rejected.push(name);
170
+ continue;
171
+ }
172
+ filters[name] = value;
173
+ }
174
+ if (rejected.length > 0) {
175
+ throw new Error(`${rejected.join(", ")} ${rejected.length === 1 ? "does" : "do"} not apply to ${args.platform}. ${args.platform} filters: ${allowed.join(", ")}. Nothing was charged.`);
176
+ }
177
+ const body = { query: args.query };
178
+ if (args.count !== undefined)
179
+ body.count = args.count;
180
+ if (args.min_score !== undefined)
181
+ body.min_score = args.min_score;
182
+ if (args.exclude !== undefined)
183
+ body.exclude = args.exclude;
184
+ if (Object.keys(filters).length > 0)
185
+ body.filters = filters;
186
+ return body;
187
+ }
188
+ function compact(fields) {
189
+ const out = {};
190
+ for (const [key, value] of Object.entries(fields)) {
191
+ if (value === undefined || value === null || value === "")
192
+ continue;
193
+ if (Array.isArray(value) && value.length === 0)
194
+ continue;
195
+ if (isPlainObject(value) && Object.keys(value).length === 0)
196
+ continue;
197
+ out[key] = value;
198
+ }
199
+ return out;
200
+ }
201
+ function objectOf(value) {
202
+ return isPlainObject(value) ? value : {};
203
+ }
204
+ function arrayOf(value) {
205
+ return Array.isArray(value) ? value : [];
206
+ }
207
+ function numberOf(value) {
208
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
209
+ }
210
+ function stringOf(value) {
211
+ return typeof value === "string" && value.trim() !== "" ? value : undefined;
212
+ }
213
+ /**
214
+ * One person as an agent needs it: who they are, how big their audience is,
215
+ * how well they fit and why, and how to reach them.
216
+ */
217
+ export function compactPerson(person) {
218
+ const p = objectOf(person);
219
+ const metrics = objectOf(p.metrics);
220
+ const attributes = objectOf(p.attributes);
221
+ const score = objectOf(p.score);
222
+ const evidence = arrayOf(p.evidence).map(objectOf);
223
+ const found = isPlainObject(p.found_by) ? p.found_by : undefined;
224
+ return compact({
225
+ id: p.id,
226
+ platform: p.platform,
227
+ handle: p.handle,
228
+ name: p.name,
229
+ url: p.url,
230
+ audience: numberOf(metrics.followers) ?? numberOf(metrics.subscribers),
231
+ location: stringOf(p.location),
232
+ verified: typeof attributes.verified === "boolean" ? attributes.verified : undefined,
233
+ headline: stringOf(attributes.headline),
234
+ company: stringOf(attributes.company),
235
+ score: numberOf(score.value),
236
+ why: stringOf(score.summary),
237
+ reasons: arrayOf(score.reasons).filter((r) => typeof r === "string").slice(0, 3),
238
+ contacts: arrayOf(p.contacts)
239
+ .map(objectOf)
240
+ .filter((c) => stringOf(c.value))
241
+ .map((c) => compact({ type: c.type, value: c.value })),
242
+ links: arrayOf(p.links)
243
+ .map(objectOf)
244
+ .filter((l) => stringOf(l.url))
245
+ .map((l) => compact({ type: l.type, url: l.url })),
246
+ evidence_url: evidence.map((e) => stringOf(e.url)).find((url) => url !== undefined),
247
+ found_by: found
248
+ ? compact({
249
+ task_id: found.task_id,
250
+ query: found.query,
251
+ times_found: found.times_found,
252
+ found_at: found.found_at,
253
+ })
254
+ : undefined,
255
+ });
256
+ }
257
+ /** Task fields an agent polls on. `progress` is the worker's counters, passed through. */
258
+ export function compactTask(task, options = {}) {
259
+ const t = objectOf(task);
260
+ const status = typeof t.status === "string" ? t.status : undefined;
261
+ return compact({
262
+ task_id: t.task_id,
263
+ platform: t.platform,
264
+ status,
265
+ stage: t.stage,
266
+ done: status ? PEOPLE_ENDED_STATUSES.has(status) : undefined,
267
+ query: t.query,
268
+ count: t.count,
269
+ result_count: t.result_count,
270
+ progress: options.progress ? t.progress : undefined,
271
+ errors: options.progress ? t.errors : undefined,
272
+ reserved_cost_usd: t.reserved_cost_usd,
273
+ final_cost_usd: t.final_cost_usd,
274
+ refunded_usd: t.refunded_usd,
275
+ created_at: t.created_at,
276
+ finished_at: t.finished_at,
277
+ results_expire_at: t.results_expire_at,
278
+ });
279
+ }
280
+ /**
281
+ * One sentence on what to do next, so an agent does not have to infer it from the status.
282
+ * `nextCursor` is the results cursor when the caller just read a page of people.
283
+ */
284
+ export function peopleNextStep(status, nextCursor, hasMore = false) {
285
+ const again = nextCursor === undefined
286
+ ? "people-search-status again"
287
+ : `people-search-status again with cursor "${nextCursor}"`;
288
+ if (hasMore) {
289
+ return `More people are ready now: call ${again}.`;
290
+ }
291
+ switch (status) {
292
+ case "queued":
293
+ case "running":
294
+ return nextCursor === undefined
295
+ ? `Still searching. Wait 15 to 30 seconds, then call ${again}.`
296
+ : `Still searching. Wait 15 to 30 seconds, then call ${again} to get only the people found since this call.`;
297
+ case "pausing":
298
+ return "Pausing after the current batch. Resume it with people-search-control action \"resume\".";
299
+ case "paused":
300
+ return "Paused. Resume it with people-search-control action \"resume\", or cancel it.";
301
+ case "cancelling":
302
+ return "Cancelling. Call people-search-status again to read the final status.";
303
+ case "completed":
304
+ return "Finished. You have every person this search found.";
305
+ case "partial":
306
+ return "Finished with partial results: some searches failed. You have every person it found.";
307
+ case "failed":
308
+ return "The search failed. See errors. A search that finds no one is not charged.";
309
+ case "cancelled":
310
+ return "Cancelled. You pay only for the people listed; the rest of the reservation is returned.";
311
+ case "expired":
312
+ return "Results expired 30 days after the search ended.";
313
+ default:
314
+ return `Call ${again} to check for changes.`;
315
+ }
316
+ }
317
+ const POLL_HINT = "Searches usually take 1 to 5 minutes. Poll people-search-status with this task_id every 15 to 30 seconds; people appear while it runs.";
318
+ /** `people-search`: start a billed background search and return the task to poll. */
319
+ export async function startPeopleSearch(client, args) {
320
+ const body = peopleSearchBody(args);
321
+ const { status, data } = await client.startSearch(args.platform, body, args.idempotency_key);
322
+ const raw = objectOf(data);
323
+ // 200 means the same Idempotency-Key already created this task; the API refunds this call.
324
+ const existing = status === 200;
325
+ return compact({
326
+ ...compactTask(data),
327
+ cost_usd: numberOf(raw.cost_usd),
328
+ currency: stringOf(raw.currency),
329
+ existing_task: existing ? true : undefined,
330
+ next: existing
331
+ ? `This idempotency_key already started this search, so it was not charged again. ${POLL_HINT}`
332
+ : POLL_HINT,
333
+ });
334
+ }
335
+ /** `people-search-status`: task status and progress, plus a page of people when there are any. */
336
+ export async function readPeopleStatus(client, args) {
337
+ const task = await client.getTask(args.task_id);
338
+ const summary = compactTask(task, { progress: true });
339
+ const status = typeof summary.status === "string" ? summary.status : undefined;
340
+ const includePeople = args.include_people !== false;
341
+ if (!includePeople) {
342
+ return { ...summary, next: peopleNextStep(status) };
343
+ }
344
+ let nextCursor = args.cursor ?? "0";
345
+ let hasMore = false;
346
+ let people = [];
347
+ const resultCount = numberOf(summary.result_count) ?? 0;
348
+ // No results yet, or expired (the results route answers 410): skip the second call.
349
+ if (resultCount > 0 && status !== "expired") {
350
+ const page = objectOf(await client.getResults(args.task_id, { cursor: args.cursor, limit: args.limit }));
351
+ people = arrayOf(page.results).map(compactPerson);
352
+ nextCursor = stringOf(page.next_cursor) ?? nextCursor;
353
+ hasMore = page.has_more === true;
354
+ }
355
+ return {
356
+ ...summary,
357
+ people,
358
+ next_cursor: nextCursor,
359
+ has_more: hasMore,
360
+ next: peopleNextStep(status, nextCursor, hasMore),
361
+ };
362
+ }
363
+ /** `people-search-control`: pause, resume, or cancel a task. */
364
+ export async function controlPeopleTask(client, args) {
365
+ const task = compactTask(await client.controlTask(args.task_id, args.action));
366
+ const status = typeof task.status === "string" ? task.status : undefined;
367
+ return { ...task, next: peopleNextStep(status) };
368
+ }
369
+ /** `people-search-tasks`: the caller's tasks, newest first. */
370
+ export async function listPeopleTasks(client, args) {
371
+ const page = objectOf(await client.listTasks({
372
+ platform: args.platform,
373
+ status: args.status?.length ? args.status.join(",") : undefined,
374
+ limit: args.limit,
375
+ cursor: args.cursor,
376
+ }));
377
+ return {
378
+ tasks: arrayOf(page.tasks).map((task) => compactTask(task)),
379
+ next_cursor: stringOf(page.next_cursor) ?? null,
380
+ };
381
+ }
382
+ /** `people-profiles`: everyone the caller's searches found on one platform. */
383
+ export async function listPeopleProfiles(client, args) {
384
+ const page = objectOf(await client.listProfiles({
385
+ platform: args.platform,
386
+ q: args.q,
387
+ sort: args.sort,
388
+ limit: args.limit,
389
+ cursor: args.cursor,
390
+ has: args.has?.length ? args.has.join(",") : undefined,
391
+ min_audience: args.min_audience,
392
+ max_audience: args.max_audience,
393
+ min_score: args.min_score,
394
+ location: args.location,
395
+ verified: args.verified,
396
+ }));
397
+ return {
398
+ total: numberOf(page.total) ?? 0,
399
+ next_cursor: stringOf(page.next_cursor) ?? null,
400
+ profiles: arrayOf(page.profiles).map(compactPerson),
401
+ };
402
+ }
package/build/server.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { type PeopleClient } from "./people.js";
2
3
  export declare const SERVER_NAME = "Desearch";
3
- export declare const SERVER_VERSION = "0.1.3";
4
+ export declare const SERVER_VERSION = "0.2.0";
4
5
  interface XSearchPayload {
5
6
  query: string;
6
7
  sort?: "Top" | "Latest";
@@ -95,9 +96,9 @@ export declare function presentSearchBody(value: unknown): unknown;
95
96
  * One MCP server bound to a single Desearch API key.
96
97
  * Stdio uses the process env key. Remote HTTP builds a new server per request
97
98
  * so each caller spends their own key.
98
- * `client` is a test seam. Production callers omit it and the server builds
99
- * a desearch-js client from `apiKey`.
99
+ * `client` and `peopleClient` are test seams. Production callers omit them and the
100
+ * server builds a desearch-js client and a People Search client (people.ts) from `apiKey`.
100
101
  */
101
- export declare function createDesearchMcpServer(apiKey: string, client?: DesearchClient): McpServer;
102
+ export declare function createDesearchMcpServer(apiKey: string, client?: DesearchClient, peopleClient?: PeopleClient): McpServer;
102
103
  export {};
103
104
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAUpE,eAAO,MAAM,WAAW,aAAa,CAAC;AACtC,eAAO,MAAM,cAAc,UA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iED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACnC,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,cAAc,EACvB,YAAY,CAAC,EAAE,YAAY,GAC5B,SAAS,CAmtBX"}
package/build/server.js CHANGED
@@ -2,15 +2,16 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import { ListPromptsRequestSchema, ListResourcesRequestSchema, ListResourceTemplatesRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
3
3
  import DesearchImport from "desearch-js";
4
4
  import { z } from "zod";
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";
5
6
  import { AI_SEARCH_TOOLS, WEB_LINK_TOOLS, toolIdSchema } from "./tool-sources.js";
6
7
  export const SERVER_NAME = "Desearch";
7
- export const SERVER_VERSION = "0.1.3";
8
+ export const SERVER_VERSION = "0.2.0";
8
9
  // desearch-js 1.5 publishes a default class. Node16 resolution types that package
9
10
  // as a module namespace, so the constructor is applied through a cast.
10
11
  const Desearch = DesearchImport;
11
12
  /**
12
- * Every tool reads live Desearch, web, or X data and returns it. None of them
13
- * write caller state. Hints only: clients must not treat them as a safety check.
13
+ * The search and X/web tools read live Desearch, web, or X data and return it.
14
+ * They do not write caller state. Hints only: clients must not treat them as a safety check.
14
15
  * destructiveHint is false so a client that ignores the readOnlyHint gate does
15
16
  * not treat a search as a destructive update (the MCP default for that hint is true).
16
17
  */
@@ -19,6 +20,26 @@ const READ_ONLY_OPEN_WORLD = {
19
20
  destructiveHint: false,
20
21
  openWorldHint: true,
21
22
  };
23
+ /**
24
+ * `people-search` creates a billed background task. Calling it again starts
25
+ * (and reserves) another search unless the same idempotency_key is sent.
26
+ */
27
+ const BILLED_TASK = {
28
+ readOnlyHint: false,
29
+ destructiveHint: false,
30
+ idempotentHint: false,
31
+ openWorldHint: true,
32
+ };
33
+ /**
34
+ * `people-search-control` changes a task's state. `cancel` cannot be undone.
35
+ * Repeating the same action has no further effect (the API answers 409).
36
+ */
37
+ const TASK_CONTROL = {
38
+ readOnlyHint: false,
39
+ destructiveHint: true,
40
+ idempotentHint: true,
41
+ openWorldHint: true,
42
+ };
22
43
  const optionalPostCount = z
23
44
  .number()
24
45
  .int()
@@ -47,6 +68,30 @@ function pageContentFields() {
47
68
  .describe("Post-load wait in milliseconds when JavaScript rendering is enabled."),
48
69
  };
49
70
  }
71
+ const peopleTaskId = z
72
+ .string()
73
+ .uuid()
74
+ .describe("task_id returned by people-search, example: '3f1c2b9e-8d4a-4c1e-9b7a-2e5f6a7b8c9d'");
75
+ const peoplePlatform = z
76
+ .enum(PEOPLE_PLATFORMS)
77
+ .describe("Platform: 'x', 'youtube', 'linkedin', or 'tiktok'.");
78
+ /**
79
+ * People tools reject unknown arguments instead of dropping them. A dropped
80
+ * filter (for example the API's nested `filters` object) would still run, and
81
+ * bill, a search without it.
82
+ */
83
+ function strictArgs(shape) {
84
+ return z.object(shape).strict();
85
+ }
86
+ // A new schema per field: one shared instance would serialize as a JSON Schema $ref.
87
+ function peopleKeywordList() {
88
+ return z.array(z.string().min(1).max(120)).max(20);
89
+ }
90
+ function platformFilterList() {
91
+ return Object.entries(PEOPLE_SEARCH_FILTERS)
92
+ .map(([platform, filters]) => `${platform}: ${filters.join(", ")}`)
93
+ .join(". ");
94
+ }
50
95
  const engagementThreshold = z
51
96
  .union([z.number().int().min(0), z.string()])
52
97
  .optional();
@@ -136,7 +181,7 @@ function fail(label, error) {
136
181
  isError: true,
137
182
  };
138
183
  }
139
- function registerTool(server, apiKey, name, title, description, inputSchema, handler) {
184
+ function registerTool(server, apiKey, name, title, description, inputSchema, handler, annotations = READ_ONLY_OPEN_WORLD) {
140
185
  // SDK 1.30's tool generics blow the TypeScript instantiation limit on these
141
186
  // schemas. Runtime registration is the same registerTool call.
142
187
  const register = server.registerTool.bind(server);
@@ -150,18 +195,19 @@ function registerTool(server, apiKey, name, title, description, inputSchema, han
150
195
  title,
151
196
  description,
152
197
  inputSchema,
153
- annotations: { ...READ_ONLY_OPEN_WORLD, title },
198
+ annotations: { ...annotations, title },
154
199
  }, guarded);
155
200
  }
156
201
  /**
157
202
  * One MCP server bound to a single Desearch API key.
158
203
  * Stdio uses the process env key. Remote HTTP builds a new server per request
159
204
  * so each caller spends their own key.
160
- * `client` is a test seam. Production callers omit it and the server builds
161
- * a desearch-js client from `apiKey`.
205
+ * `client` and `peopleClient` are test seams. Production callers omit them and the
206
+ * server builds a desearch-js client and a People Search client (people.ts) from `apiKey`.
162
207
  */
163
- export function createDesearchMcpServer(apiKey, client) {
208
+ export function createDesearchMcpServer(apiKey, client, peopleClient) {
164
209
  const desearch = client ?? new Desearch(apiKey);
210
+ const people = peopleClient ?? createPeopleClient(apiKey);
165
211
  const server = new McpServer({
166
212
  name: SERVER_NAME,
167
213
  version: SERVER_VERSION,
@@ -172,7 +218,7 @@ export function createDesearchMcpServer(apiKey, client) {
172
218
  .array(toolIdSchema(AI_SEARCH_TOOLS))
173
219
  .optional()
174
220
  .default(["web", "twitter"])
175
- .describe("Source ids sent to POST /desearch/ai/search. Use short ids such as 'web' and 'twitter'. Legacy labels such as 'Web Search' are accepted and rewritten to those ids. Example: ['web', 'twitter']."),
221
+ .describe("Source ids sent to POST /desearch/ai/search. Short ids: 'web', 'twitter', 'arxiv', 'wikipedia', 'hackernews', 'reddit'. Legacy labels such as 'Web Search', 'ArXiv Search', 'Wikipedia Search', 'Hacker News Search', and 'Reddit Search' are rewritten to those ids. Example: ['web', 'twitter']."),
176
222
  date_filter: z
177
223
  .enum([
178
224
  "PAST_24_HOURS",
@@ -455,6 +501,209 @@ export function createDesearchMcpServer(apiKey, client) {
455
501
  return fail("X Trends error", error);
456
502
  }
457
503
  });
504
+ registerTool(server, apiKey, "people-search", "People Search", "Start a People Search: find people on X, YouTube, LinkedIn, or TikTok who match a plain-language description. Each person comes back with a fit score, why they matched, their audience, and public contacts and links. Billed and asynchronous: this call reserves count times the platform's per-person price (reserved_cost_usd) and returns a task_id at once. When the search ends you pay only for the people it delivered (a per-search minimum applies when it finds anyone; a search that finds no one is free) and the rest of the reservation is returned. The search runs in the background, usually for 1 to 5 minutes: poll people-search-status with the task_id to read progress and the people found so far, and use people-search-control to pause, resume, or cancel it. Do not start the same search twice; send idempotency_key so a retry returns the first task instead of charging again. Filters depend on the platform. " +
505
+ platformFilterList() +
506
+ ".", strictArgs({
507
+ platform: peoplePlatform.describe("Where to look: 'x' (X profiles), 'youtube' (YouTube creators), 'linkedin' (LinkedIn members), or 'tiktok' (TikTok creators)."),
508
+ query: z
509
+ .string()
510
+ .min(3)
511
+ .max(1000)
512
+ .describe("Who you are looking for, in plain language, example: 'Skincare creators who review sunscreen'."),
513
+ count: z
514
+ .number()
515
+ .int()
516
+ .min(5)
517
+ .max(200)
518
+ .optional()
519
+ .describe("How many qualified people to find (5-200, API default 25). The search reserves this many and bills only the people it delivers."),
520
+ min_score: z
521
+ .number()
522
+ .int()
523
+ .min(0)
524
+ .max(100)
525
+ .optional()
526
+ .describe("Only return people with at least this fit score (0-100)."),
527
+ exclude: z
528
+ .array(z.string().min(1))
529
+ .max(1000)
530
+ .optional()
531
+ .describe("Handles to leave out, for example people you already contacted."),
532
+ idempotency_key: z
533
+ .string()
534
+ .min(1)
535
+ .max(200)
536
+ .optional()
537
+ .describe("Any unique string for this search, for example a UUID. Sending the same key again returns the first task and is not charged again."),
538
+ min_followers: z
539
+ .number()
540
+ .int()
541
+ .min(0)
542
+ .optional()
543
+ .describe("Minimum follower count. x, linkedin, tiktok."),
544
+ max_followers: z
545
+ .number()
546
+ .int()
547
+ .min(0)
548
+ .optional()
549
+ .describe("Maximum follower count. x, linkedin, tiktok."),
550
+ min_subscribers: z
551
+ .number()
552
+ .int()
553
+ .min(0)
554
+ .optional()
555
+ .describe("Minimum subscriber count. youtube only."),
556
+ max_subscribers: z
557
+ .number()
558
+ .int()
559
+ .min(0)
560
+ .optional()
561
+ .describe("Maximum subscriber count. youtube only."),
562
+ verified_only: z
563
+ .boolean()
564
+ .optional()
565
+ .describe("Only verified or X Premium accounts. x only."),
566
+ require_contact: z
567
+ .boolean()
568
+ .optional()
569
+ .describe("Only creators with a public email (tiktok: in the bio; youtube: an email or contact link). youtube, tiktok."),
570
+ countries: peopleKeywordList()
571
+ .optional()
572
+ .describe("Countries to prefer, example: ['US', 'GB']. x, youtube, linkedin."),
573
+ keywords: peopleKeywordList()
574
+ .optional()
575
+ .describe("Words that should appear in their posts, videos, or bio. All platforms."),
576
+ exclude_keywords: peopleKeywordList()
577
+ .optional()
578
+ .describe("Leave out people who mention these words. All platforms."),
579
+ }), async (args) => {
580
+ try {
581
+ return ok(await startPeopleSearch(people, args));
582
+ }
583
+ catch (error) {
584
+ return fail("People Search error", error);
585
+ }
586
+ }, BILLED_TASK);
587
+ registerTool(server, apiKey, "people-search-status", "Get People Search Status", "Status, progress, and cost of one People Search task, plus a page of the people found so far: name, handle, url, platform, audience, location, fit score, why they matched, contacts, and links. Free. People arrive while the search runs: pass the returned next_cursor as cursor on the next call to get only the people found since then. When done is true and has_more is false you have everyone the search found.", strictArgs({
588
+ task_id: peopleTaskId,
589
+ cursor: z
590
+ .string()
591
+ .max(64)
592
+ .optional()
593
+ .describe("next_cursor from the previous people-search-status call. Omit to start from the first person."),
594
+ limit: z
595
+ .number()
596
+ .int()
597
+ .min(1)
598
+ .max(100)
599
+ .default(25)
600
+ .describe("People per page (1-100, default 25)."),
601
+ include_people: z
602
+ .boolean()
603
+ .default(true)
604
+ .describe("Set false to read only the status, progress, and cost."),
605
+ }), async (args) => {
606
+ try {
607
+ return ok(await readPeopleStatus(people, args));
608
+ }
609
+ catch (error) {
610
+ return fail("People Search Status error", error);
611
+ }
612
+ });
613
+ registerTool(server, apiKey, "people-search-control", "Control People Search", "Pause, resume, or cancel a People Search task. Free. pause: a queued search pauses at once; a running one finishes its current batch first (status pausing, then paused). A search paused for more than 7 days is cancelled. resume: continues a paused search where it stopped, with no new charge. cancel: stops the search for good; you pay only for the people it already delivered and the rest of the reservation is returned. People found so far stay readable for 30 days.", strictArgs({
614
+ task_id: peopleTaskId,
615
+ action: z
616
+ .enum(PEOPLE_CONTROL_ACTIONS)
617
+ .describe("'pause', 'resume', or 'cancel'. cancel cannot be undone."),
618
+ }), async (args) => {
619
+ try {
620
+ return ok(await controlPeopleTask(people, args));
621
+ }
622
+ catch (error) {
623
+ return fail("People Search Control error", error);
624
+ }
625
+ }, TASK_CONTROL);
626
+ registerTool(server, apiKey, "people-search-tasks", "List People Search Tasks", "Your People Search tasks, newest first, with status, counts, and cost. Free. Use it to find a task_id, or to see which searches are still queued, running, or paused: a new search is refused while too many are active.", strictArgs({
627
+ platform: peoplePlatform.optional().describe("Only tasks on this platform: 'x', 'youtube', 'linkedin', or 'tiktok'."),
628
+ status: z
629
+ .array(z.enum(PEOPLE_TASK_STATUSES))
630
+ .optional()
631
+ .describe("Only tasks in these statuses, example: ['running', 'paused']."),
632
+ limit: z
633
+ .number()
634
+ .int()
635
+ .min(1)
636
+ .max(100)
637
+ .optional()
638
+ .describe("Tasks per page (1-100, API default 20)."),
639
+ cursor: z.string().optional().describe("next_cursor from the previous page."),
640
+ }), async (args) => {
641
+ try {
642
+ return ok(await listPeopleTasks(people, args));
643
+ }
644
+ catch (error) {
645
+ return fail("People Search Tasks error", error);
646
+ }
647
+ });
648
+ registerTool(server, apiKey, "people-profiles", "List People Found", "Everyone your People Searches found on one platform, one entry per person: their best-scoring result and the search that found them (found_by). Free; it does not run a new search. Search by name, handle, bio, or location with q, filter by contact channels (has), audience, fit score, location, or verification, and sort by score, recent, or audience. People from searches that ended more than 30 days ago are left out.", strictArgs({
649
+ platform: peoplePlatform,
650
+ q: z
651
+ .string()
652
+ .max(200)
653
+ .optional()
654
+ .describe("Text in the name, handle, bio, or location, example: 'skincare'."),
655
+ sort: z
656
+ .enum(PEOPLE_PROFILE_SORTS)
657
+ .optional()
658
+ .describe("'score' (API default), 'recent', or 'audience'."),
659
+ limit: z
660
+ .number()
661
+ .int()
662
+ .min(1)
663
+ .max(200)
664
+ .default(25)
665
+ .describe("People per page (1-200, default 25)."),
666
+ cursor: z.string().optional().describe("next_cursor from the previous page."),
667
+ has: z
668
+ .array(z.enum(PEOPLE_FILTER_CHANNELS))
669
+ .optional()
670
+ .describe("Channels every person must have, example: ['email', 'instagram']. 'email' is a public email; the others are a link of that type."),
671
+ min_audience: z
672
+ .number()
673
+ .int()
674
+ .min(0)
675
+ .optional()
676
+ .describe("Minimum followers (subscribers on YouTube)."),
677
+ max_audience: z
678
+ .number()
679
+ .int()
680
+ .min(0)
681
+ .optional()
682
+ .describe("Maximum followers (subscribers on YouTube)."),
683
+ min_score: z
684
+ .number()
685
+ .int()
686
+ .min(0)
687
+ .max(100)
688
+ .optional()
689
+ .describe("Minimum fit score (0-100)."),
690
+ location: z
691
+ .string()
692
+ .max(100)
693
+ .optional()
694
+ .describe("Text in the location, example: 'united states'."),
695
+ verified: z
696
+ .boolean()
697
+ .optional()
698
+ .describe("Only verified accounts. Only X and TikTok people carry a verified flag."),
699
+ }), async (args) => {
700
+ try {
701
+ return ok(await listPeopleProfiles(people, args));
702
+ }
703
+ catch (error) {
704
+ return fail("People Profiles error", error);
705
+ }
706
+ });
458
707
  // Scanners ask for these lists during discovery. There is nothing to return,
459
708
  // but an empty list is a successful response. Method-not-found looks like a
460
709
  // broken server to some directory crawlers.
@@ -1,24 +1,17 @@
1
1
  import { z } from "zod";
2
2
  /**
3
- * Short source ids shared by ai-search and web-links-search.
3
+ * Short source ids for ai-search and web-links-search.
4
4
  *
5
- * Wire values are the short ids from live OpenAPI
6
- * (https://api.desearch.ai/openapi.json, checked 2026-10-01) and from
7
- * desearch-js `ToolEnum` / `WebToolEnum`. Display labels such as "Web Search"
8
- * are the previous ai-search schema. They are accepted here and rewritten to
9
- * the short id before the Desearch call.
5
+ * Display labels such as "Web Search" are the previous ai-search schema.
6
+ * They are accepted here and rewritten to the short id before the Desearch call.
7
+ * "Youtube Search" is not rewritten; `youtube` is not an ai-search tool id.
10
8
  *
11
- * Live OpenAPI names a narrower set than desearch-js 1.5:
12
- * - `ToolEnum` (`POST /desearch/ai/search`): `web`, `twitter`. Items are
13
- * `ToolEnum | string`, and the previous MCP tool already offered the other
14
- * desearch-js sources under display labels. Those stay, spelled as short ids.
15
- * PR #13 did not see a 422 for this route.
16
- * - `WebToolEnum` (`POST /desearch/ai/search/links/web`): `web` only. The other
17
- * short ids 422 (`supported tools are Web Search`). `WEB_LINK_TOOLS` is
18
- * `["web"]` so the MCP enum does not offer ids the route rejects.
9
+ * - `AI_SEARCH_TOOLS` (`POST /desearch/ai/search`): `web`, `twitter`, `arxiv`,
10
+ * `wikipedia`, `hackernews`, `reddit`. Same order as before, without `youtube`.
11
+ * - `WEB_LINK_TOOLS` (`POST /desearch/ai/search/links/web`): `web` only.
19
12
  * `"Web Search"` still rewrites to `web`.
20
13
  */
21
- export declare const AI_SEARCH_TOOLS: readonly ["web", "twitter", "arxiv", "wikipedia", "youtube", "hackernews", "reddit"];
14
+ export declare const AI_SEARCH_TOOLS: readonly ["web", "twitter", "arxiv", "wikipedia", "hackernews", "reddit"];
22
15
  export declare const WEB_LINK_TOOLS: readonly ["web"];
23
16
  /** Previous ai-search labels. Not advertised in the JSON Schema enum. */
24
17
  export declare const LEGACY_DISPLAY_TO_ID: Readonly<Record<string, string>>;
@@ -1 +1 @@
1
- {"version":3,"file":"tool-sources.d.ts","sourceRoot":"","sources":["../tool-sources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,eAAe,sFAQlB,CAAC;AAEX,eAAO,MAAM,cAAc,kBAAmB,CAAC;AAE/C,yEAAyE;AACzE,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQjE,CAAC;AAEF,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,KAAK,WAAW,GAAG,SAAS,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;AAElD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,WAAW,EAAE,GAAG,EAAE,CAAC,mEAKzD"}
1
+ {"version":3,"file":"tool-sources.d.ts","sourceRoot":"","sources":["../tool-sources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,2EAOlB,CAAC;AAEX,eAAO,MAAM,cAAc,kBAAmB,CAAC;AAE/C,yEAAyE;AACzE,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOjE,CAAC;AAEF,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,KAAK,WAAW,GAAG,SAAS,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;AAElD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,WAAW,EAAE,GAAG,EAAE,CAAC,mEAKzD"}
@@ -1,21 +1,14 @@
1
1
  import { z } from "zod";
2
2
  /**
3
- * Short source ids shared by ai-search and web-links-search.
3
+ * Short source ids for ai-search and web-links-search.
4
4
  *
5
- * Wire values are the short ids from live OpenAPI
6
- * (https://api.desearch.ai/openapi.json, checked 2026-10-01) and from
7
- * desearch-js `ToolEnum` / `WebToolEnum`. Display labels such as "Web Search"
8
- * are the previous ai-search schema. They are accepted here and rewritten to
9
- * the short id before the Desearch call.
5
+ * Display labels such as "Web Search" are the previous ai-search schema.
6
+ * They are accepted here and rewritten to the short id before the Desearch call.
7
+ * "Youtube Search" is not rewritten; `youtube` is not an ai-search tool id.
10
8
  *
11
- * Live OpenAPI names a narrower set than desearch-js 1.5:
12
- * - `ToolEnum` (`POST /desearch/ai/search`): `web`, `twitter`. Items are
13
- * `ToolEnum | string`, and the previous MCP tool already offered the other
14
- * desearch-js sources under display labels. Those stay, spelled as short ids.
15
- * PR #13 did not see a 422 for this route.
16
- * - `WebToolEnum` (`POST /desearch/ai/search/links/web`): `web` only. The other
17
- * short ids 422 (`supported tools are Web Search`). `WEB_LINK_TOOLS` is
18
- * `["web"]` so the MCP enum does not offer ids the route rejects.
9
+ * - `AI_SEARCH_TOOLS` (`POST /desearch/ai/search`): `web`, `twitter`, `arxiv`,
10
+ * `wikipedia`, `hackernews`, `reddit`. Same order as before, without `youtube`.
11
+ * - `WEB_LINK_TOOLS` (`POST /desearch/ai/search/links/web`): `web` only.
19
12
  * `"Web Search"` still rewrites to `web`.
20
13
  */
21
14
  export const AI_SEARCH_TOOLS = [
@@ -23,7 +16,6 @@ export const AI_SEARCH_TOOLS = [
23
16
  "twitter",
24
17
  "arxiv",
25
18
  "wikipedia",
26
- "youtube",
27
19
  "hackernews",
28
20
  "reddit",
29
21
  ];
@@ -34,7 +26,6 @@ export const LEGACY_DISPLAY_TO_ID = {
34
26
  "Twitter Search": "twitter",
35
27
  "ArXiv Search": "arxiv",
36
28
  "Wikipedia Search": "wikipedia",
37
- "Youtube Search": "youtube",
38
29
  "Hacker News Search": "hackernews",
39
30
  "Reddit Search": "reddit",
40
31
  };
package/package.json CHANGED
@@ -1,16 +1,19 @@
1
1
  {
2
2
  "name": "desearch-mcp-server",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "mcpName": "io.github.Desearch-ai/mcp-desearch",
5
- "description": "AI search, X search and web search for AI agents, plus page extraction and X data tools. Bring your own Desearch API key.",
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",
7
- "homepage": "https://www.desearch.ai/docs/guide/sdk/mcp",
7
+ "homepage": "https://desearch.ai",
8
8
  "type": "module",
9
9
  "author": "Desearch AI",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "git+https://github.com/Desearch-ai/mcp-desearch.git"
13
13
  },
14
+ "bugs": {
15
+ "url": "https://github.com/Desearch-ai/mcp-desearch/issues"
16
+ },
14
17
  "bin": {
15
18
  "desearch-mcp-server": "./build/index.js"
16
19
  },
@@ -19,13 +22,32 @@
19
22
  "CHANGELOG.md"
20
23
  ],
21
24
  "keywords": [
22
- "desearch",
23
25
  "mcp",
24
- "model context protocol",
25
- "ai",
26
- "twitter",
27
- "websearch",
28
- "claude"
26
+ "mcp-server",
27
+ "model-context-protocol",
28
+ "desearch",
29
+ "ai-search",
30
+ "web-search",
31
+ "x-search",
32
+ "twitter-search",
33
+ "search-api",
34
+ "bittensor",
35
+ "subnet-22",
36
+ "ai-agents",
37
+ "llm",
38
+ "claude",
39
+ "cursor",
40
+ "reddit",
41
+ "hackernews",
42
+ "arxiv",
43
+ "wikipedia",
44
+ "people-search",
45
+ "creator-search",
46
+ "influencer-search",
47
+ "lead-generation",
48
+ "youtube",
49
+ "tiktok",
50
+ "linkedin"
29
51
  ],
30
52
  "scripts": {
31
53
  "build": "tsc && node -e \"require('fs').chmodSync('build/index.js', '755')\"",