allframe 0.1.28

Complete Rust web framework with built-in HTTP/2 server, REST/GraphQL/gRPC, compile-time DI, CQRS - TDD from day zero
Documentation
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
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
# MCP Distribution Model - Library vs Binary

**Date**: 2025-12-04
**Status**: Clarified ✅

---

## Executive Summary

`allframe-mcp` is distributed as a **library crate**, NOT as a pre-compiled binary. This document clarifies the distribution model and corrects outdated references to binary distribution.

---

## Distribution Model

### ✅ Complete: Library Distribution

**Package**: `allframe-mcp` on crates.io
**Type**: Library crate
**Usage**: Embedded in user applications

```toml
# User's Cargo.toml
[dependencies]
allframe-core = "0.1"
allframe-mcp = "0.1"  # Library dependency
```

```rust
// User's application code
use allframe_core::router::Router;
use allframe_mcp::McpServer;

#[tokio::main]
async fn main() {
    let mut router = Router::new();
    router.register("get_user", get_user_handler);

    // Create MCP server from router
    let mcp = McpServer::new(router);

    // User can implement their own server logic
    // serve_stdio(), serve_http(), etc.
}
```

### ❌ Previous Misconception: Binary Distribution

**What was planned** (now outdated):
- Pre-compiled binaries: `allframe-mcp-linux-x86_64`, etc.
- GitHub Releases with platform-specific executables
- MCP Registry submission with binary installation

**Why this was incorrect**:
1. `allframe-mcp/Cargo.toml` has no `[[bin]]` section
2. `allframe-mcp/src/` only has `lib.rs`, no `main.rs`
3. MCP server is designed as a library component, not a standalone application

---

## Architecture Rationale

### Why Library Distribution?

**1. Flexibility**
- Users can embed MCP server in their own applications
- Full control over server lifecycle and configuration
- Can integrate with existing authentication, logging, metrics

**2. Zero-Bloat Guarantee**
- Library only compiled when explicitly added as dependency
- No forced binary installation
- Users choose their own runtime environment

**3. Composability**
- Can be combined with other AllFrame features
- Works with any async runtime (tokio, async-std)
- Supports custom transport layers (stdio, HTTP, WebSocket)

**4. Deployment Options**
- Docker containers with user's application
- Serverless functions (AWS Lambda, etc.)
- Standalone microservices
- Embedded in larger applications

---

## Usage Patterns

### Pattern 1: Standalone MCP Server Binary (User-Created)

Users can create their own binary wrapper:

```rust
// User creates: src/main.rs
use allframe_core::router::Router;
use allframe_mcp::McpServer;

#[tokio::main]
async fn main() {
    let mut router = Router::new();

    // Register handlers from config, database, etc.
    router.register("get_user", get_user_handler);
    router.register("create_order", create_order_handler);

    let mcp = McpServer::new(router);

    // Implement stdio transport
    // (User's responsibility)
    mcp.serve_stdio().await;
}
```

```toml
# User's Cargo.toml
[package]
name = "my-mcp-server"
version = "0.1.0"

[[bin]]
name = "my-mcp-server"
path = "src/main.rs"

[dependencies]
allframe-core = "0.1"
allframe-mcp = "0.1"
tokio = { version = "1.48", features = ["full"] }
```

### Pattern 2: Embedded in Web Application

```rust
// User's web server
use axum::{Router as AxumRouter, routing::post};
use allframe_core::router::Router;
use allframe_mcp::McpServer;

#[tokio::main]
async fn main() {
    // AllFrame router for business logic
    let mut af_router = Router::new();
    af_router.register("get_user", get_user_handler);

    // MCP server exposes AllFrame handlers
    let mcp = McpServer::new(af_router);

    // Axum web server with MCP endpoint
    let app = AxumRouter::new()
        .route("/api/users", get(get_users))
        .route("/mcp/tools", post(mcp_tools_handler))
        .route("/mcp/call", post(mcp_call_handler));

    axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
        .serve(app.into_make_service())
        .await
        .unwrap();
}
```

### Pattern 3: Serverless Function

```rust
// AWS Lambda handler
use lambda_runtime::{service_fn, LambdaEvent, Error};
use allframe_core::router::Router;
use allframe_mcp::McpServer;

#[tokio::main]
async fn main() -> Result<(), Error> {
    let mut router = Router::new();
    router.register("process", process_handler);

    let mcp = McpServer::new(router);

    lambda_runtime::run(service_fn(|event| handle(event, &mcp))).await
}
```

---

## Distribution Channels

### Primary: crates.io

**URL**: https://crates.io/crates/allframe-mcp
**Installation**: `cargo add allframe-mcp`
**Documentation**: https://docs.rs/allframe-mcp
**Cost**: $0 (free hosting)

### Secondary: GitHub

**Repository**: https://github.com/all-source-os/all-frame
**Path**: `crates/allframe-mcp/`
**Source Access**: Direct Git dependency

```toml
[dependencies]
allframe-mcp = { git = "https://github.com/all-source-os/all-frame" }
```

### NOT: MCP Registry with Binaries

**Status**: Not applicable
**Reason**: MCP Registry is for standalone binary servers, not libraries

If users want to submit their own binary wrappers to MCP Registry, that's their choice.

---

## Documentation Updates Required

### ✅ Completed

1. Created this document (MCP_DISTRIBUTION_MODEL.md)
2. Archived LAUNCH_CHECKLIST.md (contains outdated binary references)

### 📋 Still Needed

1. Create `crates/allframe-mcp/README.md` with:
   - Clear library usage examples
   - Pattern examples (standalone, embedded, serverless)
   - No mention of pre-compiled binaries

2. Update `docs/guides/MCP_ZERO_BLOAT_STRATEGY.md`:
   - Clarify library distribution model
   - Remove any binary distribution references

3. Update root `README.md`:
   - Add allframe-mcp installation instructions
   - Link to usage patterns

---

## CI/CD Implications

### No Binary Build Workflow Needed

**Status**: Correct ✅
**Reason**: Library crates don't need binary builds

Current CI workflows are correct:
- `compatibility-matrix.yml` - Tests library compilation
- `binary-size.yml` - Tests allframe-core binary size only
- No release workflow needed for binaries

### Future: crates.io Publishing

When ready to publish `allframe-mcp` to crates.io:

```bash
# One-time setup
cargo login <api-token>

# Publish
cd crates/allframe-mcp
cargo publish

# Verify
https://crates.io/crates/allframe-mcp
https://docs.rs/allframe-mcp
```

**GitHub Actions** (optional):
```yaml
# .github/workflows/publish.yml
name: Publish to crates.io

on:
  push:
    tags:
      - 'v*'

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable

      - name: Publish allframe-core
        run: |
          cd crates/allframe-core
          cargo publish --token ${{ secrets.CARGO_TOKEN }}

      - name: Publish allframe-mcp
        run: |
          cd crates/allframe-mcp
          cargo publish --token ${{ secrets.CARGO_TOKEN }}
```

---

## User Communication

### Correct Messaging

✅ "Install via cargo: `cargo add allframe-mcp`"
✅ "Embed MCP server in your application"
✅ "Create your own binary wrapper if needed"
✅ "Deploy as library in Docker, Lambda, etc."

### Incorrect Messaging

❌ "Download pre-compiled MCP binary"
❌ "Install from MCP Registry"
❌ "GitHub Releases contain allframe-mcp binaries"
❌ "Platform-specific executables available"

---

## Comparison: Library vs Binary Distribution

| Aspect | Library (Current ✅) | Binary (Outdated ❌) |
|--------|---------------------|---------------------|
| **Distribution** | crates.io | GitHub Releases |
| **Installation** | `cargo add` | Download executable |
| **Flexibility** | Full control | Limited to binary features |
| **Integration** | Embedded in apps | Standalone process |
| **Deployment** | Docker, Lambda, etc. | VM, container only |
| **Zero-Bloat** | 100% (opt-in) | N/A (always installed) |
| **Maintenance** | Cargo ecosystem | Manual version management |
| **Updates** | `cargo update` | Re-download binary |
| **Customization** | Full access | Config files only |

---

## Example: User Creates MCP Binary

If a user wants a standalone MCP binary server:

```bash
# User creates new project
cargo new my-allframe-mcp --bin
cd my-allframe-mcp

# Add dependencies
cargo add allframe allframe-mcp tokio --features full
```

```rust
// src/main.rs
use allframe_core::router::Router;
use allframe_mcp::McpServer;
use std::io::{stdin, stdout, BufRead, Write};

#[tokio::main]
async fn main() {
    // Build router from config
    let mut router = Router::new();
    router.register("echo", |input: String| async move { input });

    // Create MCP server
    let mcp = McpServer::new(router);

    // Stdio transport (MCP protocol)
    let stdin = stdin();
    let mut stdout = stdout();

    for line in stdin.lock().lines() {
        let line = line.unwrap();

        // Parse MCP request
        let request: serde_json::Value = serde_json::from_str(&line).unwrap();

        // Handle request
        let response = match request["method"].as_str() {
            Some("tools/list") => {
                let tools = mcp.list_tools().await;
                serde_json::json!({ "tools": tools })
            }
            Some("tools/call") => {
                let name = request["params"]["name"].as_str().unwrap();
                let args = &request["params"]["arguments"];
                let result = mcp.call_tool(name, args.clone()).await;
                serde_json::json!({ "result": result })
            }
            _ => serde_json::json!({ "error": "Unknown method" })
        };

        // Write response
        writeln!(stdout, "{}", serde_json::to_string(&response).unwrap()).unwrap();
        stdout.flush().unwrap();
    }
}
```

```bash
# Build binary
cargo build --release

# Binary available at:
# target/release/my-allframe-mcp
```

**This is the user's responsibility**, not ours.

---

## Questions & Answers

**Q: Why not provide a reference binary implementation?**
A: Different users have different needs (stdio, HTTP, WebSocket, auth, etc.). A library gives maximum flexibility.

**Q: Will this make it harder to use?**
A: No. Advanced users prefer libraries. Beginners can use examples or community binaries.

**Q: What about MCP Registry?**
A: Users can create their own binaries and submit to MCP Registry if desired.

**Q: Should we provide an example binary?**
A: Yes, as an `examples/mcp_stdio_server.rs` in the allframe-mcp crate for reference.

**Q: Will docs.rs automatically build docs?**
A: Yes, when published to crates.io, docs.rs builds documentation automatically (free).

---

## Next Steps

1. ✅ Document the library distribution model (this document)
2. 📋 Create `crates/allframe-mcp/README.md` with usage examples
3. 📋 Add example binary: `examples/mcp_stdio_server.rs`
4. 📋 Update root README.md with installation instructions
5. 📋 When ready: Publish to crates.io

---

## Related Documentation

- `/docs/archive/LAUNCH_CHECKLIST.md` - Outdated binary distribution plan
- `/docs/guides/MCP_ZERO_BLOAT_STRATEGY.md` - Zero-bloat architecture
- `/docs/phases/MCP_ZERO_BLOAT_COMPLETE.md` - Separate crate implementation
- `/crates/allframe-mcp/Cargo.toml` - Library crate configuration

---

**Status**: ✅ Distribution model clarified
**Decision**: Library distribution via crates.io (NOT binaries)
**Owner**: @all-source-os
**Last Updated**: 2025-12-04