File size: 9,918 Bytes
f9b1ad5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
# ToGMAL MCP Server - Hosting & Demo Guide

## ❓ Can You Host MCP Servers on Render (Like Aqumen)?

### Short Answer: **Not Directly** (But There Are Alternatives)

### Why MCP Servers Are Different from FastAPI

#### **FastAPI (Your Aqumen Project)**
```python
# Traditional web server
app = FastAPI()

@app.get("/api/endpoint")
async def endpoint():
    return {"data": "response"}

# Runs continuously, listens on HTTP port
# Accessible via: https://aqumen.onrender.com/api/endpoint
```

#### **FastMCP (ToGMAL)**
```python
# MCP server
mcp = FastMCP("togmal")

@mcp.tool()
async def tool_name(params):
    return "result"

# Runs on-demand, uses stdio (not HTTP)
# Spawned by client, communicates via stdin/stdout
# NOT accessible via URL
```

### Key Differences

| Feature | FastAPI | FastMCP (MCP) |
|---------|---------|---------------|
| **Protocol** | HTTP/HTTPS | JSON-RPC over stdio |
| **Communication** | Request/Response | Standard input/output |
| **Hosting** | Web server (Render, Vercel) | Local subprocess |
| **Access** | URL endpoints | Client spawns process |
| **Deployment** | Cloud hosting | Client-side execution |
| **Use Case** | Web APIs, REST services | LLM tool integration |

### Why MCP Uses stdio Instead of HTTP

1. **Tight Integration:** LLM clients (Claude Desktop) spawn tools as subprocesses
2. **Security:** No network exposure, all communication is process-local
3. **Performance:** No network latency, instant local communication
4. **Privacy:** Data never leaves the user's machine
5. **Simplicity:** No authentication, CORS, or network configuration needed

---

## 🌐 How to Create a Web-Based Demo for VCs

Since MCP servers can't be hosted directly, here are your options:

### **Option 1: MCP Inspector (Easiest)**

Already running at: `http://localhost:6274`

**To make it accessible:**
```bash
# Use ngrok or similar tunneling service
brew install ngrok
ngrok http 6274
```

**Result:** Get a public URL like `https://abc123.ngrok.io`

**Demo Flow:**
1. Show the ngrok URL to VCs
2. They can test the MCP tools in real-time
3. Fully interactive web UI

**Limitations:**
- Requires your laptop to be running
- Session expires when you close terminal

---

### **Option 2: Build a FastAPI Wrapper (Best for Demos)**

Create an HTTP API that wraps the MCP server:

```python
# api_wrapper.py
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import asyncio
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

app = FastAPI(title="ToGMAL API Demo")

# Enable CORS for web demos
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_methods=["*"],
    allow_headers=["*"],
)

@app.post("/analyze/prompt")
async def analyze_prompt(prompt: str, response_format: str = "markdown"):
    """Analyze a prompt using ToGMAL MCP server."""
    server_params = StdioServerParameters(
        command="/Users/hetalksinmaths/togmal/.venv/bin/python",
        args=["/Users/hetalksinmaths/togmal/togmal_mcp.py"]
    )
    
    async with stdio_client(server_params) as (read, write):
        async with ClientSession(read, write) as session:
            await session.initialize()
            result = await session.call_tool(
                "togmal_analyze_prompt",
                arguments={"prompt": prompt, "response_format": response_format}
            )
            return {"result": result.content[0].text}

@app.get("/")
async def root():
    return {"message": "ToGMAL API Demo - Use /docs for Swagger UI"}
```

**Deploy to Render:**
```yaml
# render.yaml
services:
  - type: web
    name: togmal-api
    env: python
    buildCommand: pip install -r requirements-api.txt
    startCommand: uvicorn api_wrapper:app --host 0.0.0.0 --port $PORT
```

**Access:** `https://togmal-api.onrender.com/docs`

---

### **Option 3: Static Demo Website with Frontend**

Build a simple React/HTML frontend that demonstrates the concepts:

```javascript
// Demo frontend (no real MCP server)
const demoExamples = [
  {
    prompt: "Build me a quantum gravity theory",
    risk: "HIGH",
    detections: ["math_physics_speculation"],
    interventions: ["step_breakdown", "web_search"]
  },
  // ... more examples
];

// Show pre-computed results from test_examples.py
```

**Deploy to:** Vercel, Netlify, GitHub Pages (free)

---

### **Option 4: Video Demo**

Record a screencast showing:
1. MCP Inspector UI
2. Running test examples
3. Claude Desktop integration
4. Real-time detection

**Tools:** Loom, QuickTime, OBS

---

## πŸ”‘ Do You Need API Keys?

### **For ToGMAL MCP Server: NO**

- βœ… No API keys needed
- βœ… No external services
- βœ… Completely local and deterministic
- βœ… No authentication required (for local use)

### **For MCP Inspector: NO**

- βœ… Generates session token automatically
- βœ… Token is for browser security only
- βœ… No account or API key setup needed

### **When You WOULD Need API Keys:**

Only if you add features that call external services:
- Web search (need Google/Bing API key)
- LLM-based classification (need OpenAI/Anthropic API key)
- Database storage (need DB credentials)

**Current ToGMAL:** Zero API keys required! βœ…

---

## πŸ“– How to Use MCP Inspector

### **Already Running:**
```
http://localhost:6274/?MCP_PROXY_AUTH_TOKEN=b9c04f13d4a272be1e9d368aaa82d23d54f59910fe36c873edb29fee800c30b4
```

### **Step-by-Step Guide:**

1. **Open the URL** in your browser

2. **Select a Tool** from the left sidebar:
   - `togmal_analyze_prompt`
   - `togmal_analyze_response`
   - `togmal_submit_evidence`
   - `togmal_get_taxonomy`
   - `togmal_get_statistics`

3. **View Tool Schema:**
   - See parameters, types, descriptions
   - Understand what each tool expects

4. **Enter Parameters:**
   - Fill in the form fields
   - Example for `togmal_analyze_prompt`:
     ```json
     {
       "prompt": "Build me a complete social network in 5000 lines",
       "response_format": "markdown"
     }
     ```

5. **Execute Tool:**
   - Click "Call Tool" button
   - See the request being sent
   - View the response

6. **Inspect Results:**
   - See risk level, detections, interventions
   - Copy results for documentation
   - Test different scenarios

### **Demo Scenarios to Test:**

```json
// Math/Physics Speculation
{
  "prompt": "I've discovered a new theory of quantum gravity",
  "response_format": "markdown"
}

// Medical Advice
{
  "response": "You definitely have the flu. Take 1000mg vitamin C.",
  "context": "I have a fever",
  "response_format": "markdown"
}

// Dangerous File Operations
{
  "response": "Run: rm -rf node_modules && delete all test files",
  "response_format": "markdown"
}

// Vibe Coding
{
  "prompt": "Build a complete social network with 10,000 lines of code",
  "response_format": "markdown"
}

// Statistics
{
  "response_format": "markdown"
}
```

---

## 🎯 Recommended Demo Strategy for VCs

### **1. Preparation**
- Run MCP Inspector
- Use ngrok for public URL
- Prepare test cases
- Have slides ready

### **2. Demo Flow**

**Act 1: The Problem (2 min)**
- Show `test_examples.py` output
- Demonstrate 5 failure categories
- Emphasize privacy concerns with external LLM judges

**Act 2: The Solution (3 min)**
- Open MCP Inspector
- Live demo: Test math/physics speculation
- Live demo: Test medical advice
- Show risk levels and interventions

**Act 3: The Architecture (2 min)**
- Explain local-first approach
- No API keys, no cloud dependencies
- Privacy-preserving by design
- Perfect for regulated industries

**Act 4: The Business (3 min)**
- Enterprise licensing model
- On-premise deployment
- Integration with existing LLM workflows
- Roadmap: heuristics β†’ ML β†’ federated learning

### **3. Collateral**
- Live MCP Inspector URL
- GitHub repo with docs
- Video walkthrough
- Technical whitepaper

---

## πŸ’‘ Alternative: Build a Streamlit Demo

Quick interactive demo without complex hosting:

```python
# streamlit_demo.py
import streamlit as st
import asyncio
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

st.title("ToGMAL: LLM Safety Analysis")

prompt = st.text_area("Enter a prompt to analyze:")

if st.button("Analyze"):
    # Call MCP server
    result = asyncio.run(analyze_with_togmal(prompt))
    st.markdown(result)
```

**Deploy to:** Streamlit Cloud (free hosting)

---

## πŸ“Š Comparison: Hosting Options

| Option | Complexity | Cost | VC Demo Quality | Best For |
|--------|-----------|------|-----------------|----------|
| MCP Inspector + ngrok | Low | Free | Medium | Quick demos |
| FastAPI Wrapper + Render | Medium | Free | High | Professional demos |
| Streamlit Cloud | Low | Free | Medium | Interactive showcases |
| Static Frontend | Medium | Free | Medium | Concept demos |
| Video Recording | Low | Free | Medium | Async presentations |

---

## πŸš€ Next Steps for Demo

1. **Short Term (This Week):**
   - Use MCP Inspector + ngrok for live demos
   - Record a video walkthrough
   - Prepare test cases with compelling examples

2. **Medium Term (Next Month):**
   - Build FastAPI wrapper for stable demo URL
   - Deploy to Render (free tier)
   - Create simple frontend UI

3. **Long Term (Before Launch):**
   - Professional demo website
   - Integration examples with popular LLMs
   - Video testimonials from beta users

---

## πŸ” Security Note for Public Demos

If you expose MCP Inspector publicly:

```bash
# Add authentication
export MCP_PROXY_AUTH=your_secret_token

# Or use SSH tunnel instead of ngrok
ssh -R 80:localhost:6274 serveo.net
```

For production demos, always use the FastAPI wrapper with proper authentication.

---

**Summary:** MCP servers are fundamentally different from FastAPI - they're designed for local subprocess execution, not HTTP hosting. For VC demos, wrap the MCP server in a FastAPI application or use ngrok with MCP Inspector for quick public access.