Skip to content

Refactor server.py to MCP Components#53

Open
adarshdigievo wants to merge 5 commits into
serpapi:mainfrom
adarshdigievo:feat/refactor-mcp-components
Open

Refactor server.py to MCP Components#53
adarshdigievo wants to merge 5 commits into
serpapi:mainfrom
adarshdigievo:feat/refactor-mcp-components

Conversation

@adarshdigievo

Copy link
Copy Markdown
Member
  • This PR refactors the MCP server by moving tools, resources, and MCP app definitions out of server.py into dedicated component files.
  • It uses FastMCP’s FileSystemProvider to discover MCP components from src/mcp_components/ - MCP tools, resources, and MCP apps now have dedicated files.
  • It removes unnecessary package marker __init__.py files that are no longer needed with the current import/discovery setup.
  • Verified with MCP inspector locally (tested resources, search tool, and apps).

Vlad M and others added 4 commits June 19, 2026 13:54
Adds engine-specific interactive UI for google_jobs via the search_dashboard
tool. When engine=google_jobs, the dashboard auto-dispatches to a dedicated
jobs view featuring:

- Metrics row: jobs found, with salary (%), remote (%), query
- Schedule type PieChart (Full-time vs Contract vs Part-time breakdown)
- Sortable jobs table (title, company, location, salary, type, posted, benefits)
- Click-to-expand detail card with salary/schedule/remote badges, description
  snippet, and link to full listing

Registers google_jobs in ENGINE_APP_BUILDERS alongside google_flights.
Adds engine-specific interactive UI for google_shopping via the
search_dashboard tool. When engine=google_shopping, the dashboard
auto-dispatches to a dedicated shopping view featuring:

- Metrics row: products found, price range, items on sale, avg rating
- Horizontal BarChart: top 10 cheapest sellers for price comparison
- Sortable products table (product, seller, price, was-price, discount, rating, reviews)
- Click-to-expand detail card with discount badge, old price, snippet, Google Shopping link

Registers google_shopping in ENGINE_APP_BUILDERS alongside flights and jobs.
Previously both dashboards hardcoded $ for price formatting. Now:

- Flights: reads search_parameters.currency (e.g. "INR") and maps to
  the correct symbol (₹) via a lookup table. Falls back to USD/$
  when not specified.
- Shopping: extracts the currency prefix from the first result's price
  string (e.g. "₹6,999" → "₹") since shopping doesn't return a
  currency code in search_parameters.

Adds _currency_symbol(), _fmt_price(), _extract_currency_prefix()
helpers shared across engine builders.
@adarshdigievo adarshdigievo requested a review from vm-serpapi June 22, 2026 15:52

@vm-serpapi vm-serpapi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good work @adarshdigievo, the refactoring works fine an is sound. Approving with a few comments to address before merge:

  1. Rebase on main and resolve merge conflicts.
  2. In tests you use private _root attributes, I think it's better to use public APIs like list_tools() there, it's better for consistency.
  3. Would be good to add empty __init__.py to mcp_components dir so it's treated as a python module.

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.

2 participants