I built an MCP server for TikTok — 10 tools in ~880 lines, and the bug I only found while writing this
Description and use
Built an MCP server for TikTok with 10 tools, but the trends tool silently failed due to an outdated API endpoint and a graceful fallback. Fixed by updating the endpoint, syncing country list, and adding a daily contract test against production. Publishing is now automated via npm, Anthropic Registry, and Glama.
Problem
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.
Outcome
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.
Workflow
- 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.
Evidence
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.
- Record date: 2026-09-21T20:00:32.449Z