Skip to content

Conversation

@omarafify7
Copy link

Summary

This PR implements a new tool called deep_research that executes parallel queries (asyncio.gather) to Serper to perform a broader, multi-perspective search on a single topic. It includes URL-based deduplication and result pruning to optimize context usage.

Motivation

The standard search tool is great for simple lookups, but complex topics often require querying multiple angles (e.g., technical specs vs. community sentiment) to avoid hallucinations. This tool automates that "research loop" in a single turn, reducing latency compared to sequential agent steps.

Implementation Details

  • Concurrency: Uses asyncio.gather to run 3 variations of the query simultaneously (General, Technical, Social), minimizing latency.
  • Deduplication: Implements URL-based deduplication to ensure the LLM context isn't wasted on the same article found via different queries.
  • Schema: Returns a pruned JSON list (Title, Link, Snippet, Date) to save tokens.
  • Pattern: Follows the existing low-level MCP server pattern (@server.call_tool) used in the repo for consistency.

Verification

  • Verified functionality using the MCP Inspector.
  • Confirmed that deep_research returns aggregated, unique results.

Omar Afify added 3 commits December 29, 2025 23:12
Implements a new 'deep_research' tool that executes parallel queries (asyncio.gather) to Serper. includes URL-based deduplication and result pruning to optimize context usage.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

init.py causes a RuntimeWarning because it is importing server at the top level when the package is initialized, before server.py is executed as main. I moved the import inside main() in init.py to defer the import and suppress the warning.
Now, when you run python -m src.serper_mcp_server.server, the init.py file runs but doesn't touch server.py, allowing Python to execute server.py freshly as the main module without conflict.

If preferred, can safely ignore this file change without breaking changes.

- `google_search_autocomplete` - Set [all the parameters](src/serper_mcp_server/schemas.py#L20)
- `webpage_scrape` - Set [all the parameters](src/serper_mcp_server/schemas.py#L62)

- `deep_research` - Performs a parallel multi-angle search (General, Technical, Reddit/HN) and aggregates unique results. Set [parameters](src/serper_mcp_server/schemas.py#L127)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main change made. Can ignore the rest - they are just clean up.

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