@withpica/mcp-server 2.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/README.md +305 -0
- package/dist/config.d.ts +34 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +33 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/pica-sdk.d.ts +1162 -0
- package/dist/pica-sdk.d.ts.map +1 -0
- package/dist/pica-sdk.js +1371 -0
- package/dist/pica-sdk.js.map +1 -0
- package/dist/prompts/index.d.ts +78 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +513 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/resources/index.d.ts +64 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +310 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/resources/llms-primer.d.ts +2 -0
- package/dist/resources/llms-primer.d.ts.map +1 -0
- package/dist/resources/llms-primer.js +67 -0
- package/dist/resources/llms-primer.js.map +1 -0
- package/dist/server.d.ts +27 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +140 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/agreement-types.d.ts +37 -0
- package/dist/tools/agreement-types.d.ts.map +1 -0
- package/dist/tools/agreement-types.js +579 -0
- package/dist/tools/agreement-types.js.map +1 -0
- package/dist/tools/agreements.d.ts +21 -0
- package/dist/tools/agreements.d.ts.map +1 -0
- package/dist/tools/agreements.js +328 -0
- package/dist/tools/agreements.js.map +1 -0
- package/dist/tools/analytics.d.ts +20 -0
- package/dist/tools/analytics.d.ts.map +1 -0
- package/dist/tools/analytics.js +126 -0
- package/dist/tools/analytics.js.map +1 -0
- package/dist/tools/assets.d.ts +23 -0
- package/dist/tools/assets.d.ts.map +1 -0
- package/dist/tools/assets.js +220 -0
- package/dist/tools/assets.js.map +1 -0
- package/dist/tools/audio-files.d.ts +21 -0
- package/dist/tools/audio-files.d.ts.map +1 -0
- package/dist/tools/audio-files.js +358 -0
- package/dist/tools/audio-files.js.map +1 -0
- package/dist/tools/bulk.d.ts +16 -0
- package/dist/tools/bulk.d.ts.map +1 -0
- package/dist/tools/bulk.js +82 -0
- package/dist/tools/bulk.js.map +1 -0
- package/dist/tools/calendar.d.ts +15 -0
- package/dist/tools/calendar.d.ts.map +1 -0
- package/dist/tools/calendar.js +69 -0
- package/dist/tools/calendar.js.map +1 -0
- package/dist/tools/collaborators.d.ts +17 -0
- package/dist/tools/collaborators.d.ts.map +1 -0
- package/dist/tools/collaborators.js +133 -0
- package/dist/tools/collaborators.js.map +1 -0
- package/dist/tools/comparisons.d.ts +22 -0
- package/dist/tools/comparisons.d.ts.map +1 -0
- package/dist/tools/comparisons.js +86 -0
- package/dist/tools/comparisons.js.map +1 -0
- package/dist/tools/credits.d.ts +17 -0
- package/dist/tools/credits.d.ts.map +1 -0
- package/dist/tools/credits.js +136 -0
- package/dist/tools/credits.js.map +1 -0
- package/dist/tools/dashboard.d.ts +20 -0
- package/dist/tools/dashboard.d.ts.map +1 -0
- package/dist/tools/dashboard.js +156 -0
- package/dist/tools/dashboard.js.map +1 -0
- package/dist/tools/directory.d.ts +15 -0
- package/dist/tools/directory.d.ts.map +1 -0
- package/dist/tools/directory.js +108 -0
- package/dist/tools/directory.js.map +1 -0
- package/dist/tools/disputes.d.ts +18 -0
- package/dist/tools/disputes.d.ts.map +1 -0
- package/dist/tools/disputes.js +66 -0
- package/dist/tools/disputes.js.map +1 -0
- package/dist/tools/documents.d.ts +15 -0
- package/dist/tools/documents.d.ts.map +1 -0
- package/dist/tools/documents.js +38 -0
- package/dist/tools/documents.js.map +1 -0
- package/dist/tools/duplicates.d.ts +16 -0
- package/dist/tools/duplicates.d.ts.map +1 -0
- package/dist/tools/duplicates.js +72 -0
- package/dist/tools/duplicates.js.map +1 -0
- package/dist/tools/enrichment.d.ts +23 -0
- package/dist/tools/enrichment.d.ts.map +1 -0
- package/dist/tools/enrichment.js +207 -0
- package/dist/tools/enrichment.js.map +1 -0
- package/dist/tools/exports.d.ts +19 -0
- package/dist/tools/exports.d.ts.map +1 -0
- package/dist/tools/exports.js +155 -0
- package/dist/tools/exports.js.map +1 -0
- package/dist/tools/health.d.ts +17 -0
- package/dist/tools/health.d.ts.map +1 -0
- package/dist/tools/health.js +69 -0
- package/dist/tools/health.js.map +1 -0
- package/dist/tools/import-documents.d.ts +21 -0
- package/dist/tools/import-documents.d.ts.map +1 -0
- package/dist/tools/import-documents.js +191 -0
- package/dist/tools/import-documents.js.map +1 -0
- package/dist/tools/import.d.ts +29 -0
- package/dist/tools/import.d.ts.map +1 -0
- package/dist/tools/import.js +404 -0
- package/dist/tools/import.js.map +1 -0
- package/dist/tools/index.d.ts +48 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +394 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/integrations.d.ts +15 -0
- package/dist/tools/integrations.d.ts.map +1 -0
- package/dist/tools/integrations.js +102 -0
- package/dist/tools/integrations.js.map +1 -0
- package/dist/tools/licensing.d.ts +40 -0
- package/dist/tools/licensing.d.ts.map +1 -0
- package/dist/tools/licensing.js +436 -0
- package/dist/tools/licensing.js.map +1 -0
- package/dist/tools/memory.d.ts +21 -0
- package/dist/tools/memory.d.ts.map +1 -0
- package/dist/tools/memory.js +121 -0
- package/dist/tools/memory.js.map +1 -0
- package/dist/tools/multimedia.d.ts +19 -0
- package/dist/tools/multimedia.d.ts.map +1 -0
- package/dist/tools/multimedia.js +293 -0
- package/dist/tools/multimedia.js.map +1 -0
- package/dist/tools/notes.d.ts +21 -0
- package/dist/tools/notes.d.ts.map +1 -0
- package/dist/tools/notes.js +126 -0
- package/dist/tools/notes.js.map +1 -0
- package/dist/tools/notifications.d.ts +17 -0
- package/dist/tools/notifications.d.ts.map +1 -0
- package/dist/tools/notifications.js +117 -0
- package/dist/tools/notifications.js.map +1 -0
- package/dist/tools/people.d.ts +53 -0
- package/dist/tools/people.d.ts.map +1 -0
- package/dist/tools/people.js +534 -0
- package/dist/tools/people.js.map +1 -0
- package/dist/tools/pica-score.d.ts +15 -0
- package/dist/tools/pica-score.d.ts.map +1 -0
- package/dist/tools/pica-score.js +30 -0
- package/dist/tools/pica-score.js.map +1 -0
- package/dist/tools/projects.d.ts +19 -0
- package/dist/tools/projects.d.ts.map +1 -0
- package/dist/tools/projects.js +142 -0
- package/dist/tools/projects.js.map +1 -0
- package/dist/tools/purchases.d.ts +15 -0
- package/dist/tools/purchases.d.ts.map +1 -0
- package/dist/tools/purchases.js +65 -0
- package/dist/tools/purchases.js.map +1 -0
- package/dist/tools/recordings.d.ts +41 -0
- package/dist/tools/recordings.d.ts.map +1 -0
- package/dist/tools/recordings.js +293 -0
- package/dist/tools/recordings.js.map +1 -0
- package/dist/tools/registration.d.ts +16 -0
- package/dist/tools/registration.d.ts.map +1 -0
- package/dist/tools/registration.js +52 -0
- package/dist/tools/registration.js.map +1 -0
- package/dist/tools/releases.d.ts +18 -0
- package/dist/tools/releases.d.ts.map +1 -0
- package/dist/tools/releases.js +138 -0
- package/dist/tools/releases.js.map +1 -0
- package/dist/tools/royalties.d.ts +23 -0
- package/dist/tools/royalties.d.ts.map +1 -0
- package/dist/tools/royalties.js +263 -0
- package/dist/tools/royalties.js.map +1 -0
- package/dist/tools/search.d.ts +30 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +117 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/send.d.ts +18 -0
- package/dist/tools/send.d.ts.map +1 -0
- package/dist/tools/send.js +189 -0
- package/dist/tools/send.js.map +1 -0
- package/dist/tools/sessions.d.ts +18 -0
- package/dist/tools/sessions.d.ts.map +1 -0
- package/dist/tools/sessions.js +107 -0
- package/dist/tools/sessions.js.map +1 -0
- package/dist/tools/settings.d.ts +18 -0
- package/dist/tools/settings.d.ts.map +1 -0
- package/dist/tools/settings.js +98 -0
- package/dist/tools/settings.js.map +1 -0
- package/dist/tools/share-links.d.ts +19 -0
- package/dist/tools/share-links.d.ts.map +1 -0
- package/dist/tools/share-links.js +126 -0
- package/dist/tools/share-links.js.map +1 -0
- package/dist/tools/split-sheets.d.ts +24 -0
- package/dist/tools/split-sheets.d.ts.map +1 -0
- package/dist/tools/split-sheets.js +189 -0
- package/dist/tools/split-sheets.js.map +1 -0
- package/dist/tools/team.d.ts +22 -0
- package/dist/tools/team.d.ts.map +1 -0
- package/dist/tools/team.js +139 -0
- package/dist/tools/team.js.map +1 -0
- package/dist/tools/telegram.d.ts +20 -0
- package/dist/tools/telegram.d.ts.map +1 -0
- package/dist/tools/telegram.js +94 -0
- package/dist/tools/telegram.js.map +1 -0
- package/dist/tools/uploads.d.ts +17 -0
- package/dist/tools/uploads.d.ts.map +1 -0
- package/dist/tools/uploads.js +159 -0
- package/dist/tools/uploads.js.map +1 -0
- package/dist/tools/works.d.ts +53 -0
- package/dist/tools/works.d.ts.map +1 -0
- package/dist/tools/works.js +517 -0
- package/dist/tools/works.js.map +1 -0
- package/dist/utils/credit-gate.d.ts +17 -0
- package/dist/utils/credit-gate.d.ts.map +1 -0
- package/dist/utils/credit-gate.js +111 -0
- package/dist/utils/credit-gate.js.map +1 -0
- package/dist/utils/errors.d.ts +29 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +114 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/formatting.d.ts +63 -0
- package/dist/utils/formatting.d.ts.map +1 -0
- package/dist/utils/formatting.js +130 -0
- package/dist/utils/formatting.js.map +1 -0
- package/dist/utils/mpp.d.ts +78 -0
- package/dist/utils/mpp.d.ts.map +1 -0
- package/dist/utils/mpp.js +136 -0
- package/dist/utils/mpp.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credit-gate.js","sourceRoot":"","sources":["../../src/utils/credit-gate.ts"],"names":[],"mapp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,MAAM,SAAS,GAAG,eAAe,EAAE;YACjC,CAAC,CAAC,KAAK,cAAc,CAAC,IAAI,CAAC,sBAAsB;YACjD,CAAC,CAAC,EAAE,CAAC;QAEP,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;wBACE,KAAK,EAAE,sBAAsB;wBAC7B,OAAO,EAAE,GAAG,aAAa,UAAU,IAAI,eAAe,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,uBAAuB,SAAS,uCAAuC,SAAS,EAAE;wBAC7J,OAAO,EAAE,SAAS;wBAClB,IAAI;wBACJ,MAAM,EAAE,SAAS;wBACjB,aAAa,EACX,qFAAqF;wBACvF,YAAY,EAAE,2CAA2C;qBAC1D,EACD,IAAI,EACJ,CAAC,CACF;iBACF;aACF;YACD,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error handling utilities for MCP server
|
|
3
|
+
*/
|
|
4
|
+
export declare class McpServerError extends Error {
|
|
5
|
+
code: string;
|
|
6
|
+
details?: any | undefined;
|
|
7
|
+
constructor(message: string, code: string, details?: any | undefined);
|
|
8
|
+
}
|
|
9
|
+
export declare class AuthenticationError extends McpServerError {
|
|
10
|
+
constructor(message?: string, details?: any);
|
|
11
|
+
}
|
|
12
|
+
export declare class ToolExecutionError extends McpServerError {
|
|
13
|
+
constructor(message: string, details?: any);
|
|
14
|
+
}
|
|
15
|
+
export declare class ResourceError extends McpServerError {
|
|
16
|
+
constructor(message: string, details?: any);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Format error for MCP response
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatError(error: any): {
|
|
22
|
+
type: string;
|
|
23
|
+
text: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Log error with structured context (JSON to stderr for machine parsing)
|
|
27
|
+
*/
|
|
28
|
+
export declare function logError(context: string, error: any): void;
|
|
29
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAa,cAAe,SAAQ,KAAK;IAG9B,IAAI,EAAE,MAAM;IACZ,OAAO,CAAC,EAAE,GAAG;gBAFpB,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,GAAG,YAAA;CAMvB;AAED,qBAAa,mBAAoB,SAAQ,cAAc;gBACzC,OAAO,GAAE,MAAgC,EAAE,OAAO,CAAC,EAAE,GAAG;CAIrE;AAED,qBAAa,kBAAmB,SAAQ,cAAc;gBACxC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;CAI3C;AAED,qBAAa,aAAc,SAAQ,cAAc;gBACnC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;CAI3C;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CA6FtE;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAc1D"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error handling utilities for MCP server
|
|
3
|
+
*/
|
|
4
|
+
export class McpServerError extends Error {
|
|
5
|
+
code;
|
|
6
|
+
details;
|
|
7
|
+
constructor(message, code, details) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.details = details;
|
|
11
|
+
this.name = "McpServerError";
|
|
12
|
+
Object.setPrototypeOf(this, McpServerError.prototype);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export class AuthenticationError extends McpServerError {
|
|
16
|
+
constructor(message = "Authentication failed", details) {
|
|
17
|
+
super(message, "AUTHENTICATION_ERROR", details);
|
|
18
|
+
this.name = "AuthenticationError";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export class ToolExecutionError extends McpServerError {
|
|
22
|
+
constructor(message, details) {
|
|
23
|
+
super(message, "TOOL_EXECUTION_ERROR", details);
|
|
24
|
+
this.name = "ToolExecutionError";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export class ResourceError extends McpServerError {
|
|
28
|
+
constructor(message, details) {
|
|
29
|
+
super(message, "RESOURCE_ERROR", details);
|
|
30
|
+
this.name = "ResourceError";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Format error for MCP response
|
|
35
|
+
*/
|
|
36
|
+
export function formatError(error) {
|
|
37
|
+
if (error instanceof McpServerError) {
|
|
38
|
+
return {
|
|
39
|
+
type: "text",
|
|
40
|
+
text: JSON.stringify({
|
|
41
|
+
error: error.code,
|
|
42
|
+
message: error.message,
|
|
43
|
+
details: error.details,
|
|
44
|
+
}, null, 2),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// Classify ApiError from SDK layer
|
|
48
|
+
const status = error?.status;
|
|
49
|
+
if (status === 0 ||
|
|
50
|
+
(error instanceof Error && error.message?.includes("timed out"))) {
|
|
51
|
+
return {
|
|
52
|
+
type: "text",
|
|
53
|
+
text: JSON.stringify({
|
|
54
|
+
error: "REQUEST_TIMEOUT",
|
|
55
|
+
message: "API request timed out after retries. The server may be slow or unreachable.",
|
|
56
|
+
}, null, 2),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
if (status === 401 || status === 403) {
|
|
60
|
+
return {
|
|
61
|
+
type: "text",
|
|
62
|
+
text: JSON.stringify({
|
|
63
|
+
error: "AUTHENTICATION_ERROR",
|
|
64
|
+
message: "API authentication failed. Check your PICA_API_KEY is valid.",
|
|
65
|
+
status,
|
|
66
|
+
}, null, 2),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
if (status === 429) {
|
|
70
|
+
return {
|
|
71
|
+
type: "text",
|
|
72
|
+
text: JSON.stringify({
|
|
73
|
+
error: "RATE_LIMITED",
|
|
74
|
+
message: "API rate limit exceeded after retries. Try again in a moment.",
|
|
75
|
+
status,
|
|
76
|
+
}, null, 2),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (error instanceof Error) {
|
|
80
|
+
return {
|
|
81
|
+
type: "text",
|
|
82
|
+
text: JSON.stringify({
|
|
83
|
+
error: "UNKNOWN_ERROR",
|
|
84
|
+
message: error.message,
|
|
85
|
+
}, null, 2),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
type: "text",
|
|
90
|
+
text: JSON.stringify({
|
|
91
|
+
error: "UNKNOWN_ERROR",
|
|
92
|
+
message: String(error),
|
|
93
|
+
}, null, 2),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Log error with structured context (JSON to stderr for machine parsing)
|
|
98
|
+
*/
|
|
99
|
+
export function logError(context, error) {
|
|
100
|
+
const entry = {
|
|
101
|
+
level: "error",
|
|
102
|
+
context,
|
|
103
|
+
message: error instanceof Error ? error.message : String(error),
|
|
104
|
+
timestamp: new Date().toISOString(),
|
|
105
|
+
};
|
|
106
|
+
if (error?.status)
|
|
107
|
+
entry.status = error.status;
|
|
108
|
+
if (error?.retryable !== undefined)
|
|
109
|
+
entry.retryable = error.retryable;
|
|
110
|
+
if (error instanceof Error && error.stack)
|
|
111
|
+
entry.stack = error.stack;
|
|
112
|
+
console.error(JSON.stringify(entry));
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../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AC,SAAS,CAClB;YACE,KAAK,EAAE,eAAe;YACtB,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC;SACvB,EACD,IAAI,EACJ,CAAC,CACF;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAe,EAAE,KAAU;IAClD,MAAM,KAAK,GAA4B;QACrC,KAAK,EAAE,OAAO;QACd,OAAO;QACP,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QAC/D,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACpC,CAAC;IAEF,IAAK,KAAa,EAAE,MAAM;QAAE,KAAK,CAAC,MAAM,GAAI,KAAa,CAAC,MAAM,CAAC;IACjE,IAAK,KAAa,EAAE,SAAS,KAAK,SAAS;QACzC,KAAK,CAAC,SAAS,GAAI,KAAa,CAAC,SAAS,CAAC;IAC7C,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,KAAK;QAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAErE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Response formatting utilities
|
|
3
|
+
*
|
|
4
|
+
* All formatters return FormattedResult — both human-readable text content
|
|
5
|
+
* AND a structuredContent object for machine parsing (ADR-104 §1.2).
|
|
6
|
+
*/
|
|
7
|
+
export interface FormattedResult {
|
|
8
|
+
content: Array<{
|
|
9
|
+
type: string;
|
|
10
|
+
text: string;
|
|
11
|
+
}>;
|
|
12
|
+
structuredContent?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Format data as JSON text for MCP response
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatAsText(data: any): FormattedResult;
|
|
18
|
+
/**
|
|
19
|
+
* Completion hint — tells the LLM what's missing on entities just touched.
|
|
20
|
+
* The LLM decides whether and how to surface these to the user.
|
|
21
|
+
*/
|
|
22
|
+
export interface CompletionHint {
|
|
23
|
+
gap: string;
|
|
24
|
+
suggestion: string;
|
|
25
|
+
count?: number;
|
|
26
|
+
severity?: "critical" | "important" | "nice_to_have";
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Format success message, with optional completion hints for the guided loop.
|
|
30
|
+
*
|
|
31
|
+
* Completion hints are structured data appended to the response so the LLM
|
|
32
|
+
* can naturally suggest the next step without PICA dictating the conversation.
|
|
33
|
+
* If no hints are provided, the response is identical to the old format.
|
|
34
|
+
*/
|
|
35
|
+
export declare function formatSuccess(message: string, data?: any, completionHints?: CompletionHint[]): FormattedResult;
|
|
36
|
+
/**
|
|
37
|
+
* Map raw gap objects from the completeness API into CompletionHints.
|
|
38
|
+
* The API response shape varies — this handles the known field names.
|
|
39
|
+
*/
|
|
40
|
+
export declare function mapGapsToHints(gaps: any[], limit?: number): CompletionHint[];
|
|
41
|
+
/**
|
|
42
|
+
* Format array of items with count
|
|
43
|
+
*/
|
|
44
|
+
export declare function formatList<T>(items: T[], metadata?: Record<string, any>): FormattedResult;
|
|
45
|
+
/**
|
|
46
|
+
* Truncate text to max length
|
|
47
|
+
*/
|
|
48
|
+
export declare function truncate(text: string, maxLength?: number): string;
|
|
49
|
+
/**
|
|
50
|
+
* Format validation error
|
|
51
|
+
*/
|
|
52
|
+
export declare function formatValidationError(fields: Record<string, string>): FormattedResult;
|
|
53
|
+
/**
|
|
54
|
+
* Format structured response with dual content blocks:
|
|
55
|
+
* - Human-readable text (includes full JSON so all MCP clients can read it)
|
|
56
|
+
* - Machine-parseable structuredContent object
|
|
57
|
+
*/
|
|
58
|
+
export declare function formatStructured(data: any, summary?: string): FormattedResult;
|
|
59
|
+
/**
|
|
60
|
+
* Format a list with both human summary and structured JSON
|
|
61
|
+
*/
|
|
62
|
+
export declare function formatStructuredList<T>(items: T[], entityName: string, metadata?: Record<string, any>): FormattedResult;
|
|
63
|
+
//# sourceMappingURL=formatting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../src/utils/formatting.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7C;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,GAAG,GAAG,eAAe,CAKvD;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,UAAU,GAAG,WAAW,GAAG,cAAc,CAAC;CACtD;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,GAAG,EACV,eAAe,CAAC,EAAE,cAAc,EAAE,GACjC,eAAe,CA0BjB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,GAAG,EAAE,EACX,KAAK,GAAE,MAAU,GAChB,cAAc,EAAE,CAOlB;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAC1B,KAAK,EAAE,CAAC,EAAE,EACV,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC7B,eAAe,CAsBjB;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,MAAa,GAAG,MAAM,CAKvE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,eAAe,CAWjB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,eAAe,CAW7E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,KAAK,EAAE,CAAC,EAAE,EACV,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC7B,eAAe,CAOjB"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Response formatting utilities
|
|
3
|
+
*
|
|
4
|
+
* All formatters return FormattedResult — both human-readable text content
|
|
5
|
+
* AND a structuredContent object for machine parsing (ADR-104 §1.2).
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Format data as JSON text for MCP response
|
|
9
|
+
*/
|
|
10
|
+
export function formatAsText(data) {
|
|
11
|
+
return {
|
|
12
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
13
|
+
structuredContent: data,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Format success message, with optional completion hints for the guided loop.
|
|
18
|
+
*
|
|
19
|
+
* Completion hints are structured data appended to the response so the LLM
|
|
20
|
+
* can naturally suggest the next step without PICA dictating the conversation.
|
|
21
|
+
* If no hints are provided, the response is identical to the old format.
|
|
22
|
+
*/
|
|
23
|
+
export function formatSuccess(message, data, completionHints) {
|
|
24
|
+
const response = {
|
|
25
|
+
success: true,
|
|
26
|
+
message,
|
|
27
|
+
};
|
|
28
|
+
if (data !== undefined) {
|
|
29
|
+
response.data = data;
|
|
30
|
+
}
|
|
31
|
+
if (completionHints && completionHints.length > 0) {
|
|
32
|
+
response.completion_hints = completionHints;
|
|
33
|
+
// Append a human-readable summary so all LLMs can see the hints
|
|
34
|
+
const hintLines = completionHints
|
|
35
|
+
.map((h) => `- ${h.suggestion}${h.count ? ` (${h.count} works)` : ""}`)
|
|
36
|
+
.join("\n");
|
|
37
|
+
message += `\n\nNext steps you could take:\n${hintLines}`;
|
|
38
|
+
response.message = message; // Keep structuredContent in sync with text
|
|
39
|
+
}
|
|
40
|
+
const jsonText = JSON.stringify(response, null, 2);
|
|
41
|
+
return {
|
|
42
|
+
content: [{ type: "text", text: `${message}\n\n${jsonText}` }],
|
|
43
|
+
structuredContent: response,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Map raw gap objects from the completeness API into CompletionHints.
|
|
48
|
+
* The API response shape varies — this handles the known field names.
|
|
49
|
+
*/
|
|
50
|
+
export function mapGapsToHints(gaps, limit = 5) {
|
|
51
|
+
if (!Array.isArray(gaps))
|
|
52
|
+
return [];
|
|
53
|
+
return gaps.slice(0, limit).map((g) => ({
|
|
54
|
+
gap: g.key || g.field || g.type || "unknown",
|
|
55
|
+
suggestion: g.suggestion || g.label || g.description || "",
|
|
56
|
+
severity: g.severity || "important",
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Format array of items with count
|
|
61
|
+
*/
|
|
62
|
+
export function formatList(items, metadata) {
|
|
63
|
+
const response = {
|
|
64
|
+
count: items.length,
|
|
65
|
+
items,
|
|
66
|
+
};
|
|
67
|
+
if (metadata) {
|
|
68
|
+
response.metadata = metadata;
|
|
69
|
+
}
|
|
70
|
+
const summary = `Found ${items.length} item${items.length !== 1 ? "s" : ""}.`;
|
|
71
|
+
const jsonText = JSON.stringify(response, null, 2);
|
|
72
|
+
return {
|
|
73
|
+
content: [
|
|
74
|
+
{
|
|
75
|
+
type: "text",
|
|
76
|
+
text: `${summary}\n\n${jsonText}`,
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
structuredContent: response,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Truncate text to max length
|
|
84
|
+
*/
|
|
85
|
+
export function truncate(text, maxLength = 1000) {
|
|
86
|
+
if (text.length <= maxLength) {
|
|
87
|
+
return text;
|
|
88
|
+
}
|
|
89
|
+
return text.substring(0, maxLength) + "... (truncated)";
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Format validation error
|
|
93
|
+
*/
|
|
94
|
+
export function formatValidationError(fields) {
|
|
95
|
+
const structured = {
|
|
96
|
+
error: "VALIDATION_ERROR",
|
|
97
|
+
message: "Validation failed",
|
|
98
|
+
fields,
|
|
99
|
+
};
|
|
100
|
+
return {
|
|
101
|
+
content: [{ type: "text", text: JSON.stringify(structured, null, 2) }],
|
|
102
|
+
structuredContent: structured,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Format structured response with dual content blocks:
|
|
107
|
+
* - Human-readable text (includes full JSON so all MCP clients can read it)
|
|
108
|
+
* - Machine-parseable structuredContent object
|
|
109
|
+
*/
|
|
110
|
+
export function formatStructured(data, summary) {
|
|
111
|
+
const jsonText = JSON.stringify(data, null, 2);
|
|
112
|
+
return {
|
|
113
|
+
content: [
|
|
114
|
+
{
|
|
115
|
+
type: "text",
|
|
116
|
+
text: summary ? `${summary}\n\n${jsonText}` : jsonText,
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
structuredContent: data,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Format a list with both human summary and structured JSON
|
|
124
|
+
*/
|
|
125
|
+
export function formatStructuredList(items, entityName, metadata) {
|
|
126
|
+
const count = items.length;
|
|
127
|
+
const summary = `Found ${count} ${entityName}${count !== 1 ? "s" : ""}${metadata?.query ? ` matching "${metadata.query}"` : ""}.`;
|
|
128
|
+
return formatStructured({ count, items, ...metadata }, summary);
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=formatting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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AK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GACnE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,cAAc,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EACtD,GAAG,CAAC;IAEJ,OAAO,gBAAgB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MPP (Machine Payments Protocol) inline payment helper.
|
|
3
|
+
*
|
|
4
|
+
* Wraps mppx to provide per-credit charging for credit-gated MCP operations.
|
|
5
|
+
* Same pricing as credit packs (pica_25 best-value rate per credit).
|
|
6
|
+
*
|
|
7
|
+
* Environment variables:
|
|
8
|
+
* MPP_SECRET_KEY — HMAC key for challenge binding (required for MPP)
|
|
9
|
+
* MPP_STRIPE_NETWORK_ID — Stripe Business Network Profile ID (required for MPP)
|
|
10
|
+
* MPP_TESTNET — set "true" for staging/dev
|
|
11
|
+
* STRIPE_SECRET_KEY — already exists, used by mppx for payment settlement
|
|
12
|
+
*
|
|
13
|
+
* If MPP_SECRET_KEY or MPP_STRIPE_NETWORK_ID are not set, MPP is disabled
|
|
14
|
+
* and the gate falls through to the existing insufficient_credits error.
|
|
15
|
+
*/
|
|
16
|
+
import type { CallToolResult, McpError } from "@modelcontextprotocol/sdk/types.js";
|
|
17
|
+
export declare const MPP_PER_CREDIT_PRICES: Record<string, number>;
|
|
18
|
+
/** Default currency for MPP charges */
|
|
19
|
+
export declare const MPP_DEFAULT_CURRENCY = "usd";
|
|
20
|
+
/** All supported MPP currencies */
|
|
21
|
+
export declare const MPP_SUPPORTED_CURRENCIES: string[];
|
|
22
|
+
/**
|
|
23
|
+
* Get per-credit amount in minor units for a currency.
|
|
24
|
+
* Falls back to USD if currency not supported.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getMppPerCreditAmount(currency: string): number;
|
|
27
|
+
/**
|
|
28
|
+
* Calculate total charge amount for a number of credits.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getMppChargeAmount(creditCost: number, currency: string): {
|
|
31
|
+
amount: string;
|
|
32
|
+
currency: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Check if MPP is configured (env vars present).
|
|
36
|
+
*/
|
|
37
|
+
export declare function isMppConfigured(): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Get or create the MPP instance. Returns null if not configured.
|
|
40
|
+
*/
|
|
41
|
+
export declare function getMppInstance(): any | null;
|
|
42
|
+
/**
|
|
43
|
+
* Reset the MPP instance (for testing).
|
|
44
|
+
*/
|
|
45
|
+
export declare function resetMppInstance(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Extra metadata from the MCP CallToolRequest.
|
|
48
|
+
* Contains MPP credentials when an agent retries after a 402.
|
|
49
|
+
*/
|
|
50
|
+
export type McpExtra = {
|
|
51
|
+
_meta?: Record<string, unknown>;
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Result of an MPP charge attempt.
|
|
56
|
+
*/
|
|
57
|
+
export type MppChargeResult = {
|
|
58
|
+
status: 402;
|
|
59
|
+
challenge: McpError;
|
|
60
|
+
} | {
|
|
61
|
+
status: 200;
|
|
62
|
+
withReceipt: (result: CallToolResult) => CallToolResult;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Attempt to charge via MPP for a credit-gated operation.
|
|
66
|
+
*
|
|
67
|
+
* @param creditCost Number of credits the operation costs
|
|
68
|
+
* @param operationName Human-readable operation name for the charge description
|
|
69
|
+
* @param currency Currency to charge in (default: usd)
|
|
70
|
+
* @param extra The MCP request extra/meta (contains credential on retry)
|
|
71
|
+
* @returns Charge result, or null if MPP is not configured
|
|
72
|
+
*/
|
|
73
|
+
export declare function chargeMpp(creditCost: number, operationName: string, currency?: string, extra?: McpExtra): Promise<MppChargeResult | null>;
|
|
74
|
+
/**
|
|
75
|
+
* Format a human-readable price for a number of credits in a currency.
|
|
76
|
+
*/
|
|
77
|
+
export declare function formatMppPrice(creditCost: number, currency?: string): string;
|
|
78
|
+
//# sourceMappingURL=mpp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mpp.d.ts","sourceRoot":"","sources":["../../src/utils/mpp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EACV,cAAc,EACd,QAAQ,EACT,MAAM,oCAAoC,CAAC;AAO5C,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAWxD,CAAC;AAEF,uCAAuC;AACvC,eAAO,MAAM,oBAAoB,QAAQ,CAAC;AAE1C,mCAAmC;AACnC,eAAO,MAAM,wBAAwB,UAAqC,CAAC;AAE3E;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAK9D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAOtC;AAaD;;GAEG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAMzC;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,GAAG,GAAG,IAAI,CAsB3C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAGvC;AAMD;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GACvB;IAAE,MAAM,EAAE,GAAG,CAAC;IAAC,SAAS,EAAE,QAAQ,CAAA;CAAE,GACpC;IAAE,MAAM,EAAE,GAAG,CAAC;IAAC,WAAW,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,cAAc,CAAA;CAAE,CAAC;AAE7E;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAC7B,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,QAAQ,GAAE,MAA6B,EACvC,KAAK,GAAE,QAAa,GACnB,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAiBjC;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,MAAM,EAClB,QAAQ,GAAE,MAA6B,GACtC,MAAM,CAKR"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MPP (Machine Payments Protocol) inline payment helper.
|
|
3
|
+
*
|
|
4
|
+
* Wraps mppx to provide per-credit charging for credit-gated MCP operations.
|
|
5
|
+
* Same pricing as credit packs (pica_25 best-value rate per credit).
|
|
6
|
+
*
|
|
7
|
+
* Environment variables:
|
|
8
|
+
* MPP_SECRET_KEY — HMAC key for challenge binding (required for MPP)
|
|
9
|
+
* MPP_STRIPE_NETWORK_ID — Stripe Business Network Profile ID (required for MPP)
|
|
10
|
+
* MPP_TESTNET — set "true" for staging/dev
|
|
11
|
+
* STRIPE_SECRET_KEY — already exists, used by mppx for payment settlement
|
|
12
|
+
*
|
|
13
|
+
* If MPP_SECRET_KEY or MPP_STRIPE_NETWORK_ID are not set, MPP is disabled
|
|
14
|
+
* and the gate falls through to the existing insufficient_credits error.
|
|
15
|
+
*/
|
|
16
|
+
import { Mppx, stripe } from "mppx/server";
|
|
17
|
+
import { Transport as McpTransport } from "mppx/mcp-sdk/server";
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
// Per-credit pricing in minor units (pica_25 pack / 25 credits)
|
|
20
|
+
// Verified against live Stripe prices 2026-03-31
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
export const MPP_PER_CREDIT_PRICES = {
|
|
23
|
+
gbp: 40, // £0.40
|
|
24
|
+
usd: 48, // $0.48
|
|
25
|
+
eur: 44, // €0.44
|
|
26
|
+
cad: 64, // CA$0.64
|
|
27
|
+
aud: 72, // A$0.72
|
|
28
|
+
zar: 396, // R4
|
|
29
|
+
ngn: 20000, // ₦200
|
|
30
|
+
kes: 3196, // KSh32
|
|
31
|
+
brl: 160, // R$1.60
|
|
32
|
+
mxn: 636, // MX$6
|
|
33
|
+
};
|
|
34
|
+
/** Default currency for MPP charges */
|
|
35
|
+
export const MPP_DEFAULT_CURRENCY = "usd";
|
|
36
|
+
/** All supported MPP currencies */
|
|
37
|
+
export const MPP_SUPPORTED_CURRENCIES = Object.keys(MPP_PER_CREDIT_PRICES);
|
|
38
|
+
/**
|
|
39
|
+
* Get per-credit amount in minor units for a currency.
|
|
40
|
+
* Falls back to USD if currency not supported.
|
|
41
|
+
*/
|
|
42
|
+
export function getMppPerCreditAmount(currency) {
|
|
43
|
+
const key = currency.toLowerCase();
|
|
44
|
+
return (MPP_PER_CREDIT_PRICES[key] ?? MPP_PER_CREDIT_PRICES[MPP_DEFAULT_CURRENCY]);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Calculate total charge amount for a number of credits.
|
|
48
|
+
*/
|
|
49
|
+
export function getMppChargeAmount(creditCost, currency) {
|
|
50
|
+
const perCredit = getMppPerCreditAmount(currency);
|
|
51
|
+
const total = perCredit * creditCost;
|
|
52
|
+
return {
|
|
53
|
+
amount: String(total),
|
|
54
|
+
currency: currency.toLowerCase(),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
// MPP instance (lazy singleton)
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
// Use `any` for the instance type — mppx generics are deeply nested and
|
|
61
|
+
// cause "two different types with this name exist" errors with explicit annotations.
|
|
62
|
+
// The runtime behavior is fully type-safe via mppx's internal validation.
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
64
|
+
let mppInstance = null;
|
|
65
|
+
let mppChecked = false;
|
|
66
|
+
/**
|
|
67
|
+
* Check if MPP is configured (env vars present).
|
|
68
|
+
*/
|
|
69
|
+
export function isMppConfigured() {
|
|
70
|
+
return !!(process.env.MPP_SECRET_KEY &&
|
|
71
|
+
process.env.MPP_STRIPE_NETWORK_ID &&
|
|
72
|
+
process.env.STRIPE_SECRET_KEY);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get or create the MPP instance. Returns null if not configured.
|
|
76
|
+
*/
|
|
77
|
+
export function getMppInstance() {
|
|
78
|
+
if (mppChecked)
|
|
79
|
+
return mppInstance;
|
|
80
|
+
mppChecked = true;
|
|
81
|
+
if (!isMppConfigured()) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
mppInstance = Mppx.create({
|
|
85
|
+
methods: [
|
|
86
|
+
stripe.charge({
|
|
87
|
+
secretKey: process.env.STRIPE_SECRET_KEY,
|
|
88
|
+
networkId: process.env.MPP_STRIPE_NETWORK_ID,
|
|
89
|
+
paymentMethodTypes: ["card", "link"],
|
|
90
|
+
}),
|
|
91
|
+
],
|
|
92
|
+
secretKey: process.env.MPP_SECRET_KEY,
|
|
93
|
+
realm: "withpica.com",
|
|
94
|
+
transport: McpTransport.mcpSdk(),
|
|
95
|
+
});
|
|
96
|
+
return mppInstance;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Reset the MPP instance (for testing).
|
|
100
|
+
*/
|
|
101
|
+
export function resetMppInstance() {
|
|
102
|
+
mppInstance = null;
|
|
103
|
+
mppChecked = false;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Attempt to charge via MPP for a credit-gated operation.
|
|
107
|
+
*
|
|
108
|
+
* @param creditCost Number of credits the operation costs
|
|
109
|
+
* @param operationName Human-readable operation name for the charge description
|
|
110
|
+
* @param currency Currency to charge in (default: usd)
|
|
111
|
+
* @param extra The MCP request extra/meta (contains credential on retry)
|
|
112
|
+
* @returns Charge result, or null if MPP is not configured
|
|
113
|
+
*/
|
|
114
|
+
export async function chargeMpp(creditCost, operationName, currency = MPP_DEFAULT_CURRENCY, extra = {}) {
|
|
115
|
+
const mpp = getMppInstance();
|
|
116
|
+
if (!mpp)
|
|
117
|
+
return null;
|
|
118
|
+
const { amount, currency: chargeCurrency } = getMppChargeAmount(creditCost, currency);
|
|
119
|
+
const handler = mpp.charge({
|
|
120
|
+
amount,
|
|
121
|
+
currency: chargeCurrency,
|
|
122
|
+
description: `${operationName} (${creditCost} pica credit${creditCost !== 1 ? "s" : ""})`,
|
|
123
|
+
});
|
|
124
|
+
const result = await handler(extra);
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Format a human-readable price for a number of credits in a currency.
|
|
129
|
+
*/
|
|
130
|
+
export function formatMppPrice(creditCost, currency = MPP_DEFAULT_CURRENCY) {
|
|
131
|
+
const perCredit = getMppPerCreditAmount(currency);
|
|
132
|
+
const total = (perCredit * creditCost) / 100;
|
|
133
|
+
const cur = currency.toUpperCase();
|
|
134
|
+
return `${total.toFixed(2)} ${cur}`;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=mpp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mpp.js","sourceRoot":"","sources":["../../src/utils/mpp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,EAAa,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAMhE,8EAA8E;AAC9E,gEAAgE;AAChE,iDAAiD;AACjD,8EAA8E;AAE9E,MAAM,CAAC,MAAM,qBAAqB,GAA2B;IAC3D,GAAG,EAAE,EAAE,EAAE,QAAQ;IACjB,GAAG,EAAE,EAAE,EAAE,QAAQ;IACjB,GAAG,EAAE,EAA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ACxB,WAAW,EAAE,GAAG,aAAa,KAAK,UAAU,eAAe,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG;KAC1F,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,KAA2B,CAAC,CAAC;IAC1D,OAAO,MAAyB,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,UAAkB,EAClB,WAAmB,oBAAoB;IAEvC,MAAM,SAAS,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAClD,MAAM,KAAK,GAAG,CAAC,SAAS,GAAG,UAAU,CAAC,GAAG,GAAG,CAAC;IAC7C,MAAM,GAAG,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IACnC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;AACtC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@withpica/mcp-server",
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "MCP Server for PICA Platform - enables AI assistants to interact with PICA",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"pica-mcp": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"dev": "tsx src/index.ts",
|
|
13
|
+
"start": "node dist/index.js",
|
|
14
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
|
|
15
|
+
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch",
|
|
16
|
+
"test:coverage": "NODE_OPTIONS=--experimental-vm-modules jest --coverage"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"mcp",
|
|
20
|
+
"model-context-protocol",
|
|
21
|
+
"pica",
|
|
22
|
+
"ai",
|
|
23
|
+
"assistant",
|
|
24
|
+
"claude",
|
|
25
|
+
"chatgpt"
|
|
26
|
+
],
|
|
27
|
+
"author": "PICA Platform",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
31
|
+
"mppx": "^0.5.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/jest": "^29.5.14",
|
|
35
|
+
"@types/node": "^20.10.0",
|
|
36
|
+
"jest": "^29.7.0",
|
|
37
|
+
"ts-jest": "^29.4.5",
|
|
38
|
+
"tsx": "^4.7.0",
|
|
39
|
+
"typescript": "^5.3.3"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=18.0.0"
|
|
43
|
+
}
|
|
44
|
+
}
|