100+ AI Agents, Agent Skills and RAG Apps - Free and Open Source.
feat: Add AI SEO Audit Team with README, agent definitions, and requirements
gargigupta97a3b55b8f129c
diff --git a/advanced_ai_agents/multi_agent_apps/agent_teams/ai_seo_audit_team/README.md b/advanced_ai_agents/multi_agent_apps/agent_teams/ai_seo_audit_team/README.mdnew file mode 100644index 00000000..e384f12d--- /dev/null+++ b/advanced_ai_agents/multi_agent_apps/agent_teams/ai_seo_audit_team/README.md@@ -0,0 +1,95 @@+# 🔍 AI SEO Audit Team++The **AI SEO Audit Team** is an autonomous, multi-agent workflow built with Google ADK. It takes a webpage URL, crawls the live page, researches real-time SERP competition, and produces a polished, prioritized SEO optimization report. The app uses Firecrawl for accurate page scraping and Google’s Gemini 2.5 Flash for analysis and reporting.++## Features++- **End-to-End On-Page SEO Evaluation**+ - Automated crawl of any public URL (Firecrawl)+ - Structured audit of titles, headings, content depth, internal/external links, and technical signals+- **Competitive SERP Intelligence**+ - Google Search research for the inferred primary keyword+ - Analysis of top competitors, content formats, title patterns, and common questions+- **Actionable Recommendations**+ - Prioritized optimization roadmap with rationale and expected impact+ - Keyword strategy, schema opportunities, internal linking ideas, and measurement plan+ - Clean Markdown report ready for stakeholders or ticket creation+- **ADK Dev UI Integration**+ - Trace view of each agent step (crawl → SERP → report)+ - Easy environment variable management through `.env`++## Agent Workflow++| Step | Agent | Responsibilities |+| --- | --- | --- |+| 1 | **Page Auditor Agent** | Calls `firecrawl_scrape`, inspects page structure, summarizes technical/content signals, and infers target keywords. |+| 2 | **Serp Analyst Agent** | Consumes the SERP data, extracts patterns, opportunities, PAA questions, and differentiation angles. |+| 3 | **Optimization Advisor Agent** | Combines audit + SERP insights into a Markdown report with clear priorities and next steps. |++All agents run sequentially using ADK’s `SequentialAgent`, passing state between stages via the shared session.++## Requirements++Install the Python dependencies:++```bash+pip install -r advanced_ai_agents/multi_agent_apps/agent_teams/ai_seo_audit_team/requirements.txt+```++You will also need valid API keys:++- `GOOGLE_API_KEY` – Gemini (Google AI Studio) for LLM + Google Search+- `FIRECRAWL_API_KEY` – Firecrawl scrape endpoint++Create a local `.env` (same directory as `agent.py`) and populate:++```+GOOGLE_API_KEY=your_gemini_key+FIRECRAWL_API_KEY=your_firecrawl_key+```++## Running the App with ADK Dev UI++1. **Activate your environment** (optional but recommended):+ ```bash+ cd advanced_ai_agents/multi_agent_apps/agent_teams/ai_seo_audit_team+ ```++2. **Install dependencies** (if not already):+ ```bash+ pip install -r requirements.txt+ ```++3. **Launch the ADK web UI** from the project root:+ ```bash+ adk web advanced_ai_agents/multi_agent_apps/agent_teams+ ```++4. In the UI:+ - Select the `ai_seo_audit_team` app.+ - Provide the target URL when prompted.+ - Watch the agents execute in the **Trace** panel (Firecrawl → Google Search → Report).++## Usage Tips++- Ensure the target URL is publicly accessible without auth requirements.+- The workflow is optimized for a single URL per run; start a new session for each distinct audit.+- The final report can be copied directly into docs, tickets, or shared with stakeholders.++## Folder Structure++```+ai_seo_audit_team/+├── agent.py # Multi-agent workflow definitions+├── requirements.txt # Minimal dependencies (google-adk, firecrawl-py, pydantic)+└── README.md # You are here+```++## Next Steps & Extensibility++- Add automated evaluations via ADK Eval Sets for regression testing.+- Hook the Markdown report into Slack/email connectors or ticketing systems.+- Swap in alternative SERP providers (Serper, Tavily) if you prefer non-Google search APIs.+- Extend the workflow with additional agents (e.g., content brief generator, schema builder) using the shared session state.++Happy auditing! 🚀diff --git a/advanced_ai_agents/multi_agent_apps/agent_teams/ai_seo_audit_team/__init__.py b/advanced_ai_agents/multi_agent_apps/agent_teams/ai_seo_audit_team/__init__.pynew file mode 100644index 00000000..5b873902--- /dev/null+++ b/advanced_ai_agents/multi_agent_apps/agent_teams/ai_seo_audit_team/__init__.py@@ -0,0 +1,5 @@+"""AI SEO Audit Team package."""++from .agent import root_agent++__all__ = ["root_agent"]\ No newline at end of filediff --git a/advanced_ai_agents/multi_agent_apps/agent_teams/ai_seo_audit_team/agent.py b/advanced_ai_agents/multi_agent_apps/agent_teams/ai_seo_audit_team/agent.pynew file mode 100644index 00000000..39c7bb4e--- /dev/null+++ b/advanced_ai_agents/multi_agent_apps/agent_teams/ai_seo_audit_team/agent.py@@ -0,0 +1,274 @@+"""+On-Page SEO Audit & Optimization Team built with Google ADK.++The workflow runs three specialized agents in sequence:+1. Page Auditor → scrapes the target URL with Firecrawl and extracts the structural audit + keyword focus.+2. SERP Analyst → performs competitive analysis with Google Search using the discovered primary keyword.+3. Optimization Advisor → synthesizes the audit and SERP insights into a prioritized optimization report.+"""++from __future__ import annotations+import os+from typing import Dict, List, Optional+from pydantic import BaseModel, Field+from google.adk.agents import LlmAgent, SequentialAgent+from google.adk.tools import FunctionTool, google_search+from google.adk.tools.agent_tool import AgentTool+from firecrawl import FirecrawlApp+++# =============================================================================+# Output Schemas+# =============================================================================+++class HeadingItem(BaseModel):+ tag: str = Field(..., description="Heading tag such as h1, h2, h3.")+ text: str = Field(..., description="Text content of the heading.")+++class LinkCounts(BaseModel):+ internal: Optional[int] = Field(None, description="Number of internal links on the page.")+ external: Optional[int] = Field(None, description="Number of external links on the page.")+ broken: Optional[int] = Field(None, description="Number of broken links detected.")+ notes: Optional[str] = Field(+ None, description="Additional qualitative observations about linking."+ )+++class AuditResults(BaseModel):+ title_tag: str = Field(..., description="Full title tag text.")+ meta_description: str = Field(..., description="Meta description text.")+ primary_heading: str = Field(..., description="Primary H1 heading on the page.")+ secondary_headings: List[HeadingItem] = Field(+ default_factory=list, description="Secondary headings (H2-H4) in reading order."+ )+ word_count: Optional[int] = Field(+ None, description="Approximate number of words in the main content."+ )+ content_summary: str = Field(+ ..., description="Summary of the main topics and structure of the content."+ )+ link_counts: LinkCounts = Field(+ ...,+ description="Quantitative snapshot of internal/external/broken links.",+ )+ technical_findings: List[str] = Field(+ default_factory=list,+ description="List of notable technical SEO issues (e.g., missing alt text, slow LCP).",+ )+ content_opportunities: List[str] = Field(+ default_factory=list,+ description="Observed content gaps or opportunities for improvement.",+ )+++class TargetKeywords(BaseModel):+ primary_keyword: str = Field(..., description="Most likely primary keyword target.")+ secondary_keywords: List[str] = Field(+ default_factory=list, description="Related secondary or supporting keywords."+ )+ search_intent: str = Field(+ ...,+ description="Dominant search intent inferred from the page (informational, transactional, etc.).",+ )+ supporting_topics: List[str] = Field(+ default_factory=list,+ description="Cluster of supporting topics or entities that reinforce the keyword strategy.",+ )+++class PageAuditOutput(BaseModel):+ audit_results: AuditResults = Field(..., description="Structured on-page audit findings.")+ target_keywords: TargetKeywords = Field(+ ..., description="Keyword focus derived from page content."+ )+++class SerpResult(BaseModel):+ rank: int = Field(..., description="Organic ranking position.")+ title: str = Field(..., description="Title of the search result.")+ url: str = Field(..., description="Landing page URL.")+ snippet: str = Field(..., description="SERP snippet or summary.")+ content_type: str = Field(+ ..., description="Content format (blog post, landing page, tool, video, etc.)."+ )+++class SerpAnalysis(BaseModel):+ primary_keyword: str = Field(..., description="Keyword used for SERP research.")+ top_10_results: List[SerpResult] = Field(+ ..., description="Top organic competitors for the keyword."+ )+ title_patterns: List[str] = Field(+ default_factory=list,+ description="Common patterns or phrases used in competitor titles.",+ )+ content_formats: List[str] = Field(+ default_factory=list,+ description="Typical content formats found (guides, listicles, comparison pages, etc.).",+ )+ people_also_ask: List[str] = Field(+ default_factory=list,+ description="Representative questions surfaced in People Also Ask.",+ )+ key_themes: List[str] = Field(+ default_factory=list,+ description="Notable recurring themes, features, or angles competitors emphasize.",+ )+ differentiation_opportunities: List[str] = Field(+ default_factory=list,+ description="Opportunities to stand out versus competitors.",+ )+++class OptimizationRecommendation(BaseModel):+ priority: str = Field(..., description="Priority level (P0, P1, P2).")+ area: str = Field(..., description="Optimization focus area (content, technical, UX, etc.).")+ recommendation: str = Field(..., description="Recommended action.")+ rationale: str = Field(..., description="Why this change matters, referencing audit/SERP data.")+ expected_impact: str = Field(..., description="Anticipated impact on SEO or user metrics.")+ effort: str = Field(..., description="Relative effort required (low/medium/high).")+++# =============================================================================+# Tools+# =============================================================================+++def firecrawl_scrape(url: str) -> Dict[str, object]:+ """+ Scrape a target URL with Firecrawl and return structured data for auditing.++ Args:+ url: Fully-qualified URL to crawl.++ Returns:+ Dictionary payload from Firecrawl that includes markdown, html, and link metadata.+ """+ api_key = os.getenv("FIRECRAWL_API_KEY")+ if not api_key:+ raise RuntimeError(+ "FIRECRAWL_API_KEY environment variable is not set. "+ "Provide a valid Firecrawl API key to enable crawling."+ )++ app = FirecrawlApp(api_key=api_key)+ try:+ document = app.scrape(+ url=url,+ formats=[+ "markdown",+ "html",+ "links",+ ],+ only_main_content=True,+ timeout=90000,+ block_ads=True,+ )+ except Exception as exc: # pragma: no cover - tool errors pass to the agent+ raise RuntimeError(f"Firecrawl scrape failed: {exc}") from exc++ payload = document.model_dump(exclude_none=True)+ if not payload.get("markdown") and not payload.get("html"):+ raise RuntimeError("Firecrawl scrape completed but returned no page content.")+ return payload+++firecrawl_tool = FunctionTool(firecrawl_scrape)+++# =============================================================================+# Helper Agents+# =============================================================================+++search_executor_agent = LlmAgent(+ name="perform_google_search",+ model="gemini-2.5-flash",+ description="Executes Google searches for provided queries and returns structured results.",+ instruction="""The latest user message contains the keyword to search.+- Call google_search with that exact query and fetch the top organic results (aim for 10).+- Respond with JSON text containing the query and an array of result objects (title, url, snippet). Use an empty array when nothing is returned.+- No additional commentary—return JSON text only.""",+ tools=[google_search],+)++google_search_tool = AgentTool(search_executor_agent)+++# =============================================================================+# Agent Definitions+# =============================================================================+++page_auditor_agent = LlmAgent(+ name="PageAuditorAgent",+ model="gemini-2.5-flash",+ description=(+ "Scrapes the target URL, performs a structural on-page SEO audit, and extracts keyword signals."+ ),+ instruction="""You are Agent 1 in a sequential SEO workflow.+- Extract the URL from the latest user message. If no valid URL is provided, ask the user for one and stop.+- Call the `firecrawl_scrape` tool exactly once to gather page content, metadata, and links.+- Audit the page structure: title tag, meta description, headings hierarchy, word count, link health, and technical flags.+- Infer the dominant search intent and identify the primary and secondary keyword targets based on page content.+- Populate every field in the PageAuditOutput schema and store the result in `state['page_audit']`.+- Output must be valid JSON only, with no extra commentary. Every string field needs meaningful text (use clear fallbacks like "Not available" if necessary). Keep numeric fields as integers and lists as arrays (use [] when empty).""",+ tools=[firecrawl_tool],+ output_schema=PageAuditOutput,+ output_key="page_audit",+)+++serp_analyst_agent = LlmAgent(+ name="SerpAnalystAgent",+ model="gemini-2.5-flash",+ description=(+ "Researches the live SERP for the discovered primary keyword and summarizes the competitive landscape."+ ),+ instruction="""You are Agent 2 in the workflow.+- Read the keyword data from `state['page_audit']['target_keywords']`.+- For the primary keyword, call the `perform_google_search` tool with arguments `{"request": "<primary keyword>"}` to fetch the top organic results (request 10 results).+- Summarize each result with rank, title, URL, snippet, and content type.+- Highlight common title patterns, dominant content formats, People Also Ask questions, recurring themes, and opportunities to differentiate the page.+- Populate the SerpAnalysis schema, store it in `state['serp_analysis']`, and return strict JSON only. Ensure `primary_keyword` is a non-empty string (use a clear fallback if the search fails) and keep every list field as an array (return [] when empty).""",+ tools=[google_search_tool],+ output_schema=SerpAnalysis,+ output_key="serp_analysis",+)+++optimization_advisor_agent = LlmAgent(+ name="OptimizationAdvisorAgent",+ model="gemini-2.5-flash",+ description="Synthesizes the audit and SERP findings into a prioritized optimization roadmap.",+ instruction="""You are Agent 3 and the final expert in the workflow.+- Review `state['page_audit']` and `state['serp_analysis']` to understand the current page and competitive landscape.+- Produce a polished Markdown report for the user that includes:+ * Executive summary+ * Key audit findings (technical + content + keyword highlights)+ * Prioritized action list grouped by priority level (P0/P1/P2) with rationale and expected impact+ * Keyword strategy and SERP insights+ * Measurement / next-step suggestions+- Reference concrete data points from the earlier agents. If some data is missing, acknowledge it directly rather than fabricating.+- Return Markdown only—no JSON.""",+)+++seo_audit_team = SequentialAgent(+ name="SeoAuditTeam",+ description=(+ "Runs a three-agent sequential pipeline that audits a page, researches SERP competitors, "+ "and produces an optimization plan."+ ),+ sub_agents=[+ page_auditor_agent,+ serp_analyst_agent,+ optimization_advisor_agent,+ ],+)+++# Expose the root agent for the ADK runtime and Dev UI.+root_agent = seo_audit_teamdiff --git a/advanced_ai_agents/multi_agent_apps/agent_teams/ai_seo_audit_team/requirements.txt b/advanced_ai_agents/multi_agent_apps/agent_teams/ai_seo_audit_team/requirements.txtnew file mode 100644index 00000000..0e057b48--- /dev/null+++ b/advanced_ai_agents/multi_agent_apps/agent_teams/ai_seo_audit_team/requirements.txt@@ -0,0 +1,3 @@+google-adk+firecrawl-py+pydantic>=2.7.0