# RenderGrid Studio — Tessera MCP Reference Implementation

> **Purpose**: Official reference architecture demonstrating how platforms and companies monetize MCP tools for autonomous AI agents using [Tessera](https://github.com/JaDi03/tessera).  
> **Protocol**: Model Context Protocol (MCP) + Tessera x402 Streaming Payments  
> **Settlement**: Circle x402 Gateway on Arc Network (USDC)  
> **Base Rate Example**: 0.001000 USDC / second of tool execution  

---

## 💡 About Tessera

[Tessera](https://github.com/JaDi03/tessera) is an open-source streaming payments sidecar for self-hosted platforms and MCP servers. 

It sits alongside your existing instance or compute stack **without modifying your core application**. Your application simply reports start and stop events via HMAC, while Tessera manages wallet authentication, off-chain x402 Gateway ticks, revenue splits, and per-second USDC settlement on Arc Network.

---

## 🤖 Instructions for Autonomous Agents

Autonomous agents (e.g., OpenClaw, Hermes, Eliza, or custom agent frameworks) can connect to this reference server, discover tools, and stream nanopayments per second.

---

## 🛠️ Reference Tool Catalog

### 1. `render-media-card`
Generates high-resolution vector media assets and motion-ready cards with custom visual themes and cryptographic SHA-256 validation.
- **Parameters**:
  - `title` (string, required): Primary headline or subject.
  - `subtitle` (string, optional): Secondary descriptive text.
  - `theme` (string, optional, enum: `"cyberpunk"`, `"matrix"`, `"minimal"`, `"sunset"`, default: `"cyberpunk"`): Visual theme.
  - `width` (number, optional, default: 1280): Canvas width in pixels.
  - `height` (number, optional, default: 720): Canvas height in pixels.
- **Rate**: `0.001000 USDC / second` of execution.

### 2. `analyze-url-performance`
Conducts low-latency remote network performance audits, TTFB benchmarking, and OpenGraph metadata parsing.
- **Parameters**:
  - `url` (string, required): Target HTTP/HTTPS URL to inspect.
- **Rate**: `0.001000 USDC / second` of execution.

### 3. `transform-dataset`
Applies in-memory statistical summaries (mean, median, variance, stddev) and transformations over JSON records.
- **Parameters**:
  - `data` (array of objects, required): Raw JSON records to process.
  - `operation` (string, required, enum: `"statistical-summary"`, `"sort"`, `"filter"`): Operation to apply.
  - `field` (string, required): Key in objects to perform calculation on.
- **Rate**: `0.001000 USDC / second` of execution.

### 4. `ping`
Zero-overhead diagnostic ping to verify connectivity latency.
- **Rate**: 0 USDC charge.

---

## 💳 Autonomous Payment Execution Guide

1. **Verify Balance**: Ensure agent wallet has at least **0.05 USDC** on Arc Testnet.
2. **Identification (`tessera/identify`)**:
   ```json
   {
     "jsonrpc": "2.0",
     "id": 1,
     "method": "tessera/identify",
     "params": { "userId": "arc_agent_<your_id>" }
   }
   ```
3. **Execution & x402 Ticks**:
   - Send `tools/call` with parameter `_meta.tesseraUserId`.
   - Transmit 1 signed Gateway tick per elapsed second via `/api/core/stream-access` to the Tessera sidecar.
   - When execution finishes, billing settles immediately.

---

## 🏢 How to Monetize Your Own MCP Service with Tessera

If you have an API or compute service and want to charge AI agents:

1. **Add `withTesseraMeter` to your MCP tool handlers**:
   ```ts
   import { withTesseraMeter } from 'tessera/mcp';

   server.setRequestHandler(CallToolRequestSchema, withTesseraMeter(yourHandler, {
     payoutAddress: process.env.TESSERA_PAYOUT_ADDRESS!,
     ratePerSecond: 0.001,
     tesseraBaseUrl: 'http://127.0.0.1:7878',
     ingestSecret: process.env.TESSERA_INGEST_SECRET!,
   }));
   ```
2. **Run the [Tessera Sidecar](https://github.com/JaDi03/tessera)** alongside your service.
3. **Expose `/agents.md`** so autonomous agents can discover your tools and pay you per second.
