@youdotcom-oss/mcp 1.5.0 → 1.6.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/bin/stdio.js +394 -415
- package/package.json +12 -23
- package/src/contents/contents.schemas.ts +3 -48
- package/src/contents/contents.utils.ts +33 -133
- package/src/contents/register-contents-tool.ts +24 -24
- package/src/contents/tests/contents.utils.spec.ts +58 -134
- package/src/express/express.schema.ts +23 -0
- package/src/express/express.utils.ts +10 -121
- package/src/express/register-express-tool.ts +19 -19
- package/src/express/tests/express.utils.spec.ts +80 -159
- package/src/get-mcp-server.ts +3 -3
- package/src/http.ts +38 -38
- package/src/search/register-search-tool.ts +23 -23
- package/src/search/search.schema.ts +38 -0
- package/src/search/search.utils.ts +18 -96
- package/src/search/tests/search.utils.spec.ts +61 -194
- package/src/shared/format-search-results-text.ts +16 -16
- package/src/shared/get-logger.ts +4 -4
- package/src/shared/tests/shared.utils.spec.ts +56 -56
- package/src/shared/use-client-version.ts +8 -8
- package/src/stdio.ts +16 -16
- package/src/tests/http.spec.ts +105 -105
- package/src/tests/tool.spec.ts +212 -212
- package/dist/contents/contents.schemas.d.ts +0 -55
- package/dist/contents/contents.utils.d.ts +0 -28
- package/dist/contents/register-contents-tool.d.ts +0 -10
- package/dist/express/express.schemas.d.ts +0 -56
- package/dist/express/express.utils.d.ts +0 -45
- package/dist/express/register-express-tool.d.ts +0 -6
- package/dist/get-mcp-server.d.ts +0 -2
- package/dist/http.d.ts +0 -3
- package/dist/main.d.ts +0 -9
- package/dist/search/register-search-tool.d.ts +0 -6
- package/dist/search/search.schemas.d.ts +0 -133
- package/dist/search/search.utils.d.ts +0 -98
- package/dist/shared/api-constants.d.ts +0 -9
- package/dist/shared/check-response-for-errors.d.ts +0 -6
- package/dist/shared/format-search-results-text.d.ts +0 -19
- package/dist/shared/generate-error-report-link.d.ts +0 -9
- package/dist/shared/get-logger.d.ts +0 -7
- package/dist/shared/use-client-version.d.ts +0 -6
- package/dist/stdio.d.ts +0 -2
- package/src/express/express.schemas.ts +0 -99
- package/src/main.ts +0 -9
- package/src/search/search.schemas.ts +0 -147
- package/src/shared/api-constants.ts +0 -10
- package/src/shared/check-response-for-errors.ts +0 -13
- package/src/shared/generate-error-report-link.ts +0 -37
- package/src/tests/exports.spec.ts +0 -24
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import * as z from 'zod';
|
|
2
|
-
|
|
3
|
-
export const SearchQuerySchema = z.object({
|
|
4
|
-
query: z.string().min(1, 'Query is required').describe('Search query (supports +, -, site:, filetype:, lang:)'),
|
|
5
|
-
count: z.number().int().min(1).max(100).optional().describe('Max results per section'),
|
|
6
|
-
freshness: z.string().optional().describe('day/week/month/year or YYYY-MM-DDtoYYYY-MM-DD'),
|
|
7
|
-
offset: z.number().int().min(0).max(9).optional().describe('Pagination offset'),
|
|
8
|
-
country: z
|
|
9
|
-
.enum([
|
|
10
|
-
'AR',
|
|
11
|
-
'AU',
|
|
12
|
-
'AT',
|
|
13
|
-
'BE',
|
|
14
|
-
'BR',
|
|
15
|
-
'CA',
|
|
16
|
-
'CL',
|
|
17
|
-
'DK',
|
|
18
|
-
'FI',
|
|
19
|
-
'FR',
|
|
20
|
-
'DE',
|
|
21
|
-
'HK',
|
|
22
|
-
'IN',
|
|
23
|
-
'ID',
|
|
24
|
-
'IT',
|
|
25
|
-
'JP',
|
|
26
|
-
'KR',
|
|
27
|
-
'MY',
|
|
28
|
-
'MX',
|
|
29
|
-
'NL',
|
|
30
|
-
'NZ',
|
|
31
|
-
'NO',
|
|
32
|
-
'CN',
|
|
33
|
-
'PL',
|
|
34
|
-
'PT',
|
|
35
|
-
'PH',
|
|
36
|
-
'RU',
|
|
37
|
-
'SA',
|
|
38
|
-
'ZA',
|
|
39
|
-
'ES',
|
|
40
|
-
'SE',
|
|
41
|
-
'CH',
|
|
42
|
-
'TW',
|
|
43
|
-
'TR',
|
|
44
|
-
'GB',
|
|
45
|
-
'US',
|
|
46
|
-
])
|
|
47
|
-
.optional()
|
|
48
|
-
.describe('Country code'),
|
|
49
|
-
safesearch: z.enum(['off', 'moderate', 'strict']).optional().describe('Filter level'),
|
|
50
|
-
site: z.string().optional().describe('Specific domain'),
|
|
51
|
-
fileType: z.string().optional().describe('File type'),
|
|
52
|
-
language: z.string().optional().describe('ISO 639-1 language code'),
|
|
53
|
-
excludeTerms: z.string().optional().describe('Terms to exclude (pipe-separated)'),
|
|
54
|
-
exactTerms: z.string().optional().describe('Exact terms (pipe-separated)'),
|
|
55
|
-
livecrawl: z.enum(['web', 'news', 'all']).optional().describe('Live-crawl sections for full content'),
|
|
56
|
-
livecrawl_formats: z.enum(['html', 'markdown']).optional().describe('Format for crawled content'),
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
export type SearchQuery = z.infer<typeof SearchQuerySchema>;
|
|
60
|
-
|
|
61
|
-
const WebResultSchema = z.object({
|
|
62
|
-
url: z.string().describe('URL'),
|
|
63
|
-
title: z.string().describe('Title'),
|
|
64
|
-
description: z.string().describe('Description'),
|
|
65
|
-
snippets: z.array(z.string()).describe('Content snippets'),
|
|
66
|
-
page_age: z.string().optional().describe('Publication timestamp'),
|
|
67
|
-
authors: z.array(z.string()).optional().describe('Authors'),
|
|
68
|
-
thumbnail_url: z.string().optional().describe('Thumbnail image URL'),
|
|
69
|
-
favicon_url: z.string().optional().describe('Favicon URL'),
|
|
70
|
-
contents: z
|
|
71
|
-
.object({
|
|
72
|
-
html: z.string().optional().describe('Full HTML content'),
|
|
73
|
-
markdown: z.string().optional().describe('Full Markdown content'),
|
|
74
|
-
})
|
|
75
|
-
.optional()
|
|
76
|
-
.describe('Live-crawled page content'),
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
const NewsResultSchema = z.object({
|
|
80
|
-
title: z.string().describe('Title'),
|
|
81
|
-
description: z.string().describe('Description'),
|
|
82
|
-
page_age: z.string().describe('Publication timestamp'),
|
|
83
|
-
url: z.string().describe('URL'),
|
|
84
|
-
thumbnail_url: z.string().optional().describe('Thumbnail image URL'),
|
|
85
|
-
contents: z
|
|
86
|
-
.object({
|
|
87
|
-
html: z.string().optional().describe('Full HTML content'),
|
|
88
|
-
markdown: z.string().optional().describe('Full Markdown content'),
|
|
89
|
-
})
|
|
90
|
-
.optional()
|
|
91
|
-
.describe('Live-crawled page content'),
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
export type NewsResult = z.infer<typeof NewsResultSchema>;
|
|
95
|
-
|
|
96
|
-
const MetadataSchema = z.object({
|
|
97
|
-
search_uuid: z.string().optional().describe('Unique search request ID'),
|
|
98
|
-
query: z.string().describe('Query'),
|
|
99
|
-
latency: z.number().describe('Latency in seconds'),
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
export const SearchResponseSchema = z.object({
|
|
103
|
-
results: z.object({
|
|
104
|
-
web: z.array(WebResultSchema).optional(),
|
|
105
|
-
news: z.array(NewsResultSchema).optional(),
|
|
106
|
-
}),
|
|
107
|
-
metadata: MetadataSchema.partial(),
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
export type SearchResponse = z.infer<typeof SearchResponseSchema>;
|
|
111
|
-
|
|
112
|
-
// Minimal schema for structuredContent (reduces payload duplication)
|
|
113
|
-
// Excludes metadata (query, search_uuid, latency) as these are not actionable by LLM
|
|
114
|
-
export const SearchStructuredContentSchema = z.object({
|
|
115
|
-
resultCounts: z.object({
|
|
116
|
-
web: z.number().describe('Web results'),
|
|
117
|
-
news: z.number().describe('News results'),
|
|
118
|
-
total: z.number().describe('Total results'),
|
|
119
|
-
}),
|
|
120
|
-
results: z
|
|
121
|
-
.object({
|
|
122
|
-
web: z
|
|
123
|
-
.array(
|
|
124
|
-
z.object({
|
|
125
|
-
url: z.string().describe('URL'),
|
|
126
|
-
title: z.string().describe('Title'),
|
|
127
|
-
page_age: z.string().optional().describe('Publication timestamp'),
|
|
128
|
-
}),
|
|
129
|
-
)
|
|
130
|
-
.optional()
|
|
131
|
-
.describe('Web results'),
|
|
132
|
-
news: z
|
|
133
|
-
.array(
|
|
134
|
-
z.object({
|
|
135
|
-
url: z.string().describe('URL'),
|
|
136
|
-
title: z.string().describe('Title'),
|
|
137
|
-
page_age: z.string().describe('Publication timestamp'),
|
|
138
|
-
}),
|
|
139
|
-
)
|
|
140
|
-
.optional()
|
|
141
|
-
.describe('News results'),
|
|
142
|
-
})
|
|
143
|
-
.optional()
|
|
144
|
-
.describe('Search results'),
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
export type SearchStructuredContent = z.infer<typeof SearchStructuredContentSchema>;
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
|
|
8
|
-
export const SEARCH_API_URL = 'https://ydc-index.io/v1/search';
|
|
9
|
-
export const EXPRESS_API_URL = 'https://api.you.com/v1/agents/runs';
|
|
10
|
-
export const CONTENTS_API_URL = 'https://ydc-index.io/v1/contents';
|
|
@@ -1,13 +0,0 @@
|
|
|
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 const checkResponseForErrors = (responseData: unknown) => {
|
|
7
|
-
if (typeof responseData === 'object' && responseData !== null && 'error' in responseData) {
|
|
8
|
-
const errorMessage =
|
|
9
|
-
typeof responseData.error === 'string' ? responseData.error : JSON.stringify(responseData.error);
|
|
10
|
-
throw new Error(`You.com API Error: ${errorMessage}`);
|
|
11
|
-
}
|
|
12
|
-
return responseData;
|
|
13
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import packageJson from '../../package.json' with { type: 'json' };
|
|
2
|
-
/**
|
|
3
|
-
* Generates a mailto link for error reporting with pre-filled context
|
|
4
|
-
* Used by tool error handlers to provide easy error reporting
|
|
5
|
-
*/
|
|
6
|
-
export const generateErrorReportLink = ({
|
|
7
|
-
errorMessage,
|
|
8
|
-
tool,
|
|
9
|
-
clientInfo,
|
|
10
|
-
}: {
|
|
11
|
-
errorMessage: string;
|
|
12
|
-
tool: string;
|
|
13
|
-
clientInfo: string;
|
|
14
|
-
}): string => {
|
|
15
|
-
const subject = `MCP Server Issue v${packageJson.version}`;
|
|
16
|
-
const body = `Server Version: v${packageJson.version}
|
|
17
|
-
Client: ${clientInfo}
|
|
18
|
-
Tool: ${tool}
|
|
19
|
-
|
|
20
|
-
Error Message:
|
|
21
|
-
${errorMessage}
|
|
22
|
-
|
|
23
|
-
Steps to Reproduce:
|
|
24
|
-
1.
|
|
25
|
-
2.
|
|
26
|
-
3.
|
|
27
|
-
|
|
28
|
-
Additional Context:
|
|
29
|
-
`;
|
|
30
|
-
|
|
31
|
-
const params = new URLSearchParams({
|
|
32
|
-
subject,
|
|
33
|
-
body,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
return `mailto:support@you.com?${params.toString()}`;
|
|
37
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// src/tests/exports.spec.ts
|
|
2
|
-
import { describe, expect, test } from 'bun:test';
|
|
3
|
-
import * as exports from '@youdotcom-oss/mcp';
|
|
4
|
-
|
|
5
|
-
describe('Package exports', () => {
|
|
6
|
-
test('should export all required schemas', async () => {
|
|
7
|
-
// Schemas
|
|
8
|
-
expect(exports.ContentsQuerySchema).toBeDefined();
|
|
9
|
-
expect(exports.ExpressAgentInputSchema).toBeDefined();
|
|
10
|
-
expect(exports.SearchQuerySchema).toBeDefined();
|
|
11
|
-
|
|
12
|
-
// Utilities
|
|
13
|
-
expect(exports.fetchContents).toBeDefined();
|
|
14
|
-
expect(exports.formatContentsResponse).toBeDefined();
|
|
15
|
-
expect(exports.callExpressAgent).toBeDefined();
|
|
16
|
-
expect(exports.formatExpressAgentResponse).toBeDefined();
|
|
17
|
-
expect(exports.fetchSearchResults).toBeDefined();
|
|
18
|
-
expect(exports.formatSearchResults).toBeDefined();
|
|
19
|
-
|
|
20
|
-
// Shared utilities
|
|
21
|
-
expect(exports.checkResponseForErrors).toBeDefined();
|
|
22
|
-
expect(exports.formatSearchResultsText).toBeDefined();
|
|
23
|
-
});
|
|
24
|
-
});
|