The Yoto Smart Stream MCP (Model Context Protocol) server has been completely refactored to use 7 specialized structured query tools instead of natural-language query parsing. This improves reliability, clarity, and LLM integration.
Status: ✅ Complete and tested (28/28 tests passing)
Version: 0.1.4
Breaking Change: Yes - query_library tool has been removed
Single tool: query_library(query: string)
- Input: "find all cards with 'math' in the title"
- Processing: Regex parsing and pattern matching
- Problem: Fragile, hard to maintain, unclear to LLMs
Seven specialized tools with explicit parameters:
1. oauth(action: "activate" | "deactivate")
2. library_stats() → {total_cards, total_playlists}
3. list_cards(limit: 1-100) → [cards...]
4. search_cards(title_contains: string, limit: 1-100) → [cards...]
5. list_playlists() → [playlists...]
6. get_metadata_keys() → [field_names...]
7. get_field_values(field_name: string, limit: 1-500) → [values...]
If you were using query_library(), you need to update your code:
| Old Query | New Tool |
|---|---|
| "Find all cards with 'math'" | search_cards(title_contains="math") |
| "How many cards?" | library_stats() |
| "List all cards" | list_cards() |
| "What field names exist?" | get_metadata_keys() |
| "What values for field X?" | get_field_values(field_name="X") |
See MCP_REFACTORING_SUMMARY.md for detailed migration guide.
The new tools are much better for LLM integration:
- ✅ Clear tool names indicate functionality
- ✅ Explicit parameters with type hints
- ✅ Structured JSON responses
- ✅ Pydantic validation prevents errors
- ✅ Better error messages
LLMs can now understand exactly what each tool does without guessing.
Implementation Details:
- All tools use Pydantic models for input validation
- Responses are structured JSON (not text)
- Each tool has a focused responsibility
- Type hints throughout for IDE support
- 25 comprehensive integration tests
Files Modified:
mcp-server/server.py- Main refactoring (364 insertions, 106 deletions)test_mcp_structure.py- Updated expectationsmcp-server/test_mcp_integration.py- 25 new integration tests
After deploying, verify the new interface works:
# Run verification script
python verify_mcp_tools.py
# Output:
# ✅ All 7 tools verified successfully
# Results: 7/7 tools verified# Run all tests (structure + integration)
cd /Users/earchibald/work/yoto-smart-stream
python -m pytest test_mcp_startup.py test_mcp_structure.py mcp-server/test_mcp_integration.py -v
# Result:
# ======================== 28 passed in 1.92s ========================Purpose: Manage Yoto account authentication
oauth(action: "activate" | "deactivate", service_url?: string)
→ {"status": string}
Purpose: Get total counts of cards and playlists
library_stats(service_url?: string)
→ {"total_cards": int, "total_playlists": int}
Purpose: List all cards with pagination
list_cards(limit: 1-100, service_url?: string)
→ [{id, title, author, type, description, ...}, ...]
Purpose: Search cards by title substring
search_cards(title_contains: string, limit: 1-100, service_url?: string)
→ [{id, title, author, ...}, ...]
Purpose: List all playlists
list_playlists(service_url?: string)
→ [{id, name, item_count, ...}, ...]
Purpose: Get all field names used in the library
get_metadata_keys(service_url?: string)
→ ["id", "title", "author", "type", "description", ...]
Purpose: Get unique values for a specific field
get_field_values(field_name: string, limit: 1-500, service_url?: string)
→ ["value1", "value2", "value3", ...]
- Eliminates fragile regex parsing
- Pydantic validation prevents invalid inputs
- Clear error messages
- Each tool has one clear purpose
- Parameter types are explicit
- Return formats are structured JSON
- Tools are clearly discoverable
- LLMs understand parameters and return types
- No more guessing at query syntax
- 28 comprehensive tests (all passing)
- Each tool tested independently
- Edge cases covered
- Simpler code (less regex, more structure)
- Type hints throughout
- Clear function responsibilities
- MCP_REFACTORING_SUMMARY.md - Detailed technical overview
- .github/skills/yoto-smart-stream/reference/mcp_server.md - Tool documentation
- mcp-server/test_mcp_integration.py - 25 integration tests as examples
- 6671f55: Implementation of 7 structured query tools
- cf137fd: Comprehensive integration tests
- b1e6cf5: Refactoring summary documentation
- 2a1a124: Verification script
# Use: search_cards
search_cards(title_contains="math", limit=20)# First: Get all field names
get_metadata_keys()
# Then: Get values for a specific field
get_field_values(field_name="author")# Use: library_stats
library_stats()
# Response: {"total_cards": 150, "total_playlists": 5}# Get all cards (with limit)
list_cards(limit=100)
# Get all playlists
list_playlists()- Make sure you're using the new tool names (e.g.,
search_cardsnotquery_library) - Verify server is running and tools are discoverable
- Check parameter types match tool specification
- For
search_cards:title_containsis required (min 1 char) - For
get_field_values:field_nameis required
- This is normal! Use
get_metadata_keys()andget_field_values()to explore data - Then use
search_cards()orlist_cards()with appropriate parameters
- Update any code using
query_library()to new tools - Update LLM prompts/instructions with new tool names
- Run
python verify_mcp_tools.pyto confirm installation - Run test suite:
pytest test_mcp_*.py - Deploy to production
- Monitor for any issues with new tool interface
Refer to:
- MCP_REFACTORING_SUMMARY.md for technical details
- .github/skills/yoto-smart-stream/reference/mcp_server.md for tool reference
- mcp-server/test_mcp_integration.py for usage examples
Status: ✅ Complete
Tests: 28/28 passing
Ready for Production: Yes