Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/application/services/billing_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,7 @@ def request_trial_license(self, email: str, source: Optional[str] = None) -> Opt
send_owner_activity_alert(
self._email_sender,
"Solicitud",
f"Nueva prueba solicitada: {email}",
"Nueva prueba solicitada",
correo=email,
origen=source or "web / oauth",
creditos=Tier.COMMUNITY.default_allowance,
Expand Down
28 changes: 14 additions & 14 deletions app/application/services/daily_growth.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"configs kills conversion. We solved it by combining OAuth 2.1 (RFC 8414 + PKCE) with a 6-digit email OTP "
"and an Ed25519 token gateway (KeyFlint).\n\n"
"Full technical write-up: https://keyflint.dev/guides/oauth-mcp-server.html\n"
"Live hub running 6 production MCP servers: https://mcp.keyflint.dev"
"Live hub with 5 production MCP servers + one unified connector: https://mcp.keyflint.dev"
),
},
{
Expand Down Expand Up @@ -137,7 +137,7 @@
),
"x_en": (
"Monetizing MCP servers in 2026: Stripe Checkout vs HTTP 402 vs Offline Ed25519 Licenses.\n\n"
"We wrote a complete engineering comparison based on running 6 production MCP servers on Cloudflare + Fly.io:\n"
"We wrote a complete engineering comparison based on running 5 production MCP servers on Cloudflare + Fly.io:\n"
"https://keyflint.dev/guides/mcp-monetization-stripe-x402.html"
),
"linkedin_es": (
Expand Down Expand Up @@ -181,8 +181,8 @@
"reddit_title": "Deterministic financial MCP servers: why the tool must own Decimal math and balance assertions",
"reddit_body": (
"When we built Flint (https://mcp.keyflint.dev) for Spanish accounting firms, our core design rule was "
"zero arithmetic inside the LLM prompt. Every Norma 43 bank statement and Facturae XML is verified with "
"Python `Decimal` and cryptographic hashes inside the MCP tool before returning structured output."
"zero arithmetic inside the LLM prompt. Every Norma 43 bank statement is checked with "
"integer-cent arithmetic and balance assertions inside the MCP tool before returning structured output."
),
},
]
Expand Down Expand Up @@ -320,24 +320,23 @@ def collect_pulse_metrics(conn: Any, now: Optional[datetime] = None) -> dict[str


def notify_ntfy(title: str, message: str, click_url: str = "https://mcp.keyflint.dev/estado/") -> bool:
"""Sends an instant mobile lockscreen push notification via ntfy.sh if NTFY_TOPIC is set."""
"""Sends a lockscreen push via ntfy.sh if NTFY_TOPIC is set.

ntfy.sh topics are public to anyone who knows the name: never pass personal data (emails, keys) here.
JSON publish keeps UTF-8 titles intact (HTTP headers are latin-1 only).
"""
topic = (get_settings().NTFY_TOPIC or "").strip()
if not topic:
return False
try:
resp = httpx.post(
f"https://ntfy.sh/{topic}",
content=message.encode("utf-8"),
headers={
"Title": title[:120],
"Click": click_url,
"Priority": "default",
},
"https://ntfy.sh/",
json={"topic": topic, "title": title[:120], "message": message[:1000], "click": click_url},
timeout=5.0,
)
return resp.status_code < 300
except Exception as exc:
logger.warning("ntfy push failed: %s", exc)
logger.warning("ntfy push failed: %s", type(exc).__name__)
return False


Expand All @@ -353,7 +352,8 @@ def send_owner_activity_alert(
return False
lines = [f"{k}: {v}" for k, v in details.items() if v is not None]
text_body = f"{title}\n\n" + "\n".join(lines) + "\n\nEstado en vivo: https://mcp.keyflint.dev/estado/\n"
notify_ntfy(f"[{kind}] {title}", "\n".join(lines))
# Push sin datos personales: el detalle (correo, sesión) solo va al correo del propietario.
notify_ntfy(f"[{kind}] KeyFlint", title if "@" not in title else kind)

to = (settings.OPS_ALERT_EMAIL or "").strip()
if not to or email_sender is None:
Expand Down
4 changes: 2 additions & 2 deletions app/presentation/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ <h3>Charge per use</h3>
<section id="ecosystem-section" class="block">
<div class="section-head">
<span class="eyebrow">Production ecosystem · Built on KeyFlint</span>
<h2>6 live MCP servers &amp; OAuth 2.1 connectors running on KeyFlint</h2>
<h2>5 live MCP servers &amp; one unified OAuth 2.1 connector running on KeyFlint</h2>
<p>See KeyFlint in production at <a href="https://mcp.keyflint.dev" target="_blank" rel="noopener">mcp.keyflint.dev</a>: passwordless 6-digit OAuth 2.1, atomic credit metering, automatic error refunds, and browser batch conversion.</p>
</div>
<div class="grid">
Expand All @@ -534,7 +534,7 @@ <h3 class="card-title">Norma 43 &amp; ContaBridge</h3>
</div>
<span class="tag">Decimal</span>
</div>
<p class="card-sub">Deterministic Spanish bank statement parser (.n43, .c43, .csv) and Facturae XML to ERP journal bridge with zero LLM arithmetic hallucinations.</p>
<p class="card-sub">Deterministic Spanish bank statement parser (.n43, .c43, .csv) plus invoice and bank-movement bookkeeping to ERP journal files, with no LLM arithmetic.</p>
<a href="https://mcp.keyflint.dev/csv-a-contasol/" target="_blank" rel="noopener" class="btn btn-secondary btn-inline">Open Web Converter</a>
</div>
<div class="card col-4">
Expand Down
15 changes: 7 additions & 8 deletions docs/guides/mcp-monetization-stripe-x402.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@
<main>
<article>
<h1>How to Monetize MCP Servers in 2026</h1>
<p class="lead">Whether you ship a local <code>stdio</code> MCP server via PyPI/npm or a remote Streamable HTTP endpoint on Cloudflare Workers, choosing the wrong billing layer either adds 150 ms of latency to every call or costs 15–30% in platform fees.</p>
<p class="lead">Whether you ship a local <code>stdio</code> MCP server via PyPI/npm or a remote Streamable HTTP endpoint on Cloudflare Workers, choosing the wrong billing layer either adds a network round-trip to every call or a platform fee on every sale.</p>

<h2>Comparing the 3 Architectures</h2>
<table>
<tr><th>Requirement</th><th>KeyFlint (Ed25519 + SQLite WAL)</th><th>Hosted MCP Marketplaces</th><th>Raw Stripe API per Call</th></tr>
<tr><td><strong>Platform cut</strong></td><td><span class="kw">0%</span> (direct Stripe / LemonSqueezy webhooks)</td><td>10% to 30% marketplace fee</td><td>Stripe fee only, but rate-limited</td></tr>
<tr><td><strong>Feature-gate latency</strong></td><td><span class="kw">0.12 ms offline</span> (Ed25519 public key)</td><td>80–250 ms proxy hop</td><td>150–400 ms HTTP call</td></tr>
<tr><td><strong>Platform cut</strong></td><td><span class="kw">0%</span> (direct Stripe / LemonSqueezy webhooks)</td><td>Marketplace fee (varies by platform)</td><td>Stripe fee only, plus API rate limits</td></tr>
<tr><td><strong>Feature-gate latency</strong></td><td><span class="kw">0.12 ms offline</span> (Ed25519 public key)</td><td>Network hop to the proxy</td><td>Network call per check</td></tr>
<tr><td><strong>Per-call credit debit</strong></td><td>Atomic SQLite WAL + idempotency key</td><td>Varies by proxy</td><td>Not designed for synchronous sub-cent debits</td></tr>
<tr><td><strong>Refund on tool error</strong></td><td>Automatic via <code>/api/v1/quota/refund</code> + circuit breaker</td><td>Rarely supported</td><td>Manual</td></tr>
<tr><td><strong>Works for local <code>stdio</code></strong></td><td>Yes (<code>@keyflint/wrap</code> + <code>keyflint-verify</code>)</td><td>No (remote proxy only)</td><td>Requires embedding secrets or proxy</td></tr>
Expand All @@ -64,11 +64,10 @@ <h2>Comparing the 3 Architectures</h2>
<h2>Pattern 1: Wrapping Any Existing MCP Server in 30 Seconds</h2>
<p>If you already have an MCP server in any language and want to gate tools without rewriting its source code, wrap it with <code>@keyflint/wrap</code>:</p>
<pre><code>npx @keyflint/wrap \
--public-key 8f4e... \
--gateway https://licenses.your-domain.com \
--cost parse_statement=2,export_journal=5 \
--tool parse_statement=2 --tool export_journal=5 \
-- npx -y @your-org/your-mcp-server</code></pre>
<p>When a user runs out of credits, the wrapper intercepts the call before your server executes and returns JSON-RPC error <code>-32062</code> with a 1-click Stripe top-up link that adds credits to the <em>same</em> license key.</p>
<p>The license, your public keys and the gateway URL come from <code>KEYFLINT_LICENSE</code>, <code>KEYFLINT_PUBLIC_KEYS</code> and <code>KEYFLINT_URL</code>.</p>
<p>When a user runs out of credits, the wrapper intercepts the call before your server executes and returns JSON-RPC error <code>-32062</code> pointing to your top-up link (<code>KEYFLINT_CHECKOUT_URL</code>), which can add credits to the <em>same</em> license key.</p>

<h2>Pattern 2: Decorator-Based Metering in Python &amp; TypeScript</h2>
<p>For fine-grained control inside FastMCP or the official MCP SDK, use <code>keyflint-verify</code>:</p>
Expand All @@ -80,7 +79,7 @@ <h2>Pattern 2: Decorator-Based Metering in Python &amp; TypeScript</h2>
@kf.metered(credits=4)
def audit_invoice_xml(xml_payload: str) -&gt; dict:
# Automatically refunded if an exception is raised or isError=True is returned
return verify_facturae_signature(xml_payload)</code></pre>
return audit(xml_payload) # your own tool logic</code></pre>

<h2>Pattern 3: Dual-Surface Monetization (MCP + Browser Batch UI)</h2>
<p>Many B2B buyers discover your tool through Google Search before they ever install an MCP client. By exposing the same KeyFlint-metered container tools behind a browser drag-and-drop UI (like <a href="https://mcp.keyflint.dev/lote/">mcp.keyflint.dev/lote</a>), the exact same <code>LIC-...</code> token and credit balance work across Claude Desktop, Cursor, REST APIs, and the web browser.</p>
Expand Down
8 changes: 4 additions & 4 deletions docs/guides/oauth-mcp-server.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ <h2>Why OAuth 2.1 + KeyFlint?</h2>
<tr><th>Step</th><th>Protocol Endpoint</th><th>What happens</th></tr>
<tr><td>1. Challenge</td><td><code>POST /&lt;slug&gt;/mcp</code> &rarr; <code>401</code></td><td>Returns <code>WWW-Authenticate: Bearer resource_metadata=".../.well-known/oauth-protected-resource"</code>.</td></tr>
<tr><td>2. Discovery &amp; DCR</td><td><code>/.well-known/oauth-authorization-server</code>, <code>/oauth/register</code></td><td>MCP client registers dynamically and starts PKCE authorization (<code>S256</code>).</td></tr>
<tr><td>3. 6-Digit Email OTP</td><td><code>GET /oauth/authorize</code></td><td>User enters their email and a 6-digit code sent via Resend.</td></tr>
<tr><td>4. License Resolution</td><td><code>GET /api/v1/licenses/by-customer</code></td><td>Gateway returns active paid licenses for that email (or auto-provisions a 25-credit Community trial).</td></tr>
<tr><td>5. Token Exchange</td><td><code>POST /oauth/token</code></td><td>Issues the <code>LIC-...</code> token as the OAuth access token. Every subsequent tool call is metered atomically.</td></tr>
<tr><td>3. 6-Digit Email OTP</td><td><code>GET /authorize</code></td><td>User enters their email and a 6-digit code sent via Resend.</td></tr>
<tr><td>4. License Resolution</td><td><code>GET /api/v1/licenses/by-customer</code></td><td>Gateway returns the active licenses for that email. If there are none, the hub issues a 25-credit Community trial via <code>POST /api/v1/licenses/issue</code>.</td></tr>
<tr><td>5. Token Exchange</td><td>Token endpoint</td><td>Issues a short-lived OAuth access token bound to that <code>LIC-...</code> license. Every subsequent tool call is metered atomically against it.</td></tr>
</table>

<h2>Querying Active Licenses by Email</h2>
Expand Down Expand Up @@ -91,7 +91,7 @@ <h2>Zero-Click Trial Fallback</h2>
</ul>

<h2>See It Live in Production</h2>
<p>This exact architecture powers <a href="https://mcp.keyflint.dev">Flint by KeyFlint</a> across 6 remote MCP servers, including our unified 17-tool accounting connector at <code>https://mcp.keyflint.dev/despacho/mcp</code>.</p>
<p>This exact architecture powers <a href="https://mcp.keyflint.dev">Flint by KeyFlint</a> across 5 remote MCP servers, including our unified 17-tool accounting connector at <code>https://mcp.keyflint.dev/despacho/mcp</code>.</p>

<a class="cta" href="/#pricing-section">Get KeyFlint Gateway</a>
<a class="cta" style="background:transparent;color:var(--fg);border:1px solid var(--line)" href="/guides/paid-mcp-server.html">Guide: Paid MCP Server</a>
Expand Down
4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ <h3>Charge per use</h3>
<section id="ecosystem-section" class="block">
<div class="section-head">
<span class="eyebrow">Production ecosystem · Built on KeyFlint</span>
<h2>6 live MCP servers &amp; OAuth 2.1 connectors running on KeyFlint</h2>
<h2>5 live MCP servers &amp; one unified OAuth 2.1 connector running on KeyFlint</h2>
<p>See KeyFlint in production at <a href="https://mcp.keyflint.dev" target="_blank" rel="noopener">mcp.keyflint.dev</a>: passwordless 6-digit OAuth 2.1, atomic credit metering, automatic error refunds, and browser batch conversion.</p>
</div>
<div class="grid">
Expand All @@ -549,7 +549,7 @@ <h3 class="card-title">Norma 43 &amp; ContaBridge</h3>
</div>
<span class="tag">Decimal</span>
</div>
<p class="card-sub">Deterministic Spanish bank statement parser (.n43, .c43, .csv) and Facturae XML to ERP journal bridge with zero LLM arithmetic hallucinations.</p>
<p class="card-sub">Deterministic Spanish bank statement parser (.n43, .c43, .csv) plus invoice and bank-movement bookkeeping to ERP journal files, with no LLM arithmetic.</p>
<a href="https://mcp.keyflint.dev/csv-a-contasol/" target="_blank" rel="noopener" class="btn btn-secondary btn-inline">Open Web Converter</a>
</div>
<div class="card col-4">
Expand Down
2 changes: 1 addition & 1 deletion docs/llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
## Live Production MCP Servers (Flint by KeyFlint · https://mcp.keyflint.dev)
- **Despacho Unified Connector** (`https://mcp.keyflint.dev/despacho/mcp`): Single OAuth 2.1 URL uniting 17 banking (AEB Norma 43) and accounting (ContaBridge) tools for Spanish accounting firms.
- **Norma 43 MCP** (`https://mcp.keyflint.dev/norma43/mcp`): Deterministic parser and balance validator for Spanish bank statements (`.n43`, `.c43`, CaixaBank, BBVA, Santander, Sabadell, Bankinter, Abanca).
- **ContaBridge MCP** (`https://mcp.keyflint.dev/contabridge/mcp`): Converts bank CSV / Norma 43 and Facturae XML into import-ready journal files for ContaSol, A3, Sage 50, and ContaPlus.
- **ContaBridge MCP** (`https://mcp.keyflint.dev/contabridge/mcp`): Converts bank CSV / Norma 43 statements and invoice lists (figures read by the assistant) into import-ready journal files for ContaSol, A3, Sage 50, and ContaPlus.
- **Veri*factu MCP** (`https://mcp.keyflint.dev/verifactu/mcp`): AEAT RD 1007/2023 SHA-256 invoice hash-chain verifier, Facturae 3.2.2 auditor, NIF/CIF/IBAN validator, and QR generator.
- **DataClean MCP** (`https://mcp.keyflint.dev/dataclean/mcp`): Deterministic CSV/JSON normalization, deduplication, and schema validation.
- **Web-Intel MCP** (`https://mcp.keyflint.dev/web-intel/mcp`): Clean Markdown extraction, structured table parsing, and metadata inspection for AI agents.
Expand Down
17 changes: 17 additions & 0 deletions tests/tier1_features/test_daily_growth.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Tier 1 tests for Automated Daily Growth Engine, Mobile Pulse & Real-Time Lead Alerts."""

from __future__ import annotations
import unittest

from datetime import datetime, timezone
from unittest.mock import patch
Expand Down Expand Up @@ -116,3 +117,19 @@ def test_admin_pulse_endpoint_requires_admin_and_returns_metrics(tmp_path, monke
assert "daily_post" in body["data"]
finally:
get_settings.cache_clear()


class TestNtfyPrivacy(unittest.TestCase):
def test_push_never_carries_customer_email(self):
from unittest import mock

from app.application.services import daily_growth

settings = mock.Mock(LEAD_ALERT_ENABLED=True, OPS_ALERT_EMAIL="", NTFY_TOPIC="t")
with mock.patch.object(daily_growth, "get_settings", return_value=settings), \
mock.patch.object(daily_growth.httpx, "post") as post:
post.return_value.status_code = 200
daily_growth.send_owner_activity_alert(None, "Solicitud", "Nueva prueba solicitada", correo="cliente@despacho.es")
sent = repr(post.call_args)
self.assertNotIn("cliente@despacho.es", sent)
self.assertIn("json", post.call_args.kwargs)
Loading