@youdotcom-oss/mcp 2.0.3 → 2.0.4
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 +22 -4
- package/package.json +2 -2
- package/src/http.ts +11 -10
- package/src/tests/http.spec.ts +43 -12
package/bin/stdio.js
CHANGED
|
@@ -12456,8 +12456,9 @@ var ContentsItemSchema = object({
|
|
|
12456
12456
|
});
|
|
12457
12457
|
var ContentsApiResponseSchema = array(ContentsItemSchema);
|
|
12458
12458
|
// ../api/src/shared/api.constants.ts
|
|
12459
|
-
var SEARCH_API_URL = "https://ydc-index.io/v1/search";
|
|
12460
|
-
var
|
|
12459
|
+
var SEARCH_API_URL = process.env.YDC_SEARCH_API_URL || "https://ydc-index.io/v1/search";
|
|
12460
|
+
var DEEP_SEARCH_API_URL = process.env.YDC_DEEP_SEARCH_API_URL || "https://api.you.com/v1/deep_search";
|
|
12461
|
+
var CONTENTS_API_URL = process.env.YDC_CONTENTS_API_URL || "https://ydc-index.io/v1/contents";
|
|
12461
12462
|
|
|
12462
12463
|
// ../api/src/shared/check-response-for-errors.ts
|
|
12463
12464
|
var checkResponseForErrors = (responseData) => {
|
|
@@ -12705,6 +12706,23 @@ var fetchSearchResults = async ({
|
|
|
12705
12706
|
throw new Error("Rate limited by You.com API. Please try again later.");
|
|
12706
12707
|
} else if (errorCode === 403) {
|
|
12707
12708
|
throw new Error("Forbidden. Please check your You.com API key.");
|
|
12709
|
+
} else if (errorCode === 402) {
|
|
12710
|
+
let errorMessage = "Free tier limit exceeded. Please upgrade to continue.";
|
|
12711
|
+
let upgradeUrl = "https://you.com/platform";
|
|
12712
|
+
try {
|
|
12713
|
+
const errorBody = await response.json();
|
|
12714
|
+
if (errorBody?.message) {
|
|
12715
|
+
errorMessage = errorBody.message;
|
|
12716
|
+
}
|
|
12717
|
+
if (errorBody?.upgrade_url) {
|
|
12718
|
+
upgradeUrl = errorBody.upgrade_url;
|
|
12719
|
+
}
|
|
12720
|
+
if (errorBody?.reset_at) {
|
|
12721
|
+
const resetDate = new Date(errorBody.reset_at).toLocaleDateString();
|
|
12722
|
+
errorMessage += ` Limit resets on ${resetDate}.`;
|
|
12723
|
+
}
|
|
12724
|
+
} catch {}
|
|
12725
|
+
throw new Error(`${errorMessage} Upgrade at: ${upgradeUrl}`);
|
|
12708
12726
|
}
|
|
12709
12727
|
throw new Error(`Failed to perform search. Error code: ${errorCode}`);
|
|
12710
12728
|
}
|
|
@@ -20252,7 +20270,7 @@ var EMPTY_COMPLETION_RESULT = {
|
|
|
20252
20270
|
// package.json
|
|
20253
20271
|
var package_default = {
|
|
20254
20272
|
name: "@youdotcom-oss/mcp",
|
|
20255
|
-
version: "2.0.
|
|
20273
|
+
version: "2.0.4",
|
|
20256
20274
|
description: "You.com API Model Context Protocol Server - For programmatic API access, use @youdotcom-oss/api",
|
|
20257
20275
|
license: "MIT",
|
|
20258
20276
|
engines: {
|
|
@@ -20308,7 +20326,7 @@ var package_default = {
|
|
|
20308
20326
|
},
|
|
20309
20327
|
mcpName: "io.github.youdotcom-oss/mcp",
|
|
20310
20328
|
dependencies: {
|
|
20311
|
-
"@youdotcom-oss/api": "0.
|
|
20329
|
+
"@youdotcom-oss/api": "0.3.0",
|
|
20312
20330
|
zod: "^4.3.6",
|
|
20313
20331
|
"@hono/mcp": "^0.2.3",
|
|
20314
20332
|
"@modelcontextprotocol/sdk": "^1.25.3",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@youdotcom-oss/mcp",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "You.com API Model Context Protocol Server - For programmatic API access, use @youdotcom-oss/api",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
},
|
|
57
57
|
"mcpName": "io.github.youdotcom-oss/mcp",
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@youdotcom-oss/api": "0.
|
|
59
|
+
"@youdotcom-oss/api": "0.3.0",
|
|
60
60
|
"zod": "^4.3.6",
|
|
61
61
|
"@hono/mcp": "^0.2.3",
|
|
62
62
|
"@modelcontextprotocol/sdk": "^1.25.3",
|
package/src/http.ts
CHANGED
|
@@ -17,19 +17,20 @@ const extractBearerToken = (authHeader: string | null): string | null => {
|
|
|
17
17
|
const handleMcpRequest = async (c: Context) => {
|
|
18
18
|
const authHeader = c.req.header('Authorization')
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
20
|
+
let YDC_API_KEY: string | undefined
|
|
21
|
+
|
|
22
|
+
if (authHeader) {
|
|
23
|
+
const token = extractBearerToken(authHeader)
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
if (!token) {
|
|
26
|
+
c.status(401)
|
|
27
|
+
c.header('Content-Type', 'text/plain')
|
|
28
|
+
return c.text('Unauthorized: Invalid Bearer token format')
|
|
29
|
+
}
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
c.status(401)
|
|
30
|
-
c.header('Content-Type', 'text/plain')
|
|
31
|
-
return c.text('Unauthorized: Bearer token required')
|
|
31
|
+
YDC_API_KEY = token
|
|
32
32
|
}
|
|
33
|
+
|
|
33
34
|
const mcp = getMCpServer()
|
|
34
35
|
const getUserAgent = useGetClientVersion(mcp)
|
|
35
36
|
|
package/src/tests/http.spec.ts
CHANGED
|
@@ -76,23 +76,39 @@ describe('HTTP Server Endpoints', () => {
|
|
|
76
76
|
expect(typeof data.version).toBe('string')
|
|
77
77
|
})
|
|
78
78
|
|
|
79
|
-
test('mcp endpoint
|
|
79
|
+
test('mcp endpoint allows requests without authorization (free tier)', async () => {
|
|
80
80
|
const response = await fetch(`${baseUrl}/mcp`, {
|
|
81
81
|
method: 'POST',
|
|
82
82
|
headers: {
|
|
83
83
|
'Content-Type': 'application/json',
|
|
84
|
+
Accept: 'application/json, text/event-stream',
|
|
84
85
|
},
|
|
85
|
-
body: JSON.stringify({
|
|
86
|
+
body: JSON.stringify({
|
|
87
|
+
jsonrpc: '2.0',
|
|
88
|
+
method: 'initialize',
|
|
89
|
+
id: 1,
|
|
90
|
+
params: {
|
|
91
|
+
protocolVersion: '2024-11-05',
|
|
92
|
+
capabilities: {},
|
|
93
|
+
clientInfo: {
|
|
94
|
+
name: 'test-client',
|
|
95
|
+
version: '1.0.0',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
}),
|
|
86
99
|
})
|
|
87
100
|
|
|
88
|
-
|
|
89
|
-
expect(response.
|
|
101
|
+
// Should succeed without auth header (free tier)
|
|
102
|
+
expect(response.status).toBe(200)
|
|
103
|
+
expect(response.headers.get('content-type')).toContain('text/event-stream')
|
|
90
104
|
|
|
91
105
|
const text = await response.text()
|
|
92
|
-
expect(text).
|
|
106
|
+
expect(text).toContain('data:')
|
|
107
|
+
expect(text).toContain('jsonrpc')
|
|
108
|
+
expect(text).toContain('result')
|
|
93
109
|
})
|
|
94
110
|
|
|
95
|
-
test('mcp endpoint requires Bearer token format', async () => {
|
|
111
|
+
test('mcp endpoint requires Bearer token format when auth header provided', async () => {
|
|
96
112
|
const response = await fetch(`${baseUrl}/mcp`, {
|
|
97
113
|
method: 'POST',
|
|
98
114
|
headers: {
|
|
@@ -106,7 +122,7 @@ describe('HTTP Server Endpoints', () => {
|
|
|
106
122
|
expect(response.headers.get('content-type')).toContain('text/plain')
|
|
107
123
|
|
|
108
124
|
const text = await response.text()
|
|
109
|
-
expect(text).toBe('Unauthorized: Bearer token
|
|
125
|
+
expect(text).toBe('Unauthorized: Invalid Bearer token format')
|
|
110
126
|
})
|
|
111
127
|
|
|
112
128
|
test('mcp endpoint accepts valid Bearer token', async () => {
|
|
@@ -178,20 +194,35 @@ describe('HTTP Server Endpoints', () => {
|
|
|
178
194
|
expect(text).toContain('capabilities')
|
|
179
195
|
})
|
|
180
196
|
|
|
181
|
-
test('mcp endpoint with trailing slash
|
|
197
|
+
test('mcp endpoint with trailing slash allows requests without authorization', async () => {
|
|
182
198
|
const response = await fetch(`${baseUrl}/mcp/`, {
|
|
183
199
|
method: 'POST',
|
|
184
200
|
headers: {
|
|
185
201
|
'Content-Type': 'application/json',
|
|
202
|
+
Accept: 'application/json, text/event-stream',
|
|
186
203
|
},
|
|
187
|
-
body: JSON.stringify({
|
|
204
|
+
body: JSON.stringify({
|
|
205
|
+
jsonrpc: '2.0',
|
|
206
|
+
method: 'initialize',
|
|
207
|
+
id: 1,
|
|
208
|
+
params: {
|
|
209
|
+
protocolVersion: '2024-11-05',
|
|
210
|
+
capabilities: {},
|
|
211
|
+
clientInfo: {
|
|
212
|
+
name: 'test-client',
|
|
213
|
+
version: '1.0.0',
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
}),
|
|
188
217
|
})
|
|
189
218
|
|
|
190
|
-
|
|
191
|
-
expect(response.
|
|
219
|
+
// Should succeed without auth header (free tier)
|
|
220
|
+
expect(response.status).toBe(200)
|
|
221
|
+
expect(response.headers.get('content-type')).toContain('text/event-stream')
|
|
192
222
|
|
|
193
223
|
const text = await response.text()
|
|
194
|
-
expect(text).
|
|
224
|
+
expect(text).toContain('data:')
|
|
225
|
+
expect(text).toContain('jsonrpc')
|
|
195
226
|
})
|
|
196
227
|
})
|
|
197
228
|
|