Skip to content

Instantly share code, notes, and snippets.

@pranjalAI
Created December 16, 2025 04:24
Show Gist options
  • Select an option

  • Save pranjalAI/1d1c3ebc4063b40eafb4429abff44d28 to your computer and use it in GitHub Desktop.

Select an option

Save pranjalAI/1d1c3ebc4063b40eafb4429abff44d28 to your computer and use it in GitHub Desktop.
# agents/profile_agent.py
from typing import Optional
from state import ResearchState
from mcp_client import call_mcp_tool
class ProfileAgent:
def _extract_symbol(self, query: str) -> Optional[str]:
# simple heuristic: if user passes "NVDA" or "AAPL"
parts = query.strip().split()
for token in parts:
if token.isupper() and 1 < len(token) <= 5:
return token
# fallback: you can later add a proper search tool
return None
def run(self, state: ResearchState) -> ResearchState:
if state.symbol is None:
state.symbol = self._extract_symbol(state.query)
if not state.symbol:
raise ValueError("Could not infer ticker symbol from query.")
result = call_mcp_tool("getCompanyProfile", {"symbol": state.symbol})
# assuming result is a list with one profile dict
profile = result[0] if isinstance(result, list) and result else result
state.profile = profile or {}
return state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment