Files
adminandClaude ec6fd7157a Add Aygea Test prompt battery: 6 prompts from real project shapes
Surveyed ~/dev (mewtwo) + jirachi. Battery mirrors actual workload:
  mcp_server      -> 9 MCP servers (joplin/obsidian/vault/project-rag/...)
  tts_pipeline    -> TTS/audio pipelines (Chatterbox, aygea-tts, vr-to-tts)
  webhook_bridge  -> Twitch/Discord bridges (multistream, notifier, overlay)
  data_service    -> data/API (Supabase MCP, PostgresHA, dashboard)
  automation_glue -> batch/cron glue (fix-tokens, notesCleanup)
  rust_service    -> big Rust services (NineSentry, aystreamer): tokio
                     channels + Arc/Mutex + error enums + graceful shutdown

Each prompt is ~2-3KB (fits 128k context with output room), single-file,
runnable, graded on the same 5-pillar rubric. aygea_test_battery.md is the
index + scoring notes + the prompt_id schema the dashboard will need for
multi-prompt support.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-28 17:16:03 -07:00

22 lines
1.7 KiB
Plaintext

Write a complete, single-file MCP (Model Context Protocol) tool server in TypeScript using `@modelcontextprotocol/sdk` (OR Python using the `mcp` package) that exposes 3 tools against the public JSONPlaceholder API (https://jsonplaceholder.typicode.com).
### Tools to implement
1. `get_user(id)` — fetch a single user by numeric id. Validate `id` is a positive integer.
2. `list_posts_by_user(user_id, limit)` — fetch a user's posts. `user_id` is a positive int; `limit` is an optional int between 1 and 100 (default 10).
3. `search_posts(query)` — fetch posts whose `title` contains the query string (case-insensitive). `query` is a non-empty string max 200 chars.
### Requirements
- **Schema validation:** every tool must validate its inputs with a schema (Zod for TS, Pydantic for Python). Invalid input returns a structured error, never crashes.
- **Typed results:** tools return typed/structured output (not raw strings).
- **Error handling:** handle HTTP errors, timeouts, and non-JSON responses gracefully — NO silent failures. Each failure path returns a clear error result. Use a reasonable per-request timeout (e.g. 8s).
- **Transport:** run over stdio (`StdioServerTransport` / `stdio_server`).
- **No external state:** pure stdlib + fetch/httpx + the MCP SDK. No database, no files.
### Included tests
At the bottom of the file, include a runnable test section that exercises:
- a) Happy path: `get_user(1)` returns a user with the expected fields.
- b) Bad-id 404 / not-found is handled (does not throw).
- c) Malformed input (e.g. `get_user(-5)`, `list_posts_by_user("x")`, `search_posts("")`) is rejected by validation with a clear error.
Provide clean, well-commented code. The file must be directly runnable: `npx tsx file.ts` (or `python file.py`).