@youdotcom-oss/mcp 1.3.8 → 1.3.9-next.1
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/bin/stdio.js +879 -774
- package/dist/contents/contents.schemas.d.ts +39 -0
- package/dist/contents/contents.utils.d.ts +28 -0
- package/dist/contents/register-contents-tool.d.ts +10 -0
- package/dist/express/express.schemas.d.ts +56 -0
- package/dist/express/express.utils.d.ts +45 -0
- package/dist/express/register-express-tool.d.ts +6 -0
- package/dist/get-mcp-server.d.ts +2 -0
- package/dist/http.d.ts +3 -0
- package/{src/utils.ts → dist/main.d.ts} +1 -0
- package/dist/search/register-search-tool.d.ts +6 -0
- package/dist/search/search.schemas.d.ts +131 -0
- package/dist/search/search.utils.d.ts +96 -0
- package/dist/shared/api-constants.d.ts +9 -0
- package/dist/shared/check-response-for-errors.d.ts +6 -0
- package/dist/shared/format-search-results-text.d.ts +19 -0
- package/dist/shared/generate-error-report-link.d.ts +9 -0
- package/dist/shared/get-logger.d.ts +7 -0
- package/dist/shared/use-client-version.d.ts +6 -0
- package/dist/stdio.d.ts +2 -0
- package/package.json +14 -7
- package/src/contents/contents.utils.ts +1 -2
- package/src/contents/tests/contents.utils.spec.ts +69 -57
- package/src/express/express.utils.ts +2 -4
- package/src/express/tests/express.utils.spec.ts +74 -62
- package/src/main.ts +9 -0
- package/src/search/search.utils.ts +2 -1
- package/src/search/tests/search.utils.spec.ts +114 -92
- package/src/shared/api-constants.ts +10 -0
- package/src/tests/http.spec.ts +35 -31
- package/src/tests/tool.spec.ts +490 -402
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Input schema for the you-contents tool
|
|
4
|
+
* Accepts an array of URLs and optional format
|
|
5
|
+
*/
|
|
6
|
+
export declare const ContentsQuerySchema: z.ZodObject<{
|
|
7
|
+
urls: z.ZodArray<z.ZodString>;
|
|
8
|
+
format: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
9
|
+
markdown: "markdown";
|
|
10
|
+
html: "html";
|
|
11
|
+
}>>>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
export type ContentsQuery = z.infer<typeof ContentsQuerySchema>;
|
|
14
|
+
/**
|
|
15
|
+
* API response schema from You.com Contents API
|
|
16
|
+
* Validates the full response array
|
|
17
|
+
*/
|
|
18
|
+
export declare const ContentsApiResponseSchema: z.ZodArray<z.ZodObject<{
|
|
19
|
+
url: z.ZodString;
|
|
20
|
+
title: z.ZodOptional<z.ZodString>;
|
|
21
|
+
html: z.ZodOptional<z.ZodString>;
|
|
22
|
+
markdown: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, z.core.$strip>>;
|
|
24
|
+
export type ContentsApiResponse = z.infer<typeof ContentsApiResponseSchema>;
|
|
25
|
+
/**
|
|
26
|
+
* Structured content schema for MCP response
|
|
27
|
+
* Includes full content and metadata for each URL
|
|
28
|
+
*/
|
|
29
|
+
export declare const ContentsStructuredContentSchema: z.ZodObject<{
|
|
30
|
+
count: z.ZodNumber;
|
|
31
|
+
format: z.ZodString;
|
|
32
|
+
items: z.ZodArray<z.ZodObject<{
|
|
33
|
+
url: z.ZodString;
|
|
34
|
+
title: z.ZodOptional<z.ZodString>;
|
|
35
|
+
content: z.ZodString;
|
|
36
|
+
contentLength: z.ZodNumber;
|
|
37
|
+
}, z.core.$strip>>;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
export type ContentsStructuredContent = z.infer<typeof ContentsStructuredContentSchema>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ContentsApiResponse, type ContentsQuery, type ContentsStructuredContent } from './contents.schemas.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Fetch content from You.com Contents API
|
|
4
|
+
* The API accepts multiple URLs in a single request and returns all results
|
|
5
|
+
* @param contentsQuery - Query parameters including URLs and format
|
|
6
|
+
* @param YDC_API_KEY - You.com API key
|
|
7
|
+
* @param getUserAgent - Function to get User-Agent string
|
|
8
|
+
* @returns Parsed and validated API response
|
|
9
|
+
*/
|
|
10
|
+
export declare const fetchContents: ({ contentsQuery: { urls, format }, YDC_API_KEY, getUserAgent, }: {
|
|
11
|
+
contentsQuery: ContentsQuery;
|
|
12
|
+
YDC_API_KEY?: string;
|
|
13
|
+
getUserAgent: () => string;
|
|
14
|
+
}) => Promise<ContentsApiResponse>;
|
|
15
|
+
/**
|
|
16
|
+
* Format contents API response for MCP output
|
|
17
|
+
* Returns full content in both text and structured formats
|
|
18
|
+
* @param response - Validated API response
|
|
19
|
+
* @param format - Format used for extraction
|
|
20
|
+
* @returns Formatted response with content and structuredContent
|
|
21
|
+
*/
|
|
22
|
+
export declare const formatContentsResponse: (response: ContentsApiResponse, format: string) => {
|
|
23
|
+
content: Array<{
|
|
24
|
+
type: "text";
|
|
25
|
+
text: string;
|
|
26
|
+
}>;
|
|
27
|
+
structuredContent: ContentsStructuredContent;
|
|
28
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
/**
|
|
3
|
+
* Register the you-contents tool with the MCP server
|
|
4
|
+
* Extracts and returns full content from multiple URLs in markdown or HTML format
|
|
5
|
+
*/
|
|
6
|
+
export declare const registerContentsTool: ({ mcp, YDC_API_KEY, getUserAgent, }: {
|
|
7
|
+
mcp: McpServer;
|
|
8
|
+
YDC_API_KEY?: string;
|
|
9
|
+
getUserAgent: () => string;
|
|
10
|
+
}) => void;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
export declare const ExpressAgentInputSchema: z.ZodObject<{
|
|
3
|
+
input: z.ZodString;
|
|
4
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
5
|
+
type: z.ZodEnum<{
|
|
6
|
+
web_search: "web_search";
|
|
7
|
+
}>;
|
|
8
|
+
}, z.core.$strip>>>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
export type ExpressAgentInput = z.infer<typeof ExpressAgentInputSchema>;
|
|
11
|
+
export declare const ExpressAgentApiResponseSchema: z.ZodObject<{
|
|
12
|
+
output: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
13
|
+
type: z.ZodLiteral<"web_search.results">;
|
|
14
|
+
content: z.ZodArray<z.ZodObject<{
|
|
15
|
+
source_type: z.ZodOptional<z.ZodString>;
|
|
16
|
+
citation_uri: z.ZodOptional<z.ZodString>;
|
|
17
|
+
url: z.ZodString;
|
|
18
|
+
title: z.ZodString;
|
|
19
|
+
snippet: z.ZodString;
|
|
20
|
+
thumbnail_url: z.ZodOptional<z.ZodString>;
|
|
21
|
+
provider: z.ZodOptional<z.ZodAny>;
|
|
22
|
+
}, z.core.$strip>>;
|
|
23
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
24
|
+
type: z.ZodLiteral<"message.answer">;
|
|
25
|
+
text: z.ZodString;
|
|
26
|
+
}, z.core.$strip>]>>;
|
|
27
|
+
agent: z.ZodOptional<z.ZodString>;
|
|
28
|
+
mode: z.ZodOptional<z.ZodString>;
|
|
29
|
+
input: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
30
|
+
}, z.core.$loose>;
|
|
31
|
+
export type ExpressAgentApiResponse = z.infer<typeof ExpressAgentApiResponseSchema>;
|
|
32
|
+
declare const ExpressAgentMcpResponseSchema: z.ZodObject<{
|
|
33
|
+
answer: z.ZodString;
|
|
34
|
+
results: z.ZodOptional<z.ZodObject<{
|
|
35
|
+
web: z.ZodArray<z.ZodObject<{
|
|
36
|
+
url: z.ZodString;
|
|
37
|
+
title: z.ZodString;
|
|
38
|
+
snippet: z.ZodString;
|
|
39
|
+
}, z.core.$strip>>;
|
|
40
|
+
}, z.core.$strip>>;
|
|
41
|
+
agent: z.ZodOptional<z.ZodString>;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
export type ExpressAgentMcpResponse = z.infer<typeof ExpressAgentMcpResponseSchema>;
|
|
44
|
+
export declare const ExpressStructuredContentSchema: z.ZodObject<{
|
|
45
|
+
answer: z.ZodString;
|
|
46
|
+
hasResults: z.ZodBoolean;
|
|
47
|
+
resultCount: z.ZodNumber;
|
|
48
|
+
agent: z.ZodOptional<z.ZodString>;
|
|
49
|
+
results: z.ZodOptional<z.ZodObject<{
|
|
50
|
+
web: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
51
|
+
url: z.ZodString;
|
|
52
|
+
title: z.ZodString;
|
|
53
|
+
}, z.core.$strip>>>;
|
|
54
|
+
}, z.core.$strip>>;
|
|
55
|
+
}, z.core.$strip>;
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type ExpressAgentInput, type ExpressAgentMcpResponse } from './express.schemas.ts';
|
|
2
|
+
export declare const callExpressAgent: ({ YDC_API_KEY, agentInput: { input, tools }, getUserAgent, }: {
|
|
3
|
+
agentInput: ExpressAgentInput;
|
|
4
|
+
YDC_API_KEY?: string;
|
|
5
|
+
getUserAgent: () => string;
|
|
6
|
+
}) => Promise<{
|
|
7
|
+
answer: string;
|
|
8
|
+
results?: {
|
|
9
|
+
web: {
|
|
10
|
+
url: string;
|
|
11
|
+
title: string;
|
|
12
|
+
snippet: string;
|
|
13
|
+
}[];
|
|
14
|
+
} | undefined;
|
|
15
|
+
agent?: string | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
export declare const formatExpressAgentResponse: (response: ExpressAgentMcpResponse) => {
|
|
18
|
+
content: {
|
|
19
|
+
type: "text";
|
|
20
|
+
text: string;
|
|
21
|
+
}[];
|
|
22
|
+
structuredContent: {
|
|
23
|
+
answer: string;
|
|
24
|
+
hasResults: boolean;
|
|
25
|
+
resultCount: number;
|
|
26
|
+
agent: string | undefined;
|
|
27
|
+
results: {
|
|
28
|
+
web: {
|
|
29
|
+
url: string;
|
|
30
|
+
title: string;
|
|
31
|
+
}[];
|
|
32
|
+
} | undefined;
|
|
33
|
+
};
|
|
34
|
+
fullResponse: {
|
|
35
|
+
answer: string;
|
|
36
|
+
results?: {
|
|
37
|
+
web: {
|
|
38
|
+
url: string;
|
|
39
|
+
title: string;
|
|
40
|
+
snippet: string;
|
|
41
|
+
}[];
|
|
42
|
+
} | undefined;
|
|
43
|
+
agent?: string | undefined;
|
|
44
|
+
};
|
|
45
|
+
};
|
package/dist/http.d.ts
ADDED
|
@@ -4,5 +4,6 @@ export * from './express/express.schemas.ts';
|
|
|
4
4
|
export * from './express/express.utils.ts';
|
|
5
5
|
export * from './search/search.schemas.ts';
|
|
6
6
|
export * from './search/search.utils.ts';
|
|
7
|
+
export * from './shared/api-constants.ts';
|
|
7
8
|
export * from './shared/check-response-for-errors.ts';
|
|
8
9
|
export * from './shared/format-search-results-text.ts';
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
export declare const SearchQuerySchema: z.ZodObject<{
|
|
3
|
+
query: z.ZodString;
|
|
4
|
+
count: z.ZodOptional<z.ZodNumber>;
|
|
5
|
+
freshness: z.ZodOptional<z.ZodString>;
|
|
6
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
7
|
+
country: z.ZodOptional<z.ZodEnum<{
|
|
8
|
+
AR: "AR";
|
|
9
|
+
AU: "AU";
|
|
10
|
+
AT: "AT";
|
|
11
|
+
BE: "BE";
|
|
12
|
+
BR: "BR";
|
|
13
|
+
CA: "CA";
|
|
14
|
+
CL: "CL";
|
|
15
|
+
DK: "DK";
|
|
16
|
+
FI: "FI";
|
|
17
|
+
FR: "FR";
|
|
18
|
+
DE: "DE";
|
|
19
|
+
HK: "HK";
|
|
20
|
+
IN: "IN";
|
|
21
|
+
ID: "ID";
|
|
22
|
+
IT: "IT";
|
|
23
|
+
JP: "JP";
|
|
24
|
+
KR: "KR";
|
|
25
|
+
MY: "MY";
|
|
26
|
+
MX: "MX";
|
|
27
|
+
NL: "NL";
|
|
28
|
+
NZ: "NZ";
|
|
29
|
+
NO: "NO";
|
|
30
|
+
CN: "CN";
|
|
31
|
+
PL: "PL";
|
|
32
|
+
PT: "PT";
|
|
33
|
+
PH: "PH";
|
|
34
|
+
RU: "RU";
|
|
35
|
+
SA: "SA";
|
|
36
|
+
ZA: "ZA";
|
|
37
|
+
ES: "ES";
|
|
38
|
+
SE: "SE";
|
|
39
|
+
CH: "CH";
|
|
40
|
+
TW: "TW";
|
|
41
|
+
TR: "TR";
|
|
42
|
+
GB: "GB";
|
|
43
|
+
US: "US";
|
|
44
|
+
}>>;
|
|
45
|
+
safesearch: z.ZodOptional<z.ZodEnum<{
|
|
46
|
+
off: "off";
|
|
47
|
+
moderate: "moderate";
|
|
48
|
+
strict: "strict";
|
|
49
|
+
}>>;
|
|
50
|
+
site: z.ZodOptional<z.ZodString>;
|
|
51
|
+
fileType: z.ZodOptional<z.ZodString>;
|
|
52
|
+
language: z.ZodOptional<z.ZodString>;
|
|
53
|
+
excludeTerms: z.ZodOptional<z.ZodString>;
|
|
54
|
+
exactTerms: z.ZodOptional<z.ZodString>;
|
|
55
|
+
livecrawl: z.ZodOptional<z.ZodEnum<{
|
|
56
|
+
web: "web";
|
|
57
|
+
news: "news";
|
|
58
|
+
all: "all";
|
|
59
|
+
}>>;
|
|
60
|
+
livecrawl_formats: z.ZodOptional<z.ZodEnum<{
|
|
61
|
+
markdown: "markdown";
|
|
62
|
+
html: "html";
|
|
63
|
+
}>>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
export type SearchQuery = z.infer<typeof SearchQuerySchema>;
|
|
66
|
+
declare const NewsResultSchema: z.ZodObject<{
|
|
67
|
+
title: z.ZodString;
|
|
68
|
+
description: z.ZodString;
|
|
69
|
+
page_age: z.ZodString;
|
|
70
|
+
url: z.ZodString;
|
|
71
|
+
thumbnail_url: z.ZodOptional<z.ZodString>;
|
|
72
|
+
contents: z.ZodOptional<z.ZodObject<{
|
|
73
|
+
html: z.ZodOptional<z.ZodString>;
|
|
74
|
+
markdown: z.ZodOptional<z.ZodString>;
|
|
75
|
+
}, z.core.$strip>>;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
export type NewsResult = z.infer<typeof NewsResultSchema>;
|
|
78
|
+
export declare const SearchResponseSchema: z.ZodObject<{
|
|
79
|
+
results: z.ZodObject<{
|
|
80
|
+
web: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
81
|
+
url: z.ZodString;
|
|
82
|
+
title: z.ZodString;
|
|
83
|
+
description: z.ZodString;
|
|
84
|
+
snippets: z.ZodArray<z.ZodString>;
|
|
85
|
+
page_age: z.ZodOptional<z.ZodString>;
|
|
86
|
+
authors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
87
|
+
thumbnail_url: z.ZodOptional<z.ZodString>;
|
|
88
|
+
favicon_url: z.ZodOptional<z.ZodString>;
|
|
89
|
+
contents: z.ZodOptional<z.ZodObject<{
|
|
90
|
+
html: z.ZodOptional<z.ZodString>;
|
|
91
|
+
markdown: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, z.core.$strip>>;
|
|
93
|
+
}, z.core.$strip>>>;
|
|
94
|
+
news: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
95
|
+
title: z.ZodString;
|
|
96
|
+
description: z.ZodString;
|
|
97
|
+
page_age: z.ZodString;
|
|
98
|
+
url: z.ZodString;
|
|
99
|
+
thumbnail_url: z.ZodOptional<z.ZodString>;
|
|
100
|
+
contents: z.ZodOptional<z.ZodObject<{
|
|
101
|
+
html: z.ZodOptional<z.ZodString>;
|
|
102
|
+
markdown: z.ZodOptional<z.ZodString>;
|
|
103
|
+
}, z.core.$strip>>;
|
|
104
|
+
}, z.core.$strip>>>;
|
|
105
|
+
}, z.core.$strip>;
|
|
106
|
+
metadata: z.ZodObject<{
|
|
107
|
+
search_uuid: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
108
|
+
query: z.ZodOptional<z.ZodString>;
|
|
109
|
+
latency: z.ZodOptional<z.ZodNumber>;
|
|
110
|
+
}, z.core.$strip>;
|
|
111
|
+
}, z.core.$strip>;
|
|
112
|
+
export type SearchResponse = z.infer<typeof SearchResponseSchema>;
|
|
113
|
+
export declare const SearchStructuredContentSchema: z.ZodObject<{
|
|
114
|
+
resultCounts: z.ZodObject<{
|
|
115
|
+
web: z.ZodNumber;
|
|
116
|
+
news: z.ZodNumber;
|
|
117
|
+
total: z.ZodNumber;
|
|
118
|
+
}, z.core.$strip>;
|
|
119
|
+
results: z.ZodOptional<z.ZodObject<{
|
|
120
|
+
web: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
121
|
+
url: z.ZodString;
|
|
122
|
+
title: z.ZodString;
|
|
123
|
+
}, z.core.$strip>>>;
|
|
124
|
+
news: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
125
|
+
url: z.ZodString;
|
|
126
|
+
title: z.ZodString;
|
|
127
|
+
}, z.core.$strip>>>;
|
|
128
|
+
}, z.core.$strip>>;
|
|
129
|
+
}, z.core.$strip>;
|
|
130
|
+
export type SearchStructuredContent = z.infer<typeof SearchStructuredContentSchema>;
|
|
131
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { type SearchQuery, type SearchResponse } from './search.schemas.ts';
|
|
2
|
+
export declare const fetchSearchResults: ({ YDC_API_KEY, searchQuery: { query, site, fileType, language, exactTerms, excludeTerms, ...rest }, getUserAgent, }: {
|
|
3
|
+
searchQuery: SearchQuery;
|
|
4
|
+
YDC_API_KEY?: string;
|
|
5
|
+
getUserAgent: () => string;
|
|
6
|
+
}) => Promise<{
|
|
7
|
+
results: {
|
|
8
|
+
web?: {
|
|
9
|
+
url: string;
|
|
10
|
+
title: string;
|
|
11
|
+
description: string;
|
|
12
|
+
snippets: string[];
|
|
13
|
+
page_age?: string | undefined;
|
|
14
|
+
authors?: string[] | undefined;
|
|
15
|
+
thumbnail_url?: string | undefined;
|
|
16
|
+
favicon_url?: string | undefined;
|
|
17
|
+
contents?: {
|
|
18
|
+
html?: string | undefined;
|
|
19
|
+
markdown?: string | undefined;
|
|
20
|
+
} | undefined;
|
|
21
|
+
}[] | undefined;
|
|
22
|
+
news?: {
|
|
23
|
+
title: string;
|
|
24
|
+
description: string;
|
|
25
|
+
page_age: string;
|
|
26
|
+
url: string;
|
|
27
|
+
thumbnail_url?: string | undefined;
|
|
28
|
+
contents?: {
|
|
29
|
+
html?: string | undefined;
|
|
30
|
+
markdown?: string | undefined;
|
|
31
|
+
} | undefined;
|
|
32
|
+
}[] | undefined;
|
|
33
|
+
};
|
|
34
|
+
metadata: {
|
|
35
|
+
search_uuid?: string | undefined;
|
|
36
|
+
query?: string | undefined;
|
|
37
|
+
latency?: number | undefined;
|
|
38
|
+
};
|
|
39
|
+
}>;
|
|
40
|
+
export declare const formatSearchResults: (response: SearchResponse) => {
|
|
41
|
+
content: {
|
|
42
|
+
type: "text";
|
|
43
|
+
text: string;
|
|
44
|
+
}[];
|
|
45
|
+
structuredContent: {
|
|
46
|
+
resultCounts: {
|
|
47
|
+
web: number;
|
|
48
|
+
news: number;
|
|
49
|
+
total: number;
|
|
50
|
+
};
|
|
51
|
+
results: {
|
|
52
|
+
web?: Array<{
|
|
53
|
+
url: string;
|
|
54
|
+
title: string;
|
|
55
|
+
}>;
|
|
56
|
+
news?: Array<{
|
|
57
|
+
url: string;
|
|
58
|
+
title: string;
|
|
59
|
+
}>;
|
|
60
|
+
} | undefined;
|
|
61
|
+
};
|
|
62
|
+
fullResponse: {
|
|
63
|
+
results: {
|
|
64
|
+
web?: {
|
|
65
|
+
url: string;
|
|
66
|
+
title: string;
|
|
67
|
+
description: string;
|
|
68
|
+
snippets: string[];
|
|
69
|
+
page_age?: string | undefined;
|
|
70
|
+
authors?: string[] | undefined;
|
|
71
|
+
thumbnail_url?: string | undefined;
|
|
72
|
+
favicon_url?: string | undefined;
|
|
73
|
+
contents?: {
|
|
74
|
+
html?: string | undefined;
|
|
75
|
+
markdown?: string | undefined;
|
|
76
|
+
} | undefined;
|
|
77
|
+
}[] | undefined;
|
|
78
|
+
news?: {
|
|
79
|
+
title: string;
|
|
80
|
+
description: string;
|
|
81
|
+
page_age: string;
|
|
82
|
+
url: string;
|
|
83
|
+
thumbnail_url?: string | undefined;
|
|
84
|
+
contents?: {
|
|
85
|
+
html?: string | undefined;
|
|
86
|
+
markdown?: string | undefined;
|
|
87
|
+
} | undefined;
|
|
88
|
+
}[] | undefined;
|
|
89
|
+
};
|
|
90
|
+
metadata: {
|
|
91
|
+
search_uuid?: string | undefined;
|
|
92
|
+
query?: string | undefined;
|
|
93
|
+
latency?: number | undefined;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* You.com API endpoints
|
|
3
|
+
*
|
|
4
|
+
* These constants define the base URLs for You.com's APIs.
|
|
5
|
+
* Exported for use in tests and external packages.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SEARCH_API_URL = "https://ydc-index.io/v1/search";
|
|
8
|
+
export declare const EXPRESS_API_URL = "https://api.you.com/v1/agents/runs";
|
|
9
|
+
export declare const CONTENTS_API_URL = "https://ydc-index.io/v1/contents";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a response object contains an error field and throws if found
|
|
3
|
+
* Handles API responses that return 200 status but contain error messages
|
|
4
|
+
* Used by both search and express agent utilities
|
|
5
|
+
*/
|
|
6
|
+
export declare const checkResponseForErrors: (responseData: unknown) => unknown;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic search result type that works for both Search and Express APIs
|
|
3
|
+
* Used by both search.utils.ts and express.utils.ts
|
|
4
|
+
*/
|
|
5
|
+
type GenericSearchResult = {
|
|
6
|
+
url: string;
|
|
7
|
+
title: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
snippet?: string;
|
|
10
|
+
snippets?: string[];
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Format array of search results into display text
|
|
14
|
+
* Used by both search and express agent formatting
|
|
15
|
+
* @param results - Array of search results to format
|
|
16
|
+
* @param includeUrls - Whether to include URLs in the text (default: true)
|
|
17
|
+
*/
|
|
18
|
+
export declare const formatSearchResultsText: (results: GenericSearchResult[]) => string;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a mailto link for error reporting with pre-filled context
|
|
3
|
+
* Used by tool error handlers to provide easy error reporting
|
|
4
|
+
*/
|
|
5
|
+
export declare const generateErrorReportLink: ({ errorMessage, tool, clientInfo, }: {
|
|
6
|
+
errorMessage: string;
|
|
7
|
+
tool: string;
|
|
8
|
+
clientInfo: string;
|
|
9
|
+
}) => string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { LoggingMessageNotification } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a logger function that sends messages through MCP server
|
|
5
|
+
* Used by tool registration files
|
|
6
|
+
*/
|
|
7
|
+
export declare const getLogger: (mcp: McpServer) => (params: LoggingMessageNotification["params"]) => Promise<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
/**
|
|
3
|
+
* Get's function that returns a formatted client version information into a string
|
|
4
|
+
* Used by stdio.ts and http.ts for logging/debugging
|
|
5
|
+
*/
|
|
6
|
+
export declare const useGetClientVersion: (mcp: McpServer) => () => string;
|
package/dist/stdio.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@youdotcom-oss/mcp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.9-next.1",
|
|
4
4
|
"description": "You.com API Model Context Protocol Server",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -24,14 +24,18 @@
|
|
|
24
24
|
],
|
|
25
25
|
"bin": "bin/stdio.js",
|
|
26
26
|
"type": "module",
|
|
27
|
-
"main": "./src/
|
|
27
|
+
"main": "./src/main.ts",
|
|
28
28
|
"exports": {
|
|
29
|
-
".":
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/main.d.ts",
|
|
31
|
+
"default": "./src/main.ts"
|
|
32
|
+
},
|
|
30
33
|
"./http": "./src/http.ts",
|
|
31
34
|
"./stdio": "./src/stdio.ts"
|
|
32
35
|
},
|
|
33
36
|
"files": [
|
|
34
37
|
"bin/stdio.js",
|
|
38
|
+
"./dist/**",
|
|
35
39
|
"./src/**",
|
|
36
40
|
"!./src/**/tests/*",
|
|
37
41
|
"!./src/**/*.spec.@(tsx|ts)"
|
|
@@ -40,7 +44,9 @@
|
|
|
40
44
|
"access": "public"
|
|
41
45
|
},
|
|
42
46
|
"scripts": {
|
|
43
|
-
"build": "bun build
|
|
47
|
+
"build": "bun run build:stdio && bun run build:types",
|
|
48
|
+
"build:stdio": "bun build ./src/stdio.ts --outfile ./bin/stdio.js --target=node",
|
|
49
|
+
"build:types": "tsc --project tsconfig.json --declaration --emitDeclarationOnly --noEmit false",
|
|
44
50
|
"check": "bun run check:biome && bun run check:types && bun run check:package",
|
|
45
51
|
"check:biome": "biome check",
|
|
46
52
|
"check:package": "format-package --check",
|
|
@@ -60,11 +66,12 @@
|
|
|
60
66
|
"test:watch": "bun test --watch"
|
|
61
67
|
},
|
|
62
68
|
"mcpName": "io.github.youdotcom-oss/mcp",
|
|
69
|
+
"types": "./dist/main.d.ts",
|
|
63
70
|
"dependencies": {
|
|
64
|
-
"zod": "^4.
|
|
65
|
-
"@hono/mcp": "^0.2.
|
|
71
|
+
"zod": "^4.2.0",
|
|
72
|
+
"@hono/mcp": "^0.2.2",
|
|
66
73
|
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
67
|
-
"hono": "^4.
|
|
74
|
+
"hono": "^4.11.1"
|
|
68
75
|
},
|
|
69
76
|
"devDependencies": {
|
|
70
77
|
"@modelcontextprotocol/inspector": "0.17.5"
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CONTENTS_API_URL } from '../shared/api-constants.ts';
|
|
1
2
|
import { checkResponseForErrors } from '../shared/check-response-for-errors.ts';
|
|
2
3
|
import {
|
|
3
4
|
type ContentsApiResponse,
|
|
@@ -6,8 +7,6 @@ import {
|
|
|
6
7
|
type ContentsStructuredContent,
|
|
7
8
|
} from './contents.schemas.ts';
|
|
8
9
|
|
|
9
|
-
const CONTENTS_API_URL = 'https://ydc-index.io/v1/contents';
|
|
10
|
-
|
|
11
10
|
/**
|
|
12
11
|
* Fetch content from You.com Contents API
|
|
13
12
|
* The API accepts multiple URLs in a single request and returns all results
|