MCPcopy Create free account
hub / github.com/RASAAS/docmcp-knowledge / check

Method check

scripts/fetch_updates.py:666–704  ·  view source on GitHub ↗
(self, source_id: str, source: dict)

Source from the content-addressed store, hash-verified

664 self.seed_mode = seed_mode
665
666 def check(self, source_id: str, source: dict) -> Optional[dict]:
667 url = source["url"]
668 prev = self.state.get(source_id, {})
669 last_checked = prev.get("last_checked")
670 try:
671 resp = self.session.get(url, timeout=30)
672 resp.raise_for_status()
673 root = ET.fromstring(resp.content)
674 new_items = []
675 for item in root.findall(".//item")[:20]:
676 pub_date_el = item.find("pubDate")
677 title_el = item.find("title")
678 link_el = item.find("link")
679 desc_el = item.find("description")
680 if pub_date_el is not None and last_checked:
681 try:
682 pub_dt = parsedate_to_datetime(pub_date_el.text)
683 last_dt = datetime.fromisoformat(last_checked)
684 if pub_dt.timestamp() <= last_dt.timestamp():
685 continue
686 except Exception:
687 pass
688 title = title_el.text if title_el is not None else "Unknown"
689 link = link_el.text if link_el is not None else ""
690 desc = (desc_el.text or "") if desc_el is not None else ""
691 if last_checked is None or "final" in title.lower() or "final" in desc.lower():
692 new_items.append({"title": title, "link": link,
693 "pub_date": pub_date_el.text if pub_date_el is not None else "",
694 "description": desc[:300]})
695 self.state[source_id] = {"url": url, "last_checked": datetime.now().isoformat()}
696 if new_items:
697 result = _make_update(source_id, source, "rss",
698 f"{len(new_items)} new Final guidance item(s) in RSS")
699 result["new_items"] = new_items
700 return result
701 return None
702 except Exception as e:
703 print(f" ERROR RSS: {e}")
704 return None
705
706
707# ---------------------------------------------------------------------------

Callers 2

_web_search_checkMethod · 0.45
check_sourceMethod · 0.45

Calls 2

getMethod · 0.80
_make_updateFunction · 0.70

Tested by

no test coverage detected