search1api-mcp 0.3.1 → 0.5.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 +21 -5
- package/build/api.js +2 -2
- package/build/config.js +1 -1
- package/build/http.js +154 -180
- package/build/index.js +30 -34
- package/build/resources.js +3 -3
- package/build/server.js +58 -72
- package/build/tools/crawl.js +14 -5
- package/build/tools/fetch.js +49 -0
- package/build/tools/handlers.js +13 -10
- package/build/tools/index.js +207 -56
- package/build/tools/news.js +15 -5
- package/build/tools/search.js +15 -5
- package/build/tools/sitemap.js +5 -5
- package/build/tools/trending.js +5 -5
- package/build/types.js +7 -0
- package/package.json +10 -5
- package/server.json +36 -0
package/build/server.js
CHANGED
|
@@ -1,86 +1,72 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { INTERNAL_ERROR, McpServer, ProtocolError, fromJsonSchema, } from "@modelcontextprotocol/server";
|
|
2
|
+
import { handleReadResource, RESOURCES } from "./resources.js";
|
|
3
3
|
import { handleToolCall } from "./tools/handlers.js";
|
|
4
|
-
import { log, formatError } from "./utils.js";
|
|
5
|
-
import { handleListResources, handleReadResource } from "./resources.js";
|
|
6
4
|
import { ALL_TOOLS } from "./tools/index.js";
|
|
5
|
+
import { formatError, log } from "./utils.js";
|
|
7
6
|
import { PACKAGE_VERSION } from "./version.js";
|
|
8
7
|
/**
|
|
9
|
-
* Create
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @returns Server instance ready to be connected to a transport
|
|
8
|
+
* Create one transport-neutral MCP server instance.
|
|
9
|
+
*
|
|
10
|
+
* The v2 serving entries call this factory once per modern HTTP exchange,
|
|
11
|
+
* once per stateless legacy HTTP request, or once per stdio connection.
|
|
14
12
|
*/
|
|
15
13
|
export function createMcpServer(credential) {
|
|
16
14
|
log("Creating Search1API MCP server");
|
|
17
|
-
const server = new
|
|
15
|
+
const server = new McpServer({
|
|
18
16
|
name: "search1api-server",
|
|
19
|
-
version: PACKAGE_VERSION
|
|
20
|
-
}, {
|
|
21
|
-
capabilities: {
|
|
22
|
-
resources: {},
|
|
23
|
-
tools: {}
|
|
24
|
-
}
|
|
17
|
+
version: PACKAGE_VERSION,
|
|
25
18
|
});
|
|
26
|
-
|
|
19
|
+
for (const tool of ALL_TOOLS) {
|
|
20
|
+
const inputSchema = fromJsonSchema(tool.inputSchema);
|
|
21
|
+
const outputSchema = tool.outputSchema
|
|
22
|
+
? fromJsonSchema(tool.outputSchema)
|
|
23
|
+
: undefined;
|
|
24
|
+
server.registerTool(tool.name, {
|
|
25
|
+
title: tool.title,
|
|
26
|
+
description: tool.description,
|
|
27
|
+
inputSchema,
|
|
28
|
+
...(outputSchema ? { outputSchema } : {}),
|
|
29
|
+
annotations: tool.annotations,
|
|
30
|
+
_meta: tool._meta,
|
|
31
|
+
}, async (args) => {
|
|
32
|
+
try {
|
|
33
|
+
const bearerCredential = typeof credential === "function" ? credential() : credential;
|
|
34
|
+
log(`Tool call received: ${tool.name}`);
|
|
35
|
+
return await handleToolCall(tool.name, args, bearerCredential);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
throw normalizeProtocolError(`handling tool call ${tool.name}`, error);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
for (const resource of RESOURCES) {
|
|
43
|
+
server.registerResource(resource.name, resource.uri, {
|
|
44
|
+
description: resource.description,
|
|
45
|
+
mimeType: resource.mimeType,
|
|
46
|
+
}, async (uri) => {
|
|
47
|
+
try {
|
|
48
|
+
const result = handleReadResource(uri.href);
|
|
49
|
+
return {
|
|
50
|
+
contents: [
|
|
51
|
+
{
|
|
52
|
+
uri: uri.href,
|
|
53
|
+
mimeType: result.mimeType || "application/json",
|
|
54
|
+
text: JSON.stringify(result),
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
throw normalizeProtocolError("reading resource", error);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
27
64
|
return server;
|
|
28
65
|
}
|
|
29
|
-
|
|
30
|
-
* Helper function to handle errors uniformly
|
|
31
|
-
*/
|
|
32
|
-
function handleError(context, error) {
|
|
66
|
+
function normalizeProtocolError(context, error) {
|
|
33
67
|
log(`Error ${context}:`, error);
|
|
34
|
-
if (error instanceof
|
|
35
|
-
|
|
68
|
+
if (error instanceof ProtocolError) {
|
|
69
|
+
return error;
|
|
36
70
|
}
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Set up server request handlers
|
|
41
|
-
*/
|
|
42
|
-
function setupRequestHandlers(server, credential) {
|
|
43
|
-
// Handle tool calls
|
|
44
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
45
|
-
try {
|
|
46
|
-
const toolName = request.params.name;
|
|
47
|
-
const toolArgs = request.params.arguments;
|
|
48
|
-
log(`Tool call received: ${toolName}`);
|
|
49
|
-
const bearerCredential = typeof credential === "function" ? credential() : credential;
|
|
50
|
-
return await handleToolCall(toolName, toolArgs, bearerCredential);
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
handleError("handling tool call", error);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
// Handle resource listing
|
|
57
|
-
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
58
|
-
try {
|
|
59
|
-
return { resources: handleListResources() };
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
handleError("listing resources", error);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
// Handle resource reading
|
|
66
|
-
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
67
|
-
try {
|
|
68
|
-
const resourceUri = request.params.uri;
|
|
69
|
-
const resource = handleReadResource(resourceUri);
|
|
70
|
-
return {
|
|
71
|
-
contents: [{
|
|
72
|
-
uri: resourceUri,
|
|
73
|
-
mimeType: resource.mimeType || "application/json",
|
|
74
|
-
text: JSON.stringify(resource)
|
|
75
|
-
}]
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
handleError("reading resource", error);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
// Handle tool listing
|
|
83
|
-
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
84
|
-
return { tools: ALL_TOOLS };
|
|
85
|
-
});
|
|
71
|
+
return new ProtocolError(INTERNAL_ERROR, `${context}: ${formatError(error)}`);
|
|
86
72
|
}
|
package/build/tools/crawl.js
CHANGED
|
@@ -2,13 +2,13 @@ import { isValidCrawlArgs } from '../types.js';
|
|
|
2
2
|
import { makeRequest } from '../api.js';
|
|
3
3
|
import { formatError, log } from '../utils.js';
|
|
4
4
|
import { API_CONFIG } from '../config.js';
|
|
5
|
-
import {
|
|
5
|
+
import { INVALID_PARAMS, ProtocolError, } from "@modelcontextprotocol/server";
|
|
6
6
|
/**
|
|
7
7
|
* Implementation of the crawl tool
|
|
8
8
|
*/
|
|
9
9
|
export async function handleCrawl(args, apiKey) {
|
|
10
10
|
if (!isValidCrawlArgs(args)) {
|
|
11
|
-
throw new
|
|
11
|
+
throw new ProtocolError(INVALID_PARAMS, "Invalid crawl arguments");
|
|
12
12
|
}
|
|
13
13
|
const { url } = args;
|
|
14
14
|
log("Starting crawl for:", url);
|
|
@@ -17,11 +17,21 @@ export async function handleCrawl(args, apiKey) {
|
|
|
17
17
|
const response = await makeRequest(API_CONFIG.ENDPOINTS.CRAWL, { url }, apiKey);
|
|
18
18
|
const endTime = Date.now();
|
|
19
19
|
log(`Crawl completed successfully in ${endTime - startTime}ms`);
|
|
20
|
+
const result = {
|
|
21
|
+
id: response.results.link || url,
|
|
22
|
+
title: response.results.title,
|
|
23
|
+
url: response.results.link || url,
|
|
24
|
+
text: response.results.content,
|
|
25
|
+
metadata: {
|
|
26
|
+
source: "search1api",
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
const structuredContent = { result };
|
|
20
30
|
return {
|
|
31
|
+
structuredContent,
|
|
21
32
|
content: [{
|
|
22
33
|
type: "text",
|
|
23
|
-
|
|
24
|
-
text: JSON.stringify(response.results, null, 2)
|
|
34
|
+
text: JSON.stringify(structuredContent)
|
|
25
35
|
}]
|
|
26
36
|
};
|
|
27
37
|
}
|
|
@@ -30,7 +40,6 @@ export async function handleCrawl(args, apiKey) {
|
|
|
30
40
|
return {
|
|
31
41
|
content: [{
|
|
32
42
|
type: "text",
|
|
33
|
-
mimeType: "text/plain",
|
|
34
43
|
text: `Crawl API error: ${formatError(error)}`
|
|
35
44
|
}],
|
|
36
45
|
isError: true
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { INVALID_PARAMS, ProtocolError, } from "@modelcontextprotocol/server";
|
|
2
|
+
import { makeRequest } from "../api.js";
|
|
3
|
+
import { API_CONFIG } from "../config.js";
|
|
4
|
+
import { isValidFetchArgs, } from "../types.js";
|
|
5
|
+
import { formatError, log } from "../utils.js";
|
|
6
|
+
/**
|
|
7
|
+
* ChatGPT-compatible fetch implementation. Search result IDs are canonical
|
|
8
|
+
* URLs, so fetch can pass the ID directly to the crawl endpoint.
|
|
9
|
+
*/
|
|
10
|
+
export async function handleFetch(args, apiKey) {
|
|
11
|
+
if (!isValidFetchArgs(args)) {
|
|
12
|
+
throw new ProtocolError(INVALID_PARAMS, "Invalid fetch arguments");
|
|
13
|
+
}
|
|
14
|
+
const { id } = args;
|
|
15
|
+
log("Fetching search result:", id);
|
|
16
|
+
try {
|
|
17
|
+
const response = await makeRequest(API_CONFIG.ENDPOINTS.CRAWL, { url: id }, apiKey);
|
|
18
|
+
const result = {
|
|
19
|
+
id,
|
|
20
|
+
title: response.results.title,
|
|
21
|
+
text: response.results.content,
|
|
22
|
+
url: response.results.link || id,
|
|
23
|
+
metadata: {
|
|
24
|
+
source: "search1api",
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
structuredContent: result,
|
|
29
|
+
content: [
|
|
30
|
+
{
|
|
31
|
+
type: "text",
|
|
32
|
+
text: JSON.stringify(result),
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
log("Fetch error:", error);
|
|
39
|
+
return {
|
|
40
|
+
content: [
|
|
41
|
+
{
|
|
42
|
+
type: "text",
|
|
43
|
+
text: `Fetch API error: ${formatError(error)}`,
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
isError: true,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
package/build/tools/handlers.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { log } from
|
|
3
|
-
import { handleSearch } from
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { INVALID_PARAMS, ProtocolError, } from "@modelcontextprotocol/server";
|
|
2
|
+
import { log } from "../utils.js";
|
|
3
|
+
import { handleSearch } from "./search.js";
|
|
4
|
+
import { handleFetch } from "./fetch.js";
|
|
5
|
+
import { handleCrawl } from "./crawl.js";
|
|
6
|
+
import { handleSitemap } from "./sitemap.js";
|
|
7
|
+
import { handleNews } from "./news.js";
|
|
8
|
+
import { handleTrending } from "./trending.js";
|
|
9
|
+
import { SEARCH_TOOL, FETCH_TOOL, CRAWL_TOOL, SITEMAP_TOOL, NEWS_TOOL, TRENDING_TOOL, } from "./index.js";
|
|
9
10
|
/**
|
|
10
11
|
* Dispatch request based on tool name
|
|
11
12
|
* @param toolName Name of the tool
|
|
12
13
|
* @param args Tool parameters
|
|
13
|
-
* @param apiKey Optional
|
|
14
|
+
* @param apiKey Optional request credential
|
|
14
15
|
* @returns Tool processing result
|
|
15
16
|
*/
|
|
16
17
|
export async function handleToolCall(toolName, args, apiKey) {
|
|
@@ -18,6 +19,8 @@ export async function handleToolCall(toolName, args, apiKey) {
|
|
|
18
19
|
switch (toolName) {
|
|
19
20
|
case SEARCH_TOOL.name:
|
|
20
21
|
return await handleSearch(args, apiKey);
|
|
22
|
+
case FETCH_TOOL.name:
|
|
23
|
+
return await handleFetch(args, apiKey);
|
|
21
24
|
case CRAWL_TOOL.name:
|
|
22
25
|
return await handleCrawl(args, apiKey);
|
|
23
26
|
case SITEMAP_TOOL.name:
|
|
@@ -28,6 +31,6 @@ export async function handleToolCall(toolName, args, apiKey) {
|
|
|
28
31
|
return await handleTrending(args, apiKey);
|
|
29
32
|
default:
|
|
30
33
|
log(`Unknown tool: ${toolName}`);
|
|
31
|
-
throw new
|
|
34
|
+
throw new ProtocolError(INVALID_PARAMS, `Unknown tool: ${toolName}`);
|
|
32
35
|
}
|
|
33
36
|
}
|
package/build/tools/index.js
CHANGED
|
@@ -1,164 +1,315 @@
|
|
|
1
|
+
const AUTHENTICATED_READ_ONLY_WEB = {
|
|
2
|
+
securitySchemes: [
|
|
3
|
+
{
|
|
4
|
+
type: "oauth2",
|
|
5
|
+
scopes: ["openid", "offline_access"],
|
|
6
|
+
},
|
|
7
|
+
],
|
|
8
|
+
_meta: {
|
|
9
|
+
securitySchemes: [
|
|
10
|
+
{
|
|
11
|
+
type: "oauth2",
|
|
12
|
+
scopes: ["openid", "offline_access"],
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
annotations: {
|
|
17
|
+
readOnlyHint: true,
|
|
18
|
+
destructiveHint: false,
|
|
19
|
+
openWorldHint: true,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
const CITABLE_RESULT_SCHEMA = {
|
|
23
|
+
type: "object",
|
|
24
|
+
properties: {
|
|
25
|
+
id: {
|
|
26
|
+
type: "string",
|
|
27
|
+
description: "Stable identifier for this result; for web results this is the canonical URL",
|
|
28
|
+
},
|
|
29
|
+
title: {
|
|
30
|
+
type: "string",
|
|
31
|
+
description: "Human-readable result title",
|
|
32
|
+
},
|
|
33
|
+
url: {
|
|
34
|
+
type: "string",
|
|
35
|
+
format: "uri",
|
|
36
|
+
description: "Canonical URL that clients can cite and users can open",
|
|
37
|
+
},
|
|
38
|
+
text: {
|
|
39
|
+
type: "string",
|
|
40
|
+
description: "Result snippet or extracted page text when available",
|
|
41
|
+
},
|
|
42
|
+
metadata: {
|
|
43
|
+
type: "object",
|
|
44
|
+
description: "Additional source metadata",
|
|
45
|
+
additionalProperties: true,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
required: ["id", "title", "url"],
|
|
49
|
+
};
|
|
50
|
+
const SEARCH_OUTPUT_SCHEMA = {
|
|
51
|
+
type: "object",
|
|
52
|
+
properties: {
|
|
53
|
+
results: {
|
|
54
|
+
type: "array",
|
|
55
|
+
items: CITABLE_RESULT_SCHEMA,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
required: ["results"],
|
|
59
|
+
};
|
|
60
|
+
const FETCH_OUTPUT_SCHEMA = {
|
|
61
|
+
type: "object",
|
|
62
|
+
properties: {
|
|
63
|
+
id: { type: "string" },
|
|
64
|
+
title: { type: "string" },
|
|
65
|
+
text: { type: "string" },
|
|
66
|
+
url: { type: "string", format: "uri" },
|
|
67
|
+
metadata: {
|
|
68
|
+
type: "object",
|
|
69
|
+
additionalProperties: true,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
required: ["id", "title", "text", "url"],
|
|
73
|
+
};
|
|
1
74
|
// Search tool definition
|
|
2
75
|
export const SEARCH_TOOL = {
|
|
3
76
|
name: "search",
|
|
4
|
-
|
|
77
|
+
title: "Search the web",
|
|
78
|
+
description: "Search the live public web when the user needs current information, sources, or research. Returns citable results with id, title, URL, and text. Pass a result id to fetch to retrieve the full page.",
|
|
79
|
+
...AUTHENTICATED_READ_ONLY_WEB,
|
|
5
80
|
inputSchema: {
|
|
6
81
|
type: "object",
|
|
7
82
|
properties: {
|
|
8
83
|
query: {
|
|
9
84
|
type: "string",
|
|
10
|
-
description: "
|
|
85
|
+
description: "Short, focused search query",
|
|
11
86
|
},
|
|
12
87
|
max_results: {
|
|
13
88
|
type: "number",
|
|
89
|
+
minimum: 1,
|
|
90
|
+
maximum: 50,
|
|
14
91
|
description: "Maximum number of results to return",
|
|
15
|
-
default: 10
|
|
92
|
+
default: 10,
|
|
16
93
|
},
|
|
17
94
|
search_service: {
|
|
18
95
|
type: "string",
|
|
19
|
-
description: "
|
|
96
|
+
description: "Search engine to use; choose one only when it matches the user's source intent",
|
|
20
97
|
default: "google",
|
|
21
|
-
enum: ["google", "bing", "duckduckgo", "yahoo", "x", "reddit", "github", "youtube", "arxiv", "wechat", "bilibili", "imdb", "wikipedia"]
|
|
98
|
+
enum: ["google", "bing", "duckduckgo", "yahoo", "x", "reddit", "github", "youtube", "arxiv", "wechat", "bilibili", "imdb", "wikipedia"],
|
|
22
99
|
},
|
|
23
100
|
crawl_results: {
|
|
24
101
|
type: "number",
|
|
25
|
-
|
|
26
|
-
|
|
102
|
+
minimum: 0,
|
|
103
|
+
description: "Number of top results to retrieve as full pages. Each successful page retrieval adds 1 credit to the base 1-credit search request",
|
|
104
|
+
default: 0,
|
|
27
105
|
},
|
|
28
106
|
include_sites: {
|
|
29
107
|
type: "array",
|
|
30
108
|
items: {
|
|
31
|
-
type: "string"
|
|
109
|
+
type: "string",
|
|
32
110
|
},
|
|
33
|
-
description: "
|
|
34
|
-
default: []
|
|
111
|
+
description: "Domains to include when the user explicitly scopes the search",
|
|
112
|
+
default: [],
|
|
35
113
|
},
|
|
36
114
|
exclude_sites: {
|
|
37
115
|
type: "array",
|
|
38
116
|
items: {
|
|
39
|
-
type: "string"
|
|
117
|
+
type: "string",
|
|
40
118
|
},
|
|
41
|
-
description: "
|
|
42
|
-
default: []
|
|
119
|
+
description: "Domains to exclude from the search",
|
|
120
|
+
default: [],
|
|
43
121
|
},
|
|
44
122
|
time_range: {
|
|
45
123
|
type: "string",
|
|
46
|
-
description: "
|
|
47
|
-
enum: ["day", "month", "year"]
|
|
48
|
-
}
|
|
124
|
+
description: "Optional recency window for time-sensitive searches",
|
|
125
|
+
enum: ["day", "month", "year"],
|
|
126
|
+
},
|
|
49
127
|
},
|
|
50
|
-
required: ["query"]
|
|
51
|
-
}
|
|
128
|
+
required: ["query"],
|
|
129
|
+
},
|
|
130
|
+
outputSchema: SEARCH_OUTPUT_SCHEMA,
|
|
131
|
+
};
|
|
132
|
+
// Fetch tool definition for ChatGPT deep research and company knowledge.
|
|
133
|
+
export const FETCH_TOOL = {
|
|
134
|
+
name: "fetch",
|
|
135
|
+
title: "Fetch a search result",
|
|
136
|
+
description: "Retrieve the full readable contents of a result returned by search. Pass the result id, which is the canonical page URL. Returns id, title, full text, URL, and metadata.",
|
|
137
|
+
...AUTHENTICATED_READ_ONLY_WEB,
|
|
138
|
+
inputSchema: {
|
|
139
|
+
type: "object",
|
|
140
|
+
properties: {
|
|
141
|
+
id: {
|
|
142
|
+
type: "string",
|
|
143
|
+
description: "Result id returned by search; for web results this is the canonical URL",
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
required: ["id"],
|
|
147
|
+
},
|
|
148
|
+
outputSchema: FETCH_OUTPUT_SCHEMA,
|
|
52
149
|
};
|
|
53
150
|
// News tool definition
|
|
54
151
|
export const NEWS_TOOL = {
|
|
55
152
|
name: "news",
|
|
56
|
-
|
|
153
|
+
title: "Search current news",
|
|
154
|
+
description: "Search current news when the user asks about recent events, announcements, or coverage. Returns citable article results with title, URL, snippet, and optional extracted text.",
|
|
155
|
+
...AUTHENTICATED_READ_ONLY_WEB,
|
|
57
156
|
inputSchema: {
|
|
58
157
|
type: "object",
|
|
59
158
|
properties: {
|
|
60
159
|
query: {
|
|
61
160
|
type: "string",
|
|
62
|
-
description: "
|
|
161
|
+
description: "Short, focused news query",
|
|
63
162
|
},
|
|
64
163
|
max_results: {
|
|
65
164
|
type: "number",
|
|
66
|
-
|
|
67
|
-
|
|
165
|
+
minimum: 1,
|
|
166
|
+
maximum: 50,
|
|
167
|
+
description: "Maximum number of articles to return",
|
|
168
|
+
default: 10,
|
|
68
169
|
},
|
|
69
170
|
search_service: {
|
|
70
171
|
type: "string",
|
|
71
|
-
description: "
|
|
172
|
+
description: "News search engine to use",
|
|
72
173
|
default: "bing",
|
|
73
|
-
enum: ["google", "bing", "duckduckgo", "yahoo", "hackernews"]
|
|
174
|
+
enum: ["google", "bing", "duckduckgo", "yahoo", "hackernews"],
|
|
74
175
|
},
|
|
75
176
|
crawl_results: {
|
|
76
177
|
type: "number",
|
|
77
|
-
|
|
78
|
-
|
|
178
|
+
minimum: 0,
|
|
179
|
+
description: "Number of top articles to retrieve as full pages. Each successful retrieval adds 1 credit to the base 1-credit news request",
|
|
180
|
+
default: 0,
|
|
79
181
|
},
|
|
80
182
|
include_sites: {
|
|
81
183
|
type: "array",
|
|
82
184
|
items: {
|
|
83
|
-
type: "string"
|
|
185
|
+
type: "string",
|
|
84
186
|
},
|
|
85
|
-
description: "
|
|
86
|
-
default: []
|
|
187
|
+
description: "News domains to include",
|
|
188
|
+
default: [],
|
|
87
189
|
},
|
|
88
190
|
exclude_sites: {
|
|
89
191
|
type: "array",
|
|
90
192
|
items: {
|
|
91
|
-
type: "string"
|
|
193
|
+
type: "string",
|
|
92
194
|
},
|
|
93
|
-
description: "
|
|
94
|
-
default: []
|
|
195
|
+
description: "News domains to exclude",
|
|
196
|
+
default: [],
|
|
95
197
|
},
|
|
96
198
|
time_range: {
|
|
97
199
|
type: "string",
|
|
98
|
-
description: "
|
|
99
|
-
enum: ["day", "month", "year"]
|
|
100
|
-
}
|
|
200
|
+
description: "Optional recency window; use day for breaking news",
|
|
201
|
+
enum: ["day", "month", "year"],
|
|
202
|
+
},
|
|
101
203
|
},
|
|
102
|
-
required: ["query"]
|
|
103
|
-
}
|
|
204
|
+
required: ["query"],
|
|
205
|
+
},
|
|
206
|
+
outputSchema: SEARCH_OUTPUT_SCHEMA,
|
|
104
207
|
};
|
|
105
208
|
// Crawl tool definition
|
|
106
209
|
export const CRAWL_TOOL = {
|
|
107
210
|
name: "crawl",
|
|
108
|
-
|
|
211
|
+
title: "Read a web page",
|
|
212
|
+
description: "Extract the readable title and full text from a specific public URL supplied by the user. Use fetch instead when following a result returned by search.",
|
|
213
|
+
...AUTHENTICATED_READ_ONLY_WEB,
|
|
109
214
|
inputSchema: {
|
|
110
215
|
type: "object",
|
|
111
216
|
properties: {
|
|
112
217
|
url: {
|
|
113
218
|
type: "string",
|
|
114
|
-
|
|
115
|
-
|
|
219
|
+
format: "uri",
|
|
220
|
+
description: "Public HTTP or HTTPS URL to retrieve",
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
required: ["url"],
|
|
224
|
+
},
|
|
225
|
+
outputSchema: {
|
|
226
|
+
type: "object",
|
|
227
|
+
properties: {
|
|
228
|
+
result: CITABLE_RESULT_SCHEMA,
|
|
116
229
|
},
|
|
117
|
-
required: ["
|
|
118
|
-
}
|
|
230
|
+
required: ["result"],
|
|
231
|
+
},
|
|
119
232
|
};
|
|
120
233
|
// Sitemap tool definition
|
|
121
234
|
export const SITEMAP_TOOL = {
|
|
122
235
|
name: "sitemap",
|
|
123
|
-
|
|
236
|
+
title: "Discover links on a site",
|
|
237
|
+
description: "Discover related public links from a page or domain when the user wants to explore a site's structure or available pages.",
|
|
238
|
+
...AUTHENTICATED_READ_ONLY_WEB,
|
|
124
239
|
inputSchema: {
|
|
125
240
|
type: "object",
|
|
126
241
|
properties: {
|
|
127
242
|
url: {
|
|
128
243
|
type: "string",
|
|
129
|
-
|
|
130
|
-
|
|
244
|
+
format: "uri",
|
|
245
|
+
description: "Public page or domain URL whose links should be discovered",
|
|
246
|
+
},
|
|
131
247
|
},
|
|
132
|
-
required: ["url"]
|
|
133
|
-
}
|
|
248
|
+
required: ["url"],
|
|
249
|
+
},
|
|
250
|
+
outputSchema: {
|
|
251
|
+
type: "object",
|
|
252
|
+
properties: {
|
|
253
|
+
links: {
|
|
254
|
+
type: "array",
|
|
255
|
+
items: {
|
|
256
|
+
type: "string",
|
|
257
|
+
format: "uri",
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
required: ["links"],
|
|
262
|
+
},
|
|
134
263
|
};
|
|
135
264
|
// Trending tool definition
|
|
136
265
|
export const TRENDING_TOOL = {
|
|
137
266
|
name: "trending",
|
|
138
|
-
|
|
267
|
+
title: "Explore trending topics",
|
|
268
|
+
description: "List currently trending repositories or stories from GitHub or Hacker News when the user asks what is popular now.",
|
|
269
|
+
...AUTHENTICATED_READ_ONLY_WEB,
|
|
139
270
|
inputSchema: {
|
|
140
271
|
type: "object",
|
|
141
272
|
properties: {
|
|
142
273
|
search_service: {
|
|
143
274
|
type: "string",
|
|
144
|
-
description: "
|
|
275
|
+
description: "Platform whose trending items should be returned",
|
|
145
276
|
enum: ["github", "hackernews"],
|
|
146
|
-
default: "github"
|
|
277
|
+
default: "github",
|
|
147
278
|
},
|
|
148
279
|
max_results: {
|
|
149
280
|
type: "number",
|
|
281
|
+
minimum: 1,
|
|
282
|
+
maximum: 50,
|
|
150
283
|
description: "Maximum number of trending items to return",
|
|
151
|
-
default: 10
|
|
152
|
-
}
|
|
284
|
+
default: 10,
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
required: ["search_service"],
|
|
288
|
+
},
|
|
289
|
+
outputSchema: {
|
|
290
|
+
type: "object",
|
|
291
|
+
properties: {
|
|
292
|
+
results: {
|
|
293
|
+
type: "array",
|
|
294
|
+
items: {
|
|
295
|
+
type: "object",
|
|
296
|
+
properties: {
|
|
297
|
+
title: { type: "string" },
|
|
298
|
+
url: { type: "string", format: "uri" },
|
|
299
|
+
description: { type: "string" },
|
|
300
|
+
},
|
|
301
|
+
required: ["title", "url"],
|
|
302
|
+
},
|
|
303
|
+
},
|
|
153
304
|
},
|
|
154
|
-
required: ["
|
|
155
|
-
}
|
|
305
|
+
required: ["results"],
|
|
306
|
+
},
|
|
156
307
|
};
|
|
157
|
-
// Export all tools
|
|
158
308
|
export const ALL_TOOLS = [
|
|
159
309
|
SEARCH_TOOL,
|
|
310
|
+
FETCH_TOOL,
|
|
160
311
|
NEWS_TOOL,
|
|
161
312
|
CRAWL_TOOL,
|
|
162
313
|
SITEMAP_TOOL,
|
|
163
|
-
TRENDING_TOOL
|
|
314
|
+
TRENDING_TOOL,
|
|
164
315
|
];
|