@youdotcom-oss/mcp 1.3.5-next.5 → 1.3.6

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/AGENTS.md DELETED
@@ -1,744 +0,0 @@
1
- ---
2
- description: Development guidelines for You.com MCP Server using Bun runtime.
3
- globs: "*.ts, *.tsx, *.js, *.jsx, package.json"
4
- alwaysApply: false
5
- ---
6
-
7
- # You.com MCP Server Development Guide
8
-
9
- A Model Context Protocol (MCP) server that provides web search, AI agent, and content extraction capabilities through You.com's APIs.
10
-
11
- ---
12
-
13
- > **Note for end users**: If you want to use this MCP server (not develop or contribute), see [README.md](./README.md) for setup instructions, getting started guides, and usage examples.
14
-
15
- **This guide (AGENTS.md) is for developers, contributors, and AI coding agents** who want to:
16
-
17
- - Set up a local development environment
18
- - Understand the codebase architecture
19
- - Contribute code or bug fixes
20
- - Run tests and quality checks
21
- - Review pull requests
22
-
23
- ---
24
-
25
- ## Tech Stack
26
-
27
- - **Runtime**: Bun >= 1.2.21 (not Node.js)
28
- - **Framework**: Model Context Protocol SDK v1.24.0
29
- - **HTTP Server**: Hono v4.10.6 with @hono/mcp for HTTP transport (SSE protocol support)
30
- - **Validation**: Zod 3.25.76 for schema validation
31
- - **Testing**: Bun test (built-in test runner)
32
- - **Code Quality**: Biome 2.3.7 (linter + formatter)
33
- - **Type Checking**: TypeScript 5.9.3
34
- - **Git Hooks**: lint-staged 16.2.7
35
-
36
- ## Quick Start
37
-
38
- ### Setup Environment
39
-
40
- ```bash
41
- echo "export YDC_API_KEY=your-actual-api-key-here" > .env
42
- source .env
43
- ```
44
-
45
- ### Development Commands
46
-
47
- ```bash
48
- bun install # Install dependencies
49
- bun run dev # Start stdio server
50
- bun start # Start HTTP server on port 4000
51
- bun test # Run tests
52
- bun test:coverage # Run tests with coverage report
53
- bun test:watch # Run tests in watch mode
54
- bun run check # Run all checks (biome + types + package format)
55
- bun run check:write # Auto-fix all issues
56
- ```
57
-
58
- ## Code Style
59
-
60
- This project uses [Biome](https://biomejs.dev/) for automated code formatting and linting. Most style rules are enforced automatically via git hooks.
61
-
62
- ### Manual Adherence Required
63
-
64
- **Arrow Functions**: Always use arrow functions for declarations (not enforced by Biome)
65
-
66
- ```ts
67
- // ✅ Preferred
68
- export const fetchData = async (params: Params) => { ... };
69
-
70
- // ❌ Avoid
71
- export async function fetchData(params: Params) { ... }
72
- ```
73
-
74
- **No Unused Exports**: All exports must be actively used (Biome detects unused variables/imports, but NOT unused exports)
75
-
76
- ```bash
77
- # Before adding exports, verify usage:
78
- grep -r "ExportName" src/
79
- ```
80
-
81
- ### MCP-Specific Patterns
82
-
83
- **Schema Design**: Always use Zod for input/output validation
84
-
85
- ```ts
86
- export const MyToolInputSchema = z.object({
87
- query: z.string().min(1).describe("Search query"),
88
- limit: z.number().optional().describe("Max results"),
89
- });
90
- ```
91
-
92
- **Error Handling**: Always use try/catch with typed error handling
93
-
94
- ```ts
95
- try {
96
- const response = await apiCall();
97
- return formatResponse(response);
98
- } catch (err: unknown) {
99
- const errorMessage = err instanceof Error ? err.message : String(err);
100
- await logger({ level: "error", data: `API call failed: ${errorMessage}` });
101
- return {
102
- content: [{ type: "text", text: `Error: ${errorMessage}` }],
103
- isError: true,
104
- };
105
- }
106
- ```
107
-
108
- **Logging**: Use `getLogger(mcp)` helper, never console.log
109
-
110
- ```ts
111
- import { getLogger } from "../shared/get-logger.ts";
112
-
113
- const logger = getLogger(mcp);
114
- await logger({ level: "info", data: `Operation successful: ${result}` });
115
- await logger({ level: "error", data: `Operation failed: ${errorMessage}` });
116
- ```
117
-
118
- **Response Format**: Return both `content` and `structuredContent`
119
-
120
- ```ts
121
- return {
122
- content: [{ type: "text", text: formattedText }],
123
- structuredContent: responseData,
124
- };
125
- ```
126
-
127
- ## Development Workflow
128
-
129
- ### Git Hooks
130
-
131
- Git hooks are automatically configured after `bun install`:
132
-
133
- - **Pre-commit**: Runs Biome check and format-package on staged files
134
- - **Setup**: `bun run prepare` (runs automatically with install)
135
- - Git hooks enforce code quality standards and should never be bypassed
136
-
137
- ### MCP Inspector
138
-
139
- Test and debug MCP tools interactively:
140
-
141
- ```bash
142
- bun run inspect # Automatically loads .env variables
143
- ```
144
-
145
- - Opens interactive UI to test MCP tools
146
- - Requires `YDC_API_KEY` in `.env` file
147
- - See [MCP Inspector docs](https://modelcontextprotocol.io/docs/tools/inspector)
148
-
149
- ### Code Quality Commands
150
-
151
- ```bash
152
- # Check everything (CI command)
153
- bun run check # Runs biome + types + package format
154
-
155
- # Individual checks
156
- bun run check:biome # Lint and format check
157
- bun run check:types # TypeScript type check
158
- bun run check:package # package.json format check
159
-
160
- # Auto-fix
161
- bun run check:write # Fix all auto-fixable issues
162
- bun run lint:fix # Fix lint issues only
163
- bun run format # Format code only
164
- bun run format:package # Format package.json only
165
- ```
166
-
167
- ## Contributing
168
-
169
- For detailed contribution guidelines, including:
170
-
171
- - Bug reporting
172
- - Feature requests
173
- - Pull request workflow
174
- - Commit message conventions (Conventional Commits)
175
- - Code review process
176
-
177
- See [CONTRIBUTING.md](./CONTRIBUTING.md)
178
-
179
- ## Publishing
180
-
181
- ### Release Process
182
-
183
- This package is published to npm via the `.github/workflows/publish-mcp.yml` workflow in the monorepo root.
184
-
185
- **Workflow Actions**:
186
- 1. Updates version in `packages/mcp/package.json`
187
- 2. Scans all workspace packages for dependencies on `@youdotcom-oss/mcp`
188
- 3. Updates dependent packages with exact version (e.g., "1.4.0")
189
- 4. Commits all version updates together
190
- 5. Creates GitHub release in private repo
191
- 6. Syncs to OSS repo via git subtree split
192
- 7. Creates GitHub release in OSS repo
193
- 8. Publishes to npm
194
-
195
- **Version Format**: Exact versions only (no `^` or `~` prefixes)
196
-
197
- ```json
198
- {
199
- "dependencies": {
200
- "@youdotcom-oss/mcp": "1.3.4"
201
- }
202
- }
203
- ```
204
-
205
- **IMPORTANT**: If you add dependencies on other workspace packages, use exact version numbers. The publish workflow will automatically keep them in sync when new versions are released.
206
-
207
- ### Version Format Convention
208
-
209
- This package follows standard Git tagging conventions:
210
-
211
- - **Git tags**: `v{version}` (e.g., `v1.3.4`, `v1.4.0-next.1`)
212
- - **GitHub releases**: `v{version}` (e.g., `Release v1.3.4`)
213
- - **package.json**: `{version}` (no "v" prefix, e.g., `1.3.4`)
214
- - **npm package**: `{version}` (no "v" prefix, e.g., `@youdotcom-oss/mcp@1.3.4`)
215
-
216
- **When triggering the publish workflow:**
217
- 1. Go to: Actions → Publish mcp-server Release → Run workflow
218
- 2. Enter version WITHOUT "v" prefix: `1.3.4` (not `v1.3.4`)
219
- 3. The workflow automatically adds "v" for Git tags
220
- 4. Validation checks prevent common mistakes
221
-
222
- **Example:**
223
- ```bash
224
- # Workflow input
225
- Version: 1.3.4
226
-
227
- # Produces:
228
- # - Git tag: v1.3.4
229
- # - package.json: "version": "1.3.4"
230
- # - npm: @youdotcom-oss/mcp@1.3.4
231
- # - Release: https://github.com/.../releases/tag/v1.3.4
232
- ```
233
-
234
- **Validation checks in workflow:**
235
- - Rejects input with "v" prefix
236
- - Verifies package.json matches release version
237
- - Ensures no "v" prefix in package.json
238
-
239
- ## MCP Server Patterns
240
-
241
- ### Tool Registration
242
-
243
- Use Zod schemas for tool parameter validation. See examples:
244
-
245
- - Search tool: `src/search/register-search-tool.ts:7-86`
246
- - Express tool: `src/express/register-express-tool.ts:7-66`
247
- - Contents tool: `src/contents/register-contents-tool.ts:7-89`
248
-
249
- ### Error Handling
250
-
251
- Always use try/catch with typed error handling (`err: unknown`). See tool registration files for standard pattern.
252
-
253
- ### Logging
254
-
255
- Use `getLogger(mcp)` helper, never console.log. See `src/shared/get-logger.ts:8-11` for implementation.
256
-
257
- ### Error Reporting
258
-
259
- Include mailto links in error logs using `generateErrorReportLink()` helper (`src/shared/generate-error-report-link.ts:6-37`). This creates one-click error reporting with full diagnostic context.
260
-
261
- ## Testing
262
-
263
- ### Test Organization
264
-
265
- - **Unit Tests**: `src/*/tests/*.spec.ts` - Test individual utilities
266
- - **Integration Tests**: `src/tests/*.spec.ts` - Test MCP tools end-to-end
267
- - **Coverage Target**: >80% for core utilities
268
-
269
- For test patterns, see:
270
-
271
- - Unit tests: `src/search/tests/search.utils.spec.ts`
272
- - Integration tests: `src/tests/tool.spec.ts`
273
-
274
- ### Test Assertion Anti-Patterns
275
-
276
- **IMPORTANT: Avoid patterns that silently skip assertions** - they hide failures.
277
-
278
- ❌ **Early Returns** - Silently exits test, skips remaining assertions
279
-
280
- ```ts
281
- if (!item) return; // Bad: test passes even if item is undefined
282
- ```
283
-
284
- ❌ **Redundant Conditionals** - Asserts defined, then conditionally checks type
285
-
286
- ```ts
287
- expect(item?.markdown).toBeDefined();
288
- if (item?.markdown) {
289
- expect(typeof item.markdown).toBe("string"); // Redundant!
290
- }
291
- ```
292
-
293
- ✅ **Let tests fail naturally** - Use optional chaining and direct assertions:
294
-
295
- ```ts
296
- expect(item).toBeDefined();
297
- expect(item).toHaveProperty("url"); // Fails with clear error if undefined
298
- ```
299
-
300
- ### Running Tests
301
-
302
- ```bash
303
- bun test # All tests
304
- bun test:coverage # With coverage report
305
- bun test:watch # Run tests in watch mode
306
- bun test:coverage:watch # Coverage with watch mode
307
- bun test src/search/tests/ # Specific directory
308
- ```
309
-
310
- Requires `YDC_API_KEY` environment variable for API tests.
311
-
312
- ## Troubleshooting
313
-
314
- ### Common Issues
315
-
316
- #### YDC_API_KEY not found
317
-
318
- **Symptom**: Error message "YDC_API_KEY environment variable is required"
319
-
320
- **Solution**:
321
-
322
- ```bash
323
- # Set up .env file
324
- echo "export YDC_API_KEY=your-actual-api-key-here" > .env
325
- source .env
326
-
327
- # Or export directly
328
- export YDC_API_KEY="your-actual-api-key-here"
329
-
330
- # Verify it's set
331
- echo $YDC_API_KEY
332
- ```
333
-
334
- #### Build Failures
335
-
336
- **Symptom**: `bun run build` fails with TypeScript errors
337
-
338
- **Solution**:
339
-
340
- ```bash
341
- # Check TypeScript errors
342
- bun run check:types
343
-
344
- # Fix code quality issues
345
- bun run check:write
346
-
347
- # Clean and rebuild
348
- rm -rf bin/
349
- bun run build
350
- ```
351
-
352
- #### Test Failures with API Rate Limits
353
-
354
- **Symptom**: Tests fail with 429 (Too Many Requests) errors
355
-
356
- **Solution**:
357
-
358
- - Wait a few minutes before re-running tests
359
- - Run specific test suites instead of all tests at once
360
- - Use `bun test --bail` to stop after first failure
361
- - Check your API key rate limits at [api.you.com](https://api.you.com)
362
-
363
-
364
- #### Biome/TypeScript Errors
365
-
366
- **Symptom**: Pre-commit hook fails or `bun run check` shows errors
367
-
368
- **Solution**:
369
-
370
- ```bash
371
- # Auto-fix most issues
372
- bun run check:write
373
-
374
- # Check specific issues
375
- bun run check:biome # Linting and formatting
376
- bun run check:types # TypeScript type errors
377
- bun run check:package # package.json formatting
378
-
379
- # Format code manually
380
- bun run format
381
-
382
- # Fix lint issues manually
383
- bun run lint:fix
384
- ```
385
-
386
- #### Import Resolution Errors
387
-
388
- **Symptom**: "Cannot find module" errors in TypeScript
389
-
390
- **Solution**:
391
-
392
- - Always use `.js` extensions in imports (even for `.ts` files)
393
- - Check that the file exists at the specified path
394
- - Use relative paths correctly (`./` for same directory, `../` for parent)
395
- - Example: `import { foo } from './utils.js'` (not `./utils`)
396
-
397
- #### MCP Client Connection Issues
398
-
399
- **Symptom**: MCP client can't connect to server
400
-
401
- **Solution for Stdio mode**:
402
-
403
- - Verify the path to `stdio.ts` or `stdio.js` is correct and absolute
404
- - Check that Bun is installed and in PATH
405
- - Test manually: `bun src/stdio.ts`
406
-
407
- **Solution for HTTP mode**:
408
-
409
- - Verify server is running: `curl http://localhost:4000/mcp-health`
410
- - Check port isn't in use: `lsof -i :4000` (macOS/Linux)
411
- - Verify Bearer token matches your API key
412
- - Check firewall settings
413
-
414
- ## API Integration
415
-
416
- ### You.com API Key
417
-
418
- This server uses a single `YDC_API_KEY` for all APIs, but they use different authentication methods:
419
-
420
- - **Search API** (`you-search`): Uses `X-API-Key` header
421
- - **Contents API** (`you-contents`): Uses `X-API-Key` header
422
- - **Agent API** (`you-express`): Uses `Authorization: Bearer` header
423
-
424
- **Important**: If you receive 401 Unauthorized errors when using the `you-express` tool, ensure your API key has permissions for agent endpoints.
425
-
426
- ### API Response Validation
427
-
428
- Always validate API responses and handle errors:
429
-
430
- ```ts
431
- // Check for error field even with 200 status
432
- checkResponseForErrors(jsonResponse);
433
-
434
- // Validate with Zod
435
- const validatedResponse = ResponseSchema.parse(jsonResponse);
436
-
437
- // Handle specific status codes
438
- if (response.status === 401) {
439
- throw new Error("Invalid or expired API key");
440
- }
441
- if (response.status === 403) {
442
- throw new Error("API key lacks permissions for this endpoint");
443
- }
444
- if (response.status === 429) {
445
- throw new Error("Rate limit exceeded");
446
- }
447
- ```
448
-
449
- ## Available MCP Tools
450
-
451
- ### 1. `you-search`
452
-
453
- Web and news search using You.com Search API
454
-
455
- - Returns web results with snippets and news articles
456
- - Supports filters: freshness, country, safesearch, file types
457
- - Authentication: `X-API-Key` header
458
-
459
- ### 2. `you-express`
460
-
461
- Fast AI responses with optional web search
462
-
463
- - Best for straightforward queries
464
- - Fast responses with real-time web information
465
- - Returns AI-synthesized answer + optional web search results
466
- - Uses non-streaming JSON responses (`stream: false`)
467
- - Authentication: `Authorization: Bearer` header
468
-
469
- ### 3. `you-contents`
470
-
471
- Content extraction from web pages
472
-
473
- - Extracts full page content in markdown or HTML format
474
- - Processes multiple URLs in a single API request
475
- - Returns both text and structured content formats
476
- - Markdown recommended for text extraction
477
- - HTML recommended for layout preservation
478
- - Authentication: `X-API-Key` header
479
-
480
- ## Architecture
481
-
482
- ### System Overview
483
-
484
- ```mermaid
485
- graph TD
486
- Clients["MCP Clients
487
- (Claude Desktop, Claude Code, Custom Clients)"]
488
-
489
- Clients -->|"Stdio (Local)"| Stdio["src/stdio.ts
490
- - Process I/O
491
- - JSON-RPC"]
492
- Clients -->|"HTTP/SSE (Remote)"| HTTP["src/http.ts (Hono + SSE)
493
- - /mcp
494
- - /mcp-health
495
- - Bearer Auth"]
496
-
497
- Stdio --> Server["src/get-mcp-server.ts
498
- MCP Server Factory
499
- - registerTool()
500
- - Tool Handlers
501
- - Logging"]
502
- HTTP --> Server
503
-
504
- Server --> Search["you-search
505
- - Validation
506
- - Query Build
507
- - Formatting"]
508
- Server --> Express["you-express
509
- - Validation
510
- - Transform
511
- - Formatting"]
512
- Server --> Contents["you-contents
513
- - Validation
514
- - Multi-URL
515
- - Formatting"]
516
-
517
- Search -->|X-API-Key| APIs["You.com APIs
518
- - Search API (ydc-index.io)
519
- - Agent API (api.you.com)
520
- - Contents API (ydc-index.io)"]
521
- Express -->|Bearer| APIs
522
- Contents -->|X-API-Key| APIs
523
- ```
524
-
525
- ### Request Flow
526
-
527
- **Stdio Transport (Local Development)**:
528
-
529
- 1. MCP Client sends JSON-RPC request via stdin
530
- 2. `stdio.ts` receives and parses request
531
- 3. Calls MCP Server with tool name + parameters
532
- 4. MCP Server validates input with Zod schemas
533
- 5. Tool handler calls You.com API
534
- 6. Response formatted for MCP
535
- 7. JSON-RPC response sent via stdout
536
-
537
- **HTTP Transport (Remote Deployment)**:
538
-
539
- 1. MCP Client connects via SSE to `/mcp`
540
- 2. Client sends tool request over SSE connection
541
- 3. `http.ts` authenticates Bearer token
542
- 4. Calls MCP Server with tool name + parameters
543
- 5. MCP Server validates input with Zod schemas
544
- 6. Tool handler calls You.com API
545
- 7. Response formatted for MCP
546
- 8. SSE event sent back to client
547
-
548
- ### Core Server Files
549
-
550
- - `src/stdio.ts` - Stdio transport entry point (used by `bun run dev`)
551
- - `src/http.ts` - HTTP transport with Bearer token auth (Hono app)
552
- - `/mcp` - Main MCP endpoint (SSE streaming)
553
- - `/mcp-health` - Health check endpoint
554
- - Bearer token authentication via `Authorization` header
555
- - `Content-Encoding: identity` header handling for compatibility
556
- - `src/get-mcp-server.ts` - MCP server factory function
557
-
558
- ### Search Tool (`you-search`)
559
-
560
- - `src/search/register-search-tool.ts` - Tool registration with validation
561
- - `src/search/search.schemas.ts` - Zod schemas for validation
562
- - `src/search/search.utils.ts` - API calls, query building, formatting
563
- - `src/search/tests/search.utils.spec.ts` - Unit tests
564
-
565
- ### Express Agent Tool (`you-express`)
566
-
567
- - `src/express/register-express-tool.ts` - Tool registration and request handling
568
- - `src/express/express.schemas.ts` - Dual schema architecture
569
- - API response validation (ExpressAgentApiResponseSchema)
570
- - Token-efficient MCP output (ExpressAgentMcpResponseSchema)
571
- - API validates full You.com response
572
- - MCP output returns only essential fields
573
- - `src/express/express.utils.ts` - API calls and response transformation
574
- - `callExpressAgent()` - Calls You.com Express API (`stream: false`)
575
- - Transforms API response to MCP format
576
- - `formatExpressAgentResponse()` - Formats MCP response
577
- - `agentThrowOnFailedStatus()` - Handles API errors
578
- - `src/express/tests/express.utils.spec.ts` - Unit tests
579
-
580
- ### Contents Tool (`you-contents`)
581
-
582
- - `src/contents/register-contents-tool.ts` - Tool registration
583
- - Calls `fetchContents()` with all URLs in single request
584
- - Formats response for text and structured output
585
- - Comprehensive error handling (401, 403, 429, 5xx)
586
- - `src/contents/contents.schemas.ts` - Zod schemas
587
- - `ContentsQuerySchema` - Input validation
588
- - `ContentsApiResponseSchema` - API response validation
589
- - `ContentsStructuredContentSchema` - MCP output format
590
- - `src/contents/contents.utils.ts` - API calls and formatting
591
- - `fetchContents()` - Single API call with all URLs
592
- - Uses `X-API-Key` header
593
- - Validates response schema
594
- - `formatContentsResponse()` - Formats for MCP output
595
- - `src/contents/tests/contents.utils.spec.ts` - Unit tests
596
-
597
- ### Shared Utilities
598
-
599
- - `src/shared/use-client-version.ts` - User-Agent generation with MCP client version info
600
- - `useGetClientVersion(mcp)` - Returns a `getUserAgent` function for creating User-Agent strings
601
- - `src/shared/get-logger.ts` - MCP server logging
602
- - `getLogger(mcp)` - Returns a logging function for MCP server notifications
603
- - `src/shared/check-response-for-errors.ts` - API response validation
604
- - `checkResponseForErrors()` - Validates API responses for error fields
605
- - `src/shared/generate-error-report-link.ts` - Error reporting utilities
606
- - `generateErrorReportLink()` - Creates mailto links for one-click error reporting
607
- - `src/shared/format-search-results-text.ts` - Search result formatting
608
- - `formatSearchResultsText()` - Formats search results for text display
609
-
610
- ### Library Export
611
-
612
- - `src/main.ts` - Public API export file for library consumers
613
- - Exports all schemas from contents, express, and search tools
614
- - Exports utility functions from contents, express, and search
615
- - Exports shared utilities (checkResponseForErrors, formatSearchResultsText)
616
- - Used when consuming this package as a library (not as MCP server)
617
-
618
- ### Integration Tests
619
-
620
- - `src/tests/http.spec.ts` - HTTP server endpoint tests
621
- - `src/tests/tool.spec.ts` - End-to-end MCP tool tests
622
-
623
- ## Deployment
624
-
625
- This section covers local development setup, self-hosting options, and production deployment strategies.
626
-
627
- ### Local development setup
628
-
629
- **Prerequisites:**
630
-
631
- - Bun >= 1.2.21 installed
632
- - You.com API key from [you.com/platform/api-keys](https://you.com/platform/api-keys)
633
-
634
- **Quick start:**
635
-
636
- ```bash
637
- # Clone repository
638
- git clone https://github.com/youdotcom-oss/mcp-server.git
639
- cd mcp-server
640
-
641
- # Install dependencies
642
- bun install
643
-
644
- # Set up environment
645
- echo "export YDC_API_KEY=your-actual-api-key-here" > .env
646
- source .env
647
-
648
- # Start development server (STDIO mode)
649
- bun run dev
650
-
651
- # Or start HTTP server on port 4000
652
- bun start
653
- ```
654
-
655
- **Verify setup:**
656
-
657
- ```bash
658
- # Test STDIO mode
659
- echo '{"jsonrpc":"2.0","method":"tools/list","id":1}' | bun src/stdio.ts
660
-
661
- # Test HTTP mode (in separate terminal)
662
- curl http://localhost:4000/mcp-health
663
- ```
664
-
665
- ### Self-hosting
666
-
667
- This package supports self-hosting in STDIO or HTTP modes (see deployment modes below).
668
-
669
- ### Deployment modes
670
-
671
- | Mode | Use Case | Transport | Command |
672
- | -------------- | ------------------------------------ | --------- | ------------------------------- |
673
- | **STDIO Dev** | Local development and testing | STDIO | `bun run dev` |
674
- | **STDIO Prod** | MCP client integration (local) | STDIO | `./bin/stdio.js` |
675
- | **HTTP Dev** | Local HTTP server testing | HTTP/SSE | `bun start` |
676
- | **HTTP Prod** | Remote clients, web apps, production | HTTP/SSE | `bun run build && bun bin/http` |
677
-
678
- ### Production deployment
679
-
680
- **Building for production:**
681
-
682
- ```bash
683
- # Build optimized STDIO bundle
684
- bun run build
685
-
686
- # Outputs:
687
- # - bin/stdio.js (compiled STDIO transport)
688
- # Note: bin/http is an executable script, not compiled
689
- ```
690
-
691
- **Running in production:**
692
-
693
- ```bash
694
- # Set API key
695
- export YDC_API_KEY=your-actual-api-key-here
696
-
697
- # STDIO mode (for MCP clients)
698
- node bin/stdio.js
699
-
700
- # HTTP mode (for remote access)
701
- PORT=4000 bun bin/http
702
- ```
703
-
704
- **Environment variables:**
705
-
706
- | Variable | Required | Default | Description |
707
- | ------------- | -------- | ------- | --------------------------------- |
708
- | `YDC_API_KEY` | Yes | - | You.com API key |
709
- | `PORT` | No | 4000 | HTTP server port (HTTP mode only) |
710
-
711
- **Production considerations:**
712
-
713
- - **Security**: Never expose STDIO mode to external networks
714
- - **HTTP mode**: Use reverse proxy (nginx, Caddy) with HTTPS in production
715
- - **Rate limiting**: Consider implementing rate limiting for HTTP endpoints
716
- - **Monitoring**: Set up health check monitoring on `/mcp-health`
717
- - **Logging**: MCP server logs to stderr; configure log aggregation as needed
718
- - **API key rotation**: Restart server after rotating API keys
719
-
720
- ### MCP client configuration
721
-
722
- For connecting MCP clients to your self-hosted server, see the "Adding to your MCP client" section in [README.md](./README.md).
723
-
724
- For complete API reference documentation including parameters, response formats, and examples, see [API.md](./docs/API.md).
725
-
726
- ## Bun Runtime
727
-
728
- This project uses Bun (>= 1.2.21) instead of Node.js:
729
-
730
- ```bash
731
- bun <file> # Run TypeScript directly
732
- bun install # Install dependencies
733
- bun test # Built-in test runner
734
- ```
735
-
736
- **Import Extensions** (enforced by Biome):
737
-
738
- - Local files: `.ts` extension
739
- - NPM packages: `.js` extension
740
- - JSON files: `.json` with import assertion
741
-
742
- See `src/contents/register-contents-tool.ts:1-5` for import examples.
743
-
744
- **Build**: Build configuration is defined in `package.json` scripts. The `bun run build` command compiles `src/stdio.ts` to `bin/stdio.js` for production use.