@coffrify/mcp 0.2.0 → 0.3.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/server.js +77 -4
- package/package.json +2 -2
package/dist/server.js
CHANGED
|
@@ -20,9 +20,11 @@ if (!apiKey) {
|
|
|
20
20
|
}
|
|
21
21
|
var coffrify = new Coffrify({ apiKey, apiUrl });
|
|
22
22
|
var server = new Server(
|
|
23
|
-
{ name: "coffrify", version: "0.
|
|
23
|
+
{ name: "coffrify", version: "0.3.0" },
|
|
24
24
|
{ capabilities: { tools: {}, resources: {}, prompts: {} } }
|
|
25
25
|
);
|
|
26
|
+
var disabledBuiltinTools = /* @__PURE__ */ new Set();
|
|
27
|
+
var customActionsByName = /* @__PURE__ */ new Map();
|
|
26
28
|
var eventEnum = COFFRIFY_EVENT_CATALOG.map((e) => e.type);
|
|
27
29
|
var TOOLS = [
|
|
28
30
|
{
|
|
@@ -368,7 +370,46 @@ Print the returned signing secret to the user \u2014 it's shown only once.`
|
|
|
368
370
|
throw new Error(`Unknown prompt: ${name}`);
|
|
369
371
|
}
|
|
370
372
|
});
|
|
371
|
-
server.setRequestHandler(ListToolsRequestSchema, async () =>
|
|
373
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
374
|
+
const enabledBuiltins = TOOLS.filter((t) => !disabledBuiltinTools.has(t.name));
|
|
375
|
+
const customTools = [...customActionsByName.values()].map((a) => ({
|
|
376
|
+
name: a.name,
|
|
377
|
+
description: a.runtime_kind === "typescript" ? `[TS, awaiting v0.4 runtime] ${a.description}` : a.description,
|
|
378
|
+
inputSchema: a.input_schema
|
|
379
|
+
}));
|
|
380
|
+
return { tools: [...enabledBuiltins, ...customTools] };
|
|
381
|
+
});
|
|
382
|
+
async function invokeCustomAction(action, input) {
|
|
383
|
+
if (action.runtime_kind === "typescript") {
|
|
384
|
+
return {
|
|
385
|
+
_stub: true,
|
|
386
|
+
message: "TypeScript runtime arrives in @coffrify/mcp v0.4.0 (Vercel Sandbox). Code persisted in DB but not executed yet.",
|
|
387
|
+
action_name: action.name,
|
|
388
|
+
received_input: input
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
let path = action.endpoint_path;
|
|
392
|
+
const queryParams = {};
|
|
393
|
+
let body = null;
|
|
394
|
+
for (const mapping of action.param_mapping ?? []) {
|
|
395
|
+
const value = input[mapping.name];
|
|
396
|
+
if (value === void 0 || value === null) continue;
|
|
397
|
+
if (mapping.source === "path") {
|
|
398
|
+
path = path.replace(`{${mapping.name}}`, encodeURIComponent(String(value)));
|
|
399
|
+
} else if (mapping.source === "query") {
|
|
400
|
+
queryParams[mapping.name] = String(value);
|
|
401
|
+
} else if (mapping.source === "body") {
|
|
402
|
+
body = body ?? {};
|
|
403
|
+
body[mapping.name] = value;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
if (Object.keys(queryParams).length > 0) {
|
|
407
|
+
const qs = new URLSearchParams(queryParams).toString();
|
|
408
|
+
path = `${path}${path.includes("?") ? "&" : "?"}${qs}`;
|
|
409
|
+
}
|
|
410
|
+
const trimmedPath = path.replace(/^\/v1/, "") || "/";
|
|
411
|
+
return await coffrify.http.request(action.endpoint_method, trimmedPath, body ?? void 0);
|
|
412
|
+
}
|
|
372
413
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
373
414
|
const { name, arguments: args = {} } = request.params;
|
|
374
415
|
try {
|
|
@@ -471,8 +512,14 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
471
512
|
case "coffrify_get_workspace_info":
|
|
472
513
|
result = await coffrify.http.request("GET", "/me");
|
|
473
514
|
break;
|
|
474
|
-
default:
|
|
515
|
+
default: {
|
|
516
|
+
const custom = customActionsByName.get(name);
|
|
517
|
+
if (custom) {
|
|
518
|
+
result = await invokeCustomAction(custom, a);
|
|
519
|
+
break;
|
|
520
|
+
}
|
|
475
521
|
throw new Error(`Unknown tool: ${name}`);
|
|
522
|
+
}
|
|
476
523
|
}
|
|
477
524
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
478
525
|
} catch (e) {
|
|
@@ -486,6 +533,32 @@ ${JSON.stringify(e?.details ?? {}, null, 2)}`
|
|
|
486
533
|
};
|
|
487
534
|
}
|
|
488
535
|
});
|
|
536
|
+
async function bootstrapWorkspaceConfig() {
|
|
537
|
+
const httpClient = coffrify.http;
|
|
538
|
+
try {
|
|
539
|
+
const toolsRes = await httpClient.request("GET", "/mcp/tools");
|
|
540
|
+
for (const t of toolsRes?.data ?? []) {
|
|
541
|
+
if (t.disabled) disabledBuiltinTools.add(t.name);
|
|
542
|
+
}
|
|
543
|
+
} catch (e) {
|
|
544
|
+
const msg = e?.message ?? String(e);
|
|
545
|
+
console.error(`[coffrify-mcp] bootstrap: tool-overrides fetch failed (${msg}). Continuing with all builtins enabled.`);
|
|
546
|
+
}
|
|
547
|
+
try {
|
|
548
|
+
const actionsRes = await httpClient.request("GET", "/mcp/custom-actions");
|
|
549
|
+
for (const a of actionsRes?.data ?? []) {
|
|
550
|
+
if (a.is_active) customActionsByName.set(a.name, a);
|
|
551
|
+
}
|
|
552
|
+
} catch (e) {
|
|
553
|
+
const msg = e?.message ?? String(e);
|
|
554
|
+
console.error(`[coffrify-mcp] bootstrap: custom-actions fetch failed (${msg}). Continuing with builtins only.`);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
await bootstrapWorkspaceConfig();
|
|
489
558
|
var transport = new StdioServerTransport();
|
|
490
559
|
await server.connect(transport);
|
|
491
|
-
|
|
560
|
+
var enabledBuiltinCount = TOOLS.filter((t) => !disabledBuiltinTools.has(t.name)).length;
|
|
561
|
+
var customCount = customActionsByName.size;
|
|
562
|
+
console.error(
|
|
563
|
+
`[coffrify-mcp] v0.3.0 connected via stdio \u2014 ${enabledBuiltinCount}/${TOOLS.length} builtins enabled, ${customCount} custom action${customCount === 1 ? "" : "s"}.`
|
|
564
|
+
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coffrify/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Coffrify MCP server — gives Claude/Cursor/Windsurf agents direct access to Coffrify (transfers, webhooks, audit, API keys).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
31
31
|
"zod": "^3.23.8",
|
|
32
|
-
"@coffrify/sdk": "0.
|
|
32
|
+
"@coffrify/sdk": "0.5.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/node": "^22.0.0",
|