@youdotcom-oss/mcp 1.3.2 → 1.3.3
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 +149 -33
- package/README.md +60 -323
- package/bin/stdio.js +59 -41
- package/package.json +14 -4
- package/src/contents/contents.schemas.ts +55 -0
- package/src/contents/contents.utils.ts +145 -0
- package/src/express/express.schemas.ts +99 -0
- package/src/express/express.utils.ts +157 -0
- package/src/search/search.schemas.ts +126 -0
- package/src/search/search.utils.ts +142 -0
- package/src/shared/check-response-for-errors.ts +13 -0
- package/src/shared/format-search-results-text.ts +41 -0
package/AGENTS.md
CHANGED
|
@@ -28,7 +28,7 @@ A Model Context Protocol (MCP) server that provides web search, AI agent, and co
|
|
|
28
28
|
- **HTTP Server**: Hono v4.10.6 with @hono/mcp for HTTP transport (SSE protocol support)
|
|
29
29
|
- **Validation**: Zod 3.25.76 for schema validation
|
|
30
30
|
- **Testing**: Bun test (built-in test runner)
|
|
31
|
-
- **Code Quality**: Biome 2.3.
|
|
31
|
+
- **Code Quality**: Biome 2.3.7 (linter + formatter)
|
|
32
32
|
- **Type Checking**: TypeScript 5.9.3
|
|
33
33
|
- **Git Hooks**: lint-staged 16.2.7
|
|
34
34
|
|
|
@@ -48,13 +48,15 @@ bun install # Install dependencies
|
|
|
48
48
|
bun run dev # Start stdio server
|
|
49
49
|
bun start # Start HTTP server on port 4000
|
|
50
50
|
bun test # Run tests
|
|
51
|
+
bun test:coverage # Run tests with coverage report
|
|
52
|
+
bun test:watch # Run tests in watch mode
|
|
51
53
|
bun run check # Run all checks (biome + types + package format)
|
|
52
54
|
bun run check:write # Auto-fix all issues
|
|
53
55
|
```
|
|
54
56
|
|
|
55
57
|
## Code Style
|
|
56
58
|
|
|
57
|
-
This project uses [Biome](https://biomejs.dev/) for automated code formatting and linting. Most style rules are enforced automatically via git hooks
|
|
59
|
+
This project uses [Biome](https://biomejs.dev/) for automated code formatting and linting. Most style rules are enforced automatically via git hooks.
|
|
58
60
|
|
|
59
61
|
### Manual Adherence Required
|
|
60
62
|
|
|
@@ -97,6 +99,8 @@ try {
|
|
|
97
99
|
|
|
98
100
|
**Logging**: Use `getLogger(mcp)` helper, never console.log
|
|
99
101
|
```ts
|
|
102
|
+
import { getLogger } from '../shared/get-logger.ts';
|
|
103
|
+
|
|
100
104
|
const logger = getLogger(mcp);
|
|
101
105
|
await logger({ level: 'info', data: `Operation successful: ${result}` });
|
|
102
106
|
await logger({ level: 'error', data: `Operation failed: ${errorMessage}` });
|
|
@@ -166,21 +170,21 @@ See [CONTRIBUTING.md](./CONTRIBUTING.md)
|
|
|
166
170
|
### Tool Registration
|
|
167
171
|
|
|
168
172
|
Use Zod schemas for tool parameter validation. See examples:
|
|
169
|
-
- Search tool: `src/search/register-search-tool.ts:7-
|
|
170
|
-
- Express tool: `src/express/register-express-tool.ts:7-
|
|
171
|
-
- Contents tool: `src/contents/register-contents-tool.ts:7-
|
|
173
|
+
- Search tool: `src/search/register-search-tool.ts:7-86`
|
|
174
|
+
- Express tool: `src/express/register-express-tool.ts:7-66`
|
|
175
|
+
- Contents tool: `src/contents/register-contents-tool.ts:7-89`
|
|
172
176
|
|
|
173
177
|
### Error Handling
|
|
174
178
|
|
|
175
|
-
Always use try/catch with typed error handling (`err: unknown`). See
|
|
179
|
+
Always use try/catch with typed error handling (`err: unknown`). See tool registration files for standard pattern.
|
|
176
180
|
|
|
177
181
|
### Logging
|
|
178
182
|
|
|
179
|
-
Use `getLogger(mcp)` helper, never console.log. See `src/shared/
|
|
183
|
+
Use `getLogger(mcp)` helper, never console.log. See `src/shared/get-logger.ts:8-11` for implementation.
|
|
180
184
|
|
|
181
185
|
### Error Reporting
|
|
182
186
|
|
|
183
|
-
Include mailto links in error logs using `generateErrorReportLink()` helper (`src/shared/
|
|
187
|
+
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.
|
|
184
188
|
|
|
185
189
|
|
|
186
190
|
## Testing
|
|
@@ -221,9 +225,11 @@ expect(item).toHaveProperty('url'); // Fails with clear error if undefined
|
|
|
221
225
|
### Running Tests
|
|
222
226
|
|
|
223
227
|
```bash
|
|
224
|
-
bun test
|
|
225
|
-
bun test
|
|
226
|
-
bun test
|
|
228
|
+
bun test # All tests
|
|
229
|
+
bun test:coverage # With coverage report
|
|
230
|
+
bun test:watch # Run tests in watch mode
|
|
231
|
+
bun test:coverage:watch # Coverage with watch mode
|
|
232
|
+
bun test src/search/tests/ # Specific directory
|
|
227
233
|
```
|
|
228
234
|
|
|
229
235
|
Requires `YDC_API_KEY` environment variable for API tests.
|
|
@@ -521,11 +527,24 @@ graph TD
|
|
|
521
527
|
|
|
522
528
|
### Shared Utilities
|
|
523
529
|
|
|
524
|
-
- `src/shared/
|
|
525
|
-
- `useGetClientVersion(mcp)` - Returns a `getUserAgent` function
|
|
530
|
+
- `src/shared/use-client-version.ts` - User-Agent generation with MCP client version info
|
|
531
|
+
- `useGetClientVersion(mcp)` - Returns a `getUserAgent` function for creating User-Agent strings
|
|
532
|
+
- `src/shared/get-logger.ts` - MCP server logging
|
|
526
533
|
- `getLogger(mcp)` - Returns a logging function for MCP server notifications
|
|
534
|
+
- `src/shared/check-response-for-errors.ts` - API response validation
|
|
527
535
|
- `checkResponseForErrors()` - Validates API responses for error fields
|
|
528
|
-
|
|
536
|
+
- `src/shared/generate-error-report-link.ts` - Error reporting utilities
|
|
537
|
+
- `generateErrorReportLink()` - Creates mailto links for one-click error reporting
|
|
538
|
+
- `src/shared/format-search-results-text.ts` - Search result formatting
|
|
539
|
+
- `formatSearchResultsText()` - Formats search results for text display
|
|
540
|
+
|
|
541
|
+
### Library Export
|
|
542
|
+
|
|
543
|
+
- `src/main.ts` - Public API export file for library consumers
|
|
544
|
+
- Exports all schemas from contents, express, and search tools
|
|
545
|
+
- Exports utility functions from contents, express, and search
|
|
546
|
+
- Exports shared utilities (checkResponseForErrors, formatSearchResultsText)
|
|
547
|
+
- Used when consuming this package as a library (not as MCP server)
|
|
529
548
|
|
|
530
549
|
### Integration Tests
|
|
531
550
|
|
|
@@ -534,35 +553,132 @@ graph TD
|
|
|
534
553
|
|
|
535
554
|
## Deployment
|
|
536
555
|
|
|
537
|
-
|
|
556
|
+
This section covers local development setup, self-hosting options, and production deployment strategies.
|
|
557
|
+
|
|
558
|
+
### Local development setup
|
|
559
|
+
|
|
560
|
+
**Prerequisites:**
|
|
561
|
+
- Bun >= 1.2.21 installed
|
|
562
|
+
- You.com API key from [you.com/platform/api-keys](https://you.com/platform/api-keys)
|
|
563
|
+
|
|
564
|
+
**Quick start:**
|
|
538
565
|
|
|
539
566
|
```bash
|
|
540
|
-
#
|
|
541
|
-
git clone
|
|
542
|
-
cd
|
|
567
|
+
# Clone repository
|
|
568
|
+
git clone https://github.com/youdotcom-oss/youdotcom-mcp-server.git
|
|
569
|
+
cd youdotcom-mcp-server
|
|
570
|
+
|
|
571
|
+
# Install dependencies
|
|
543
572
|
bun install
|
|
544
|
-
|
|
573
|
+
|
|
574
|
+
# Set up environment
|
|
575
|
+
echo "export YDC_API_KEY=your-actual-api-key-here" > .env
|
|
545
576
|
source .env
|
|
546
|
-
bun run dev # Stdio mode
|
|
547
577
|
|
|
548
|
-
#
|
|
549
|
-
bun
|
|
578
|
+
# Start development server (STDIO mode)
|
|
579
|
+
bun run dev
|
|
580
|
+
|
|
581
|
+
# Or start HTTP server on port 4000
|
|
582
|
+
bun start
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
**Verify setup:**
|
|
586
|
+
```bash
|
|
587
|
+
# Test STDIO mode
|
|
588
|
+
echo '{"jsonrpc":"2.0","method":"tools/list","id":1}' | bun src/stdio.ts
|
|
589
|
+
|
|
590
|
+
# Test HTTP mode (in separate terminal)
|
|
591
|
+
curl http://localhost:4000/mcp-health
|
|
592
|
+
```
|
|
550
593
|
|
|
551
|
-
|
|
594
|
+
### Self-hosting with Docker
|
|
595
|
+
|
|
596
|
+
**Build and run:**
|
|
597
|
+
|
|
598
|
+
```bash
|
|
599
|
+
# Build Docker image
|
|
552
600
|
docker build -t youdotcom-mcp-server .
|
|
553
|
-
|
|
601
|
+
|
|
602
|
+
# Run container with API key
|
|
603
|
+
docker run -d \
|
|
604
|
+
-p 4000:4000 \
|
|
605
|
+
--name youdotcom-mcp \
|
|
606
|
+
-e YDC_API_KEY=your-actual-api-key-here \
|
|
607
|
+
youdotcom-mcp-server
|
|
608
|
+
|
|
609
|
+
# Check health
|
|
610
|
+
curl http://localhost:4000/mcp-health
|
|
554
611
|
```
|
|
555
612
|
|
|
556
|
-
|
|
613
|
+
**Docker Compose:**
|
|
614
|
+
|
|
615
|
+
```yaml
|
|
616
|
+
version: '3.8'
|
|
617
|
+
services:
|
|
618
|
+
youdotcom-mcp:
|
|
619
|
+
build: .
|
|
620
|
+
ports:
|
|
621
|
+
- "4000:4000"
|
|
622
|
+
environment:
|
|
623
|
+
- YDC_API_KEY=${YDC_API_KEY}
|
|
624
|
+
restart: unless-stopped
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
### Deployment modes
|
|
628
|
+
|
|
629
|
+
| Mode | Use Case | Transport | Command |
|
|
630
|
+
|------|----------|-----------|---------|
|
|
631
|
+
| **STDIO Dev** | Local development and testing | STDIO | `bun run dev` |
|
|
632
|
+
| **STDIO Prod** | MCP client integration (local) | STDIO | `./bin/stdio.js` |
|
|
633
|
+
| **HTTP Dev** | Local HTTP server testing | HTTP/SSE | `bun start` |
|
|
634
|
+
| **HTTP Prod** | Remote clients, web apps, production | HTTP/SSE | `bun run build && bun bin/http` |
|
|
635
|
+
| **Docker** | Containerized deployment | HTTP/SSE | `docker run ...` |
|
|
636
|
+
|
|
637
|
+
### Production deployment
|
|
638
|
+
|
|
639
|
+
**Building for production:**
|
|
640
|
+
|
|
641
|
+
```bash
|
|
642
|
+
# Build optimized STDIO bundle
|
|
643
|
+
bun run build
|
|
644
|
+
|
|
645
|
+
# Outputs:
|
|
646
|
+
# - bin/stdio.js (compiled STDIO transport)
|
|
647
|
+
# Note: bin/http is an executable script, not compiled
|
|
648
|
+
```
|
|
649
|
+
|
|
650
|
+
**Running in production:**
|
|
651
|
+
|
|
652
|
+
```bash
|
|
653
|
+
# Set API key
|
|
654
|
+
export YDC_API_KEY=your-actual-api-key-here
|
|
655
|
+
|
|
656
|
+
# STDIO mode (for MCP clients)
|
|
657
|
+
node bin/stdio.js
|
|
658
|
+
|
|
659
|
+
# HTTP mode (for remote access)
|
|
660
|
+
PORT=4000 bun bin/http
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
**Environment variables:**
|
|
664
|
+
|
|
665
|
+
| Variable | Required | Default | Description |
|
|
666
|
+
|----------|----------|---------|-------------|
|
|
667
|
+
| `YDC_API_KEY` | Yes | - | You.com API key |
|
|
668
|
+
| `PORT` | No | 4000 | HTTP server port (HTTP mode only) |
|
|
669
|
+
|
|
670
|
+
**Production considerations:**
|
|
671
|
+
|
|
672
|
+
- **Security**: Never expose STDIO mode to external networks
|
|
673
|
+
- **HTTP mode**: Use reverse proxy (nginx, Caddy) with HTTPS in production
|
|
674
|
+
- **Rate limiting**: Consider implementing rate limiting for HTTP endpoints
|
|
675
|
+
- **Monitoring**: Set up health check monitoring on `/mcp-health`
|
|
676
|
+
- **Logging**: MCP server logs to stderr; configure log aggregation as needed
|
|
677
|
+
- **API key rotation**: Restart server after rotating API keys
|
|
557
678
|
|
|
558
|
-
|
|
559
|
-
|------|----------|---------|
|
|
560
|
-
| **Stdio Dev** | Local development | `bun run dev` |
|
|
561
|
-
| **Stdio Prod** | MCP client integration | `./bin/stdio.js` |
|
|
562
|
-
| **HTTP** | Web apps, remote clients | `bun start` |
|
|
563
|
-
| **Docker** | Containerized deployment | `docker run ...` |
|
|
679
|
+
### MCP client configuration
|
|
564
680
|
|
|
565
|
-
For
|
|
681
|
+
For connecting MCP clients to your self-hosted server, see the "Adding to your MCP client" section in [README.md](./README.md).
|
|
566
682
|
|
|
567
683
|
For complete API reference documentation including parameters, response formats, and examples, see [API.md](./docs/API.md).
|
|
568
684
|
|
|
@@ -583,4 +699,4 @@ bun test # Built-in test runner
|
|
|
583
699
|
|
|
584
700
|
See `src/contents/register-contents-tool.ts:1-5` for import examples.
|
|
585
701
|
|
|
586
|
-
**Build**:
|
|
702
|
+
**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.
|