You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update README with new features and configuration options
Expanded documentation to cover resource and prompt conflict resolution, environment variable interpolation in configs, outbound x402 payments, per-server wallet overrides, and new payment modes. Added details on HTTP/SSE transport wrappers, header propagation, and request lifecycle. Updated configuration examples, environment variable references, and testing instructions. Improved clarity on conflict resolution, payment flows, and provided additional example configurations.
- [`examples/absorb-config.yaml`](examples/absorb-config.yaml) - Subscription model (absorb)
541
+
- [`examples/coingecko-wrapper-config.yaml`](examples/coingecko-wrapper-config.yaml) - HTTP wrapper for CoinGecko
499
542
500
543
## 🧪 Testing
501
544
@@ -516,6 +559,7 @@ bun run test:all
516
559
bun run test:quick # Quick smoke tests (~45s)
517
560
bun run test # Full E2E tests (~180s)
518
561
bun run test:payment # Payment E2E tests (~31s)
562
+
bun run test:passthrough # Passthrough/Markup/Absorb E2E tests
519
563
```
520
564
521
565
### Test Specific Configurations
@@ -569,7 +613,7 @@ bun run test:quick # Fast, essential tests only
569
613
bun run test:all # Complete test suite
570
614
```
571
615
572
-
See [TESTING.md](docs/TESTING.md) for detailed testing guide.
616
+
See `tests/README.md` for the detailed testing guide.
573
617
574
618
## 📊 Example Output
575
619
@@ -636,6 +680,21 @@ Available tools with namespacing:
636
680
Local Remote Streaming
637
681
```
638
682
683
+
### Transport Wrapper Options
684
+
685
+
- **HTTP Wrapper (`src/transports/http-wrapper.ts`)**: Spawns the stdio gateway per SSE session, handles HTTP/SSE endpoints, returns HTTP 402 for payments, and injects request headers into MCP messages for verification.
686
+
- **SSE Server Transport (`src/transports/sse-server.ts`)**: Alternative built-in SSE/HTTP transport that can host the MCP server directly with CORS and header handling. Useful when you don’t want a subprocess per session.
687
+
688
+
Both wrappers inject inbound HTTP headers into MCP request params as metadata so the gateway core can verify payments.
689
+
690
+
### Header Propagation and Verification
691
+
692
+
1. Client sends HTTP request with headers (e.g., `X-PAYMENT`, `X-ELIZA-API-KEY`).
693
+
2. Wrapper injects headers into MCP params as `_meta.headers`.
694
+
3. Gateway core retrieves headers from `request.params._meta.headers`.
695
+
4. `PaymentMiddleware.verifyPayment()` authorizes via API key or x402, or returns requirements for a 402 challenge.
696
+
5. On success, request routes to the correct downstream MCP server.
697
+
639
698
### Complete Payment Flow
640
699
641
700
```mermaid
@@ -670,6 +729,12 @@ sequenceDiagram
670
729
Wrapper-->>Agent: Tool result (SSE stream)
671
730
```
672
731
732
+
### Payment Modes at a Glance
733
+
734
+
-**Passthrough**: Client pays upstream provider directly. Wrapper/gateway returns 402 and forwards/accepts x402 headers as needed; pricing is defined by the upstream. Use when aggregating already-paid MCP servers.
735
+
-**Markup**: Client pays your gateway price; gateway calculates final price and pays the upstream via outbound wallet if needed. Use `payment.outboundWallet` (global) or `paymentWallet` (per server) to control the paying account.
736
+
-**Absorb**: Client authenticates (e.g., API key tier free), and gateway pays all downstream costs using outbound wallet. Useful for subscriptions.
#### 7. **SSE Server Transport** (`src/transports/sse-server.ts`)
779
+
- Hosts SSE and message endpoints directly (no subprocess)
780
+
- Injects headers and supports CORS/keep-alive
781
+
- Can be paired with `PaymentMiddleware` for inline checks
782
+
783
+
### Conflict Resolution Rules
784
+
785
+
-**Tools**: If `enableToolConflictResolution` and a duplicate name is detected, the registry appends the server ID (e.g., `name` → `name_serverA`). Namespacing (`namespace: "docs"`) prefixes names (e.g., `docs:get-library-docs`).
786
+
-**Resources**: If `enableResourceConflictResolution`, URIs are namespaced (query param when URL-like; otherwise `namespace:uri`). Duplicates are suffixed with server ID.
787
+
-**Prompts**: If `enablePromptConflictResolution`, duplicate prompt names are suffixed with server ID; namespacing applies as with tools.
788
+
789
+
### Request Lifecycle (HTTP/SSE mode)
790
+
791
+
1. Client opens `GET /sse` to receive streaming events and obtains a per-session `POST /message` endpoint.
792
+
2. Client posts MCP requests to `/message` with payment or API key headers.
793
+
3. Wrapper injects headers into `_meta.headers` and forwards to the gateway stdio server (or inline MCP server for SSE transport).
794
+
4. Gateway resolves the target tool/resource/prompt via the registry.
795
+
5. Payment middleware authorizes or responds with 402 + `X-Accept-Payment`.
796
+
6. On success, the request is routed to the downstream MCP server; response streams back via SSE and HTTP.
797
+
7. Optional: for markup/absorb flows, outbound payments are executed with the configured wallet.
798
+
708
799
---
709
800
710
801
## 💼 Real-World Use Cases
@@ -815,11 +906,9 @@ payment:
815
906
816
907
## 📖 Documentation
817
908
818
-
- **[Payment Implementation](docs/PAYMENT_IMPLEMENTATION.md)** - Payment system details
0 commit comments