From 3987995ad184c9e75466f59dc490a526a8055389 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 9 Nov 2026 19:51:08 +0000 Subject: [PATCH] =?UTF-8?q?fix(growth):=20push=20ntfy=20sin=20datos=20pers?= =?UTF-8?q?onales=20y=20gu=C3=ADas=20sin=20afirmaciones=20falsas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ntfy.sh es público por nombre de tema: el aviso ya no lleva el correo del cliente; publicación JSON (cabeceras UTF-8 fallaban). - Guías/llms.txt/landing: 5 MCP + conector unificado (no 6), ContaBridge no lee Facturae XML, endpoints OAuth reales (/authorize), flags reales de @keyflint/wrap, sin cifras de latencia/comisión inventadas. - Test: el push nunca contiene el correo. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01R4cLjeGWkqgSkYAFxeutDS --- app/application/services/billing_service.py | 2 +- app/application/services/daily_growth.py | 28 +++++++++---------- app/presentation/static/index.html | 4 +-- docs/guides/mcp-monetization-stripe-x402.html | 15 +++++----- docs/guides/oauth-mcp-server.html | 8 +++--- docs/index.html | 4 +-- docs/llms.txt | 2 +- tests/tier1_features/test_daily_growth.py | 17 +++++++++++ 8 files changed, 48 insertions(+), 32 deletions(-) diff --git a/app/application/services/billing_service.py b/app/application/services/billing_service.py index fb21703..b8768c1 100644 --- a/app/application/services/billing_service.py +++ b/app/application/services/billing_service.py @@ -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, diff --git a/app/application/services/daily_growth.py b/app/application/services/daily_growth.py index dbd88fe..b06fce3 100644 --- a/app/application/services/daily_growth.py +++ b/app/application/services/daily_growth.py @@ -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" ), }, { @@ -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": ( @@ -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." ), }, ] @@ -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 @@ -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: diff --git a/app/presentation/static/index.html b/app/presentation/static/index.html index afaea0a..4ceb7d0 100644 --- a/app/presentation/static/index.html +++ b/app/presentation/static/index.html @@ -511,7 +511,7 @@

Charge per use

Production ecosystem · Built on KeyFlint -

6 live MCP servers & OAuth 2.1 connectors running on KeyFlint

+

5 live MCP servers & one unified OAuth 2.1 connector running on KeyFlint

See KeyFlint in production at mcp.keyflint.dev: passwordless 6-digit OAuth 2.1, atomic credit metering, automatic error refunds, and browser batch conversion.

@@ -534,7 +534,7 @@

Norma 43 & ContaBridge

Decimal -

Deterministic Spanish bank statement parser (.n43, .c43, .csv) and Facturae XML to ERP journal bridge with zero LLM arithmetic hallucinations.

+

Deterministic Spanish bank statement parser (.n43, .c43, .csv) plus invoice and bank-movement bookkeeping to ERP journal files, with no LLM arithmetic.

Open Web Converter
diff --git a/docs/guides/mcp-monetization-stripe-x402.html b/docs/guides/mcp-monetization-stripe-x402.html index a57351a..9920fbb 100644 --- a/docs/guides/mcp-monetization-stripe-x402.html +++ b/docs/guides/mcp-monetization-stripe-x402.html @@ -49,13 +49,13 @@

How to Monetize MCP Servers in 2026

-

Whether you ship a local stdio 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.

+

Whether you ship a local stdio 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.

Comparing the 3 Architectures

- - + + @@ -64,11 +64,10 @@

Comparing the 3 Architectures

Pattern 1: Wrapping Any Existing MCP Server in 30 Seconds

If you already have an MCP server in any language and want to gate tools without rewriting its source code, wrap it with @keyflint/wrap:

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
-

When a user runs out of credits, the wrapper intercepts the call before your server executes and returns JSON-RPC error -32062 with a 1-click Stripe top-up link that adds credits to the same license key.

+

The license, your public keys and the gateway URL come from KEYFLINT_LICENSE, KEYFLINT_PUBLIC_KEYS and KEYFLINT_URL.

+

When a user runs out of credits, the wrapper intercepts the call before your server executes and returns JSON-RPC error -32062 pointing to your top-up link (KEYFLINT_CHECKOUT_URL), which can add credits to the same license key.

Pattern 2: Decorator-Based Metering in Python & TypeScript

For fine-grained control inside FastMCP or the official MCP SDK, use keyflint-verify:

@@ -80,7 +79,7 @@

Pattern 2: Decorator-Based Metering in Python & TypeScript

@kf.metered(credits=4) def audit_invoice_xml(xml_payload: str) -> dict: # Automatically refunded if an exception is raised or isError=True is returned - return verify_facturae_signature(xml_payload) + return audit(xml_payload) # your own tool logic

Pattern 3: Dual-Surface Monetization (MCP + Browser Batch UI)

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 mcp.keyflint.dev/lote), the exact same LIC-... token and credit balance work across Claude Desktop, Cursor, REST APIs, and the web browser.

diff --git a/docs/guides/oauth-mcp-server.html b/docs/guides/oauth-mcp-server.html index 4cf8a18..ac35394 100644 --- a/docs/guides/oauth-mcp-server.html +++ b/docs/guides/oauth-mcp-server.html @@ -58,9 +58,9 @@

Why OAuth 2.1 + KeyFlint?

- - - + + +
RequirementKeyFlint (Ed25519 + SQLite WAL)Hosted MCP MarketplacesRaw Stripe API per Call
Platform cut0% (direct Stripe / LemonSqueezy webhooks)10% to 30% marketplace feeStripe fee only, but rate-limited
Feature-gate latency0.12 ms offline (Ed25519 public key)80–250 ms proxy hop150–400 ms HTTP call
Platform cut0% (direct Stripe / LemonSqueezy webhooks)Marketplace fee (varies by platform)Stripe fee only, plus API rate limits
Feature-gate latency0.12 ms offline (Ed25519 public key)Network hop to the proxyNetwork call per check
Per-call credit debitAtomic SQLite WAL + idempotency keyVaries by proxyNot designed for synchronous sub-cent debits
Refund on tool errorAutomatic via /api/v1/quota/refund + circuit breakerRarely supportedManual
Works for local stdioYes (@keyflint/wrap + keyflint-verify)No (remote proxy only)Requires embedding secrets or proxy
StepProtocol EndpointWhat happens
1. ChallengePOST /<slug>/mcp → 401Returns WWW-Authenticate: Bearer resource_metadata=".../.well-known/oauth-protected-resource".
2. Discovery & DCR/.well-known/oauth-authorization-server, /oauth/registerMCP client registers dynamically and starts PKCE authorization (S256).
3. 6-Digit Email OTPGET /oauth/authorizeUser enters their email and a 6-digit code sent via Resend.
4. License ResolutionGET /api/v1/licenses/by-customerGateway returns active paid licenses for that email (or auto-provisions a 25-credit Community trial).
5. Token ExchangePOST /oauth/tokenIssues the LIC-... token as the OAuth access token. Every subsequent tool call is metered atomically.
3. 6-Digit Email OTPGET /authorizeUser enters their email and a 6-digit code sent via Resend.
4. License ResolutionGET /api/v1/licenses/by-customerGateway returns the active licenses for that email. If there are none, the hub issues a 25-credit Community trial via POST /api/v1/licenses/issue.
5. Token ExchangeToken endpointIssues a short-lived OAuth access token bound to that LIC-... license. Every subsequent tool call is metered atomically against it.

Querying Active Licenses by Email

@@ -91,7 +91,7 @@

Zero-Click Trial Fallback

See It Live in Production

-

This exact architecture powers Flint by KeyFlint across 6 remote MCP servers, including our unified 17-tool accounting connector at https://mcp.keyflint.dev/despacho/mcp.

+

This exact architecture powers Flint by KeyFlint across 5 remote MCP servers, including our unified 17-tool accounting connector at https://mcp.keyflint.dev/despacho/mcp.

Get KeyFlint Gateway Guide: Paid MCP Server diff --git a/docs/index.html b/docs/index.html index 87b3a8a..214f1ef 100644 --- a/docs/index.html +++ b/docs/index.html @@ -526,7 +526,7 @@

Charge per use

Production ecosystem · Built on KeyFlint -

6 live MCP servers & OAuth 2.1 connectors running on KeyFlint

+

5 live MCP servers & one unified OAuth 2.1 connector running on KeyFlint

See KeyFlint in production at mcp.keyflint.dev: passwordless 6-digit OAuth 2.1, atomic credit metering, automatic error refunds, and browser batch conversion.

@@ -549,7 +549,7 @@

Norma 43 & ContaBridge

Decimal
-

Deterministic Spanish bank statement parser (.n43, .c43, .csv) and Facturae XML to ERP journal bridge with zero LLM arithmetic hallucinations.

+

Deterministic Spanish bank statement parser (.n43, .c43, .csv) plus invoice and bank-movement bookkeeping to ERP journal files, with no LLM arithmetic.

Open Web Converter
diff --git a/docs/llms.txt b/docs/llms.txt index 61601d7..703d9df 100644 --- a/docs/llms.txt +++ b/docs/llms.txt @@ -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. diff --git a/tests/tier1_features/test_daily_growth.py b/tests/tier1_features/test_daily_growth.py index aab14a7..a7a61c4 100644 --- a/tests/tier1_features/test_daily_growth.py +++ b/tests/tier1_features/test_daily_growth.py @@ -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 @@ -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)