Back to DevLog

Building a License Gate for MemStack: From Zero to Tiered SaaS in 45 Minutes

3 min read

Just wrapped up a fun multi-agent coding session where I built out license validation for MemStack from scratch. What started as a simple "check if user has pro license" turned into a full tiered access system with some nice touches.

The Challenge

MemStack has 80 skills, and I wanted to gate some premium features behind a Pro license while still giving users a taste with a free tier. The tricky part was doing this without breaking the user experience or leaking skill names to unauthorized users.

What I Built

v1: Basic Pro Gate

Started with a clean license.py module that:

  • Validates license keys against my AdminStack API
  • Caches responses in-memory with server-controlled TTL
  • Uses per-key async locks to prevent duplicate API calls
  • Gracefully handles network errors with stale cache fallback
  • Reads license keys from env vars or ~/.memstack/license.json

Integrated this into the MCP server to gate all tools, plus added an activate_license tool for interactive key entry. My Reviewer agent caught 6 issues including a nasty async race condition - good catch!

v2: Tiered Access System

Realized a pure Pro/no-access split was too harsh, so I pivoted to:

  • No key: Fully blocked with "Get your free key" message
  • Free key: Access to 77 out of 80 skills
  • Pro key: Full access to all 80 skills

The 3 Pro-exclusive skills are consolidate, context-db, and api-docs - the power user features that justify the upgrade.

The Fun Details

What I love about this implementation:

Smart caching: The API tells the client how long to cache responses, so I can adjust validation frequency server-side without client updates.

Graceful degradation: Network hiccup? Use the stale cache. HTTP 4xx error? That's a real rejection, fail immediately.

No skill leakage: Unauthorized users don't even see the names of skills they can't access. Clean UX.

Email capture: The activate_license tool now asks for email, feeding into my AdminStack for contact tracking.

Multi-Agent Magic

This was a Manager/Builder/Reviewer session using my agent-bridge setup. Having the Reviewer catch issues like the async race condition and skill name leakage saved me from shipping bugs. It's wild how much cleaner code gets when you have an extra set of AI eyes on it.

What's Next

The license gate is live and working, but there's more to do:

  • Build the memstack.pro landing page with free key signup
  • Add AdminStack UI for managing license keys
  • Move the Pro-exclusive skill list to config instead of hardcoding
  • Add usage analytics to see which skills people actually use

Pretty happy with 45 minutes of work that took MemStack from "free tool" to "proper SaaS with tiered access." Sometimes the best features are the ones that just work invisibly in the background.

Got the test keys created and everything's pushed. Time to see how users react to the new gating!

Share this post