Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add instructions/toniher/substack-saved-mcp/claude-mdgit clone --depth 1 https://github.com/toniher/substack-saved-mcpWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/instructions/toniher/substack-saved-mcp/claude-md)<a href="https://agentmods.dev/instructions/toniher/substack-saved-mcp/claude-md"><img src="https://agentmods.dev/badge/instructions/toniher/substack-saved-mcp/claude-md.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.07695 | $0.07695 |
| Opus 5 | $0.03847 | $0.03847 |
| Sonnet 5 | $0.01539 | $0.01539 |
| Haiku 4.5 | $0.00769 | $0.00769 |
Grade A, and why
substack-saved-mcp CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 51 lines — stays where its author put it; the contents beside it link to each section on GitHub.
CLAUDE.md
This file provides guidance to Claude Code when working with this repository.
Commands
Use uv for all development commands. Set up the environment with:
uv sync --extra dev
| Task | Command |
|---|---|
| Run all tests | uv run python -m pytest |
| Run one test file | uv run python -m pytest tests/test_database.py |
| Run one test | uv run python -m pytest tests/test_database.py::test_fts5_search |
| Build the package | uv build |
| Run the CLI | uv run substack-saved-mcp --help |
| Reinstall tool globally | uv tool install . --no-cache --force |
ruff is configured in pyproject.toml (rules: E4, E7, E9, F, I, UP, B, RUF, line length 88, target py311). Lint with uvx ruff check . or uv run ruff check ..
After any change to dependencies or tracked files, run uv lock to keep uv.lock current, then prek run --all-files (using the repo's .pre-commit-config.yaml) before considering the work done.
Architecture
cli.pyis the Click entry point (substack-saved-mcp). Its commands initialize the database and then delegate to the repository, sync engine, Playwright client, or MCP server.mcp_server.pyexposes the same application operations as FastMCP stdio tools and resources. Read tools query the local cache; sync and save/unsave operations use the authenticated browser session.substack_client.pyowns Playwright authentication and remote Substack interaction.loginis the only intended headful workflow; normal sync and write paths usestorage_state.jsonheadlessly. Synchronous Playwright API calls are routed through_run_playwright_sync()to safely execute in a worker thread if anasyncioevent loop is active (e.g. under FastMCP). Saved-post fetching prefers the reader inbox API (GET /api/v1/reader/posts?inboxType=saved), which exposes the real bookmark timestamp (saved_at) and an ISO publication date (post_date) per post._fetch_all_saved_via_reader_api()cursor-paginates that endpoint (each page's oldestsaved_atbecomes the nextafter=cursor, untilmoreis false), dedupes by canonical URL, and enriches each flat post with itspublicationobject (from the response'spublicationsarray, matched bypublication_id) andauthor_name(frompublishedBylines). The full result is cached in_api_cacheand sliced by offset;_fetch_saved_posts_page_impl()accepts an optionalplaywright_instance(same pattern as the notes fetcher and_fetch_via_dom) so this caching/slicing/fallback branch is directly testable with a Playwright double instead of only reachable through a real browser. Each page request goes through_reader_api_get(), which retries transient failures (HTTP 429 and 5xx) up tomax_retries(default 3) withRetry-After-aware backoff:_retry_after_seconds()honors an integerRetry-Afterheader (clamped to a 30s cap so a hostile value can't hang the sync) and otherwise uses capped exponential backoff (0.5s, 1s, 2s, ...); 401/403 and other 4xx are returned unretried so the existing auth/fallback handling applies. A 429 that survives all retries is deliberately treated as "unavailable" (partial list, orNone→ DOM fallback) rather than as a silent empty-success, so rate-limiting never masquerades as "you have no saved posts." Both_reader_api_get()and_fetch_all_saved_via_reader_api()accept an injectablesleep_func(defaulttime.sleep) so tests exercise the backoff without real delays. If that endpoint is unavailable, it falls back to headless DOM extraction onhttps://substack.com/saved, which scrapesdiv.reader2-post-containercards, caches scrolling results in_dom_cache, and marks each dict with_dom: True; DOM cards only expose a localized relative publish string and no bookmark time, sosaved_atstays unknown on that path. Bothsave_post()andunsave_post()were originally guesswork (an unverified DOM button selector plus an unverifiedPOST /api/v1/bookmarkcall) and were fixed once real endpoints were captured viainspect-network. Every post page server-renders awindow._preloadsblob containing that post's own numeric ID and rich metadata (preloads.post.id,.title,.audience,.description/.subtitle,.post_date, pluspreloads.pub.name);_save_post_implreads this viapage.evaluate("() => window._preloads")right after page load and, when an ID is found, calls the realPOST https://substack.com/api/v1/posts/savedendpoint (body{"post_id": ...}) directly via the Playwright API request context — this also lets it populate the returnedSavedPostwith accurate title/publication/audience/excerpt instead of parsingpage.title()._unsave_post_impldoes the mirror image: when the post'ssubstack_post_idis already known (true for any post that has been through a normalsync, since the reader API'sidfield populates it), it callsDELETE https://substack.com/api/v1/posts/savedwith the same body shape, no DOM interaction at all. Both treat anokresponse as"confirmed"and only fall back to the old best-effort DOM click (_click_bookmark_toggle(), used when the numeric ID can't be obtained or the direct call doesn't confirm) — note its selector is English-only (aria-label*='save'/'bookmark') and can silently fail on non-English Substack UIs, which is part of why the direct API path is preferred whenever possible._click_bookmark_toggle()fingerprints the button'saria-label/aria-pressed/classbefore and after the click and returns"confirmed"only if that fingerprint changed, else"unconfirmed","not_found", or"click_failed"—save_post()returns(SavedPost, confirmation)andunsave_post()returns just the confirmation string; both accept an optionalplaywright_instancefor test injection (same pattern as_fetch_via_dom).fetch_post_content()reuses the samewindow._preloadsmechanism to retrieve a saved post's full content:_fetch_post_content_implnavigates to the post's page and readspreloads.post.body_html(Substack's field name for full content —parse_remote_post()already expects this key from the reader API, though the saved-list payload never actually populates it, only individual post pages do), returningNoneforbody_htmlif the page's embed format doesn't expose it (frontend change) or the account lacks paywall access; this is the case where the caller should be told to runinspect-networkagainst an open post page to re-discover the real content source.cli.py'sinspect-networkcommand (which logs anyapi/v1/bookmark/saved/notes?/comment/reader/feed/restackrequest's method, URL, status, and JSON response body) is the tool for discovering/re-verifying these endpoints when Substack's frontend changes. It supports--authenticated/--anonymous(reusesstorage_state.jsonviaget_storage_state_path()so/savedrenders the real logged-in page instead of the marketing page),--urlto target any page,--filterto override the response-matching regex,--max-bodyto cap logged response bytes, and--out PATHto append each exchange as JSON Lines for later grepping. Response bodies are captured viacontext.route("**/*", handle_route)+route.fetch()/route.fulfill(), not the more obviouspage.on("response", ...)+response.text(): the latter can deadlock callingresponse.text()inside a sync-API response event handler on the same driver thread, and in practice silently produced zero captured bodies across an entire 108-request session before this fix (everyresponse_bodycame backnullwith no error surfaced) —route.fetch()reads the body outside that handler androute.fulfill(response=...)re-serves the exact response so page behavior is unaffected; a body that still can't be read now logs a visible yellow warning instead of writingnullsilently.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 3d ago First seen · 51 lines · 7,695 tokens per session scan A 1a2fd0e3da11
substack-saved-mcp CLAUDE.md is an instructions file published in the GitHub repository toniher/substack-saved-mcp (0 stars, last pushed 12d ago), licensed MIT. It adds 7,695 tokens to every session, about $0.0385 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other instructions, from other repositories
vscode buildNext.instructions.md
Working notes and architecture documentation for the new esbuild-based build system in build/next. Use when making changes to the new build pipeline (transpile/bundle commands, NLS plugin, source-map handling, resource copying, or self-hosting watch tasks).
spec-kit AGENTS.md
AGENTS.md instructions for github/spec-kit, covering agents.md, about spec kit and specify, quickstart — add a new integration in 5 steps, integration architecture and integrationmanifest — file tracking.
codex AGENTS.md
AGENTS.md instructions for openai/codex, covering rust/codex-rs, the codex-core crate, code review rules, crate api surface and model visible context.
langchain AGENTS.md
AGENTS.md instructions for langchain-ai/langchain, covering global development guidelines for the langchain monorepo, corridor security analysis, project architecture and context, monorepo structure and development tools & commands.
vscode oss-third-party-notices.instructions.md
Instructions for microsoft/vscode, covering vs code oss third-party-notices pipeline, architecture, pipeline flow in ci, applying the notice (cutover) and fallback chain (never fail the build).
next.js AGENTS.md
Instructions for vercel/next.js, covering next.js development guide, codebase structure, monorepo overview, core package: packages/next and other important packages.