{
  "markdown": "## 🏆 Track 01 Hackathon Criteria Addressed\nThis project strictly adheres to the Razorpay Track 01 requirements for AI-agent storefronts:\n\n## 🔒 Gated (Transactable End-to-End): \nAI Agents are charged per API call. If the wallet is empty, the FastAPI middleware intercepts the request and throws a graceful 402 Payment Required. If funded, it verifies the crypto token and settles USDC via the Base network.\n\n## ⏱️ Bounded (Zero Resource Exhaustion): \nAll sandboxes run inside Azure Container Apps Dynamic Sessions. Code execution is strictly bounded to a 15-second maximum timeout limit enforced by Pydantic models. Malicious memory-clogging scripts are instantly killed.\n\n## 📊 Explainable (Audit Trail): \nEvery successful and failed transaction generates an immutable AUDIT_RECORD locally, detailing the exact price_usdc, duration_ms, and execution exit code.\n\n## 🏗️ Architecture & File Structure\n\n```mermaid\ngraph TD\n    A[Claude Desktop App<br>Agent Client] -->|Tool Invocation| B{FastAPI x402 Middleware}\n    \n    subgraph Gate [\"The Payment Gate\"]\n        B -->|Funded Wallet| D[Settle USDC via Base Network]\n        B -->|Empty Wallet| C[HTTP 402 Payment Required<br>Graceful Failure]\n        D -.->|Log| Z[(Local Audit Trail)]\n        C -.->|Log| Z\n    end\n    \n    %% Invisible structural link to force vertical placement\n    Z ~~~ E\n    \n    D --> E[Azure Container Apps<br>Dynamic Session Pool]\n    C -.->|Agent Retries| A\n    \n    subgraph Cloud [\"Bounded Cloud Execution\"]\n        E --> F[15s Python Execution Timeout]\n        F --> G[Generate Text / Base64 Image]\n    end\n    \n    G -->|Stream Payload| H[mcp_client.py]\n    \n    subgraph Local [\"Local System (Zero-Context Rendering)\"]\n        H -->|JSON Response| A\n        H -->|Image Payload| I[(Save to Local PNG)]\n    end\n    \n    classDef gate fill:#ffebee,stroke:#c62828,stroke-width:2px;\n    classDef success fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px;\n    class C gate;\n    class D success;\n```\n```plaintext\nagentic-compute-mcp/\n├── README.md                      # Documentation & Setup\n├── .env.example                   # Environment variable template\n├── main.py                        # The Backend: FastAPI, x402 Gate, and Azure routing\n├── mcp_client.py                  # The Bridge: Claude Desktop tool definitions\n├── sandbox.py                     # Core Azure Dynamic Sessions execution logic\n├── pyproject.toml                 # Python package and dependency configurations\n├── requirements.txt               # Dependencies (FastAPI, azure-identity, uvicorn, etc.)\n├── server.json                    # MCP server configuration details\n├── glama.json                     # Glama registry metadata for the AI agent storefront\n└── llms.txt                       # Context file for LLM integration\n```\n\n## 🖼️ Feature Highlight: Zero-Context Image Rendering\nHandling base64 image strings in LLM context windows is notoriously unreliable and eats up thousands of tokens. agentic-compute-mcp solves this locally.\n\nWhen Claude calls generate_plot, the Azure sandbox generates the chart and streams the payload back to the MCP client. The client automatically intercepts the payload, decodes it, and saves it directly to your local machine as optimized_load_trend.png—completely bypassing the LLM context window to prevent token exhaustion.\n\n\n## 🌙 Developer Note: The 2 AM Story & Graceful Failures\n\n**The Graceful Failure:** To meet the Track 01 requirement for agent-to-agent commerce, the backend is designed to fail gracefully. If an agent attempts to execute code without funding, the FastAPI middleware intercepts the payload and throws a clean `402 Payment Required` error. This prevents compute theft and allows the agent to automatically reroute to the `/verify` and `/settle` endpoints.\n\n**The 2 AM Debug:** We built a strict 5-second Pydantic execution bound to prevent malicious resource exhaustion. But at 2 AM, our trivial Python test scripts kept timing out. We realized that to guarantee security, Azure Dynamic Sessions provisions a 100% fresh, isolated microVM for *every* request—resulting in an 8-second cold-start latency. By bumping the MCP client boundary to 15 seconds, we allowed the sandbox to boot, run the code, and return the result in exactly 5.7 seconds, proving our boundaries worked without suffocating the cloud infrastructure.\n\n\n## ⚙️ Installation & Setup\nYou need to run two components: the Backend Server and the MCP Client.\n\n1. Backend Server (main.py) Setup\nThe backend handles the x402 payment gate and routes code to Azure.\n\n## Install dependencies:\n```bash\npip install -r requirements.txt\n```   \n\nCreate a .env file based on .env.example and add your configurations:\n\nCode snippet:\n```bash\nAZURE_POOL_ENDPOINT=\"https://<YOUR-POOL-NAME>.azurecontainerapps.io\"\nMY_WALLET_ADDRESS=\"0xYourActualWalletAddress\"\n```   \n## Run the FastAPI server locally:\n```bash\nuvicorn main:app --host 127.0.0.1 --port 8000 --reload\n```   \n\n2. MCP Client (mcp_client.py) Setup\nTo install this server for Claude Desktop, add the following to your claude_desktop_config.json:\n```json\n{\n  \"mcpServers\": {\n    \"agentic-compute\": {\n      \"command\": \"python\",\n      \"args\": [\"/path/to/your/repo/mcp_client.py\"],\n      \"env\": {\n        \"EVM_PRIVATE_KEY\": \"your_private_key_here\"\n      }\n    }\n  }\n}\n```\nNote: Make sure to replace the path and provide a funded EVM wallet key to allow Claude to process x402 microtransactions.\n\n## 🧰 Available MCP Tools\n\nThis server exposes the following endpoints. Agents must evaluate the required capability and cost before invoking.\n\n| Tool | Cost (USDC) | Input | Output | When to use |\n| :--- | :--- | :--- | :--- | :--- |\n| **`execute_code`** | 0.10 | Valid Python script string. | Text (stdout/stderr). Max return limit 8KB. | Execute arbitrary Python logic, heavy calculations, or data sorting in an isolated Azure sandbox. Do NOT use for local FS operations. |\n| **`sanitize_csv`** | 0.25 | Raw, unformatted CSV string. | JSON array. | Handle null values (converts NaN to null), normalize headers, and drop empty rows prior to modeling. |\n| **`optimize_ga`** | 0.50 | JSON array of numerical data. | Optimized model parameters and MAPE score. | Load forecasting, predictive modeling, or curve fitting. Employs proportional mutation for <1% MAPE accuracy. |\n| **`generate_plot`** | 0.30 | JSON array of coordinates and chart config. | Success string (File saved locally). | Visualize data without hitting token generation limits or requiring local GUI dependencies. |\n\n\n\n## 🤖 System Prompt Instructions (For Developers)\nCopy and paste this snippet into your agent's system prompt or .cursorrules file to enable autonomous tool usage:\n```plaintext\nYou are equipped with the `agentic-compute-mcp` backend. Use these tools for heavy computation or secure data execution. \n- You must pay for invocations automatically using the configured x402 EVM private key.\n- Do NOT attempt to run Python locally if data requires complex optimization; route it to `execute_code`.\n- For any unformatted CSV data, run `sanitize_csv` before performing mathematical analysis.\n- When generating charts, use `generate_plot`. The backend will automatically save the chart directly to the local file system as a PNG. Do not attempt to read base64 strings.\n```\n\n## License\nMIT License - see LICENSE file for details.\n\n",
  "bytes": 7330,
  "sha": "019985fdda8ea3900da4ee3870ec01d6d85a01c52c75c0b2c1ccc99e6d8ae77c",
  "repo_slug": "codelad1304/agentic-compute-mcp",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_codelad1304_agentic_compute_7737b53e/readme"
}