data-breach-detector 0.2.0__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: data-breach-detector
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Read-only breach-intelligence MCP: reports THAT an organization was breached and which data types leaked, across full history from public feeds (HaveIBeenPwned, RansomLook, ransomwatch archive, SEC 8-K 1.05). Never the leaked data.
5
5
  Project-URL: Homepage, https://github.com/beepboop2025/data-breach-detector
6
6
  Project-URL: Repository, https://github.com/beepboop2025/data-breach-detector
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "data-breach-detector"
7
- version = "0.2.0"
7
+ version = "0.2.2"
8
8
  description = "Read-only breach-intelligence MCP: reports THAT an organization was breached and which data types leaked, across full history from public feeds (HaveIBeenPwned, RansomLook, ransomwatch archive, SEC 8-K 1.05). Never the leaked data."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -2,8 +2,8 @@
2
2
  "$schema": "https://static.modelcontextprotocol.io/schemas/2025-09-29/server.schema.json",
3
3
  "name": "io.github.beepboop2025/data-breach-detector",
4
4
  "title": "data-breach-detector",
5
- "description": "Read-only breach intelligence from public feeds, full history 2007-today: reports THAT an organization was breached, never the data.",
6
- "version": "0.2.0",
5
+ "description": "Read-only breach intel, full history 2007-today: reports THAT an org was breached, never the data.",
6
+ "version": "0.2.2",
7
7
  "repository": {
8
8
  "url": "https://github.com/beepboop2025/data-breach-detector",
9
9
  "source": "github"
@@ -12,7 +12,7 @@
12
12
  {
13
13
  "registryType": "pypi",
14
14
  "identifier": "data-breach-detector",
15
- "version": "0.2.0",
15
+ "version": "0.2.2",
16
16
  "transport": {
17
17
  "type": "stdio"
18
18
  }
@@ -2,5 +2,5 @@
2
2
 
3
3
  from .server import mcp
4
4
 
5
- __version__ = "0.2.0"
5
+ __version__ = "0.2.2"
6
6
  __all__ = ["mcp"]
@@ -330,6 +330,20 @@ def _year_of(r: dict) -> int | None:
330
330
  return None
331
331
 
332
332
 
333
+ def _slim(r: dict, summary_cap: int = 140) -> dict:
334
+ """Compact projection for list payloads.
335
+
336
+ Full records carry prose summaries that add up fast: a 30-row timeline ran
337
+ to ~13k tokens, which is enough to stall an agent's tool loop. Every field
338
+ an analyst acts on is kept; only the narrative is trimmed.
339
+ """
340
+ out = dict(r)
341
+ summary = r.get("summary") or ""
342
+ out["summary"] = (summary[:summary_cap].rstrip() + "…"
343
+ if len(summary) > summary_cap else summary)
344
+ return out
345
+
346
+
333
347
  def _haystack(r: dict) -> str:
334
348
  return (r.get("entity", "") + " " + r.get("title", "") + " "
335
349
  + r.get("summary", "") + " " + " ".join(r.get("categories", []))
@@ -351,8 +365,9 @@ async def breach_news(
351
365
  description="optional source filter: 'HaveIBeenPwned', 'RansomLook', "
352
366
  "'ransomwatch-archive' or 'SEC EDGAR 8-K 1.05'")] = None,
353
367
  limit: Annotated[int, Field(
354
- description="maximum disclosures to return (default 25)",
355
- ge=1, le=100)] = 25,
368
+ description="maximum disclosures to return (default 10; raise it "
369
+ "deliberately, large pages are heavy for an agent loop)",
370
+ ge=1, le=100)] = 10,
356
371
  ) -> dict:
357
372
  """Read recent breach and ransomware DISCLOSURES from public threat-intel
358
373
  feeds (HaveIBeenPwned, the RansomLook live leak-site tracker and SEC 8-K
@@ -371,7 +386,8 @@ async def breach_news(
371
386
  s = source.lower()
372
387
  rows = [r for r in rows if s in r["source"].lower()]
373
388
  return {"count": len(rows), "since_days": since_days, "sector": sector,
374
- "disclosures": rows[:limit],
389
+ "returned": min(len(rows), limit),
390
+ "disclosures": [_slim(r) for r in rows[:limit]],
375
391
  "note": "Disclosure metadata only. No leaked records are served by this tool."}
376
392
 
377
393
 
@@ -406,7 +422,7 @@ async def check_exposure(
406
422
  "total_accounts_exposed": sum(h["pwn_count"] for h in hits),
407
423
  "exposed_data_types": sorted({t for h in hits for t in h["exposed_data_types"]}),
408
424
  "latest_disclosure": hits[0]["sort_date"] if hits else None,
409
- "matches": hits[:15],
425
+ "matches": [_slim(h) for h in hits[:8]],
410
426
  "note": ("Presence signal from public disclosure feeds: reports THAT an entity "
411
427
  "appears in breach data, not the breached data. Confirm before acting."),
412
428
  }
@@ -433,7 +449,9 @@ async def breach_history(
433
449
  order: Annotated[str, Field(
434
450
  description="'newest' (default), 'oldest' or 'largest' (by accounts exposed)")] = "newest",
435
451
  limit: Annotated[int, Field(
436
- description="maximum incidents to return (default 25)", ge=1, le=100)] = 25,
452
+ description="maximum incidents to return (default 10; raise it "
453
+ "deliberately, large pages are heavy for an agent loop)",
454
+ ge=1, le=100)] = 10,
437
455
  ) -> dict:
438
456
  """Search the FULL historical breach archive — every incident this server
439
457
  knows about, back to 2007: HaveIBeenPwned's verified breach directory, the
@@ -471,7 +489,8 @@ async def breach_history(
471
489
  "total_accounts_exposed": sum(r["pwn_count"] for r in rows),
472
490
  "span": {"earliest": min(years), "latest": max(years)} if years else None,
473
491
  "order": order,
474
- "incidents": rows[:limit],
492
+ "returned": min(len(rows), limit),
493
+ "incidents": [_slim(r) for r in rows[:limit]],
475
494
  "note": "Full-archive disclosure metadata only. No leaked records are served.",
476
495
  }
477
496
 
@@ -524,7 +543,7 @@ async def breach_timeline(
524
543
  "worst_threat_level": worst if hits else "none",
525
544
  "total_accounts_exposed": sum(h["pwn_count"] for h in hits),
526
545
  "sources": sorted({h["source"] for h in hits}),
527
- "timeline": hits[:30],
546
+ "timeline": [_slim(h) for h in hits[:12]],
528
547
  "assessment": stance,
529
548
  "note": "Chronology of public disclosures only. No leaked records are served.",
530
549
  }
@@ -126,6 +126,35 @@ def test_history_data_type_and_min_accounts():
126
126
  assert [r["id"] for r in out["incidents"]] == ["hibp:Adobe"]
127
127
 
128
128
 
129
+ def test_slim_trims_narrative_but_keeps_facts():
130
+ long_summary = "x" * 400
131
+ r = _rec(entity="a.example", summary=long_summary, pwn_count=5,
132
+ exposed_data_types=["Passwords"], threat_level="high")
133
+ s = S._slim(r)
134
+ assert len(s["summary"]) <= 141 and s["summary"].endswith("…")
135
+ for field in ("entity", "pwn_count", "exposed_data_types", "threat_level",
136
+ "source", "disclosed_at"):
137
+ assert field in s
138
+ assert S._slim(_rec(summary=""))["summary"] == ""
139
+
140
+
141
+ def test_list_payloads_are_slimmed():
142
+ out = run(S.check_exposure("acme.example"))
143
+ assert all(len(m.get("summary", "")) <= 141 for m in out["matches"])
144
+ hist = run(S.breach_history(limit=5))
145
+ assert hist["returned"] == min(hist["count"], 5)
146
+
147
+
148
+ def test_default_pages_stay_small_enough_for_a_tool_loop():
149
+ """A 25-row default serialized to ~14KB and stalled an agent's tool loop."""
150
+ import json
151
+ for payload in (run(S.breach_news(since_days=100000)),
152
+ run(S.breach_history()),
153
+ run(S.breach_timeline("acme.example")),
154
+ run(S.check_exposure("acme.example"))):
155
+ assert len(json.dumps(payload)) < 8000
156
+
157
+
129
158
  def test_timeline_repeat_victim_judgment():
130
159
  out = run(S.breach_timeline("acme.example"))
131
160
  assert out["repeat_victim"] is True