Skip to content

feat: add Tavily as alternative search provider alongside Perplexity#16

Open
tavily-integrations wants to merge 2 commits into
jsonallen:mainfrom
Tavily-FDE:feat/tavily-migration/perplexity-mcp-server
Open

feat: add Tavily as alternative search provider alongside Perplexity#16
tavily-integrations wants to merge 2 commits into
jsonallen:mainfrom
Tavily-FDE:feat/tavily-migration/perplexity-mcp-server

Conversation

@tavily-integrations

Copy link
Copy Markdown

Summary

Adds Tavily as a configurable search backend alongside the existing Perplexity AI provider. The search provider is selected via the SEARCH_PROVIDER environment variable (perplexity by default, or tavily).

What changed

  • src/perplexity_mcp/server.py: Added call_tavily() function using the tavily-python SDK (TavilyClient.search() with search_depth="advanced" and time_range mapped from the existing recency parameter). Updated call_tool dispatcher to branch on SEARCH_PROVIDER env var. Updated main() and main_async() startup validation to require TAVILY_API_KEY when SEARCH_PROVIDER=tavily, and log which provider is active.
  • pyproject.toml: Added tavily-python>=0.5 to project dependencies.
  • README.md: Documented SEARCH_PROVIDER and TAVILY_API_KEY environment variables and updated config example.

Dependency changes

  • Added tavily-python>=0.5 to pyproject.toml dependencies

Environment variable changes

  • Added SEARCH_PROVIDER (optional, default: perplexity, values: perplexity | tavily)
  • Added TAVILY_API_KEY (required when SEARCH_PROVIDER=tavily)

Notes for reviewers

  • This is an additive change — all existing Perplexity code paths and env vars are preserved unchanged.
  • The Tavily time_range parameter accepts the same values (day, week, month, year) as the existing recency parameter, so no mapping conversion is needed.
  • Tavily results are formatted as a numbered list with title, URL, and content snippet per result.

Automated Review

  • Passed after 2 attempt(s)
  • Final review: The migration correctly adds Tavily as an additive, opt-in search provider behind a SEARCH_PROVIDER env var. AsyncTavilyClient is used and properly awaited, the recencytime_range mapping is 1:1 with Tavily's accepted enum values (day/week/month/year), error handling is present, pyproject.toml gains the tavily-python>=0.5 dependency, and README documents the new env vars. Existing Perplexity behavior is fully preserved as the default path. No critical or major issues found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant