@kelviq/mcp-server 1.2.1 → 1.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/README.md +40 -3
- package/dist/config.d.ts +5 -0
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/docs/ai/docs-for-agents.md +21 -0
- package/dist/docs/ai/overview.md +43 -0
- package/dist/docs/api-reference/authentication.md +9 -3
- package/dist/docs/api-reference/introduction.md +23 -2
- package/dist/docs/backend-integration/node-sdk.md +12 -6
- package/dist/docs/backend-integration/python-sdk.md +14 -8
- package/dist/docs/changelog.md +352 -3
- package/dist/docs/checkout/checkout-configuration.md +25 -75
- package/dist/docs/checkout/checkout-design.md +76 -0
- package/dist/docs/checkout/checkout-examples.md +212 -0
- package/dist/docs/checkout/checkout-metadata.md +1 -1
- package/dist/docs/checkout/custom-fields.md +60 -0
- package/dist/docs/checkout/embed-checkout.md +280 -0
- package/dist/docs/checkout/payment-methods/upi.md +69 -0
- package/dist/docs/checkout/payment-methods.md +119 -0
- package/dist/docs/checkout/static-checkout-url.md +3 -2
- package/dist/docs/cli/commands.md +57 -4
- package/dist/docs/cli/kelviq-config.md +1 -1
- package/dist/docs/cli/overview.md +1 -0
- package/dist/docs/customer-portal/managing-payment-methods.md +4 -4
- package/dist/docs/customer-portal/overview.md +7 -7
- package/dist/docs/customer-portal/retention.md +109 -0
- package/dist/docs/customers-management/overview.md +105 -0
- package/dist/docs/frontend-integration/js-sdk.md +11 -11
- package/dist/docs/frontend-integration/promotions-ui-js.md +2 -2
- package/dist/docs/frontend-integration/react-sdk.md +8 -49
- package/dist/docs/frontend-integration/react-ui.md +8 -6
- package/dist/docs/getstarted/fees.md +27 -11
- package/dist/docs/getstarted/introduction-to-kelviq.md +29 -66
- package/dist/docs/getstarted/merchant-of-record.md +18 -24
- package/dist/docs/getstarted/overview.md +98 -0
- package/dist/docs/getstarted/review-process.md +59 -59
- package/dist/docs/guides/agent-toolkit.md +14 -9
- package/dist/docs/guides/mcp-server.md +24 -9
- package/dist/docs/guides/migrate-from-lemon-squeezy.md +405 -0
- package/dist/docs/guides/sandbox.md +6 -4
- package/dist/docs/guides/set-up-with-ai.md +43 -0
- package/dist/docs/guides/subscription-integration-for-nextjs.md +10 -11
- package/dist/docs/guides/subscription-integration.md +1 -1
- package/dist/docs/guides/test-payments.md +640 -0
- package/dist/docs/guides/webhooks.md +182 -30
- package/dist/docs/integrations/woocommerce.md +88 -0
- package/dist/docs/integrations/zapier.md +22 -0
- package/dist/docs/legal/account-and-funds.md +59 -0
- package/dist/docs/legal/approved-prohibited-policy.md +32 -27
- package/dist/docs/legal/payment-flow-diagram.md +7 -7
- package/dist/docs/manifest.json +160 -41
- package/dist/docs/openapi.json +1359 -109
- package/dist/docs/payouts/overview.md +14 -12
- package/dist/docs/payouts/payout-account.md +1 -1
- package/dist/docs/payouts/transactions.md +3 -3
- package/dist/docs/product-catalog/create-a-feature.md +3 -3
- package/dist/docs/product-catalog/digital-downloads.md +5 -5
- package/dist/docs/product-catalog/discounts.md +2 -2
- package/dist/docs/product-catalog/entitlements.md +20 -27
- package/dist/docs/product-catalog/free-and-trials.md +4 -4
- package/dist/docs/product-catalog/license-keys.md +56 -29
- package/dist/docs/product-catalog/links.md +3 -3
- package/dist/docs/product-catalog/location-based-pricing.md +6 -10
- package/dist/docs/product-catalog/one-time-payments.md +3 -7
- package/dist/docs/product-catalog/pay-as-you-go.md +8 -8
- package/dist/docs/product-catalog/plans.md +22 -19
- package/dist/docs/product-catalog/products.md +11 -3
- package/dist/docs/product-catalog/proration.md +69 -0
- package/dist/docs/product-catalog/seat-based-pricing.md +7 -7
- package/dist/docs/product-catalog/subscriptions.md +52 -22
- package/dist/docs/product-catalog/tax-settings.md +8 -8
- package/dist/docs/product-catalog/usage-alerts.md +7 -7
- package/dist/docs/product-catalog/usage-based-billing.md +156 -29
- package/dist/docs/product-catalog/usage-limits.md +78 -0
- package/dist/docs/promotions/create-a-promotion.md +2 -2
- package/dist/docs/promotions/overview.md +1 -1
- package/dist/docs/quickstart/core-concepts.md +36 -30
- package/dist/docs/quickstart/dashboard-setup.md +26 -22
- package/dist/docs/quickstart/integrate-with-your-app.md +133 -52
- package/dist/docs/sales/abandoned-cart-recovery.md +7 -3
- package/dist/docs/sales/checkout-sessions.md +28 -39
- package/dist/docs/sales/orders.md +30 -54
- package/dist/docs/settings/customer-emails.md +52 -0
- package/dist/docs/settings/members.md +27 -0
- package/dist/docs/settings/profile.md +26 -0
- package/dist/docs/settings/zapier.md +22 -0
- package/dist/http/errors.d.ts +20 -1
- package/dist/http/errors.js +83 -31
- package/dist/http/errors.js.map +1 -1
- package/dist/schemas/kelviq.d.ts +54 -0
- package/dist/schemas/kelviq.js +64 -0
- package/dist/schemas/kelviq.js.map +1 -1
- package/dist/server.js +3 -2
- package/dist/server.js.map +1 -1
- package/dist/tools/imports.d.ts +68 -0
- package/dist/tools/imports.js +242 -0
- package/dist/tools/imports.js.map +1 -0
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.js +4 -1
- package/dist/tools/index.js.map +1 -1
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -29,17 +29,18 @@ async function main() {
|
|
|
29
29
|
`API tools act on the Kelviq ${config.env} environment (${envDefaulted ? 'KELVIQ_ENV is unset; sandbox is the default' : `KELVIQ_ENV=${config.env}`}). Keys only work against their own environment, and sandbox and production data never mix.`,
|
|
30
30
|
'`promotion_get` is the only tool that uses `KELVIQ_CLIENT_API_KEY` (client-side edge endpoint).',
|
|
31
31
|
'Webhook signing secrets are hidden in tool results unless you pass `revealSecret: true`. Keep them out of the conversation: an app reads its secret from its env file.',
|
|
32
|
+
'`import_start` queues a store import from Lemon Squeezy and reads the Lemon Squeezy key from `LEMONSQUEEZY_API_KEY` in this server\'s environment, never from the conversation. For a store\'s first import, run it with `dryRun: true`; a real import needs the user\'s explicit go-ahead, and by default it publishes the imported plans and switches on the discount codes. The result only means "queued": the report arrives by email and there is nothing to poll.',
|
|
32
33
|
'',
|
|
33
34
|
'All API errors are returned as `{ error: { status, message } }` JSON content — read them rather than retrying blindly.',
|
|
34
35
|
].join('\n'),
|
|
35
36
|
});
|
|
36
|
-
registerTools(server, http);
|
|
37
|
+
registerTools(server, http, config);
|
|
37
38
|
registerResources(server);
|
|
38
39
|
registerPrompts(server);
|
|
39
40
|
const transport = new StdioServerTransport();
|
|
40
41
|
await server.connect(transport);
|
|
41
42
|
// Diagnostics go to stderr — stdout is reserved for the JSON-RPC stream.
|
|
42
|
-
process.stderr.write(`kelviq-mcp ready (env=${config.env}${envDefaulted ? ' (default)' : ''}, base=${config.baseUrl}, edge=${config.edgeUrl}, server-key=${config.serverApiKey ? 'set' : 'MISSING'}, client-key=${config.clientApiKey ? 'set' : 'unset'})\n`);
|
|
43
|
+
process.stderr.write(`kelviq-mcp ready (env=${config.env}${envDefaulted ? ' (default)' : ''}, base=${config.baseUrl}, edge=${config.edgeUrl}, server-key=${config.serverApiKey ? 'set' : 'MISSING'}, client-key=${config.clientApiKey ? 'set' : 'unset'}, ls-key=${config.lemonSqueezyApiKey ? 'set' : 'unset'})\n`);
|
|
43
44
|
if (envDefaulted) {
|
|
44
45
|
process.stderr.write('kelviq-mcp: KELVIQ_ENV is not set, so using sandbox (the default since 1.0.0). Set KELVIQ_ENV=production to work with live data.\n');
|
|
45
46
|
}
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,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AAC,OAAO,UAAU,MAAM,CAAC,OAAO,gBAAgB,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,gBAAgB,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,YAAY,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,KAAK,CAC/R,CAAC;IACF,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,oIAAoI,CACrI,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC;QAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,wBAAwB,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,iFAAiF;YACvI,yGAAyG,CAC5G,CAAC;IACJ,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAEnB,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;IAClD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { KelviqConfig } from '../config.js';
|
|
4
|
+
import type { KelviqHttpClient, Result } from '../http/client.js';
|
|
5
|
+
import { ImportSource, ImportStart } from '../schemas/kelviq.js';
|
|
6
|
+
type ImportSourceId = z.infer<typeof ImportSource>;
|
|
7
|
+
type ImportStartInput = z.infer<typeof ImportStart>;
|
|
8
|
+
/** Config fields that hold a source platform's API key. */
|
|
9
|
+
type CredentialField = 'lemonSqueezyApiKey';
|
|
10
|
+
/** Inputs every source accepts. Sent as-is when provided. */
|
|
11
|
+
declare const COMMON_FIELDS: readonly ["dryRun", "only", "skip", "publishPlan", "publishDiscount", "reportEmail"];
|
|
12
|
+
type CommonField = (typeof COMMON_FIELDS)[number];
|
|
13
|
+
type SourceField = Exclude<keyof ImportStartInput, CommonField | 'source'>;
|
|
14
|
+
/**
|
|
15
|
+
* Everything that is particular to one source. The handler below is shared:
|
|
16
|
+
* adding a source means adding its enum value to `ImportSource`, its key to
|
|
17
|
+
* the config, and one entry here.
|
|
18
|
+
*/
|
|
19
|
+
export interface ImportSourceDefinition {
|
|
20
|
+
/** Name used in messages. */
|
|
21
|
+
label: string;
|
|
22
|
+
/** Endpoint that queues the import, beneath the API base URL. */
|
|
23
|
+
path: string;
|
|
24
|
+
credential: {
|
|
25
|
+
/** Field on `KelviqConfig` that holds the source platform's API key. */
|
|
26
|
+
configField: CredentialField;
|
|
27
|
+
/** Environment variable that field is read from; named wherever a message is about the key. */
|
|
28
|
+
envVar: string;
|
|
29
|
+
/** Request body field the key is sent in. */
|
|
30
|
+
bodyField: string;
|
|
31
|
+
};
|
|
32
|
+
/** Source-only inputs that must be present. */
|
|
33
|
+
requiredFields: readonly SourceField[];
|
|
34
|
+
/** Source-only inputs sent when provided. Other sources' inputs are never sent. */
|
|
35
|
+
optionalFields: readonly SourceField[];
|
|
36
|
+
/** Step names accepted in `only` and `skip`, in the order they run. */
|
|
37
|
+
steps: readonly string[];
|
|
38
|
+
}
|
|
39
|
+
export declare const IMPORT_SOURCES: Record<ImportSourceId, ImportSourceDefinition>;
|
|
40
|
+
export declare const HIDDEN_SOURCE_KEY = "[hidden]";
|
|
41
|
+
/**
|
|
42
|
+
* A shorter value is not a source platform key, and hiding it would also hide
|
|
43
|
+
* unrelated text that happens to contain it (a key of `12345` is a store id).
|
|
44
|
+
*/
|
|
45
|
+
export declare const MIN_SOURCE_KEY_LENGTH = 20;
|
|
46
|
+
/**
|
|
47
|
+
* Replace every occurrence of a secret in a value, in strings and in object
|
|
48
|
+
* keys at any depth, in each of the forms above. The API does not return the
|
|
49
|
+
* source key, but an error can carry the raw response body, and a proxy or a
|
|
50
|
+
* future API change could echo the request: the key must not reach the model
|
|
51
|
+
* either way.
|
|
52
|
+
*/
|
|
53
|
+
export declare function scrubSecret(value: unknown, secret: string): unknown;
|
|
54
|
+
/**
|
|
55
|
+
* Scrub what the API sent: the data of a success, and the values of an
|
|
56
|
+
* error. The property names of the result itself (`ok`, `data`, `error`,
|
|
57
|
+
* `status`, `message`, `httpStatus`, `raw`) are ours and are never rewritten.
|
|
58
|
+
*/
|
|
59
|
+
export declare function scrubResult(result: Result<unknown>, secret: string): Result<unknown>;
|
|
60
|
+
/**
|
|
61
|
+
* The HTTP client appends a wrong-environment hint to every 401/403. This
|
|
62
|
+
* endpoint also answers 403 for a valid key that the organization owner did
|
|
63
|
+
* not create, where that hint would send the user the wrong way: show the
|
|
64
|
+
* API's own sentence instead. Every other 403 keeps the hint.
|
|
65
|
+
*/
|
|
66
|
+
export declare function withoutEnvironmentHint(result: Result<unknown>): Result<unknown>;
|
|
67
|
+
export declare function registerImportTools(server: McpServer, http: KelviqHttpClient, config: KelviqConfig): void;
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { collectFieldErrors, fromHttpResponse } from '../http/errors.js';
|
|
2
|
+
import { ImportStart } from '../schemas/kelviq.js';
|
|
3
|
+
import { resultToContent } from './_util.js';
|
|
4
|
+
/** Inputs every source accepts. Sent as-is when provided. */
|
|
5
|
+
const COMMON_FIELDS = ['dryRun', 'only', 'skip', 'publishPlan', 'publishDiscount', 'reportEmail'];
|
|
6
|
+
export const IMPORT_SOURCES = {
|
|
7
|
+
'lemon-squeezy': {
|
|
8
|
+
label: 'Lemon Squeezy',
|
|
9
|
+
path: '/integrations/lemon-squeezy/migrate/',
|
|
10
|
+
credential: { configField: 'lemonSqueezyApiKey', envVar: 'LEMONSQUEEZY_API_KEY', bodyField: 'apiKey' },
|
|
11
|
+
requiredFields: ['storeId'],
|
|
12
|
+
optionalFields: ['orderType', 'overwriteProfile', 'skipAnalytics'],
|
|
13
|
+
steps: ['store', 'products', 'customers', 'files', 'orders', 'renewals', 'discounts', 'licenses'],
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
export const HIDDEN_SOURCE_KEY = '[hidden]';
|
|
17
|
+
/**
|
|
18
|
+
* A shorter value is not a source platform key, and hiding it would also hide
|
|
19
|
+
* unrelated text that happens to contain it (a key of `12345` is a store id).
|
|
20
|
+
*/
|
|
21
|
+
export const MIN_SOURCE_KEY_LENGTH = 20;
|
|
22
|
+
const TOOL_DESCRIPTION = "Queue a server-side import of a Lemon Squeezy store into this server's Kelviq environment (the result names it). " +
|
|
23
|
+
"Rules: (1) For a store's first import, call with dryRun: true and let the user read the emailed report. " +
|
|
24
|
+
'(2) Call with dryRun: false only when the user has explicitly asked for that real run; by default it publishes the imported plans and discount codes. ' +
|
|
25
|
+
'(3) The result means queued, not finished: the report arrives by email and there is nothing to poll. ' +
|
|
26
|
+
'The Lemon Squeezy key comes from LEMONSQUEEZY_API_KEY in the server environment; never ask for it in the conversation. ' +
|
|
27
|
+
'KELVIQ_SERVER_API_KEY must be a server key created by the organization owner. ' +
|
|
28
|
+
'A repeat run adds what is new and, by default, publishes earlier drafts. ' +
|
|
29
|
+
'No customer emails or webhooks are sent. ' +
|
|
30
|
+
'Imported subscriptions are history and keep billing on Lemon Squeezy.';
|
|
31
|
+
function failure(status, message) {
|
|
32
|
+
return { ok: false, error: { status, message } };
|
|
33
|
+
}
|
|
34
|
+
function provided(value) {
|
|
35
|
+
return value !== undefined && value !== null && value !== '';
|
|
36
|
+
}
|
|
37
|
+
function isPlainObject(value) {
|
|
38
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
39
|
+
}
|
|
40
|
+
/** A message describing what is wrong with the input for this source, or undefined when it is fine. */
|
|
41
|
+
function validateInput(source, input) {
|
|
42
|
+
const missing = source.requiredFields.filter((field) => !provided(input[field]));
|
|
43
|
+
if (missing.length > 0) {
|
|
44
|
+
const names = missing.map((field) => `\`${field}\``).join(', ');
|
|
45
|
+
return `${names} ${missing.length === 1 ? 'is' : 'are'} required to import from ${source.label}.`;
|
|
46
|
+
}
|
|
47
|
+
for (const field of ['only', 'skip']) {
|
|
48
|
+
const unknown = (input[field] ?? []).filter((step) => !source.steps.includes(step));
|
|
49
|
+
if (unknown.length > 0) {
|
|
50
|
+
const names = unknown.map((step) => `"${step}"`).join(', ');
|
|
51
|
+
return (`\`${field}\` has ${unknown.length === 1 ? 'a step' : 'steps'} that ${source.label} imports do not have: ${names}. ` +
|
|
52
|
+
`Allowed steps: ${source.steps.join(', ')}.`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The source key from the server environment, or a message saying why it
|
|
59
|
+
* cannot be sent. Every message tells the model where the key lives, so that
|
|
60
|
+
* it never asks for it in the conversation.
|
|
61
|
+
*/
|
|
62
|
+
function readKey(source, config) {
|
|
63
|
+
const { configField, envVar } = source.credential;
|
|
64
|
+
const key = config[configField];
|
|
65
|
+
if (!key) {
|
|
66
|
+
const placeholder = config.unexpandedVars?.includes(envVar)
|
|
67
|
+
? ' The MCP client passed an unexpanded ${...} placeholder for it instead of a value.'
|
|
68
|
+
: '';
|
|
69
|
+
return {
|
|
70
|
+
problem: `Missing ${envVar} in this server's environment.${placeholder} ` +
|
|
71
|
+
"Ask the user to set it where KELVIQ_SERVER_API_KEY is set (their shell profile, or the env block of the server entry in the MCP client's config) and restart the client. " +
|
|
72
|
+
'It is never a tool input: do not ask for it in the conversation.',
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (key.length < MIN_SOURCE_KEY_LENGTH) {
|
|
76
|
+
return {
|
|
77
|
+
problem: `${envVar} does not look like a ${source.label} API key (it is too short). ` +
|
|
78
|
+
"Ask the user to check the value in this server's environment.",
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return { key };
|
|
82
|
+
}
|
|
83
|
+
/** The request body: the source key, the required inputs, then only the optional inputs that were provided. */
|
|
84
|
+
function buildBody(source, input, key) {
|
|
85
|
+
const body = { [source.credential.bodyField]: key };
|
|
86
|
+
for (const field of [...source.requiredFields, ...COMMON_FIELDS, ...source.optionalFields]) {
|
|
87
|
+
if (input[field] !== undefined)
|
|
88
|
+
body[field] = input[field];
|
|
89
|
+
}
|
|
90
|
+
return body;
|
|
91
|
+
}
|
|
92
|
+
const HTML_ESCAPES = { '&': '&', '<': '<', '>': '>', '"': '"' };
|
|
93
|
+
/**
|
|
94
|
+
* The forms a secret can take in a response: as it is, inside a JSON string,
|
|
95
|
+
* in a URL, and in HTML (an error page), where `'` is written either way.
|
|
96
|
+
* Longest first, so that an encoded form is replaced whole.
|
|
97
|
+
*/
|
|
98
|
+
function secretForms(secret) {
|
|
99
|
+
const html = secret.replace(/[&<>"]/g, (char) => HTML_ESCAPES[char]);
|
|
100
|
+
const forms = new Set([
|
|
101
|
+
secret,
|
|
102
|
+
JSON.stringify(secret).slice(1, -1),
|
|
103
|
+
html.replace(/'/g, '''),
|
|
104
|
+
html.replace(/'/g, '''),
|
|
105
|
+
]);
|
|
106
|
+
try {
|
|
107
|
+
forms.add(encodeURIComponent(secret));
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
// A lone surrogate cannot be URL-encoded, so there is no such form to hide.
|
|
111
|
+
}
|
|
112
|
+
return [...forms].sort((a, b) => b.length - a.length);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Replace every occurrence of a secret in a value, in strings and in object
|
|
116
|
+
* keys at any depth, in each of the forms above. The API does not return the
|
|
117
|
+
* source key, but an error can carry the raw response body, and a proxy or a
|
|
118
|
+
* future API change could echo the request: the key must not reach the model
|
|
119
|
+
* either way.
|
|
120
|
+
*/
|
|
121
|
+
export function scrubSecret(value, secret) {
|
|
122
|
+
if (secret.length === 0)
|
|
123
|
+
return value;
|
|
124
|
+
const forms = secretForms(secret);
|
|
125
|
+
const clean = (text) => forms.reduce((out, form) => out.split(form).join(HIDDEN_SOURCE_KEY), text);
|
|
126
|
+
const walk = (node) => {
|
|
127
|
+
if (typeof node === 'string')
|
|
128
|
+
return clean(node);
|
|
129
|
+
if (Array.isArray(node))
|
|
130
|
+
return node.map(walk);
|
|
131
|
+
if (node !== null && typeof node === 'object') {
|
|
132
|
+
return Object.fromEntries(Object.entries(node).map(([key, child]) => [clean(key), walk(child)]));
|
|
133
|
+
}
|
|
134
|
+
return node;
|
|
135
|
+
};
|
|
136
|
+
return walk(value);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Scrub what the API sent: the data of a success, and the values of an
|
|
140
|
+
* error. The property names of the result itself (`ok`, `data`, `error`,
|
|
141
|
+
* `status`, `message`, `httpStatus`, `raw`) are ours and are never rewritten.
|
|
142
|
+
*/
|
|
143
|
+
export function scrubResult(result, secret) {
|
|
144
|
+
if (result.ok)
|
|
145
|
+
return { ok: true, data: scrubSecret(result.data, secret) };
|
|
146
|
+
const error = Object.fromEntries(Object.entries(result.error).map(([name, value]) => [name, scrubSecret(value, secret)]));
|
|
147
|
+
return { ok: false, error };
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* The HTTP client appends a wrong-environment hint to every 401/403. This
|
|
151
|
+
* endpoint also answers 403 for a valid key that the organization owner did
|
|
152
|
+
* not create, where that hint would send the user the wrong way: show the
|
|
153
|
+
* API's own sentence instead. Every other 403 keeps the hint.
|
|
154
|
+
*/
|
|
155
|
+
export function withoutEnvironmentHint(result) {
|
|
156
|
+
if (result.ok || result.error.httpStatus !== 403)
|
|
157
|
+
return result;
|
|
158
|
+
const raw = result.error.raw;
|
|
159
|
+
const detail = isPlainObject(raw) ? raw.detail : undefined;
|
|
160
|
+
if (typeof detail !== 'string' || !/owner/i.test(detail))
|
|
161
|
+
return result;
|
|
162
|
+
return { ok: false, error: { ...result.error, message: detail } };
|
|
163
|
+
}
|
|
164
|
+
const MENTIONS_API_KEY = /api[\s_-]?key/i;
|
|
165
|
+
/**
|
|
166
|
+
* A 400 about the source key reads as if a key input were wrong, and the
|
|
167
|
+
* tool has none. Name the key by its environment variable rather than by the
|
|
168
|
+
* request field, and say where to correct it.
|
|
169
|
+
*/
|
|
170
|
+
function explainKeyError(source, error) {
|
|
171
|
+
if (error.httpStatus !== 400)
|
|
172
|
+
return error;
|
|
173
|
+
const { bodyField, envVar } = source.credential;
|
|
174
|
+
let explained = error;
|
|
175
|
+
const raw = error.raw;
|
|
176
|
+
if (isPlainObject(raw) && collectFieldErrors({ [bodyField]: raw[bodyField] }).length > 0) {
|
|
177
|
+
const renamed = Object.fromEntries(Object.entries(raw).map(([name, value]) => [name === bodyField ? envVar : name, value]));
|
|
178
|
+
explained = fromHttpResponse(400, renamed).error;
|
|
179
|
+
}
|
|
180
|
+
if (!MENTIONS_API_KEY.test(explained.message))
|
|
181
|
+
return explained;
|
|
182
|
+
return {
|
|
183
|
+
...explained,
|
|
184
|
+
message: `${explained.message} The ${source.label} key comes from ${envVar} in this server's environment. ` +
|
|
185
|
+
'Ask the user to correct it there and restart the MCP client; do not ask them to paste the key into the conversation.',
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* What a queued import returns: the API's JSON, the environment it was
|
|
190
|
+
* queued in, and a note that says what "queued" means, because the response
|
|
191
|
+
* alone reads like a finished import.
|
|
192
|
+
*/
|
|
193
|
+
function queuedResult(source, config, input, data) {
|
|
194
|
+
const response = isPlainObject(data) ? data : { response: data };
|
|
195
|
+
const environment = config.env;
|
|
196
|
+
const dryRun = typeof response.dryRun === 'boolean' ? response.dryRun : input.dryRun;
|
|
197
|
+
const reportEmail = [response.reportEmail, input.reportEmail].find((address) => typeof address === 'string' && address !== '') ??
|
|
198
|
+
'the organization owner';
|
|
199
|
+
const sentences = [
|
|
200
|
+
dryRun
|
|
201
|
+
? `Dry run queued in ${environment}. Nothing will be saved.`
|
|
202
|
+
: `Import queued in ${environment}; nothing has been imported yet.`,
|
|
203
|
+
`A report will be emailed to ${reportEmail} when it ends, which can take from seconds to over an hour.`,
|
|
204
|
+
'There is no status to check, so do not call this tool again for progress.',
|
|
205
|
+
];
|
|
206
|
+
if (dryRun)
|
|
207
|
+
sentences.push('Start the real import only when the user has read the report and asks for it.');
|
|
208
|
+
if (response.storeName === null) {
|
|
209
|
+
sentences.push(`${source.label} could not be reached to confirm the store name; the import is still queued.`);
|
|
210
|
+
}
|
|
211
|
+
return { ...response, environment, note: sentences.join(' ') };
|
|
212
|
+
}
|
|
213
|
+
export function registerImportTools(server, http, config) {
|
|
214
|
+
server.registerTool('import_start', {
|
|
215
|
+
title: 'Start a store import',
|
|
216
|
+
description: TOOL_DESCRIPTION,
|
|
217
|
+
// A real run publishes the imported plans by default and can overwrite the business profile.
|
|
218
|
+
annotations: { destructiveHint: true, idempotentHint: false },
|
|
219
|
+
inputSchema: ImportStart.shape,
|
|
220
|
+
}, async (input) => {
|
|
221
|
+
const source = IMPORT_SOURCES[input.source];
|
|
222
|
+
const problem = validateInput(source, input);
|
|
223
|
+
if (problem)
|
|
224
|
+
return resultToContent(failure('Invalid input', problem));
|
|
225
|
+
const credential = readKey(source, config);
|
|
226
|
+
if ('problem' in credential)
|
|
227
|
+
return resultToContent(failure('Configuration error', credential.problem));
|
|
228
|
+
const { key } = credential;
|
|
229
|
+
const result = await http.request({
|
|
230
|
+
method: 'POST',
|
|
231
|
+
path: source.path,
|
|
232
|
+
body: buildBody(source, input, key),
|
|
233
|
+
auth: 'server',
|
|
234
|
+
});
|
|
235
|
+
// Scrub first: everything added after this point is our own wording.
|
|
236
|
+
const scrubbed = scrubResult(withoutEnvironmentHint(result), key);
|
|
237
|
+
if (!scrubbed.ok)
|
|
238
|
+
return resultToContent({ ok: false, error: explainKeyError(source, scrubbed.error) });
|
|
239
|
+
return resultToContent({ ok: true, data: queuedResult(source, config, input, scrubbed.data) });
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=imports.js.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CAAC,CAAC;QAC3C,IAAI,SAAS,IAAI,UAAU;YAAE,OAAO,eAAe,CAAC,OAAO,CAAC,qBAAqB,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;QACxG,MAAM,EAAE,GAAG,EAAE,GAAG,UAAU,CAAC;QAE3B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC;YAChC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC;YACnC,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;QAEH,qEAAqE;QACrE,MAAM,QAAQ,GAAG,WAAW,CAAC,sBAAsB,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC;QAClE,IAAI,CAAC,QAAQ,CAAC,EAAE;YAAE,OAAO,eAAe,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,eAAe,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACxG,OAAO,eAAe,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjG,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { KelviqConfig } from '../config.js';
|
|
2
3
|
import type { KelviqHttpClient } from '../http/client.js';
|
|
3
|
-
export declare function registerTools(server: McpServer, http: KelviqHttpClient): void;
|
|
4
|
+
export declare function registerTools(server: McpServer, http: KelviqHttpClient, config: KelviqConfig): void;
|
package/dist/tools/index.js
CHANGED
|
@@ -18,7 +18,8 @@ import { registerPlanEntitlementTools } from './plan-entitlements.js';
|
|
|
18
18
|
import { registerPlanFileTools } from './plan-files.js';
|
|
19
19
|
import { registerDocsTools } from './docs.js';
|
|
20
20
|
import { registerConnectionTools } from './connection.js';
|
|
21
|
-
|
|
21
|
+
import { registerImportTools } from './imports.js';
|
|
22
|
+
export function registerTools(server, http, config) {
|
|
22
23
|
// Diagnostics
|
|
23
24
|
registerConnectionTools(server, http);
|
|
24
25
|
// Commerce primitives
|
|
@@ -41,6 +42,8 @@ export function registerTools(server, http) {
|
|
|
41
42
|
registerPlanTools(server, http);
|
|
42
43
|
registerPlanEntitlementTools(server, http);
|
|
43
44
|
registerPlanFileTools(server, http);
|
|
45
|
+
// Store imports (the source platform's key comes from config, never from tool input)
|
|
46
|
+
registerImportTools(server, http, config);
|
|
44
47
|
// Docs (local resources, no API key)
|
|
45
48
|
registerDocsTools(server);
|
|
46
49
|
}
|
package/dist/tools/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,M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C,CAAC;IACpC,oBAAoB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAEnC,qBAAqB;IACrB,oBAAoB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACnC,4BAA4B,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC3C,wBAAwB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACvC,oBAAoB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACnC,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAChC,4BAA4B,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC3C,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAEpC,qFAAqF;IACrF,mBAAmB,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAE1C,qCAAqC;IACrC,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kelviq/mcp-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Model Context Protocol server for Kelviq — typed tools for the Kelviq API plus searchable documentation resources.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Kelviq <hi@kelviq.com>",
|