@opencard-dev/mcp-server 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/dist/index.d.ts +64 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +186 -0
- package/dist/index.js.map +1 -0
- package/dist/tools.d.ts +353 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +1199 -0
- package/dist/tools.js.map +1 -0
- package/package.json +45 -0
- package/references/gotchas.md +141 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCard MCP Server
|
|
3
|
+
* ===================
|
|
4
|
+
* Initializes and exports the MCP server that exposes OpenCard tools
|
|
5
|
+
* to AI agents via the Model Context Protocol.
|
|
6
|
+
*
|
|
7
|
+
* ─── Usage ───────────────────────────────────────────────────────────────────
|
|
8
|
+
*
|
|
9
|
+
* Run this file directly to start the MCP server over stdio:
|
|
10
|
+
*
|
|
11
|
+
* STRIPE_SECRET_KEY=sk_test_... node dist/index.js
|
|
12
|
+
*
|
|
13
|
+
* The server will listen for MCP requests on stdin and write responses to stdout.
|
|
14
|
+
* Connect it to an MCP-compatible agent (Claude, GPT, etc.) by registering it
|
|
15
|
+
* as a tool provider.
|
|
16
|
+
*
|
|
17
|
+
* ─── Environment ─────────────────────────────────────────────────────────────
|
|
18
|
+
*
|
|
19
|
+
* STRIPE_SECRET_KEY — Required for all card operations. Starts with sk_test_
|
|
20
|
+
* for test mode or sk_live_ for production.
|
|
21
|
+
*
|
|
22
|
+
* ─── Available tools ─────────────────────────────────────────────────────────
|
|
23
|
+
*
|
|
24
|
+
* opencard_list_cards Discover available cards (call FIRST)
|
|
25
|
+
* opencard_check_rules Dry-run a charge against card rules (instant, local)
|
|
26
|
+
* opencard_create_card Create a virtual card for an agent
|
|
27
|
+
* opencard_get_balance Get spend totals and remaining budget for a card
|
|
28
|
+
* opencard_get_transactions List transaction history for a card
|
|
29
|
+
* opencard_pause_card Temporarily disable a card
|
|
30
|
+
* opencard_resume_card Re-enable a paused card
|
|
31
|
+
* opencard_set_limits Update Stripe-native spending limits
|
|
32
|
+
* opencard_get_card_details Fetch full card details
|
|
33
|
+
* opencard_request_approval Request human approval for a purchase
|
|
34
|
+
*/
|
|
35
|
+
export { openCardTools, createToolHandler } from './tools';
|
|
36
|
+
/**
|
|
37
|
+
* MCP server configuration metadata.
|
|
38
|
+
* Used by agents and registries to identify this server.
|
|
39
|
+
*/
|
|
40
|
+
export declare const mcpServerConfig: {
|
|
41
|
+
name: string;
|
|
42
|
+
version: string;
|
|
43
|
+
description: string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Starts the OpenCard MCP server using the @modelcontextprotocol/sdk.
|
|
47
|
+
*
|
|
48
|
+
* Registers all OpenCard tools and connects over stdio transport so the server
|
|
49
|
+
* can be launched as a subprocess by any MCP-compatible agent.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* // In your agent's MCP config:
|
|
53
|
+
* {
|
|
54
|
+
* "mcpServers": {
|
|
55
|
+
* "opencard": {
|
|
56
|
+
* "command": "node",
|
|
57
|
+
* "args": ["path/to/mcp-server/dist/index.js"],
|
|
58
|
+
* "env": { "STRIPE_SECRET_KEY": "sk_test_..." }
|
|
59
|
+
* }
|
|
60
|
+
* }
|
|
61
|
+
* }
|
|
62
|
+
*/
|
|
63
|
+
export declare function startMcpServer(): Promise<void>;
|
|
64
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE3D;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;CAoB3B,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAoEpD"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* OpenCard MCP Server
|
|
4
|
+
* ===================
|
|
5
|
+
* Initializes and exports the MCP server that exposes OpenCard tools
|
|
6
|
+
* to AI agents via the Model Context Protocol.
|
|
7
|
+
*
|
|
8
|
+
* ─── Usage ───────────────────────────────────────────────────────────────────
|
|
9
|
+
*
|
|
10
|
+
* Run this file directly to start the MCP server over stdio:
|
|
11
|
+
*
|
|
12
|
+
* STRIPE_SECRET_KEY=sk_test_... node dist/index.js
|
|
13
|
+
*
|
|
14
|
+
* The server will listen for MCP requests on stdin and write responses to stdout.
|
|
15
|
+
* Connect it to an MCP-compatible agent (Claude, GPT, etc.) by registering it
|
|
16
|
+
* as a tool provider.
|
|
17
|
+
*
|
|
18
|
+
* ─── Environment ─────────────────────────────────────────────────────────────
|
|
19
|
+
*
|
|
20
|
+
* STRIPE_SECRET_KEY — Required for all card operations. Starts with sk_test_
|
|
21
|
+
* for test mode or sk_live_ for production.
|
|
22
|
+
*
|
|
23
|
+
* ─── Available tools ─────────────────────────────────────────────────────────
|
|
24
|
+
*
|
|
25
|
+
* opencard_list_cards Discover available cards (call FIRST)
|
|
26
|
+
* opencard_check_rules Dry-run a charge against card rules (instant, local)
|
|
27
|
+
* opencard_create_card Create a virtual card for an agent
|
|
28
|
+
* opencard_get_balance Get spend totals and remaining budget for a card
|
|
29
|
+
* opencard_get_transactions List transaction history for a card
|
|
30
|
+
* opencard_pause_card Temporarily disable a card
|
|
31
|
+
* opencard_resume_card Re-enable a paused card
|
|
32
|
+
* opencard_set_limits Update Stripe-native spending limits
|
|
33
|
+
* opencard_get_card_details Fetch full card details
|
|
34
|
+
* opencard_request_approval Request human approval for a purchase
|
|
35
|
+
*/
|
|
36
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
37
|
+
if (k2 === undefined) k2 = k;
|
|
38
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
39
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
40
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
41
|
+
}
|
|
42
|
+
Object.defineProperty(o, k2, desc);
|
|
43
|
+
}) : (function(o, m, k, k2) {
|
|
44
|
+
if (k2 === undefined) k2 = k;
|
|
45
|
+
o[k2] = m[k];
|
|
46
|
+
}));
|
|
47
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
48
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
49
|
+
}) : function(o, v) {
|
|
50
|
+
o["default"] = v;
|
|
51
|
+
});
|
|
52
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
53
|
+
var ownKeys = function(o) {
|
|
54
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
55
|
+
var ar = [];
|
|
56
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
57
|
+
return ar;
|
|
58
|
+
};
|
|
59
|
+
return ownKeys(o);
|
|
60
|
+
};
|
|
61
|
+
return function (mod) {
|
|
62
|
+
if (mod && mod.__esModule) return mod;
|
|
63
|
+
var result = {};
|
|
64
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
65
|
+
__setModuleDefault(result, mod);
|
|
66
|
+
return result;
|
|
67
|
+
};
|
|
68
|
+
})();
|
|
69
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
|
+
exports.mcpServerConfig = exports.createToolHandler = exports.openCardTools = void 0;
|
|
71
|
+
exports.startMcpServer = startMcpServer;
|
|
72
|
+
var tools_1 = require("./tools");
|
|
73
|
+
Object.defineProperty(exports, "openCardTools", { enumerable: true, get: function () { return tools_1.openCardTools; } });
|
|
74
|
+
Object.defineProperty(exports, "createToolHandler", { enumerable: true, get: function () { return tools_1.createToolHandler; } });
|
|
75
|
+
/**
|
|
76
|
+
* MCP server configuration metadata.
|
|
77
|
+
* Used by agents and registries to identify this server.
|
|
78
|
+
*/
|
|
79
|
+
exports.mcpServerConfig = {
|
|
80
|
+
name: 'opencard',
|
|
81
|
+
version: '0.1.0',
|
|
82
|
+
description: `OpenCard — give AI agents credit cards with guardrails.
|
|
83
|
+
|
|
84
|
+
WORKFLOW (follow this order):
|
|
85
|
+
1. list_cards → find the right card and check its budget
|
|
86
|
+
2. check_rules → verify your purchase would be approved
|
|
87
|
+
3. Make the purchase through your normal flow
|
|
88
|
+
4. get_balance → confirm the charge and check remaining budget
|
|
89
|
+
|
|
90
|
+
If a purchase would exceed limits, use request_approval to ask a human.
|
|
91
|
+
|
|
92
|
+
GOTCHAS:
|
|
93
|
+
- All amounts are in CENTS, not dollars. $25.00 = 2500 cents.
|
|
94
|
+
- check_rules is instant and local. create_card and set_limits hit the Stripe API.
|
|
95
|
+
- request_approval returns permission, NOT execution. You still make the charge yourself.
|
|
96
|
+
- Cards spend from the operator's Stripe balance, not the end user's bank account.
|
|
97
|
+
- Don't hardcode card IDs. Always use list_cards to discover them.
|
|
98
|
+
- If no rule is assigned to a card, all charges are DECLINED by default (default-deny).`,
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Starts the OpenCard MCP server using the @modelcontextprotocol/sdk.
|
|
102
|
+
*
|
|
103
|
+
* Registers all OpenCard tools and connects over stdio transport so the server
|
|
104
|
+
* can be launched as a subprocess by any MCP-compatible agent.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* // In your agent's MCP config:
|
|
108
|
+
* {
|
|
109
|
+
* "mcpServers": {
|
|
110
|
+
* "opencard": {
|
|
111
|
+
* "command": "node",
|
|
112
|
+
* "args": ["path/to/mcp-server/dist/index.js"],
|
|
113
|
+
* "env": { "STRIPE_SECRET_KEY": "sk_test_..." }
|
|
114
|
+
* }
|
|
115
|
+
* }
|
|
116
|
+
* }
|
|
117
|
+
*/
|
|
118
|
+
async function startMcpServer() {
|
|
119
|
+
// Dynamically import the MCP SDK to keep it optional at module load time.
|
|
120
|
+
// This allows the module to be imported for its exports (openCardTools, etc.)
|
|
121
|
+
// without requiring the MCP SDK to be running.
|
|
122
|
+
const { Server } = await Promise.resolve().then(() => __importStar(require('@modelcontextprotocol/sdk/server/index.js')));
|
|
123
|
+
const { StdioServerTransport } = await Promise.resolve().then(() => __importStar(require('@modelcontextprotocol/sdk/server/stdio.js')));
|
|
124
|
+
const { ListToolsRequestSchema, CallToolRequestSchema } = await Promise.resolve().then(() => __importStar(require('@modelcontextprotocol/sdk/types.js')));
|
|
125
|
+
const { openCardTools, createToolHandler } = await Promise.resolve().then(() => __importStar(require('./tools')));
|
|
126
|
+
const server = new Server({
|
|
127
|
+
name: exports.mcpServerConfig.name,
|
|
128
|
+
version: exports.mcpServerConfig.version,
|
|
129
|
+
}, {
|
|
130
|
+
capabilities: {
|
|
131
|
+
tools: {},
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
// ── Register tool list handler ────────────────────────────────────────────
|
|
135
|
+
// Responds to ListTools requests — agents call this to discover available tools.
|
|
136
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
137
|
+
tools: openCardTools,
|
|
138
|
+
}));
|
|
139
|
+
// ── Register tool call handler ────────────────────────────────────────────
|
|
140
|
+
// Routes each tool call to the appropriate handler in tools.ts.
|
|
141
|
+
// Errors are caught and returned as text content rather than crashing.
|
|
142
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
143
|
+
const { name, arguments: toolArgs } = request.params;
|
|
144
|
+
const args = (toolArgs ?? {});
|
|
145
|
+
try {
|
|
146
|
+
const result = await createToolHandler(name, args);
|
|
147
|
+
return {
|
|
148
|
+
content: [
|
|
149
|
+
{
|
|
150
|
+
type: 'text',
|
|
151
|
+
text: JSON.stringify(result, null, 2),
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
catch (err) {
|
|
157
|
+
// This catch is a safety net — individual handlers already catch their
|
|
158
|
+
// own errors. This only fires if createToolHandler itself throws.
|
|
159
|
+
return {
|
|
160
|
+
content: [
|
|
161
|
+
{
|
|
162
|
+
type: 'text',
|
|
163
|
+
text: JSON.stringify({ status: 'error', message: String(err) }),
|
|
164
|
+
},
|
|
165
|
+
],
|
|
166
|
+
isError: true,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
// ── Connect via stdio transport ───────────────────────────────────────────
|
|
171
|
+
// stdio is the standard MCP transport for subprocess-based servers.
|
|
172
|
+
const transport = new StdioServerTransport();
|
|
173
|
+
await server.connect(transport);
|
|
174
|
+
// Log to stderr so it doesn't interfere with the stdio MCP protocol on stdout.
|
|
175
|
+
process.stderr.write('OpenCard MCP server running on stdio\n');
|
|
176
|
+
}
|
|
177
|
+
// ── Auto-start when run directly ─────────────────────────────────────────────
|
|
178
|
+
// When this file is executed as `node dist/index.js`, start the server.
|
|
179
|
+
// When imported as a module, just export the functions.
|
|
180
|
+
if (require.main === module) {
|
|
181
|
+
startMcpServer().catch((err) => {
|
|
182
|
+
process.stderr.write(`Failed to start MCP server: ${err}\n`);
|
|
183
|
+
process.exit(1);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCard MCP Tool Definitions and Handlers
|
|
3
|
+
* ==================================== * Defines the MCP tool schemas and wires each tool to the real
|
|
4
|
+
* @opencard/core SDK so AI agents can manage virtual cards via MCP.
|
|
5
|
+
*
|
|
6
|
+
* ─── Architecture ────────────────────────────────────────────────────────────
|
|
7
|
+
*
|
|
8
|
+
* Each tool follows this pattern:
|
|
9
|
+
* 1. Extract + validate input args
|
|
10
|
+
* 2. Initialize StripeClient with the API key from env
|
|
11
|
+
* 3. Call the appropriate SDK method
|
|
12
|
+
* 4. Return a structured result or error object (never throw)
|
|
13
|
+
*
|
|
14
|
+
* ─── Error handling ──────────────────────────────────────────────────────────
|
|
15
|
+
*
|
|
16
|
+
* All handlers catch errors and return `{ status: 'error', message }` rather
|
|
17
|
+
* than throwing. This prevents the MCP server from crashing on Stripe API
|
|
18
|
+
* errors, network failures, or bad input. The caller decides what to do with
|
|
19
|
+
* the error.
|
|
20
|
+
*
|
|
21
|
+
* ─── Stripe key ──────────────────────────────────────────────────────────────
|
|
22
|
+
*
|
|
23
|
+
* The StripeClient reads STRIPE_SECRET_KEY from the environment by default.
|
|
24
|
+
* Callers can also pass it explicitly via the `stripe_secret_key` arg (useful
|
|
25
|
+
* when the MCP server is shared across multiple callers with different keys).
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* MCP Tool definition for OpenCard.
|
|
29
|
+
* These schemas are consumed by MCP-compatible agents to discover available tools.
|
|
30
|
+
*/
|
|
31
|
+
export declare const openCardTools: ({
|
|
32
|
+
name: string;
|
|
33
|
+
description: string;
|
|
34
|
+
inputSchema: {
|
|
35
|
+
type: string;
|
|
36
|
+
properties: {
|
|
37
|
+
agent_name: {
|
|
38
|
+
type: string;
|
|
39
|
+
description: string;
|
|
40
|
+
};
|
|
41
|
+
cardholder_id: {
|
|
42
|
+
type: string;
|
|
43
|
+
description: string;
|
|
44
|
+
};
|
|
45
|
+
rule_template: {
|
|
46
|
+
type: string;
|
|
47
|
+
enum: string[];
|
|
48
|
+
description: string;
|
|
49
|
+
};
|
|
50
|
+
daily_limit_cents: {
|
|
51
|
+
type: string;
|
|
52
|
+
description: string;
|
|
53
|
+
};
|
|
54
|
+
max_per_transaction_cents: {
|
|
55
|
+
type: string;
|
|
56
|
+
description: string;
|
|
57
|
+
};
|
|
58
|
+
description: {
|
|
59
|
+
type: string;
|
|
60
|
+
description: string;
|
|
61
|
+
};
|
|
62
|
+
metadata: {
|
|
63
|
+
type: string;
|
|
64
|
+
description: string;
|
|
65
|
+
};
|
|
66
|
+
card_id?: undefined;
|
|
67
|
+
limit?: undefined;
|
|
68
|
+
status?: undefined;
|
|
69
|
+
reason?: undefined;
|
|
70
|
+
monthly_limit_cents?: undefined;
|
|
71
|
+
per_tx_limit_cents?: undefined;
|
|
72
|
+
amount_cents?: undefined;
|
|
73
|
+
merchant_category?: undefined;
|
|
74
|
+
merchant_name?: undefined;
|
|
75
|
+
rule_id?: undefined;
|
|
76
|
+
timeout_seconds?: undefined;
|
|
77
|
+
};
|
|
78
|
+
required: string[];
|
|
79
|
+
};
|
|
80
|
+
} | {
|
|
81
|
+
name: string;
|
|
82
|
+
description: string;
|
|
83
|
+
inputSchema: {
|
|
84
|
+
type: string;
|
|
85
|
+
properties: {
|
|
86
|
+
card_id: {
|
|
87
|
+
type: string;
|
|
88
|
+
description: string;
|
|
89
|
+
};
|
|
90
|
+
agent_name?: undefined;
|
|
91
|
+
cardholder_id?: undefined;
|
|
92
|
+
rule_template?: undefined;
|
|
93
|
+
daily_limit_cents?: undefined;
|
|
94
|
+
max_per_transaction_cents?: undefined;
|
|
95
|
+
description?: undefined;
|
|
96
|
+
metadata?: undefined;
|
|
97
|
+
limit?: undefined;
|
|
98
|
+
status?: undefined;
|
|
99
|
+
reason?: undefined;
|
|
100
|
+
monthly_limit_cents?: undefined;
|
|
101
|
+
per_tx_limit_cents?: undefined;
|
|
102
|
+
amount_cents?: undefined;
|
|
103
|
+
merchant_category?: undefined;
|
|
104
|
+
merchant_name?: undefined;
|
|
105
|
+
rule_id?: undefined;
|
|
106
|
+
timeout_seconds?: undefined;
|
|
107
|
+
};
|
|
108
|
+
required: string[];
|
|
109
|
+
};
|
|
110
|
+
} | {
|
|
111
|
+
name: string;
|
|
112
|
+
description: string;
|
|
113
|
+
inputSchema: {
|
|
114
|
+
type: string;
|
|
115
|
+
properties: {
|
|
116
|
+
card_id: {
|
|
117
|
+
type: string;
|
|
118
|
+
description: string;
|
|
119
|
+
};
|
|
120
|
+
limit: {
|
|
121
|
+
type: string;
|
|
122
|
+
description: string;
|
|
123
|
+
};
|
|
124
|
+
status: {
|
|
125
|
+
type: string;
|
|
126
|
+
enum: string[];
|
|
127
|
+
description: string;
|
|
128
|
+
};
|
|
129
|
+
agent_name?: undefined;
|
|
130
|
+
cardholder_id?: undefined;
|
|
131
|
+
rule_template?: undefined;
|
|
132
|
+
daily_limit_cents?: undefined;
|
|
133
|
+
max_per_transaction_cents?: undefined;
|
|
134
|
+
description?: undefined;
|
|
135
|
+
metadata?: undefined;
|
|
136
|
+
reason?: undefined;
|
|
137
|
+
monthly_limit_cents?: undefined;
|
|
138
|
+
per_tx_limit_cents?: undefined;
|
|
139
|
+
amount_cents?: undefined;
|
|
140
|
+
merchant_category?: undefined;
|
|
141
|
+
merchant_name?: undefined;
|
|
142
|
+
rule_id?: undefined;
|
|
143
|
+
timeout_seconds?: undefined;
|
|
144
|
+
};
|
|
145
|
+
required: string[];
|
|
146
|
+
};
|
|
147
|
+
} | {
|
|
148
|
+
name: string;
|
|
149
|
+
description: string;
|
|
150
|
+
inputSchema: {
|
|
151
|
+
type: string;
|
|
152
|
+
properties: {
|
|
153
|
+
card_id: {
|
|
154
|
+
type: string;
|
|
155
|
+
description: string;
|
|
156
|
+
};
|
|
157
|
+
reason: {
|
|
158
|
+
type: string;
|
|
159
|
+
description: string;
|
|
160
|
+
};
|
|
161
|
+
agent_name?: undefined;
|
|
162
|
+
cardholder_id?: undefined;
|
|
163
|
+
rule_template?: undefined;
|
|
164
|
+
daily_limit_cents?: undefined;
|
|
165
|
+
max_per_transaction_cents?: undefined;
|
|
166
|
+
description?: undefined;
|
|
167
|
+
metadata?: undefined;
|
|
168
|
+
limit?: undefined;
|
|
169
|
+
status?: undefined;
|
|
170
|
+
monthly_limit_cents?: undefined;
|
|
171
|
+
per_tx_limit_cents?: undefined;
|
|
172
|
+
amount_cents?: undefined;
|
|
173
|
+
merchant_category?: undefined;
|
|
174
|
+
merchant_name?: undefined;
|
|
175
|
+
rule_id?: undefined;
|
|
176
|
+
timeout_seconds?: undefined;
|
|
177
|
+
};
|
|
178
|
+
required: string[];
|
|
179
|
+
};
|
|
180
|
+
} | {
|
|
181
|
+
name: string;
|
|
182
|
+
description: string;
|
|
183
|
+
inputSchema: {
|
|
184
|
+
type: string;
|
|
185
|
+
properties: {
|
|
186
|
+
card_id: {
|
|
187
|
+
type: string;
|
|
188
|
+
description: string;
|
|
189
|
+
};
|
|
190
|
+
daily_limit_cents: {
|
|
191
|
+
type: string;
|
|
192
|
+
description: string;
|
|
193
|
+
};
|
|
194
|
+
monthly_limit_cents: {
|
|
195
|
+
type: string;
|
|
196
|
+
description: string;
|
|
197
|
+
};
|
|
198
|
+
per_tx_limit_cents: {
|
|
199
|
+
type: string;
|
|
200
|
+
description: string;
|
|
201
|
+
};
|
|
202
|
+
agent_name?: undefined;
|
|
203
|
+
cardholder_id?: undefined;
|
|
204
|
+
rule_template?: undefined;
|
|
205
|
+
max_per_transaction_cents?: undefined;
|
|
206
|
+
description?: undefined;
|
|
207
|
+
metadata?: undefined;
|
|
208
|
+
limit?: undefined;
|
|
209
|
+
status?: undefined;
|
|
210
|
+
reason?: undefined;
|
|
211
|
+
amount_cents?: undefined;
|
|
212
|
+
merchant_category?: undefined;
|
|
213
|
+
merchant_name?: undefined;
|
|
214
|
+
rule_id?: undefined;
|
|
215
|
+
timeout_seconds?: undefined;
|
|
216
|
+
};
|
|
217
|
+
required: string[];
|
|
218
|
+
};
|
|
219
|
+
} | {
|
|
220
|
+
name: string;
|
|
221
|
+
description: string;
|
|
222
|
+
inputSchema: {
|
|
223
|
+
type: string;
|
|
224
|
+
properties: {
|
|
225
|
+
status: {
|
|
226
|
+
type: string;
|
|
227
|
+
enum: string[];
|
|
228
|
+
description: string;
|
|
229
|
+
};
|
|
230
|
+
limit: {
|
|
231
|
+
type: string;
|
|
232
|
+
description: string;
|
|
233
|
+
};
|
|
234
|
+
agent_name?: undefined;
|
|
235
|
+
cardholder_id?: undefined;
|
|
236
|
+
rule_template?: undefined;
|
|
237
|
+
daily_limit_cents?: undefined;
|
|
238
|
+
max_per_transaction_cents?: undefined;
|
|
239
|
+
description?: undefined;
|
|
240
|
+
metadata?: undefined;
|
|
241
|
+
card_id?: undefined;
|
|
242
|
+
reason?: undefined;
|
|
243
|
+
monthly_limit_cents?: undefined;
|
|
244
|
+
per_tx_limit_cents?: undefined;
|
|
245
|
+
amount_cents?: undefined;
|
|
246
|
+
merchant_category?: undefined;
|
|
247
|
+
merchant_name?: undefined;
|
|
248
|
+
rule_id?: undefined;
|
|
249
|
+
timeout_seconds?: undefined;
|
|
250
|
+
};
|
|
251
|
+
required: never[];
|
|
252
|
+
};
|
|
253
|
+
} | {
|
|
254
|
+
name: string;
|
|
255
|
+
description: string;
|
|
256
|
+
inputSchema: {
|
|
257
|
+
type: string;
|
|
258
|
+
properties: {
|
|
259
|
+
card_id: {
|
|
260
|
+
type: string;
|
|
261
|
+
description: string;
|
|
262
|
+
};
|
|
263
|
+
amount_cents: {
|
|
264
|
+
type: string;
|
|
265
|
+
description: string;
|
|
266
|
+
};
|
|
267
|
+
merchant_category: {
|
|
268
|
+
type: string;
|
|
269
|
+
description: string;
|
|
270
|
+
};
|
|
271
|
+
merchant_name: {
|
|
272
|
+
type: string;
|
|
273
|
+
description: string;
|
|
274
|
+
};
|
|
275
|
+
rule_id: {
|
|
276
|
+
type: string;
|
|
277
|
+
description: string;
|
|
278
|
+
};
|
|
279
|
+
agent_name?: undefined;
|
|
280
|
+
cardholder_id?: undefined;
|
|
281
|
+
rule_template?: undefined;
|
|
282
|
+
daily_limit_cents?: undefined;
|
|
283
|
+
max_per_transaction_cents?: undefined;
|
|
284
|
+
description?: undefined;
|
|
285
|
+
metadata?: undefined;
|
|
286
|
+
limit?: undefined;
|
|
287
|
+
status?: undefined;
|
|
288
|
+
reason?: undefined;
|
|
289
|
+
monthly_limit_cents?: undefined;
|
|
290
|
+
per_tx_limit_cents?: undefined;
|
|
291
|
+
timeout_seconds?: undefined;
|
|
292
|
+
};
|
|
293
|
+
required: string[];
|
|
294
|
+
};
|
|
295
|
+
} | {
|
|
296
|
+
name: string;
|
|
297
|
+
description: string;
|
|
298
|
+
inputSchema: {
|
|
299
|
+
type: string;
|
|
300
|
+
properties: {
|
|
301
|
+
card_id: {
|
|
302
|
+
type: string;
|
|
303
|
+
description: string;
|
|
304
|
+
};
|
|
305
|
+
amount_cents: {
|
|
306
|
+
type: string;
|
|
307
|
+
description: string;
|
|
308
|
+
};
|
|
309
|
+
merchant_name: {
|
|
310
|
+
type: string;
|
|
311
|
+
description: string;
|
|
312
|
+
};
|
|
313
|
+
merchant_category: {
|
|
314
|
+
type: string;
|
|
315
|
+
description: string;
|
|
316
|
+
};
|
|
317
|
+
reason: {
|
|
318
|
+
type: string;
|
|
319
|
+
description: string;
|
|
320
|
+
};
|
|
321
|
+
timeout_seconds: {
|
|
322
|
+
type: string;
|
|
323
|
+
description: string;
|
|
324
|
+
};
|
|
325
|
+
agent_name?: undefined;
|
|
326
|
+
cardholder_id?: undefined;
|
|
327
|
+
rule_template?: undefined;
|
|
328
|
+
daily_limit_cents?: undefined;
|
|
329
|
+
max_per_transaction_cents?: undefined;
|
|
330
|
+
description?: undefined;
|
|
331
|
+
metadata?: undefined;
|
|
332
|
+
limit?: undefined;
|
|
333
|
+
status?: undefined;
|
|
334
|
+
monthly_limit_cents?: undefined;
|
|
335
|
+
per_tx_limit_cents?: undefined;
|
|
336
|
+
rule_id?: undefined;
|
|
337
|
+
};
|
|
338
|
+
required: string[];
|
|
339
|
+
};
|
|
340
|
+
})[];
|
|
341
|
+
/**
|
|
342
|
+
* Routes an MCP tool call to the appropriate handler and returns the result.
|
|
343
|
+
*
|
|
344
|
+
* All handlers are async and catch their own errors — this function will
|
|
345
|
+
* always return a result object, never throw. Unknown tool names return an
|
|
346
|
+
* error result rather than crashing.
|
|
347
|
+
*
|
|
348
|
+
* @param toolName - The MCP tool name (e.g. 'opencard_create_card')
|
|
349
|
+
* @param args - The tool's input arguments from the MCP request
|
|
350
|
+
* @returns A result object. Structure varies per tool; always includes `status`.
|
|
351
|
+
*/
|
|
352
|
+
export declare function createToolHandler(toolName: string, args: Record<string, unknown>): Promise<unknown>;
|
|
353
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAQH;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA+OzB,CAAC;AAIF;;;;;;;;;;GAUG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,OAAO,CAAC,CAsClB"}
|