@caypo/canton-mcp 0.1.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/.turbo/turbo-build.log +14 -0
- package/.turbo/turbo-test.log +12 -0
- package/README.md +84 -0
- package/SPEC.md +93 -0
- package/dist/index.js +643 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
- package/src/index.ts +40 -0
- package/src/prompts/index.ts +207 -0
- package/src/tools/balance.ts +79 -0
- package/src/tools/checking.ts +75 -0
- package/src/tools/index.ts +60 -0
- package/src/tools/mpp.ts +98 -0
- package/src/tools/safeguards.ts +67 -0
- package/src/tools/stubs.ts +46 -0
- package/src/tools/traffic.ts +44 -0
- package/src/tools/types.ts +15 -0
- package/tsconfig.json +8 -0
- package/tsup.config.ts +12 -0
- package/vitest.config.ts +8 -0
package/src/tools/mpp.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MPP Payment tools (3): caypo_pay, caypo_pay_status, caypo_services
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { CantonAgent } from "@caypo/canton-sdk";
|
|
6
|
+
import type { ToolDef } from "./types.js";
|
|
7
|
+
|
|
8
|
+
export function mppTools(agent: CantonAgent): ToolDef[] {
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
name: "caypo_pay",
|
|
12
|
+
description: "Pay for an API call via MPP (HTTP 402 auto-handling). Fetches URL, handles payment if 402, returns response.",
|
|
13
|
+
inputSchema: {
|
|
14
|
+
type: "object",
|
|
15
|
+
properties: {
|
|
16
|
+
url: { type: "string", description: "URL to fetch" },
|
|
17
|
+
method: { type: "string", description: "HTTP method", default: "GET" },
|
|
18
|
+
body: { type: "string", description: "Request body (JSON string)" },
|
|
19
|
+
maxPrice: { type: "string", description: "Maximum price willing to pay in USDCx" },
|
|
20
|
+
},
|
|
21
|
+
required: ["url"],
|
|
22
|
+
},
|
|
23
|
+
handler: async (args) => {
|
|
24
|
+
const { url, method, body, maxPrice } = args as {
|
|
25
|
+
url: string; method?: string; body?: string; maxPrice?: string;
|
|
26
|
+
};
|
|
27
|
+
const result = await agent.mpp.pay(url, {
|
|
28
|
+
method,
|
|
29
|
+
body,
|
|
30
|
+
maxPrice,
|
|
31
|
+
headers: body ? { "Content-Type": "application/json" } : undefined,
|
|
32
|
+
});
|
|
33
|
+
const responseBody = await result.response.text();
|
|
34
|
+
return {
|
|
35
|
+
content: [
|
|
36
|
+
{
|
|
37
|
+
type: "text",
|
|
38
|
+
text: JSON.stringify({
|
|
39
|
+
status: result.response.status,
|
|
40
|
+
paid: result.paid,
|
|
41
|
+
receipt: result.receipt,
|
|
42
|
+
body: responseBody.slice(0, 2000),
|
|
43
|
+
}, null, 2),
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "caypo_pay_status",
|
|
51
|
+
description: "Check payment status by Canton update ID",
|
|
52
|
+
inputSchema: {
|
|
53
|
+
type: "object",
|
|
54
|
+
properties: {
|
|
55
|
+
updateId: { type: "string", description: "Canton transaction update ID" },
|
|
56
|
+
},
|
|
57
|
+
required: ["updateId"],
|
|
58
|
+
},
|
|
59
|
+
handler: async () => ({
|
|
60
|
+
content: [{ type: "text", text: "Payment status lookup requires gateway integration. Use the updateId with the Canton Ledger API directly." }],
|
|
61
|
+
}),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "caypo_services",
|
|
65
|
+
description: "List available MPP gateway services and pricing",
|
|
66
|
+
inputSchema: { type: "object", properties: {}, required: [] },
|
|
67
|
+
handler: async () => ({
|
|
68
|
+
content: [
|
|
69
|
+
{
|
|
70
|
+
type: "text",
|
|
71
|
+
text: JSON.stringify({
|
|
72
|
+
gateway: "mpp.cayvox.io",
|
|
73
|
+
services: [
|
|
74
|
+
{ name: "OpenAI", path: "/openai", price: "$0.001-$0.05" },
|
|
75
|
+
{ name: "Anthropic", path: "/anthropic", price: "$0.01" },
|
|
76
|
+
{ name: "fal.ai", path: "/fal", price: "$0.01-$0.10" },
|
|
77
|
+
{ name: "Firecrawl", path: "/firecrawl", price: "$0.005-$0.02" },
|
|
78
|
+
{ name: "Google Gemini", path: "/gemini", price: "$0.005-$0.02" },
|
|
79
|
+
{ name: "Groq", path: "/groq", price: "$0.001-$0.005" },
|
|
80
|
+
{ name: "Perplexity", path: "/perplexity", price: "$0.01" },
|
|
81
|
+
{ name: "Brave Search", path: "/brave", price: "$0.001-$0.005" },
|
|
82
|
+
{ name: "DeepSeek", path: "/deepseek", price: "$0.005" },
|
|
83
|
+
{ name: "Resend", path: "/resend", price: "$0.005" },
|
|
84
|
+
{ name: "Together AI", path: "/together", price: "$0.001-$0.02" },
|
|
85
|
+
{ name: "ElevenLabs", path: "/elevenlabs", price: "$0.02-$0.05" },
|
|
86
|
+
{ name: "OpenWeather", path: "/openweather", price: "$0.001" },
|
|
87
|
+
{ name: "Google Maps", path: "/googlemaps", price: "$0.005" },
|
|
88
|
+
{ name: "Judge0", path: "/judge0", price: "$0.002" },
|
|
89
|
+
{ name: "Reloadly", path: "/reloadly", price: "$0.01+" },
|
|
90
|
+
{ name: "Lob", path: "/lob", price: "$0.01-$0.50" },
|
|
91
|
+
],
|
|
92
|
+
}, null, 2),
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
}),
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safeguard tools (3): caypo_safeguards, caypo_set_limit, caypo_lock
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { CantonAgent } from "@caypo/canton-sdk";
|
|
6
|
+
import type { ToolDef } from "./types.js";
|
|
7
|
+
|
|
8
|
+
export function safeguardTools(agent: CantonAgent): ToolDef[] {
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
name: "caypo_safeguards",
|
|
12
|
+
description: "View current safeguard settings: tx limit, daily limit, lock status, daily spending",
|
|
13
|
+
inputSchema: { type: "object", properties: {}, required: [] },
|
|
14
|
+
handler: async () => {
|
|
15
|
+
const s = agent.safeguards.settings();
|
|
16
|
+
return {
|
|
17
|
+
content: [{ type: "text", text: JSON.stringify(s, null, 2) }],
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "caypo_set_limit",
|
|
23
|
+
description: "Set per-transaction or daily spending limit",
|
|
24
|
+
inputSchema: {
|
|
25
|
+
type: "object",
|
|
26
|
+
properties: {
|
|
27
|
+
type: { type: "string", enum: ["tx", "daily"], description: "Limit type" },
|
|
28
|
+
amount: { type: "string", description: "Limit amount in USDCx" },
|
|
29
|
+
},
|
|
30
|
+
required: ["type", "amount"],
|
|
31
|
+
},
|
|
32
|
+
handler: async (args) => {
|
|
33
|
+
const { type, amount } = args as { type: "tx" | "daily"; amount: string };
|
|
34
|
+
if (type === "tx") {
|
|
35
|
+
agent.safeguards.setTxLimit(amount);
|
|
36
|
+
} else {
|
|
37
|
+
agent.safeguards.setDailyLimit(amount);
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
content: [{ type: "text", text: `${type === "tx" ? "Per-transaction" : "Daily"} limit set to ${amount} USDCx` }],
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "caypo_lock",
|
|
46
|
+
description: "Lock or unlock the wallet. When locked, all transactions are rejected.",
|
|
47
|
+
inputSchema: {
|
|
48
|
+
type: "object",
|
|
49
|
+
properties: {
|
|
50
|
+
action: { type: "string", enum: ["lock", "unlock"], description: "Action to perform" },
|
|
51
|
+
pin: { type: "string", description: "PIN for lock/unlock" },
|
|
52
|
+
},
|
|
53
|
+
required: ["action"],
|
|
54
|
+
},
|
|
55
|
+
handler: async (args) => {
|
|
56
|
+
const { action, pin } = args as { action: "lock" | "unlock"; pin?: string };
|
|
57
|
+
if (action === "lock") {
|
|
58
|
+
agent.safeguards.lock(pin);
|
|
59
|
+
return { content: [{ type: "text", text: "Wallet locked. All transactions will be rejected until unlocked." }] };
|
|
60
|
+
} else {
|
|
61
|
+
agent.safeguards.unlock(pin ?? "");
|
|
62
|
+
return { content: [{ type: "text", text: "Wallet unlocked." }] };
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stub tools for Phase 3/4 features.
|
|
3
|
+
* savings (4), credit (3), exchange (2), investment (8), rewards (2) = 19 stubs
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ToolDef } from "./types.js";
|
|
7
|
+
|
|
8
|
+
function stub(name: string, description: string, phase: string): ToolDef {
|
|
9
|
+
return {
|
|
10
|
+
name,
|
|
11
|
+
description: `${description} (Coming in ${phase})`,
|
|
12
|
+
inputSchema: { type: "object", properties: {} },
|
|
13
|
+
handler: async () => ({
|
|
14
|
+
content: [{ type: "text", text: `${description} is not yet available. Coming in ${phase} when Canton DeFi protocols launch.` }],
|
|
15
|
+
}),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function stubTools(): ToolDef[] {
|
|
20
|
+
return [
|
|
21
|
+
// Savings (4)
|
|
22
|
+
stub("caypo_save", "Deposit USDCx into savings for yield", "Phase 3"),
|
|
23
|
+
stub("caypo_withdraw", "Withdraw from savings to checking", "Phase 3"),
|
|
24
|
+
stub("caypo_rebalance_savings", "Rebalance savings across protocols", "Phase 3"),
|
|
25
|
+
stub("caypo_earnings", "View savings earnings and APY", "Phase 3"),
|
|
26
|
+
// Credit (3)
|
|
27
|
+
stub("caypo_borrow", "Borrow USDCx against collateral", "Phase 3"),
|
|
28
|
+
stub("caypo_repay", "Repay borrowed amount", "Phase 3"),
|
|
29
|
+
stub("caypo_health", "Check credit health factor", "Phase 3"),
|
|
30
|
+
// Exchange (2)
|
|
31
|
+
stub("caypo_exchange", "Exchange tokens on Canton DEX", "Phase 3"),
|
|
32
|
+
stub("caypo_quote", "Get exchange rate quote", "Phase 3"),
|
|
33
|
+
// Investment (8)
|
|
34
|
+
stub("caypo_invest_buy", "Buy investment assets", "Phase 4"),
|
|
35
|
+
stub("caypo_invest_sell", "Sell investment assets", "Phase 4"),
|
|
36
|
+
stub("caypo_invest_earn", "Stake assets for yield", "Phase 4"),
|
|
37
|
+
stub("caypo_invest_unearn", "Unstake assets", "Phase 4"),
|
|
38
|
+
stub("caypo_invest_rebalance", "Rebalance investment portfolio", "Phase 4"),
|
|
39
|
+
stub("caypo_portfolio", "View investment portfolio", "Phase 4"),
|
|
40
|
+
stub("caypo_strategy_buy", "Execute investment strategy", "Phase 4"),
|
|
41
|
+
stub("caypo_auto_invest", "Configure auto-invest DCA", "Phase 4"),
|
|
42
|
+
// Rewards (2)
|
|
43
|
+
stub("caypo_claim_rewards", "Claim Canton Coin mining rewards", "Phase 3"),
|
|
44
|
+
stub("caypo_reward_history", "View reward claim history", "Phase 3"),
|
|
45
|
+
];
|
|
46
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Traffic tools (2): caypo_traffic, caypo_purchase_traffic
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { CantonAgent } from "@caypo/canton-sdk";
|
|
6
|
+
import type { ToolDef } from "./types.js";
|
|
7
|
+
|
|
8
|
+
export function trafficTools(agent: CantonAgent): ToolDef[] {
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
name: "caypo_traffic",
|
|
12
|
+
description: "Check validator traffic balance. Canton uses traffic budgets, not gas fees.",
|
|
13
|
+
inputSchema: { type: "object", properties: {}, required: [] },
|
|
14
|
+
handler: async () => {
|
|
15
|
+
const bal = await agent.traffic.trafficBalance();
|
|
16
|
+
return {
|
|
17
|
+
content: [
|
|
18
|
+
{
|
|
19
|
+
type: "text",
|
|
20
|
+
text: JSON.stringify({
|
|
21
|
+
...bal,
|
|
22
|
+
note: "Canton uses traffic budgets per validator, not per-transaction gas fees.",
|
|
23
|
+
}, null, 2),
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "caypo_purchase_traffic",
|
|
31
|
+
description: "Purchase additional traffic by burning Canton Coin (CC). Coming soon.",
|
|
32
|
+
inputSchema: {
|
|
33
|
+
type: "object",
|
|
34
|
+
properties: {
|
|
35
|
+
ccAmount: { type: "string", description: "Amount of CC to burn" },
|
|
36
|
+
},
|
|
37
|
+
required: ["ccAmount"],
|
|
38
|
+
},
|
|
39
|
+
handler: async () => ({
|
|
40
|
+
content: [{ type: "text", text: "Traffic purchase is not yet implemented. Requires validator admin API access." }],
|
|
41
|
+
}),
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool definition type for MCP server.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export interface ToolResult {
|
|
6
|
+
content: Array<{ type: string; text: string }>;
|
|
7
|
+
isError?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ToolDef {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
inputSchema: Record<string, unknown>;
|
|
14
|
+
handler: (args: Record<string, unknown>) => Promise<ToolResult>;
|
|
15
|
+
}
|
package/tsconfig.json
ADDED
package/tsup.config.ts
ADDED