Turn Any Python Script into a Paid MCP Server via Static AST Inspection
Proven Python libraries such as python-phonenumbers (Apache-2.0, v9.0.44), jsonschema (MIT, v4.26.0), and croniter (MIT, v7.0.0) replace paid APIs like Numverify ($59.99/mo) and Twilio Lookup ($0.008/req) at 83%-84% lower cost—yet turning a script into a billed MCP server normally requires FastAPI, Stripe, Redis, and manual JSON-RPC plumbing. Monetize-Anything parses Python source statically via stdlib ast (never calling exec() during inspection) and emits a standalone paid /mcp + REST server in one call. Verified in our live adversarial Gauntlet (16/16 real non-mocked heterogeneous cases passing in 13546.33 ms total, median 305.8 ms, plus 34/34 unit tests under python3 -W default with 0 warnings).
HTTP 422, and empty or fake-200 errors bill strictly $0.00.
Deterministic Architecture & Billing Invariants
src/probes.py inspects Python function AST nodes, type hints, defaults, and docstrings into a canonical JSON Schema without executing untrusted module code. src/compiler.py emits a zero-dependency Python 3 stdlib server.py exposing POST /mcp (initialize, tools/list, tools/call), POST /v1/execute, SQLite WAL BEGIN IMMEDIATE prepaid credits, and 7d-30d ArchiveCache.
1-Source → 3-Channel Publishing: Every compiled target emits (1) a self-hosted Creem prepaid storefront + SQLite WAL gateway (3.9% + $0.40 MoR, $0/mo base), (2) a remote Streamable JSON-RPC 2.0 /mcp endpoint + Causal Bazaar public card (b01_monetize_anything_compiler_v1), and (3) a 4-file treg_hub/ merchant pack at 0% commission (treg call monetize-anything).
Data-Backed Comparison & Live Benchmarks
| Verified Python Utility Target | Incumbent Paid API | Monetize-Anything Prepaid Tier | Cold / Cached Gross Margin |
|---|---|---|---|
| Python PhoneNumbers E.164 International Parser & Validator (Apache-2.0, 3,780 GitHub stars) — https://github.com/daviddrysdale/python-phonenumbers | Numverify Professional · $59.99/mo · $0.003/call | $19 Starter (38,000 calls, $0.0005/call) | 83.3% cheaper; 92% cold / 100% cached margin |
| JSONSchema Draft 2020-12 Strict Validator & Diff Function (MIT, 5,004 GitHub stars) — https://github.com/python-jsonschema/jsonschema | RapidAPI Hosted JSON Validation APIs · $29/mo · $0.0029/call | $19 Starter (38,000 calls, $0.0005/call) | 82.8% cheaper; 94% cold / 100% cached margin |
| Croniter Deterministic Cron Schedule Expander & Collision Auditor (MIT, 568 GitHub stars) — https://github.com/kiorky/croniter | RapidAPI / Cron Monitoring Utility APIs · $25/mo · $0.0025/call | $19 Starter (47,500 calls, $0.0004/call) | 84% cheaper; 93.75% cold / 100% cached margin |
| Inspection Security | importlib / exec executes untrusted code | Pure ast.parse() static analysis (zero exec) | Safe on arbitrary public .py files |
Copy-Paste Integration Example
curl -fsSL -X POST "https://monetize.fastmesh.dev/v1/compile" \
-H "Content-Type: application/json" \
-d '{"target_kind":"python_ast","source_code":"def validate_e164_phone(raw_number: str, default_region: str = \"US\") -> dict:\n \"\"\"Validate E.164 phone format.\"\"\"\n digits = \"\".join(ch for ch in raw_number if ch.isdigit())\n return {\"valid\": len(digits) >= 10, \"e164\": \"+\" + digits}","subdomain":"phone-mcp"}'
Deterministic Output
{
"ok": true,
"target_kind": "python_ast",
"previews": {
"mcp_tools": [{"name": "validate_e164_phone", "inputSchema": {"type": "object", "required": ["raw_number"]}}]
}
}
Implementation Steps
- Submit Python source or allowlisted file path: POST to /v1/inspect with target_kind='python_ast' to extract typed function schemas safely without exec().
- Compile unified OpenAPI 3.1 + /mcp bundle: Run POST /v1/compile to emit zero-dependency server.py with SQLite WAL credit metering and Creem webhooks.
- Collect $19/$79/$249 prepaid packs & 0% treg hub tolls: Charge $0.0004-$0.0005/call (92%-94% cold gross margin, 100% on cross-tenant cache hits) with $0 on invalid inputs.
Frequently Asked Questions
Does AST inspection run untrusted Python code?
No. Monetize-Anything uses Python's built-in ast.parse() strictly for static inspection, preventing arbitrary code execution.
How does a compiled Python MCP compare to Numverify or Twilio Lookup?
Using python-phonenumbers at $0.0005/call ($19 Starter = 38,000 calls) saves 83.3% compared to Numverify ($14.99-$59.99/mo) and 93.8% compared to Twilio Lookup ($0.008/req).
What happens if a Python function raises an error or returns empty?
The post-execution guard intercepts exceptions and empty outputs and bills strictly $0.00.
support@fastmesh.dev.