Designing a Portable Keep-to-Blogger Antigravity Plugin: An Undergraduate Software Architecture Case Study

Close-up photograph of a dark pen resting on a textured black notebook representing note-taking and software architecture planning

Note. From Pen on a notebook (Unsplash) [Photograph], by Thomas Martinsen, 2014, Wikimedia Commons (https://commons.wikimedia.org/wiki/File:Pen_on_a_notebook_(Unsplash).jpg). CC0 1.0 Universal (https://creativecommons.org/publicdomain/zero/1.0/).

Moving from classroom scripts to public software requires a shift in engineering mindset. A personal utility only needs to work on one laptop with hardcoded paths and single-account assumptions. A reusable community plugin must serve strangers safely across different operating systems, accounts, and publishing domains.

This case study walks undergraduate software engineering and information systems students through the complete conceptual blueprint of Keep to Blogger Drafts (keep-to-blogger), a free, non-commercial, open-source Google Antigravity plugin released under the MIT licence. Students can inspect the full source code for study and hands-on learning on its public GitHub repository.

Keep to Blogger Drafts is an independent, non-commercial educational open-source project. It is provided strictly free of charge with no paid tiers, sponsorships, advertising, or data monetisation. It is not affiliated with, sponsored by, or endorsed by Google or Alphabet, and all product names appear strictly to describe software interoperability.


1. Problem Definition and Real-World API Constraints

Good architecture starts by mapping external constraints before writing any application code. Many writers draft notes in local Markdown, Word documents, or PDF files before capturing quick edits in Google Keep and publishing articles on Blogger. Bridging these three spaces manually invites copy-paste errors, broken formatting, and scattered drafts.

Real-world platforms rarely offer frictionless APIs for every personal workflow. Google Keep enforces a strict 20,000-character limit per note and restricts its official Google Keep API v1 to Google Workspace Enterprise accounts using Domain-Wide Delegation. Consumer accounts therefore lack an officially supported write API from Google.

Blogger API v3 introduces two further engineering constraints that shape the design immediately. First, the API accepts HTML strings for post bodies rather than direct binary uploads for local image files. Second, Blogger OAuth grants broad authoring scope, meaning accidental calls could modify live public pages if left unguarded.

Undergraduates often treat API limitations as roadblocks, yet senior engineers treat them as architectural inputs. Every guardrail in keep-to-blogger exists because of those exact boundaries: automatic text chunking, external image guidance, pluggable note backends, and strictly draft-only post creation.


2. Understanding the Model Context Protocol (MCP) Mental Model

Modern AI agents interact with external tools through the Model Context Protocol (MCP), an open specification built on structured JSON-RPC messages. Rather than embedding cloud credentials inside prompt text, the AI host launches a dedicated local MCP server subprocess and invokes typed tools on demand.

In keep-to-blogger, a single Python server (keep-to-blogger-mcp) communicates over standard input and standard output (stdio). That transport choice teaches an essential systems programming rule: stdout belongs exclusively to valid JSON-RPC frames. Even one stray print() call to standard output breaks the wire protocol immediately, so all diagnostic logs must route to stderr.

Running the MCP server locally over stdio also delivers strong privacy by design. No developer-hosted cloud relay sits between the user and Google services, and zero telemetry or analytics leave the workstation. Students should notice how transport selection directly reduces operational cost, attack surface, and data-governance risk.


3. Layered Module Architecture and Separation of Concerns

Rather than placing all logic in one monolithic script, the server organises its codebase into eight focused Python modules under server/src/keep_to_blogger_mcp/. Each module owns one well-defined responsibility, allowing undergraduate developers to reason about security, parsing, networking, and formatting independently.

  • config.py resolves runtime paths, reads environment variables, and validates backend settings cleanly.
  • security.py enforces directory allowlists, resolves symbolic links, and blocks path-traversal attempts before reading any file.
  • parsers.py converts 23 local document formats into clean note text, checklists, frontmatter metadata, and safe chunks.
  • keep_backend.py abstracts Google Keep access behind a pluggable backend interface supporting three distinct operating modes.
  • blogger_client.py handles Blogger API v3 OAuth, multi-blog discovery, context retrieval, and draft-only mutations.
  • formatter.py generates clean semantic HTML by default and offers an optional responsive preset.
  • server.py exposes 15 typed MCP tools over stdio with structured error responses.
  • cli.py provides interactive terminal setup commands (doctor, setup-blogger, setup-keep) so secrets never enter chat transcripts.

Separating the interactive terminal helper (cli.py) from the AI-facing server (server.py) highlights an important security boundary. OAuth client files, browser consent flows, and credential exchanges stay inside the user's local terminal. The AI model invokes safe operational tools without ever seeing raw authentication secrets.


4. Multi-Format Ingestion and Defensive File Handling

Users rarely keep ideas in one tidy file format. The ingestion module (parsers.py) therefore supports 23 text-bearing formats spanning Markdown, plain text, Word, OpenDocument, Rich Text, EPUB, PowerPoint, Excel, PDF, HTML, XML, email files, and structured data formats including CSV, TSV, JSON, YAML, and TOML.

For Markdown notes, the parser reads optional YAML frontmatter to capture titles and labels automatically, falls back to the first heading when needed, and detects task checkboxes so they can map to native Google Keep checklists. Unsupported binary files such as images, audio, video, or compressed archives fail early with clear guidance.

Long documents require careful handling because Google Keep rejects notes exceeding 20,000 characters. The chunking algorithm targets an 18,500-character threshold, preserving a safety buffer for metadata and splitting on paragraph boundaries first before falling back to line breaks. Multi-part imports automatically receive clean sequence markers such as (Part 1/3).

Local file access is one of the highest-risk surfaces in any desktop AI plugin. Before opening a file, security.py canonicalises the target path and verifies it remains inside an explicitly allowlisted directory from KEEP_ALLOWED_DIRS. This check neutralises parent-directory traversal sequences and symbolic links pointing outside permitted folders.

Batch folder imports add a second usability safeguard through a preview-first workflow. The import_folder_to_keep tool defaults to dry_run=True, listing every matched file, skipped binary, and estimated chunk count before writing anything to Google Keep. Designing reversible previews prevents accidental bulk clutter.


5. Applying the Adapter Pattern to Pluggable Keep Backends

Software engineering courses frequently teach the Adapter pattern in theory, and Google Keep provides an ideal real-world illustration. Because personal Gmail users, privacy-focused offline readers, and Google Workspace Enterprise administrators face completely different API entitlements, hardcoding one access library would lock out most users.

Instead, keep_backend.py defines an abstract KeepBackend contract specifying uniform operations for listing, reading, creating, and tagging notes. Three concrete adapters satisfy that contract without changing any upstream parsing or downstream blogging code.

  • takeout_local reads official local Google Takeout exports completely offline, providing zero-network read-only access for drafting blog posts.
  • workspace_api connects to the official Google Keep API v1 using a Google Workspace Service Account configured with Domain-Wide Delegation.
  • gkeepapi offers an optional community adapter for personal Gmail accounts, storing credentials strictly inside the native operating system credential vault via Python keyring.

This three-adapter architecture also delivers an important lesson in ethical compliance and dependency isolation. Students must clearly distinguish official vendor APIs from unofficial community libraries and document platform Terms of Service implications transparently. Isolating each backend behind an interface means users can switch modes through configuration alone whenever platform policies evolve.


6. Multi-Tenant Blogger Discovery and Draft-Only Guardrails

Converting a personal Blogger script into a public plugin immediately exposes hidden assumptions. A personal prototype often hardcodes one blog identifier, scrapes public RSS feeds, and applies inline styles tailored to a single theme. Every one of those shortcuts breaks when a second person installs the software.

To support any user-defined Blogger site, blogger_client.py replaces static identifiers with runtime discovery. Calling list_user_blogs invokes blogs.listByUser(userId="self") to enumerate every blog linked to the signed-in Google account. Calling resolve_blog_by_url invokes blogs.getByUrl to resolve both standard Blogger subdomains and custom domains seamlessly.

Context awareness follows the same authenticated design. Rather than relying on public feeds that fail on private or invite-only blogs, get_blog_context fetches existing post titles and label frequencies directly through Blogger API v3. AI assistants can then propose non-duplicate titles and consistent labels tailored to each author's taxonomy.

Visual portability requires equally disciplined restraint in formatter.py. Because different bloggers run vastly different themes, the default clean_semantic mode emits unadorned headings, paragraphs, lists, and blockquotes that inherit the host theme cleanly. Authors wanting responsive inline typography can opt into styled_responsive deliberately without forcing that aesthetic onto everyone.

Most importantly, safety guardrails belong in executable code rather than polite prompt instructions. In blogger_client.py, create_blogger_draft hardcodes isDraft=True, while update_blogger_draft verifies the target post status is strictly DRAFT before patching. Any attempt to edit a live or scheduled post raises DraftOnlyViolationError, and no publish tool exists.


7. Portable Plugin Packaging, Skills, and Agent Guardrails

An Antigravity plugin packages more than Python code; it bundles runtime wiring, behavioural rules, and structured workflows so both humans and AI agents operate predictably. Two declarative manifests anchor the root directory: plugin.json describes plugin identity, version, MIT licence, and suggested prompts, while mcp_config.json configures the local MCP server command.

Achieving portability across macOS, Linux, and Windows requires avoiding absolute filesystem paths. Inside mcp_config.json, the plugin references ${PLUGIN_ROOT} for installed source files and ${PLUGIN_DATA} for persistent user configuration and OAuth tokens. Setting UV_PROJECT_ENVIRONMENT to ${PLUGIN_DATA}/venv keeps Python dependencies outside the immutable plugin directory and prevents symlink conflicts during installation.

Beyond executables, the plugin ships one always-on rule file (rules/AGENTS.md) alongside three progressive-disclosure skills: setup-keep-blogger, import-files-to-keep, and keep-to-blogger-draft. Always-on rules enforce universal invariants such as keeping secrets out of chat and preserving draft-only publishing. Skills load step-by-step procedures only when relevant, conserving the AI model's context window.


8. Testing, Privacy Hygiene, and Legal Alignment

Reliable open-source engineering combines automated verification with disciplined privacy hygiene before every public commit. The server includes 24 automated pytest tests spanning configuration validation, path-traversal defence, multi-format parsing, backend adapters, draft-only Blogger safety, HTML formatting, end-to-end stdio JSON-RPC discovery, and non-commercial repository hygiene.

Dedicated hygiene tests scan every tracked file using generic regular-expression patterns to reject personal emails, OAuth tokens, home paths, funding files, storefront links, or external trackers. Pairing automated privacy and non-commercial scans with a GitHub noreply commit email and strict .gitignore rules keeps permanent Git history clean.

Publishing software and documentation also demands alignment with Australian and international law. Releasing the codebase under the MIT licence clarifies reuse rights under the Australian Copyright Act 1968 and international copyright conventions. Meanwhile, PRIVACY.md documents transparent local-first data handling aligned with the Australian Privacy Act 1988 and the Australian Privacy Principles.

Finally, keeping every blog output draft-only helps authors uphold Blogger and Google platform content standards before any text reaches the public web. Writers retain full editorial control to verify factual accuracy, family-safe imagery, lawful attributions, and copyright compliance prior to manual publication.


9. Accessing the Source Code and Study Exercises for Students

The complete keep-to-blogger source repository, including its Python MCP server, 24-test pytest suite, skills, guardrail rules, and privacy documentation, is publicly available at no cost as a non-commercial educational resource at github.com/Jianfa888Tsai/keep-to-blogger. Readers using Google Antigravity can also inspect or run the plugin locally with this command:

agy plugin install https://github.com/Jianfa888Tsai/keep-to-blogger

After installation, enable the plugin through /plugin to supply your preferred Keep backend, allowed import folders, and optional default Blogger URL, then run the local terminal setup helpers to authenticate securely.

If you are an undergraduate studying software architecture, try extending this blueprint yourself through three practical exercises:

  • Write a fourth KeepBackend adapter for a local SQLite or plain-Markdown vault without modifying server.py or blogger_client.py.
  • Add a unit test in server/tests/test_security.py simulating a nested symlink chain pointing outside KEEP_ALLOWED_DIRS and verify it fails safely.
  • Design a custom HTML formatter preset in formatter.py that adds accessible table styling while keeping all external links safe and theme-compatible.

Studying a compact, production-minded plugin from requirements through public release bridges the gap between lecture slides and real engineering practice. Fork the repository, run pytest, trace a single JSON-RPC call from server.py down to blogger_client.py, and adapt the pattern to your own ideas.