@kelviq/mcp-server 0.4.0 → 1.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.
Files changed (76) hide show
  1. package/README.md +43 -27
  2. package/dist/config.d.ts +4 -0
  3. package/dist/config.js +30 -9
  4. package/dist/config.js.map +1 -1
  5. package/dist/docs/README.md +16 -0
  6. package/dist/docs/backend-integration/better-auth.md +369 -0
  7. package/dist/docs/backend-integration/node-sdk.md +373 -5
  8. package/dist/docs/backend-integration/python-sdk.md +444 -6
  9. package/dist/docs/changelog/api.md +516 -5
  10. package/dist/docs/changelog/app.md +162 -0
  11. package/dist/docs/changelog/cli.md +33 -0
  12. package/dist/docs/changelog/mcp-server.md +23 -0
  13. package/dist/docs/changelog/node-sdk.md +124 -0
  14. package/dist/docs/changelog/python-sdk.md +135 -0
  15. package/dist/docs/changelog.md +3968 -0
  16. package/dist/docs/checkout/apply-a-discount-code.md +150 -0
  17. package/dist/docs/checkout/checkout-configuration.md +88 -22
  18. package/dist/docs/checkout/checkout-metadata.md +219 -0
  19. package/dist/docs/checkout/static-checkout-url.md +201 -0
  20. package/dist/docs/cli/commands.md +1 -1
  21. package/dist/docs/cli/environments.md +17 -9
  22. package/dist/docs/cli/kelviq-config.md +35 -1
  23. package/dist/docs/cli/overview.md +2 -0
  24. package/dist/docs/coustomers-management/overview.md +15 -19
  25. package/dist/docs/customer-portal/managing-payment-methods.md +30 -48
  26. package/dist/docs/frontend-integration/react-ui.md +51 -16
  27. package/dist/docs/getstarted/fees.md +45 -54
  28. package/dist/docs/getstarted/payment-security-and-seller-funds.md +98 -0
  29. package/dist/docs/getstarted/review-process.md +3 -3
  30. package/dist/docs/guides/agent-toolkit.md +143 -0
  31. package/dist/docs/guides/mcp-server.md +138 -35
  32. package/dist/docs/guides/migrate-from-cashfree.md +7 -0
  33. package/dist/docs/guides/sandbox.md +34 -0
  34. package/dist/docs/guides/subscription-integration-for-nextjs.md +44 -18
  35. package/dist/docs/guides/subscription-integration.md +28 -4
  36. package/dist/docs/guides/webhooks.md +367 -6
  37. package/dist/docs/manifest.json +98 -56
  38. package/dist/docs/openapi.json +7411 -2648
  39. package/dist/docs/payouts/overview.md +30 -0
  40. package/dist/docs/payouts/transactions.md +50 -6
  41. package/dist/docs/product-catalog/create-a-feature.md +113 -0
  42. package/dist/docs/product-catalog/create-an-enterprise-plan.md +133 -0
  43. package/dist/docs/product-catalog/discounts.md +25 -12
  44. package/dist/docs/product-catalog/entitlements.md +53 -16
  45. package/dist/docs/product-catalog/free-and-trials.md +8 -4
  46. package/dist/docs/product-catalog/location-based-pricing.md +2 -0
  47. package/dist/docs/product-catalog/one-time-payments.md +4 -0
  48. package/dist/docs/product-catalog/pay-as-you-go.md +177 -0
  49. package/dist/docs/product-catalog/plans.md +14 -0
  50. package/dist/docs/product-catalog/products.md +5 -13
  51. package/dist/docs/product-catalog/seat-based-pricing.md +233 -0
  52. package/dist/docs/product-catalog/subscriptions.md +109 -12
  53. package/dist/docs/product-catalog/usage-alerts.md +257 -0
  54. package/dist/docs/product-catalog/usage-based-billing.md +49 -12
  55. package/dist/docs/quickstart/dashboard-setup.md +1 -1
  56. package/dist/docs/sales/abandoned-cart-recovery.md +64 -0
  57. package/dist/docs/sales/create-a-one-time-charge.md +144 -0
  58. package/dist/http/client.js +9 -2
  59. package/dist/http/client.js.map +1 -1
  60. package/dist/http/errors.d.ts +8 -0
  61. package/dist/http/errors.js +20 -0
  62. package/dist/http/errors.js.map +1 -1
  63. package/dist/schemas/kelviq.d.ts +199 -0
  64. package/dist/schemas/kelviq.js +173 -0
  65. package/dist/schemas/kelviq.js.map +1 -1
  66. package/dist/server.js +11 -1
  67. package/dist/server.js.map +1 -1
  68. package/dist/tools/discounts.d.ts +3 -0
  69. package/dist/tools/discounts.js +74 -0
  70. package/dist/tools/discounts.js.map +1 -0
  71. package/dist/tools/index.js +4 -0
  72. package/dist/tools/index.js.map +1 -1
  73. package/dist/tools/webhooks.d.ts +10 -0
  74. package/dist/tools/webhooks.js +114 -0
  75. package/dist/tools/webhooks.js.map +1 -0
  76. package/package.json +1 -1
@@ -0,0 +1,74 @@
1
+ import { DiscountArchive, DiscountCreate, DiscountRetrieve, DiscountUpdate, ListDiscounts, } from '../schemas/kelviq.js';
2
+ import { resultToContent } from './_util.js';
3
+ export function registerDiscountTools(server, http) {
4
+ server.registerTool('discount_list', {
5
+ title: 'List discounts',
6
+ description: 'List discount codes, newest first. Optional `search` matches name and code; `page` and `pageSize` paginate. Returns { count, next, previous, results }.',
7
+ annotations: { readOnlyHint: true },
8
+ inputSchema: ListDiscounts.shape,
9
+ }, async (input) => {
10
+ const result = await http.request({
11
+ method: 'GET',
12
+ path: '/discount/',
13
+ auth: 'server',
14
+ query: { search: input.search, page: input.page, page_size: input.pageSize },
15
+ });
16
+ return resultToContent(result);
17
+ });
18
+ server.registerTool('discount_create', {
19
+ title: 'Create discount',
20
+ description: 'Create a discount code customers can enter at checkout (Merchant of Record organizations only). PERCENTAGE needs percentageOff; FIXED_AMOUNT needs amountOff and currency. `code` must be uppercase letters and numbers. Use `appliesTo` to limit it to specific products or plans. Only `isActive` can change afterwards, so confirm the details with the user first.',
21
+ annotations: { destructiveHint: false, idempotentHint: false },
22
+ inputSchema: DiscountCreate.shape,
23
+ }, async (input) => {
24
+ const result = await http.request({
25
+ method: 'POST',
26
+ path: '/discount/',
27
+ body: input,
28
+ auth: 'server',
29
+ });
30
+ return resultToContent(result);
31
+ });
32
+ server.registerTool('discount_retrieve', {
33
+ title: 'Retrieve discount',
34
+ description: 'Fetch one discount by ID, including how many times it has been redeemed and whether it is active.',
35
+ annotations: { readOnlyHint: true },
36
+ inputSchema: DiscountRetrieve.shape,
37
+ }, async (input) => {
38
+ const result = await http.request({
39
+ method: 'GET',
40
+ path: `/discount/${encodeURIComponent(input.discountId)}/`,
41
+ auth: 'server',
42
+ });
43
+ return resultToContent(result);
44
+ });
45
+ server.registerTool('discount_update', {
46
+ title: 'Enable or disable discount',
47
+ description: 'Turn a discount code on or off with `isActive`. Nothing else about a discount can change after creation — to change the amount or code, create a new discount and disable the old one.',
48
+ annotations: { destructiveHint: false, idempotentHint: true },
49
+ inputSchema: DiscountUpdate.shape,
50
+ }, async (input) => {
51
+ const { discountId, ...body } = input;
52
+ const result = await http.request({
53
+ method: 'PATCH',
54
+ path: `/discount/${encodeURIComponent(discountId)}/`,
55
+ body,
56
+ auth: 'server',
57
+ });
58
+ return resultToContent(result);
59
+ });
60
+ server.registerTool('discount_archive', {
61
+ title: 'Archive discount',
62
+ description: 'Archive (soft-delete) a discount so the code can no longer be used. Archiving an already-archived discount returns an error. Confirm with the user first.',
63
+ annotations: { destructiveHint: true, idempotentHint: false },
64
+ inputSchema: DiscountArchive.shape,
65
+ }, async (input) => {
66
+ const result = await http.request({
67
+ method: 'DELETE',
68
+ path: `/discount/${encodeURIComponent(input.discountId)}/`,
69
+ auth: 'server',
70
+ });
71
+ return resultToContent(result);
72
+ });
73
+ }
74
+ //# sourceMappingURL=discounts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discounts.js","sourceRoot":"","sources":["../../src/tools/discounts.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,UAAU,qBAAqB,CAAC,MAAiB,EAAE,IAAsB;IAC7E,MAAM,CAAC,YAAY,CACjB,eAAe,EACf;QACE,KAAK,EAAE,gBAAgB;QACvB,WAAW,EACT,yJAAyJ;QAC3J,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE;QACnC,WAAW,EAAE,aAAa,CAAC,KAAK;KACjC,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;QACd,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC;YAChC,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,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AiB,EACjB;QACE,KAAK,EAAE,4BAA4B;QACnC,WAAW,EACT,wLAAwL;QAC1L,WAAW,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE;QAC7D,WAAW,EAAE,cAAc,CAAC,KAAK;KAClC,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;QACd,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;QACtC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC;YAChC,MAAM,EAAE,OAAO;YACf,IAAI,EAAE,aAAa,kBAAkB,CAAC,UAAU,CAAC,GAAG;YACpD,IAAI;YACJ,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;QACH,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC,CACF,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,kBAAkB,EAClB;QACE,KAAK,EAAE,kBAAkB;QACzB,WAAW,EACT,2JAA2J;QAC7J,WAAW,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE;QAC7D,WAAW,EAAE,eAAe,CAAC,KAAK;KACnC,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;QACd,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC;YAChC,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,aAAa,kBAAkB,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG;YAC1D,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;QACH,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -7,6 +7,8 @@ import { registerSubscriptionTools } from './subscriptions.js';
7
7
  import { registerOfferingTools } from './offerings.js';
8
8
  import { registerPromotionTools } from './promotions.js';
9
9
  import { registerPortalTools } from './portal.js';
10
+ import { registerDiscountTools } from './discounts.js';
11
+ import { registerWebhookTools } from './webhooks.js';
10
12
  import { registerProductTools } from './products.js';
11
13
  import { registerProductSettingsTools } from './product-settings.js';
12
14
  import { registerProductFileTools } from './product-files.js';
@@ -26,6 +28,8 @@ export function registerTools(server, http) {
26
28
  registerOfferingTools(server, http);
27
29
  registerPromotionTools(server, http);
28
30
  registerPortalTools(server, http);
31
+ registerDiscountTools(server, http);
32
+ registerWebhookTools(server, http);
29
33
  // Catalog management
30
34
  registerProductTools(server, http);
31
35
  registerProductSettingsTools(server, http);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAEA,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,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAA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,CAAC;IACpC,sBAAsB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACrC,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAClC,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,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,qCAAqC;IACrC,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { KelviqHttpClient } from '../http/client.js';
3
+ export declare const HIDDEN_SECRET = "[hidden \u2014 pass revealSecret: true to include it, or write it straight to the app env file with a command]";
4
+ /**
5
+ * The webhook endpoint API returns the signing secret on list, create,
6
+ * retrieve and update. Hide it unless the caller explicitly asks, so a secret
7
+ * doesn't land in the conversation just because an endpoint was looked at.
8
+ */
9
+ export declare function redactSecrets(value: unknown): unknown;
10
+ export declare function registerWebhookTools(server: McpServer, http: KelviqHttpClient): void;
@@ -0,0 +1,114 @@
1
+ import { ListWebhookEndpoints, ListWebhookLogs, WebhookEndpointCreate, WebhookEndpointDelete, WebhookEndpointRetrieve, WebhookEndpointUpdate, } from '../schemas/kelviq.js';
2
+ import { resultToContent } from './_util.js';
3
+ export const HIDDEN_SECRET = '[hidden — pass revealSecret: true to include it, or write it straight to the app env file with a command]';
4
+ /**
5
+ * The webhook endpoint API returns the signing secret on list, create,
6
+ * retrieve and update. Hide it unless the caller explicitly asks, so a secret
7
+ * doesn't land in the conversation just because an endpoint was looked at.
8
+ */
9
+ export function redactSecrets(value) {
10
+ if (Array.isArray(value))
11
+ return value.map(redactSecrets);
12
+ if (value !== null && typeof value === 'object') {
13
+ return Object.fromEntries(Object.entries(value).map(([key, v]) => [
14
+ key,
15
+ key === 'secret' && typeof v === 'string' && v.length > 0 ? HIDDEN_SECRET : redactSecrets(v),
16
+ ]));
17
+ }
18
+ return value;
19
+ }
20
+ function secretAware(result, revealSecret) {
21
+ return result.ok && !revealSecret ? { ok: true, data: redactSecrets(result.data) } : result;
22
+ }
23
+ export function registerWebhookTools(server, http) {
24
+ server.registerTool('webhook_endpoint_list', {
25
+ title: 'List webhook endpoints',
26
+ description: 'List registered webhook endpoints with their URLs, events and enabled state. Signing secrets are hidden unless revealSecret is true. Use this before creating an endpoint to avoid registering the same URL twice.',
27
+ annotations: { readOnlyHint: true },
28
+ inputSchema: ListWebhookEndpoints.shape,
29
+ }, async (input) => {
30
+ const result = await http.request({
31
+ method: 'GET',
32
+ path: '/webhook/endpoints/',
33
+ auth: 'server',
34
+ query: { page: input.page, page_size: input.pageSize },
35
+ });
36
+ return resultToContent(secretAware(result, input.revealSecret));
37
+ });
38
+ server.registerTool('webhook_endpoint_create', {
39
+ title: 'Create webhook endpoint',
40
+ description: 'Register a URL to receive webhook events. The URL must be publicly reachable — localhost and private addresses are rejected. A signing secret is generated; it is hidden in this result unless revealSecret is true, and stays available later via webhook_endpoint_retrieve. The app verifies deliveries with this secret (SDK: validateEvent).',
41
+ annotations: { destructiveHint: false, idempotentHint: false },
42
+ inputSchema: WebhookEndpointCreate.shape,
43
+ }, async (input) => {
44
+ const { revealSecret, ...body } = input;
45
+ const result = await http.request({
46
+ method: 'POST',
47
+ path: '/webhook/endpoints/',
48
+ body,
49
+ auth: 'server',
50
+ });
51
+ return resultToContent(secretAware(result, revealSecret));
52
+ });
53
+ server.registerTool('webhook_endpoint_retrieve', {
54
+ title: 'Retrieve webhook endpoint',
55
+ description: 'Fetch one webhook endpoint by ID. The signing secret is hidden unless revealSecret is true.',
56
+ annotations: { readOnlyHint: true },
57
+ inputSchema: WebhookEndpointRetrieve.shape,
58
+ }, async (input) => {
59
+ const result = await http.request({
60
+ method: 'GET',
61
+ path: `/webhook/endpoints/${encodeURIComponent(input.endpointId)}/`,
62
+ auth: 'server',
63
+ });
64
+ return resultToContent(secretAware(result, input.revealSecret));
65
+ });
66
+ server.registerTool('webhook_endpoint_update', {
67
+ title: 'Update webhook endpoint',
68
+ description: 'Change a webhook endpoint’s URL, subscribed events, or enabled state. Only the fields you pass change. The signing secret is hidden unless revealSecret is true.',
69
+ annotations: { destructiveHint: false, idempotentHint: true },
70
+ inputSchema: WebhookEndpointUpdate.shape,
71
+ }, async (input) => {
72
+ const { endpointId, revealSecret, ...body } = input;
73
+ const result = await http.request({
74
+ method: 'PATCH',
75
+ path: `/webhook/endpoints/${encodeURIComponent(endpointId)}/`,
76
+ body,
77
+ auth: 'server',
78
+ });
79
+ return resultToContent(secretAware(result, revealSecret));
80
+ });
81
+ server.registerTool('webhook_endpoint_delete', {
82
+ title: 'Delete webhook endpoint',
83
+ description: 'Permanently delete a webhook endpoint. It stops receiving deliveries immediately. Confirm with the user first.',
84
+ annotations: { destructiveHint: true, idempotentHint: true },
85
+ inputSchema: WebhookEndpointDelete.shape,
86
+ }, async (input) => {
87
+ const result = await http.request({
88
+ method: 'DELETE',
89
+ path: `/webhook/endpoints/${encodeURIComponent(input.endpointId)}/`,
90
+ auth: 'server',
91
+ });
92
+ return resultToContent(result);
93
+ });
94
+ server.registerTool('webhook_log_list', {
95
+ title: 'List webhook deliveries',
96
+ description: 'List webhook delivery attempts (including retries), newest first, with event type, status code and success. Covers the last 30 days at most; `startDate` and `endDate` (YYYY-MM-DD) narrow the window. Use it to debug why an app is not receiving events.',
97
+ annotations: { readOnlyHint: true },
98
+ inputSchema: ListWebhookLogs.shape,
99
+ }, async (input) => {
100
+ const result = await http.request({
101
+ method: 'GET',
102
+ path: '/webhook/logs/',
103
+ auth: 'server',
104
+ query: {
105
+ start_date: input.startDate,
106
+ end_date: input.endDate,
107
+ page: input.page,
108
+ page_size: input.pageSize,
109
+ },
110
+ });
111
+ return resultToContent(result);
112
+ });
113
+ }
114
+ //# sourceMappingURL=webhooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/tools/webhooks.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,CAAC,MAAM,aAAa,GACxB,2GAA2G,CAAC;AAE9G;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC1D,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;YACtC,GAAG;YACH,GAAG,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;SAC7F,CAAC,CACH,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,WAAW,CAAC,MAAuB,EAAE,YAAiC;IA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q/mcp-server",
3
- "version": "0.4.0",
3
+ "version": "1.1.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>",