@fil-b/foc-storage-mcp 0.1.6 → 0.1.8
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 +26 -2
- package/dist/mcp-server.js +60 -31
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -19,10 +19,13 @@
|
|
|
19
19
|
|
|
20
20
|
## Configuration
|
|
21
21
|
|
|
22
|
-
**
|
|
22
|
+
**Requirements:**
|
|
23
|
+
|
|
24
|
+
- Node.js >= 20.10.0 ([Check version](https://nodejs.org/): `node --version`)
|
|
23
25
|
- `PRIVATE_KEY` - Your Filecoin wallet private key (0x...)
|
|
24
26
|
|
|
25
27
|
**Optional:**
|
|
28
|
+
|
|
26
29
|
- `FILECOIN_NETWORK` - `mainnet` (production) or `calibration` (testing, default)
|
|
27
30
|
- `TOTAL_STORAGE_NEEDED_GiB` - Default storage capacity for calculations (default: 150 GiB)
|
|
28
31
|
- `PERSISTENCE_PERIOD_DAYS` - Data retention duration (default: 365 days)
|
|
@@ -148,23 +151,26 @@ Most MCP tools support this format:
|
|
|
148
151
|
|
|
149
152
|
**Example:** 150 GiB for 1 year ≈ 0.44 USDFC ($0.44)
|
|
150
153
|
|
|
151
|
-
💡 Ask your agent:
|
|
154
|
+
💡 Ask your agent: _"How much to store 500 GiB for 6 months?"_
|
|
152
155
|
|
|
153
156
|
## Tools
|
|
154
157
|
|
|
155
158
|
Ask naturally in Claude, Cursor, or any MCP client:
|
|
156
159
|
|
|
157
160
|
**File Operations**
|
|
161
|
+
|
|
158
162
|
- `uploadFile` - Upload files with auto-payment
|
|
159
163
|
- `getDatasets` - List all stored datasets
|
|
160
164
|
- `getDataset` - Get dataset details
|
|
161
165
|
- `createDataset` - Create new dataset container
|
|
162
166
|
|
|
163
167
|
**Balance & Payments**
|
|
168
|
+
|
|
164
169
|
- `getBalances` - Check wallet and storage metrics
|
|
165
170
|
- `processPayment` - Deposit USDFC tokens
|
|
166
171
|
|
|
167
172
|
**Providers & Pricing**
|
|
173
|
+
|
|
168
174
|
- `getProviders` - List storage providers
|
|
169
175
|
- `estimateStoragePricing` - Calculate costs
|
|
170
176
|
- `getStoragePricingInfo` - Explain pricing models
|
|
@@ -182,12 +188,30 @@ Ask naturally in Claude, Cursor, or any MCP client:
|
|
|
182
188
|
|
|
183
189
|
## Troubleshooting
|
|
184
190
|
|
|
191
|
+
**"Unexpected token 'with'" or import syntax error:**
|
|
192
|
+
|
|
193
|
+
1. Verify Node.js >= 20.10.0: `node --version`
|
|
194
|
+
2. Clear npx cache:
|
|
195
|
+
- Command: `npx clear-npx-cache`
|
|
196
|
+
- Windows: Delete `%LOCALAPPDATA%\npm-cache\_npx`
|
|
197
|
+
- Linux/Mac: Delete `~/.npm/_npx`
|
|
198
|
+
3. Force fresh install: `npx --yes @fil-b/foc-storage-mcp@latest`
|
|
199
|
+
4. Restart your IDE
|
|
200
|
+
5. If issue persists, check IDE is using correct Node version
|
|
201
|
+
|
|
185
202
|
**Server not found:** Verify `npx --version`, check JSON syntax, restart IDE
|
|
186
203
|
|
|
187
204
|
**"PRIVATE_KEY is required":** Add to `env` section, must start with `0x`
|
|
188
205
|
|
|
189
206
|
**Transaction fails:** Check FIL for gas, verify network setting, confirm USDFC balance
|
|
190
207
|
|
|
208
|
+
**"Invalid Version" or npm dependency errors:**
|
|
209
|
+
|
|
210
|
+
1. Clear npm cache: `npm cache clean --force`
|
|
211
|
+
2. Clear npx cache: `npx clear-npx-cache`
|
|
212
|
+
3. Update npm: `npm install -g npm@latest`
|
|
213
|
+
4. As last resort, use older npm: `npm install -g npm@10`
|
|
214
|
+
|
|
191
215
|
## Security
|
|
192
216
|
|
|
193
217
|
- Never commit private keys or `.env` files
|
package/dist/mcp-server.js
CHANGED
|
@@ -524,6 +524,34 @@ var calculateStorageCost = (prices, sizeInBytes) => {
|
|
|
524
524
|
perMonth
|
|
525
525
|
};
|
|
526
526
|
};
|
|
527
|
+
var defaultStorageBalanceResult = {
|
|
528
|
+
filBalance: 0n,
|
|
529
|
+
usdfcBalance: 0n,
|
|
530
|
+
availableStorageFundsUsdfc: 0n,
|
|
531
|
+
depositNeeded: 0n,
|
|
532
|
+
availableToFreeUp: 0n,
|
|
533
|
+
daysLeftAtMaxBurnRate: 0,
|
|
534
|
+
daysLeftAtBurnRate: 0,
|
|
535
|
+
isRateSufficient: false,
|
|
536
|
+
isLockupSufficient: false,
|
|
537
|
+
isSufficient: false,
|
|
538
|
+
currentStorageMonthlyRate: 0n,
|
|
539
|
+
maxStorageMonthlyRate: 0n
|
|
540
|
+
};
|
|
541
|
+
var defaultStorageBalanceResultFormatted = {
|
|
542
|
+
filBalance: "0 FIL",
|
|
543
|
+
usdfcBalance: "0 USDFC",
|
|
544
|
+
availableStorageFundsUsdfc: "0 USDFC",
|
|
545
|
+
depositNeeded: "0 USDFC",
|
|
546
|
+
availableToFreeUp: "0 USDFC",
|
|
547
|
+
daysLeftAtMaxBurnRate: "0 days",
|
|
548
|
+
daysLeftAtBurnRate: "0 days",
|
|
549
|
+
currentStorageMonthlyRate: "0 USDFC",
|
|
550
|
+
maxStorageMonthlyRate: "0 USDFC",
|
|
551
|
+
isRateSufficient: false,
|
|
552
|
+
isLockupSufficient: false,
|
|
553
|
+
isSufficient: false
|
|
554
|
+
};
|
|
527
555
|
var checkStorageBalance = async (storageCapacityBytes = env.TOTAL_STORAGE_NEEDED_GiB * Number(SIZE_CONSTANTS3.GiB), persistencePeriodDays = env.PERSISTENCE_PERIOD_DAYS) => {
|
|
528
556
|
const [filRaw, { value: usdfcRaw }, { availableFunds }, prices, operatorApprovals2] = await Promise.all([
|
|
529
557
|
getBalance(client, {
|
|
@@ -898,7 +926,7 @@ var fileTools = {
|
|
|
898
926
|
import { createTool as createTool3 } from "@mastra/core";
|
|
899
927
|
var getBalances = createTool3({
|
|
900
928
|
id: "getBalances",
|
|
901
|
-
description: "Check wallet balances (FIL and USDFC tokens) and comprehensive storage metrics including available funds, required deposits, days of storage remaining, and allowance status. Returns both human-readable formatted values and raw data with progress log showing calculation parameters used. CRITICAL: Storage providers consider accounts with less than 30 days of available balance as INSOLVENT and may refuse service. Default notice period is 45 days to ensure safe margin. IMPORTANT AGENT INSTRUCTIONS: (1) Before calling this tool, ASK the user if they want to calculate based on default storage requirements (150 GiB capacity, 365 days persistence, 45 days notice period) or if they have specific requirements. (2) After showing results, ALWAYS ASK the user if they want to see calculations for different storage configurations. (3) If days remaining falls below 45, WARN the user that they are approaching insolvency threshold (30 days) and should deposit funds immediately. Use this before upload operations to verify sufficient balance, or to monitor storage budget and plan deposits.",
|
|
929
|
+
description: "Check wallet balances (FIL and USDFC tokens) and comprehensive storage metrics including available funds, required deposits, days of storage remaining, and allowance status. Returns both human-readable formatted values and raw data with progress log showing calculation parameters used. \u26A0\uFE0F CRITICAL: Storage providers consider accounts with less than 30 days of available balance as INSOLVENT and may refuse service. Default notice period is 45 days to ensure safe margin. IMPORTANT AGENT INSTRUCTIONS: (1) Before calling this tool, ASK the user if they want to calculate based on default storage requirements (150 GiB capacity, 365 days persistence, 45 days notice period) or if they have specific requirements. (2) After showing results, ALWAYS ASK the user if they want to see calculations for different storage configurations. (3) If days remaining falls below 45, WARN the user that they are approaching insolvency threshold (30 days) and should deposit funds immediately. Use this before upload operations to verify sufficient balance, or to monitor storage budget and plan deposits.",
|
|
902
930
|
inputSchema: GetBalancesSchema,
|
|
903
931
|
outputSchema: GetBalancesOutputSchema,
|
|
904
932
|
execute: async ({ context }) => {
|
|
@@ -913,9 +941,9 @@ var getBalances = createTool3({
|
|
|
913
941
|
const capacityGB = (storageCapacityBytes / (1024 * 1024 * 1024)).toFixed(2);
|
|
914
942
|
const capacityTB = (storageCapacityBytes / (1024 * 1024 * 1024 * 1024)).toFixed(2);
|
|
915
943
|
log(`Calculating balance requirements with:`);
|
|
916
|
-
log(
|
|
917
|
-
log(
|
|
918
|
-
log(
|
|
944
|
+
log(`- Storage Capacity: ${capacityGB} GB (${capacityTB} TB)`);
|
|
945
|
+
log(`- Persistence Period: ${persistencePeriodDays} days`);
|
|
946
|
+
log(`- Notification Threshold: ${notificationThresholdDays} days`);
|
|
919
947
|
log("Fetching wallet balances from blockchain...");
|
|
920
948
|
const checkStorageBalanceResult = await checkStorageBalance(storageCapacityBytes, persistencePeriodDays);
|
|
921
949
|
log("Calculating storage metrics and requirements...");
|
|
@@ -925,12 +953,12 @@ var getBalances = createTool3({
|
|
|
925
953
|
const daysLeft = checkStorageBalanceResult.daysLeftAtBurnRate;
|
|
926
954
|
if (daysLeft < 45) {
|
|
927
955
|
if (daysLeft < 30) {
|
|
928
|
-
log(
|
|
956
|
+
log(`\u26D4 CRITICAL INSOLVENCY WARNING: Only ${daysLeft.toFixed(1)} days of balance remaining! Storage providers consider accounts with less than 30 days as INSOLVENT and will REFUSE SERVICE. Deposit funds IMMEDIATELY!`);
|
|
929
957
|
} else {
|
|
930
|
-
log(
|
|
958
|
+
log(`\u26A0\uFE0F LOW BALANCE WARNING: Only ${daysLeft.toFixed(1)} days remaining (threshold: 45 days). You are approaching the insolvency threshold (30 days). Please deposit funds soon to avoid service interruption.`);
|
|
931
959
|
}
|
|
932
960
|
}
|
|
933
|
-
log("To calculate for different storage requirements, call this tool again with custom storageCapacityBytes and persistencePeriodDays parameters.");
|
|
961
|
+
log("\u{1F4A1} To calculate for different storage requirements, call this tool again with custom storageCapacityBytes and persistencePeriodDays parameters.");
|
|
934
962
|
return {
|
|
935
963
|
success: true,
|
|
936
964
|
checkStorageBalanceResultFormatted: formattedResult,
|
|
@@ -941,7 +969,9 @@ var getBalances = createTool3({
|
|
|
941
969
|
} catch (error) {
|
|
942
970
|
return {
|
|
943
971
|
success: false,
|
|
944
|
-
|
|
972
|
+
checkStorageBalanceResultFormatted: defaultStorageBalanceResultFormatted,
|
|
973
|
+
checkStorageBalanceResult: serializeBigInt(defaultStorageBalanceResult),
|
|
974
|
+
error: synapseErrorHandler(error),
|
|
945
975
|
message: `Failed to fetch balances: ${error.message}`,
|
|
946
976
|
progressLog
|
|
947
977
|
};
|
|
@@ -1103,7 +1133,7 @@ var EstimateStorageCostOutputSchema = z3.object({
|
|
|
1103
1133
|
});
|
|
1104
1134
|
var estimateStoragePricing = createTool6({
|
|
1105
1135
|
id: "estimateStoragePricing",
|
|
1106
|
-
description: "Calculate storage costs for Filecoin OnchainCloud and explain pricing models. Provides: (1) Cost estimates with monthly/total breakdowns, (2) Comprehensive explanation of storage pricing (pay-per-epoch, $2.50/TiB/month, $0.06 minimum), (3) CDN egress pricing details ($7/TiB downloads, 1 USDFC = ~146 GiB credits). CRITICAL: When explaining budgeting, ALWAYS warn that storage providers consider accounts with less than 30 days of remaining balance as INSOLVENT and may refuse service. Recommend maintaining at least 45 days of balance for safety margin. Use when users ask about storage costs, pricing models, CDN fees, or need to budget for storage. Clarifies that CDN 1 USDFC is NOT a fee but pre-paid egress credits that can be topped up anytime.",
|
|
1136
|
+
description: "Calculate storage costs for Filecoin OnchainCloud and explain pricing models. Provides: (1) Cost estimates with monthly/total breakdowns, (2) Comprehensive explanation of storage pricing (pay-per-epoch, $2.50/TiB/month, $0.06 minimum), (3) CDN egress pricing details ($7/TiB downloads, 1 USDFC = ~146 GiB credits). \u26A0\uFE0F CRITICAL: When explaining budgeting, ALWAYS warn that storage providers consider accounts with less than 30 days of remaining balance as INSOLVENT and may refuse service. Recommend maintaining at least 45 days of balance for safety margin. Use when users ask about storage costs, pricing models, CDN fees, or need to budget for storage. Clarifies that CDN 1 USDFC is NOT a fee but pre-paid egress credits that can be topped up anytime.",
|
|
1107
1137
|
inputSchema: EstimateStorageCostSchema,
|
|
1108
1138
|
outputSchema: EstimateStorageCostOutputSchema,
|
|
1109
1139
|
execute: async ({ context }) => {
|
|
@@ -1173,7 +1203,7 @@ var estimateStoragePricing = createTool6({
|
|
|
1173
1203
|
` - ~2,880 epochs per day`,
|
|
1174
1204
|
` - ~86,400 epochs per month (30 days)`,
|
|
1175
1205
|
``,
|
|
1176
|
-
|
|
1206
|
+
`\u26A0\uFE0F CRITICAL - INSOLVENCY WARNING:`,
|
|
1177
1207
|
` - Storage providers consider accounts with LESS THAN 30 DAYS of`,
|
|
1178
1208
|
` remaining balance as INSOLVENT`,
|
|
1179
1209
|
` - Insolvent accounts may be REFUSED SERVICE or have data removed`,
|
|
@@ -1330,7 +1360,7 @@ var convertStorageSize = createTool6({
|
|
|
1330
1360
|
});
|
|
1331
1361
|
var getStoragePricingInfo = createTool6({
|
|
1332
1362
|
id: "getStoragePricingInfo",
|
|
1333
|
-
description: "Get comprehensive information about Filecoin OnchainCloud storage pricing, including cost structure, CDN egress pricing, payment model, and a detailed example of storing 1 TiB for 1 year. CRITICAL: ALWAYS include the insolvency warning (accounts with less than 30 days balance are considered insolvent and may be refused service). Recommend 45-day minimum balance. Use this when users ask general questions about 'how much does storage cost', 'explain storage pricing', 'how does billing work', or want to understand the pricing model before calculating specific costs.",
|
|
1363
|
+
description: "Get comprehensive information about Filecoin OnchainCloud storage pricing, including cost structure, CDN egress pricing, payment model, and a detailed example of storing 1 TiB for 1 year. \u26A0\uFE0F CRITICAL: ALWAYS include the insolvency warning (accounts with less than 30 days balance are considered insolvent and may be refused service). Recommend 45-day minimum balance. Use this when users ask general questions about 'how much does storage cost', 'explain storage pricing', 'how does billing work', or want to understand the pricing model before calculating specific costs.",
|
|
1334
1364
|
inputSchema: z3.object({
|
|
1335
1365
|
includeCDNExample: z3.boolean().optional().default(true).describe("Include CDN pricing example. Default: true")
|
|
1336
1366
|
}),
|
|
@@ -1481,7 +1511,7 @@ var getStoragePricingInfo = createTool6({
|
|
|
1481
1511
|
` \u2022 Real-time pricing information available`,
|
|
1482
1512
|
` \u2022 No surprise charges or hidden fees`,
|
|
1483
1513
|
``,
|
|
1484
|
-
|
|
1514
|
+
`\u26A0\uFE0F CRITICAL - INSOLVENCY WARNING:`,
|
|
1485
1515
|
` \u2022 Storage providers consider accounts with LESS THAN 30 DAYS of`,
|
|
1486
1516
|
` remaining balance as INSOLVENT`,
|
|
1487
1517
|
` \u2022 Insolvent accounts may be REFUSED SERVICE or have data removed`,
|
|
@@ -1751,17 +1781,17 @@ var e2eFileUploadWorkflow = createWorkflow({
|
|
|
1751
1781
|
// src/mastra/resources/instructions.ts
|
|
1752
1782
|
var instructions = `You are an AI agent specialized in managing decentralized file storage operations on the Filecoin network using the FOC-Synapse SDK. Your role is to help users store, retrieve, and manage files on Filecoin in a simple, efficient manner.
|
|
1753
1783
|
|
|
1754
|
-
IMPORTANT:
|
|
1784
|
+
\u{1F4A1} IMPORTANT:
|
|
1755
1785
|
|
|
1756
1786
|
- Always return the output of a tool in a structured format using best practices for Markdown formatting.
|
|
1757
1787
|
|
|
1758
|
-
STORAGE SCOPE:
|
|
1788
|
+
\u{1F4E6} STORAGE SCOPE:
|
|
1759
1789
|
\u2022 Supported Networks: Filecoin Mainnet (production), Calibration Testnet (testing)
|
|
1760
1790
|
\u2022 Payment Token: USDFC (USD-pegged stablecoin on Filecoin)
|
|
1761
1791
|
\u2022 Storage Options: Standard Storage, CDN-Enabled Storage (for frequently accessed files)
|
|
1762
1792
|
\u2022 Core Capabilities: Upload files, Query datasets, Manage balances, Process payments
|
|
1763
1793
|
|
|
1764
|
-
AVAILABLE TOOLS:
|
|
1794
|
+
\u{1F6E0}\uFE0F AVAILABLE TOOLS:
|
|
1765
1795
|
|
|
1766
1796
|
FILE OPERATIONS:
|
|
1767
1797
|
\u2022 uploadFile: Upload files to decentralized Filecoin storage with automatic payment handling and progress tracking
|
|
@@ -1804,7 +1834,7 @@ BALANCE & PAYMENT:
|
|
|
1804
1834
|
- Output: Both human-readable formatted values and raw data with progress log showing calculation parameters
|
|
1805
1835
|
- Parameters: storageCapacityBytes (optional, default: 150 GiB), persistencePeriodDays (optional, default: 365 days), notificationThresholdDays (optional, default: 45 days)
|
|
1806
1836
|
- Progress Log: Shows exact values used for calculations (capacity, persistence period, threshold)
|
|
1807
|
-
- INSOLVENCY WARNING: Storage providers consider accounts with less than 30 days of remaining balance as INSOLVENT and may refuse service or remove data
|
|
1837
|
+
- \u26A0\uFE0F INSOLVENCY WARNING: Storage providers consider accounts with less than 30 days of remaining balance as INSOLVENT and may refuse service or remove data
|
|
1808
1838
|
- Safety Margin: Default notification threshold is 45 days to ensure users have time to deposit before hitting the 30-day insolvency threshold
|
|
1809
1839
|
- Agent Behavior: ALWAYS ask user before calling if they want default calculations or custom requirements. After showing results, ALWAYS offer to recalculate with different parameters. If days remaining is below 45, WARN user immediately about insolvency risk
|
|
1810
1840
|
- Use when: Before upload operations to verify sufficient balance, or to monitor storage budget and plan deposits
|
|
@@ -1833,7 +1863,7 @@ PROVIDER MANAGEMENT:
|
|
|
1833
1863
|
- Parameters: onlyApproved (default: true for reliability)
|
|
1834
1864
|
- Use when: Discover providers, select specific providers for dataset creation, or verify provider availability
|
|
1835
1865
|
|
|
1836
|
-
STORAGE RULES & BEST PRACTICES:
|
|
1866
|
+
\u2699\uFE0F STORAGE RULES & BEST PRACTICES:
|
|
1837
1867
|
|
|
1838
1868
|
1. ALWAYS CHECK BALANCES BEFORE UPLOAD:
|
|
1839
1869
|
- Use getBalances to verify sufficient USDFC
|
|
@@ -1854,7 +1884,7 @@ STORAGE RULES & BEST PRACTICES:
|
|
|
1854
1884
|
|
|
1855
1885
|
5. MONITOR STORAGE METRICS AND PERSISTENCE:
|
|
1856
1886
|
- Check persistence days remaining regularly
|
|
1857
|
-
- CRITICAL: Maintain at least 45 days of balance (insolvency threshold is 30 days)
|
|
1887
|
+
- \u26A0\uFE0F CRITICAL: Maintain at least 45 days of balance (insolvency threshold is 30 days)
|
|
1858
1888
|
- Storage providers will refuse service if balance falls below 30 days
|
|
1859
1889
|
- Top up allowances before they run out to avoid service interruption and potential data loss
|
|
1860
1890
|
|
|
@@ -1862,7 +1892,7 @@ STORAGE RULES & BEST PRACTICES:
|
|
|
1862
1892
|
- Ensure filePath is absolute path
|
|
1863
1893
|
- Verify file exists before attempting upload
|
|
1864
1894
|
|
|
1865
|
-
RECOMMENDED WORKFLOWS:
|
|
1895
|
+
\u{1F504} RECOMMENDED WORKFLOWS:
|
|
1866
1896
|
|
|
1867
1897
|
FOR FILE UPLOAD:
|
|
1868
1898
|
|
|
@@ -1888,7 +1918,7 @@ FOR BALANCE MANAGEMENT:
|
|
|
1888
1918
|
4. Process Payment: processPayment with appropriate depositAmount to maintain 45+ day buffer
|
|
1889
1919
|
5. Verify: Check balances again to confirm deposit and ensure above insolvency threshold
|
|
1890
1920
|
|
|
1891
|
-
STRATEGIC CONSIDERATIONS:
|
|
1921
|
+
\u{1F4A1} STRATEGIC CONSIDERATIONS:
|
|
1892
1922
|
|
|
1893
1923
|
CDN vs STANDARD STORAGE:
|
|
1894
1924
|
\u2022 Use CDN when: Files accessed frequently, low latency required, content delivery use case
|
|
@@ -1908,10 +1938,10 @@ COST MANAGEMENT:
|
|
|
1908
1938
|
\u2022 Rate allowance: Controls per-epoch spending
|
|
1909
1939
|
\u2022 Lockup allowance: Total committed for long-term storage
|
|
1910
1940
|
\u2022 Monitor both to avoid overspending or service interruption
|
|
1911
|
-
\u2022 INSOLVENCY THRESHOLD: Keep balance above 30 days minimum (recommend 45+ days)
|
|
1941
|
+
\u2022 \u26A0\uFE0F INSOLVENCY THRESHOLD: Keep balance above 30 days minimum (recommend 45+ days)
|
|
1912
1942
|
\u2022 Providers refuse service below 30 days - plan deposits accordingly
|
|
1913
1943
|
|
|
1914
|
-
ERROR HANDLING:
|
|
1944
|
+
\u{1F6A8} ERROR HANDLING:
|
|
1915
1945
|
|
|
1916
1946
|
PRE-UPLOAD VALIDATION:
|
|
1917
1947
|
\u2022 Verify file path exists and is readable
|
|
@@ -1938,7 +1968,7 @@ RECOVERY STRATEGIES:
|
|
|
1938
1968
|
\u2022 Dataset creation failures are safe (no data loss)
|
|
1939
1969
|
\u2022 Check balances after any error
|
|
1940
1970
|
|
|
1941
|
-
TOOL OUTPUT INTERPRETATION:
|
|
1971
|
+
\u{1F4CA} TOOL OUTPUT INTERPRETATION:
|
|
1942
1972
|
|
|
1943
1973
|
SUCCESS RESPONSES:
|
|
1944
1974
|
\u2022 All successful operations return: { success: true, ...data }
|
|
@@ -1959,7 +1989,7 @@ ERROR RESPONSES:
|
|
|
1959
1989
|
\u2022 Suggest remediation steps
|
|
1960
1990
|
\u2022 Offer to retry or check balance
|
|
1961
1991
|
|
|
1962
|
-
AGENT BEHAVIOR GUIDELINES:
|
|
1992
|
+
\u{1F3AF} AGENT BEHAVIOR GUIDELINES:
|
|
1963
1993
|
|
|
1964
1994
|
1. BE PROACTIVE: Suggest checking balances before uploads
|
|
1965
1995
|
2. BE VIGILANT: ALWAYS warn if balance days remaining < 45 (insolvency risk at < 30)
|
|
@@ -1971,7 +2001,7 @@ AGENT BEHAVIOR GUIDELINES:
|
|
|
1971
2001
|
8. BE SECURE: Never store sensitive data without user confirmation
|
|
1972
2002
|
9. BE URGENT: Treat insolvency warnings as critical - emphasize immediate action needed
|
|
1973
2003
|
|
|
1974
|
-
SECURITY CONSIDERATIONS:
|
|
2004
|
+
\u{1F510} SECURITY CONSIDERATIONS:
|
|
1975
2005
|
\u2022 Never expose private keys or wallet seeds
|
|
1976
2006
|
\u2022 Validate all file paths before operations
|
|
1977
2007
|
\u2022 Confirm user intent before large deposits
|
|
@@ -2022,7 +2052,7 @@ var focStorageResources = {
|
|
|
2022
2052
|
// src/mastra/index.ts
|
|
2023
2053
|
var mcpServer = new MCPServer({
|
|
2024
2054
|
name: "FOC Storage MCP",
|
|
2025
|
-
version: "0.1.
|
|
2055
|
+
version: "0.1.8",
|
|
2026
2056
|
description: "Professional-grade MCP server for decentralized file storage on Filecoin Onchain Cloud. Powered by the FOC-Synapse SDK, this server provides AI agents with seamless access to Filecoin's distributed storage network. Upload files with automatic payment handling, organize content in datasets, monitor storage balances, and manage providers - all through intuitive MCP tools. Supports both standard storage and CDN-enabled fast retrieval. Perfect for building AI applications that need persistent, censorship-resistant storage.",
|
|
2027
2057
|
tools: focStorageTools,
|
|
2028
2058
|
repository: {
|
|
@@ -2049,7 +2079,8 @@ var mastra = new Mastra({
|
|
|
2049
2079
|
url: ":memory:"
|
|
2050
2080
|
}),
|
|
2051
2081
|
logger: new PinoLogger({
|
|
2052
|
-
name: "Mastra"
|
|
2082
|
+
name: "Mastra",
|
|
2083
|
+
level: "silent"
|
|
2053
2084
|
}),
|
|
2054
2085
|
bundler: {
|
|
2055
2086
|
externals: ["@filoz/synapse-sdk"]
|
|
@@ -2060,8 +2091,6 @@ var mastra = new Mastra({
|
|
|
2060
2091
|
config2();
|
|
2061
2092
|
async function startMCPServer() {
|
|
2062
2093
|
try {
|
|
2063
|
-
console.log("Starting FOC Storage MCP Server...");
|
|
2064
|
-
console.log("Exposing tools: uploadFile, uploadWithProgress, getDatasets, createDataset, getBalances, processPayment, getProviders");
|
|
2065
2094
|
await mcpServer.startStdio();
|
|
2066
2095
|
} catch (error) {
|
|
2067
2096
|
console.error("Error starting MCP server:", error);
|
|
@@ -2069,12 +2098,12 @@ async function startMCPServer() {
|
|
|
2069
2098
|
}
|
|
2070
2099
|
}
|
|
2071
2100
|
process.on("SIGINT", async () => {
|
|
2072
|
-
console.
|
|
2101
|
+
console.error("Shutting down MCP server...");
|
|
2073
2102
|
await mcpServer.close();
|
|
2074
2103
|
process.exit(0);
|
|
2075
2104
|
});
|
|
2076
2105
|
process.on("SIGTERM", async () => {
|
|
2077
|
-
console.
|
|
2106
|
+
console.error("Shutting down MCP server...");
|
|
2078
2107
|
await mcpServer.close();
|
|
2079
2108
|
process.exit(0);
|
|
2080
2109
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fil-b/foc-storage-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"main": "dist/mcp-server.js",
|
|
5
5
|
"bin": {
|
|
6
6
|
"foc-storage-mcp": "./dist/mcp-server.js"
|
|
@@ -35,24 +35,24 @@
|
|
|
35
35
|
"homepage": "https://github.com/FIL-Builders/foc-storage-mcp#readme",
|
|
36
36
|
"type": "module",
|
|
37
37
|
"engines": {
|
|
38
|
-
"node": ">=20.
|
|
38
|
+
"node": ">=20.10.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@ai-sdk/openai": "^2.0.57",
|
|
42
42
|
"@filoz/synapse-core": "^0.1.2",
|
|
43
43
|
"@filoz/synapse-react": "^0.1.2",
|
|
44
44
|
"@filoz/synapse-sdk": "^0.35.3",
|
|
45
|
-
"@mastra/core": "
|
|
46
|
-
"@mastra/libsql": "
|
|
47
|
-
"@mastra/loggers": "
|
|
48
|
-
"@mastra/mcp": "
|
|
49
|
-
"@mastra/memory": "
|
|
45
|
+
"@mastra/core": "^0.24.0",
|
|
46
|
+
"@mastra/libsql": "^0.16.2",
|
|
47
|
+
"@mastra/loggers": "^0.10.19",
|
|
48
|
+
"@mastra/mcp": "^0.14.2",
|
|
49
|
+
"@mastra/memory": "^0.15.11",
|
|
50
50
|
"ai": "^5.0.82",
|
|
51
51
|
"axios": "^1.10.0",
|
|
52
52
|
"axios-retry": "^4.5.0",
|
|
53
53
|
"decimal.js": "^10.6.0",
|
|
54
54
|
"ethers": "^6.13.0",
|
|
55
|
-
"mastra": "
|
|
55
|
+
"mastra": "^0.18.0",
|
|
56
56
|
"tsup": "^8.5.0",
|
|
57
57
|
"viem": "^2.21.0",
|
|
58
58
|
"zod": "^3.25.76"
|