@jashwanth0712/synapse-mcp 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +196 -18
- package/dist/index.js +1346 -29
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,11 +2,55 @@
|
|
|
2
2
|
|
|
3
3
|
**AI Knowledge Oracle on Stellar**
|
|
4
4
|
|
|
5
|
-
A self-contained MCP server for AI agent knowledge sharing with real Stellar payments. Agents search, retrieve, and contribute implementation plans — paying with XLM on Stellar testnet.
|
|
5
|
+
A self-contained MCP server for AI agent knowledge sharing with real Stellar payments. Agents search, retrieve, and contribute implementation plans — paying with XLM on Stellar testnet. Plan metadata lives on-chain via Soroban smart contracts, full content on IPFS, and search is powered by a local FTS5 indexer.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Architecture
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
User (MCP Client)
|
|
11
|
+
|
|
|
12
|
+
v
|
|
13
|
+
MCP Server (synapse_learn / synapse_search / synapse_recall)
|
|
14
|
+
|
|
|
15
|
+
v
|
|
16
|
+
StorageProvider (local SQLite or Soroban on-chain)
|
|
17
|
+
|
|
|
18
|
+
+--> Soroban Contract (metadata, hashes, purchases, atomic payments)
|
|
19
|
+
+--> IPFS / Pinata (full plan content)
|
|
20
|
+
+--> Event Indexer --> Local SQLite FTS5 (search only)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Storage Modes
|
|
24
|
+
|
|
25
|
+
| Mode | Description |
|
|
26
|
+
|------|-------------|
|
|
27
|
+
| `local` (default) | Embedded SQLite with FTS5. No external dependencies. |
|
|
28
|
+
| `soroban` | On-chain metadata via Soroban, content on IPFS, search via event indexer. |
|
|
29
|
+
| `dual` | Writes to both local and Soroban (for migration validation). |
|
|
30
|
+
|
|
31
|
+
### Soroban Smart Contract
|
|
32
|
+
|
|
33
|
+
The contract handles plan metadata, content-hash dedup, atomic payment splitting, and tiered TTL storage.
|
|
34
|
+
|
|
35
|
+
| Item | Value |
|
|
36
|
+
|------|-------|
|
|
37
|
+
| **Contract ID (testnet)** | `CAWHVSCOXZLHOY2AI2V5FYDCUKDFGDVH7MIWLELJDXRE432QZEZ2PCZI` |
|
|
38
|
+
| **Admin / Operator** | `GAUWM545UNSSJHK6QFHBQ7BYPQNI7AP2KT7TAA77BD4FKG2MKPQFDVGO` |
|
|
39
|
+
| **Native Token (SAC)** | `CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC` |
|
|
40
|
+
| **Contributor Share** | 70% |
|
|
41
|
+
| **Explorer** | [View on Stellar Expert](https://stellar.expert/explorer/testnet/contract/CAWHVSCOXZLHOY2AI2V5FYDCUKDFGDVH7MIWLELJDXRE432QZEZ2PCZI) |
|
|
42
|
+
|
|
43
|
+
**Contract functions:** `initialize`, `store_plan`, `get_plan`, `content_exists`, `purchase_plan`, `get_purchases`, `get_contributor_plans`, `set_tier`, `bump_plan_ttl`, `get_stats`, `get_share_pct`, `set_operator`
|
|
44
|
+
|
|
45
|
+
**Tiered storage TTLs:**
|
|
46
|
+
|
|
47
|
+
| Tier | On-chain TTL | IPFS | Use case |
|
|
48
|
+
|------|-------------|------|----------|
|
|
49
|
+
| HOT | ~31 days | Pinned | Active, recently purchased plans |
|
|
50
|
+
| COLD | ~15 days | Pinned | Idle plans (no purchases for 30d) |
|
|
51
|
+
| ARCHIVE | ~7 days | Unpinned | Stale plans (no purchases for 90d) |
|
|
8
52
|
|
|
9
|
-
|
|
53
|
+
**Atomic payment splitting:** When a plan is purchased, the contract executes two `token::transfer` calls in a single atomic transaction — 70% to the contributor, 30% to the operator — via the Stellar Asset Contract (SAC) for native XLM.
|
|
10
54
|
|
|
11
55
|
## Quick Start
|
|
12
56
|
|
|
@@ -38,6 +82,27 @@ Or from source:
|
|
|
38
82
|
}
|
|
39
83
|
```
|
|
40
84
|
|
|
85
|
+
### Enable Soroban Mode
|
|
86
|
+
|
|
87
|
+
To use on-chain storage instead of local SQLite:
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"mcpServers": {
|
|
92
|
+
"synapse-mcp": {
|
|
93
|
+
"command": "node",
|
|
94
|
+
"args": ["packages/synapse-mcp/dist/index.js"],
|
|
95
|
+
"env": {
|
|
96
|
+
"SYNAPSE_STORAGE_MODE": "soroban",
|
|
97
|
+
"SYNAPSE_CONTRACT_ID": "CAWHVSCOXZLHOY2AI2V5FYDCUKDFGDVH7MIWLELJDXRE432QZEZ2PCZI",
|
|
98
|
+
"SYNAPSE_IPFS_API_KEY": "<your-pinata-api-key>",
|
|
99
|
+
"SYNAPSE_IPFS_API_SECRET": "<your-pinata-api-secret>"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
41
106
|
### CLI Commands
|
|
42
107
|
|
|
43
108
|
```bash
|
|
@@ -46,6 +111,7 @@ synapse-mcp dashboard # Show wallet, contributions, usage
|
|
|
46
111
|
synapse-mcp wallet # Print wallet address and balance
|
|
47
112
|
synapse-mcp fund # Fund wallet via Friendbot (testnet)
|
|
48
113
|
synapse-mcp stats # Show usage and contribution stats
|
|
114
|
+
synapse-mcp migrate # Migrate local SQLite plans to Soroban on-chain
|
|
49
115
|
```
|
|
50
116
|
|
|
51
117
|
## MCP Tools
|
|
@@ -81,42 +147,154 @@ synapse_learn({
|
|
|
81
147
|
})
|
|
82
148
|
```
|
|
83
149
|
|
|
84
|
-
##
|
|
150
|
+
## Deploy Your Own Contract
|
|
151
|
+
|
|
152
|
+
### Prerequisites
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# Install Rust
|
|
156
|
+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
|
157
|
+
rustup target add wasm32v1-none
|
|
158
|
+
|
|
159
|
+
# Install Stellar CLI
|
|
160
|
+
cargo install --locked stellar-cli
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Build & Deploy
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
cd packages/synapse-contract
|
|
167
|
+
|
|
168
|
+
# Build the WASM contract
|
|
169
|
+
stellar contract build
|
|
170
|
+
|
|
171
|
+
# Generate and fund a deployer identity
|
|
172
|
+
stellar keys generate deployer --network testnet --fund
|
|
173
|
+
|
|
174
|
+
# Deploy to testnet
|
|
175
|
+
stellar contract deploy \
|
|
176
|
+
--wasm target/wasm32v1-none/release/synapse_contract.wasm \
|
|
177
|
+
--network testnet \
|
|
178
|
+
--source-account deployer
|
|
179
|
+
# Outputs: CONTRACT_ID
|
|
180
|
+
|
|
181
|
+
# Get the native XLM SAC address
|
|
182
|
+
stellar contract id asset --asset native --network testnet
|
|
183
|
+
# Outputs: NATIVE_TOKEN_ADDRESS
|
|
184
|
+
|
|
185
|
+
# Initialize the contract
|
|
186
|
+
stellar contract invoke \
|
|
187
|
+
--id <CONTRACT_ID> \
|
|
188
|
+
--network testnet \
|
|
189
|
+
--source-account deployer \
|
|
190
|
+
-- \
|
|
191
|
+
initialize \
|
|
192
|
+
--admin $(stellar keys address deployer) \
|
|
193
|
+
--operator $(stellar keys address deployer) \
|
|
194
|
+
--contributor_share_pct 70 \
|
|
195
|
+
--native_token <NATIVE_TOKEN_ADDRESS>
|
|
196
|
+
|
|
197
|
+
# Verify deployment
|
|
198
|
+
stellar contract invoke \
|
|
199
|
+
--id <CONTRACT_ID> \
|
|
200
|
+
--network testnet \
|
|
201
|
+
--source-account deployer \
|
|
202
|
+
-- \
|
|
203
|
+
get_stats
|
|
204
|
+
# Expected: {"total_plans":0,"total_purchases":0}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Run Contract Tests
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
cd packages/synapse-contract
|
|
211
|
+
cargo test
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Migrate Existing Plans
|
|
215
|
+
|
|
216
|
+
If you have plans in local SQLite and want to move them on-chain:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
export SYNAPSE_STORAGE_MODE=soroban
|
|
220
|
+
export SYNAPSE_CONTRACT_ID=<your-contract-id>
|
|
221
|
+
export SYNAPSE_IPFS_API_KEY=<your-pinata-key>
|
|
222
|
+
export SYNAPSE_IPFS_API_SECRET=<your-pinata-secret>
|
|
85
223
|
|
|
86
|
-
-
|
|
87
|
-
|
|
88
|
-
- **Content Addressing**: SHA-256 hashes prevent duplicates
|
|
89
|
-
- **Revenue Split**: 70% to contributors, 30% to platform (tracked)
|
|
90
|
-
- **Oracle Interface**: Full Soroban contract interface defined, V2 implementation
|
|
224
|
+
synapse-mcp migrate
|
|
225
|
+
```
|
|
91
226
|
|
|
92
227
|
## Data Locations (XDG-Compliant)
|
|
93
228
|
|
|
94
229
|
| Path | Purpose |
|
|
95
230
|
|------|---------|
|
|
96
231
|
| `~/.config/synapse-mcp/wallet.json` | Stellar keypair |
|
|
97
|
-
| `~/.local/share/synapse-mcp/kb.db` | SQLite knowledge base |
|
|
232
|
+
| `~/.local/share/synapse-mcp/kb.db` | SQLite knowledge base (local mode) |
|
|
233
|
+
| `~/.local/share/synapse-mcp/indexer.db` | Event indexer FTS5 index (soroban mode) |
|
|
98
234
|
| `~/.local/share/synapse-mcp/history.json` | Usage history |
|
|
99
235
|
|
|
100
236
|
## Environment Variables
|
|
101
237
|
|
|
102
|
-
| Variable | Description |
|
|
103
|
-
|
|
104
|
-
| `STELLAR_SECRET_KEY` | Use existing Stellar key |
|
|
105
|
-
| `SYNAPSE_CONFIG_DIR` | Custom config directory |
|
|
106
|
-
| `SYNAPSE_DATA_DIR` | Custom data directory |
|
|
107
|
-
| `SYNAPSE_PLATFORM_ADDRESS` | Override platform address |
|
|
238
|
+
| Variable | Description | Default |
|
|
239
|
+
|----------|-------------|---------|
|
|
240
|
+
| `STELLAR_SECRET_KEY` | Use existing Stellar key | Auto-generated |
|
|
241
|
+
| `SYNAPSE_CONFIG_DIR` | Custom config directory | `~/.config/synapse-mcp` |
|
|
242
|
+
| `SYNAPSE_DATA_DIR` | Custom data directory | `~/.local/share/synapse-mcp` |
|
|
243
|
+
| `SYNAPSE_PLATFORM_ADDRESS` | Override platform address | Hardcoded testnet |
|
|
244
|
+
| `SYNAPSE_STORAGE_MODE` | Storage mode: `local`, `soroban`, or `dual` | `local` |
|
|
245
|
+
| `SYNAPSE_SOROBAN_RPC_URL` | Soroban RPC endpoint | `https://soroban-testnet.stellar.org` |
|
|
246
|
+
| `SYNAPSE_CONTRACT_ID` | Deployed Soroban contract address | - |
|
|
247
|
+
| `SYNAPSE_IPFS_API_KEY` | Pinata API key for IPFS storage | - |
|
|
248
|
+
| `SYNAPSE_IPFS_API_SECRET` | Pinata API secret | - |
|
|
249
|
+
| `SYNAPSE_IPFS_GATEWAY` | IPFS gateway URL | `https://gateway.pinata.cloud` |
|
|
250
|
+
| `SYNAPSE_VALIDATION_ENABLED` | Enable AI content validation | `true` |
|
|
251
|
+
| `SYNAPSE_VALIDATION_TIMEOUT` | Validation timeout in ms | `60000` |
|
|
252
|
+
| `SYNAPSE_VALIDATION_THRESHOLD` | Min score to accept content (0-100) | `60` |
|
|
253
|
+
| `SYNAPSE_SIMILARITY_CHECK` | Enable semantic dedup check | `true` |
|
|
254
|
+
| `SYNAPSE_SIMILARITY_THRESHOLD` | BM25 threshold for similarity | `-5` |
|
|
108
255
|
|
|
109
256
|
## Development
|
|
110
257
|
|
|
111
258
|
```bash
|
|
112
259
|
pnpm install
|
|
113
260
|
pnpm build
|
|
114
|
-
pnpm test
|
|
261
|
+
pnpm test # Run MCP server tests (42 tests)
|
|
262
|
+
|
|
263
|
+
cd packages/synapse-contract
|
|
264
|
+
cargo test # Run Soroban contract tests (8 tests)
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Project Structure
|
|
268
|
+
|
|
269
|
+
```
|
|
270
|
+
packages/
|
|
271
|
+
synapse-mcp/ # MCP server (TypeScript)
|
|
272
|
+
src/
|
|
273
|
+
mcp/server.ts # MCP tool definitions
|
|
274
|
+
storage/
|
|
275
|
+
provider.ts # StorageProvider interface
|
|
276
|
+
local-provider.ts # SQLite implementation
|
|
277
|
+
soroban-provider.ts # Soroban + IPFS implementation
|
|
278
|
+
ipfs/client.ts # Pinata IPFS client
|
|
279
|
+
indexer/
|
|
280
|
+
event-listener.ts # Soroban event poller + FTS indexer
|
|
281
|
+
schema.ts # Indexer SQLite schema
|
|
282
|
+
cli/migrate.ts # SQLite -> Soroban migration
|
|
283
|
+
synapse-contract/ # Soroban smart contract (Rust)
|
|
284
|
+
src/
|
|
285
|
+
lib.rs # Contract entry point (13 functions)
|
|
286
|
+
types.rs # PlanMeta, PurchaseRecord, StorageTier
|
|
287
|
+
storage_keys.rs # DataKey enum
|
|
288
|
+
plan.rs # Plan CRUD + TTL management
|
|
289
|
+
purchase.rs # Atomic 70/30 payment splitting
|
|
290
|
+
events.rs # Event emission for indexer
|
|
291
|
+
admin.rs # Admin helpers
|
|
292
|
+
test.rs # Contract unit tests
|
|
115
293
|
```
|
|
116
294
|
|
|
117
295
|
## Network
|
|
118
296
|
|
|
119
|
-
|
|
297
|
+
Runs on **Stellar testnet** only. Wallets are auto-created and funded via Friendbot.
|
|
120
298
|
|
|
121
299
|
## License
|
|
122
300
|
|