I built an MCP server for TikTok — 10 tools in ~880 lines, and the bug I only found while writing this
Описание и применение
Создан MCP‑сервер для TikTok с 10 инструментами, но инструмент трендов не работал из‑за устаревшего API‑пути и скрытого отката. Исправлено обновлением эндпоинта, синхронизацией списка стран и добавлением ежедневного теста, проверяющего живой API. Публикация теперь автоматизирована через npm, Anthropic Registry и Glama.
Задача
The MCP server’s trends tool silently failed due to API endpoint drift and a graceful fallback that hid the error, leading to stale or missing trend data for users.
Результат
The MCP server now reliably fetches TikTok trends, with accurate API calls, synchronized country data, and a contract test that prevents silent failures. Publishing is automated across npm, Anthropic Registry, and Glama, ensuring the server is always up‑to‑date.
Рабочий процесс
- 1. Identify the tool needing improvement (get_tiktok_trends_by_country).
- 2. Inspect the API call and note the outdated endpoint.
- 3. Update the endpoint to the current /api/trends?country=US&category=videos format.
- 4. Add a daily contract test that calls the live endpoint and verifies the response is not the fallback.
- 5. Synchronize the country enum with the site’s supported countries.
- 6. Rebuild and redeploy the MCP server.
- 7. Publish to npm, Anthropic Registry, and Glama using mcp-publisher.
- 8. Monitor logs for any fallback usage and adjust as needed.
Доказательства
The tool was calling tiktapdown.com/api/trends/US. The web app's route is /api/trends?country=US&category=videos.
Add a contract test that hits production once a day and fails if any tool that touches the site returns its fallback.
The MCP tool doesn't know any of this. It gets the same JSON the site gets.
- Дата записи: 2026-09-21T20:00:32.449Z