@wolido/pi-anysearch 0.1.0 → 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/README.md +1 -1
- package/package.json +1 -1
- package/src/anysearch.ts +5 -4
- package/src/index.ts +47 -3
package/README.md
CHANGED
package/package.json
CHANGED
package/src/anysearch.ts
CHANGED
|
@@ -50,7 +50,7 @@ export interface AnySearchClient {
|
|
|
50
50
|
search(params: SearchParams): Promise<SearchResult>;
|
|
51
51
|
batchSearch(params: BatchSearchParams): Promise<SearchResult[]>;
|
|
52
52
|
extract(url: string): Promise<string>;
|
|
53
|
-
getDomains(domain: string): Promise<string>;
|
|
53
|
+
getDomains(domain: string | string[]): Promise<string>;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
const DEFAULT_BASE_URL = "https://api.anysearch.com";
|
|
@@ -168,7 +168,7 @@ export function createAnySearchClient(options: AnySearchClientOptions = {}): Any
|
|
|
168
168
|
params: {
|
|
169
169
|
protocolVersion: "2025-03-26",
|
|
170
170
|
capabilities: {},
|
|
171
|
-
clientInfo: { name: "pi-anysearch", version: "0.
|
|
171
|
+
clientInfo: { name: "pi-anysearch", version: "0.2.0" },
|
|
172
172
|
},
|
|
173
173
|
}),
|
|
174
174
|
});
|
|
@@ -244,8 +244,9 @@ export function createAnySearchClient(options: AnySearchClientOptions = {}): Any
|
|
|
244
244
|
return mcpCall("extract", { url });
|
|
245
245
|
},
|
|
246
246
|
|
|
247
|
-
getDomains(
|
|
248
|
-
|
|
247
|
+
getDomains(domainOrDomains: string | string[]): Promise<string> {
|
|
248
|
+
const args = Array.isArray(domainOrDomains) ? { domains: domainOrDomains } : { domain: domainOrDomains };
|
|
249
|
+
return mcpCall("get_sub_domains", args);
|
|
249
250
|
},
|
|
250
251
|
};
|
|
251
252
|
}
|
package/src/index.ts
CHANGED
|
@@ -107,12 +107,52 @@ const batchSearchSchema = Type.Object({
|
|
|
107
107
|
...sharedSearchParams,
|
|
108
108
|
});
|
|
109
109
|
|
|
110
|
+
// 17 top-level capability domains accepted by the MCP get_sub_domains tool.
|
|
111
|
+
const DOMAIN_VALUES = [
|
|
112
|
+
"general",
|
|
113
|
+
"resource",
|
|
114
|
+
"social_media",
|
|
115
|
+
"finance",
|
|
116
|
+
"academic",
|
|
117
|
+
"legal",
|
|
118
|
+
"health",
|
|
119
|
+
"business",
|
|
120
|
+
"security",
|
|
121
|
+
"ip",
|
|
122
|
+
"code",
|
|
123
|
+
"energy",
|
|
124
|
+
"environment",
|
|
125
|
+
"agriculture",
|
|
126
|
+
"travel",
|
|
127
|
+
"film",
|
|
128
|
+
"gaming",
|
|
129
|
+
] as const;
|
|
130
|
+
|
|
131
|
+
const DOMAIN_LIST_TEXT = DOMAIN_VALUES.join(", ");
|
|
132
|
+
|
|
133
|
+
const DOMAIN_DESCRIPTION =
|
|
134
|
+
"Top-level capability domain. Valid values: " + DOMAIN_LIST_TEXT;
|
|
135
|
+
|
|
136
|
+
const DOMAINS_ARRAY_DESCRIPTION =
|
|
137
|
+
"List of top-level capability domains to inspect. Valid values: " +
|
|
138
|
+
DOMAIN_LIST_TEXT +
|
|
139
|
+
". Pass all 17 values to list the full capability table. The official recommendation is to request at most 5 domains per call.";
|
|
140
|
+
|
|
110
141
|
const extractSchema = Type.Object({
|
|
111
142
|
url: Type.String({ description: "URL of the page to extract readable content from" }),
|
|
112
143
|
});
|
|
113
144
|
|
|
114
145
|
const domainsSchema = Type.Object({
|
|
115
|
-
domain: Type.
|
|
146
|
+
domain: Type.Optional(
|
|
147
|
+
StringEnum(DOMAIN_VALUES, {
|
|
148
|
+
description: DOMAIN_DESCRIPTION,
|
|
149
|
+
}),
|
|
150
|
+
),
|
|
151
|
+
domains: Type.Optional(
|
|
152
|
+
Type.Array(StringEnum(DOMAIN_VALUES), {
|
|
153
|
+
description: DOMAINS_ARRAY_DESCRIPTION,
|
|
154
|
+
}),
|
|
155
|
+
),
|
|
116
156
|
});
|
|
117
157
|
|
|
118
158
|
/** Byte-level truncation of a single field value (e.g. one result's content). */
|
|
@@ -313,10 +353,14 @@ export default function anysearchExtension(pi: ExtensionAPI) {
|
|
|
313
353
|
parameters: domainsSchema,
|
|
314
354
|
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
315
355
|
const client = await getClient(ctx);
|
|
316
|
-
const
|
|
356
|
+
const target = params.domains?.length ? params.domains : params.domain;
|
|
357
|
+
if (!target) {
|
|
358
|
+
throw new Error(`domain or domains is required. Valid values: ${DOMAIN_LIST_TEXT}`);
|
|
359
|
+
}
|
|
360
|
+
const text = await client.getDomains(target);
|
|
317
361
|
return {
|
|
318
362
|
content: [{ type: "text", text: truncateForOutput(text) }],
|
|
319
|
-
details: { domain: params.domain },
|
|
363
|
+
details: { domain: params.domain, domains: params.domains },
|
|
320
364
|
};
|
|
321
365
|
},
|
|
322
366
|
});
|