agentic-compute-mcp
This server provides secure, remote backend computation for AI agents, with x402 USDC microtransactions per API call. Capabilities include:
execute_code_securely: Execute arbitrary Python code in an isolated Azure sandbox. Returns stdout/stderr (up to 8KB). Cost: 0.10 USDC.
sanitize_csv_securely: Clean and normalize raw CSV strings, handling nulls (NaN → null), normalizing headers, and dropping empty rows. Returns a JSON array. Cost: 0.25 USDC.
optimize_ga_securely: Run a Genetic Algorithm to optimize model parameters (polynomial, exponential, logistic) against numerical data, minimizing MAPE. Supports configurable generations. Returns optimized parameters and MAPE. Cost: 0.50 USDC.
generate_plot_securely: Generate line or scatter charts from coordinate arrays, with customizable titles and labels. Returns a base64-encoded image string. Cost: 0.30 USDC.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@agentic-compute-mcp Optimize my sales forecast using genetic algorithm"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
🏆 Track 01 Hackathon Criteria Addressed
This project strictly adheres to the Razorpay Track 01 requirements for AI-agent storefronts:
Related MCP server: code-sandbox-mcp
🔒 Gated (Transactable End-to-End):
AI 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.
⏱️ Bounded (Zero Resource Exhaustion):
All 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.
📊 Explainable (Audit Trail):
Every successful and failed transaction generates an immutable AUDIT_RECORD locally, detailing the exact price_usdc, duration_ms, and execution exit code.
🏗️ Architecture & File Structure
graph TD
A[Claude Desktop App<br>Agent Client] -->|Tool Invocation| B{FastAPI x402 Middleware}
subgraph Gate ["The Payment Gate"]
B -->|Funded Wallet| D[Settle USDC via Base Network]
B -->|Empty Wallet| C[HTTP 402 Payment Required<br>Graceful Failure]
D -.->|Log| Z[(Local Audit Trail)]
C -.->|Log| Z
end
%% Invisible structural link to force vertical placement
Z ~~~ E
D --> E[Azure Container Apps<br>Dynamic Session Pool]
C -.->|Agent Retries| A
subgraph Cloud ["Bounded Cloud Execution"]
E --> F[15s Python Execution Timeout]
F --> G[Generate Text / Base64 Image]
end
G -->|Stream Payload| H[mcp_client.py]
subgraph Local ["Local System (Zero-Context Rendering)"]
H -->|JSON Response| A
H -->|Image Payload| I[(Save to Local PNG)]
end
classDef gate fill:#ffebee,stroke:#c62828,stroke-width:2px;
classDef success fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px;
class C gate;
class D success;agentic-compute-mcp/
├── README.md # Documentation & Setup
├── .env.example # Environment variable template
├── main.py # The Backend: FastAPI, x402 Gate, and Azure routing
├── mcp_client.py # The Bridge: Claude Desktop tool definitions
├── sandbox.py # Core Azure Dynamic Sessions execution logic
├── pyproject.toml # Python package and dependency configurations
├── requirements.txt # Dependencies (FastAPI, azure-identity, uvicorn, etc.)
├── server.json # MCP server configuration details
├── glama.json # Glama registry metadata for the AI agent storefront
└── llms.txt # Context file for LLM integration🖼️ Feature Highlight: Zero-Context Image Rendering
Handling base64 image strings in LLM context windows is notoriously unreliable and eats up thousands of tokens. agentic-compute-mcp solves this locally.
When 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.
🌙 Developer Note: The 2 AM Story & Graceful Failures
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.
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.
⚙️ Installation & Setup
You need to run two components: the Backend Server and the MCP Client.
Backend Server (main.py) Setup The backend handles the x402 payment gate and routes code to Azure.
Install dependencies:
pip install -r requirements.txtCreate a .env file based on .env.example and add your configurations:
Code snippet:
AZURE_POOL_ENDPOINT="https://<YOUR-POOL-NAME>.azurecontainerapps.io"
MY_WALLET_ADDRESS="0xYourActualWalletAddress"Run the FastAPI server locally:
uvicorn main:app --host 127.0.0.1 --port 8000 --reloadMCP Client (mcp_client.py) Setup To install this server for Claude Desktop, add the following to your claude_desktop_config.json:
{
"mcpServers": {
"agentic-compute": {
"command": "python",
"args": ["/path/to/your/repo/mcp_client.py"],
"env": {
"EVM_PRIVATE_KEY": "your_private_key_here"
}
}
}
}Note: Make sure to replace the path and provide a funded EVM wallet key to allow Claude to process x402 microtransactions.
🧰 Available MCP Tools
This server exposes the following endpoints. Agents must evaluate the required capability and cost before invoking.
Tool | Cost (USDC) | Input | Output | When to use |
| 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. |
| 0.25 | Raw, unformatted CSV string. | JSON array. | Handle null values (converts NaN to null), normalize headers, and drop empty rows prior to modeling. |
| 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. |
| 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. |
🤖 System Prompt Instructions (For Developers)
Copy and paste this snippet into your agent's system prompt or .cursorrules file to enable autonomous tool usage:
You are equipped with the `agentic-compute-mcp` backend. Use these tools for heavy computation or secure data execution.
- You must pay for invocations automatically using the configured x402 EVM private key.
- Do NOT attempt to run Python locally if data requires complex optimization; route it to `execute_code`.
- For any unformatted CSV data, run `sanitize_csv` before performing mathematical analysis.
- 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.License
MIT License - see LICENSE file for details.
Available Tools
4 toolsexecute_code_securelyA
Executes Python code in a remote, isolated Azure sandbox environment with automatic x402 payment handling.
Use this tool to safely evaluate Python algorithms, process data structures, perform math calculations, or run custom scripts.
Usage Guidelines:
Code must be standard Python 3.
Script execution is subject to a 30-second timeout limit; avoid infinite loops or blocking operations.
Ensure all required imports are included within the snippet.
x402 micropayments (USDC on Base) are automatically verified per execution call.
Inputs: code (required). Returns: result
generate_plot_securelyA
Generate line or scatter charts from x and y data in an isolated Azure sandbox, enabling secure remote data visualization for AI agents.
ARCHITECTURE NOTE: The remote sandbox generates the plot, but the local MCP client intercepts the base64 payload and securely writes it directly to the user's local home directory as a PNG.
Use this tool to visually represent numerical trends. Keep data arrays under 10,000 points to prevent sandbox timeouts.
Inputs: x (required), y (required), title, x_label, +2 more. Returns: result
optimize_ga_securelyA
Executes a Genetic Algorithm in a secure remote Azure sandbox to minimize Mean Absolute Percentage Error (MAPE) against ground-truth target values.
Ideal for driving down error metrics in complex time-series predictions, such as electrical load forecasting.
Usage Guidelines:
actualsarray size must not exceed 5,000 data points to prevent sandbox execution timeouts.generationsshould be kept under 1,000 iterations for optimal performance vs. compute cost.model_typeis strictly limited to 'polynomial', 'exponential', or 'logistic'.
Inputs: actuals (required), model_type, generations. Returns: result
sanitize_csv_securelyA
Sanitize raw CSV data by cleaning and normalizing it within a secure remote Azure sandbox environment.
Use this tool to prepare messy tabular data for downstream processing. It automatically strips leading/trailing whitespace, standardizes delimiters to commas, and resolves malformed rows.
Usage Guidelines:
csv_contentmust be a plain-text string representation of a CSV.Limit payload size to a maximum of 50,000 rows to prevent sandbox memory limits and payload timeouts.
Do not pass binary files or Excel (.xlsx) formats; strictly text-based CSV data.
Inputs: csv_content (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a clearly distinct purpose: generic code execution, CSV sanitization, genetic algorithm optimization, and plotting. There is no overlap or ambiguity between them.
All tool names follow the consistent pattern of verb_object_securely (e.g., execute_code_securely, generate_plot_securely). This makes the set predictable and easy to navigate.
With 4 tools, the set is well-scoped and each tool earns its place. The count is within the ideal 3-15 range and matches the server's focus on secure remote compute tasks.
The code execution tool provides a general catch-all capability, and the specialized tools cover data cleaning, optimization, and visualization. Minor gaps exist (e.g., no generic data transformation tool), but the core workflows are covered without dead ends.
Maintenance
Related MCP Connectors
Remote MCP server exposing 330 production AI-agent services for web/data processing, validation, AI utilities, blockchain/crypto utilities, and x402 pay-per-use access.
Paid deterministic utilities and automation services for AI agents via MCP and x402.
Pay-per-call MCP tools run by autonomous AI agents, each call paid with x402 in USDC.
MCP server connecting AI agents to non-custodial staking data across 130+ networks.
Related MCP Servers
AlicenseNot gradedqualityCmaintenanceAn MCP server that enables AI agents to search, pay for, and call paid APIs using the x402 protocol, with automatic USDC settlement.2MIT- AlicenseAqualityDmaintenanceMCP server for E2B code sandbox, enabling creation, management, and execution of code in secure sandboxes using Python and shell commands.41MIT
- AlicenseAqualityDmaintenanceMCP server enabling AI agents to purchase VPS and blockchain node products using USDC on Base via Easy Node's x402 API.720 npm7Business Source 1.1
- AlicenseAqualityDmaintenanceSandboxed Python execution with automatic dependency management. Executes Python scripts in isolated environments (bubblewrap or Docker) with PEP 723 inline dependencies, preventing host pollution.334 PyPI1MIT