@henrylabs/mcp 0.2.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/LICENSE +201 -0
- package/README.md +255 -0
- package/code-tool-paths.cjs +6 -0
- package/code-tool-paths.cjs.map +1 -0
- package/code-tool-paths.d.cts +2 -0
- package/code-tool-paths.d.cts.map +1 -0
- package/code-tool-types.d.mts +14 -0
- package/code-tool-types.d.mts.map +1 -0
- package/code-tool-types.d.ts +14 -0
- package/code-tool-types.d.ts.map +1 -0
- package/code-tool-types.js +4 -0
- package/code-tool-types.js.map +1 -0
- package/code-tool-types.mjs +3 -0
- package/code-tool-types.mjs.map +1 -0
- package/code-tool-worker.d.mts +5 -0
- package/code-tool-worker.d.mts.map +1 -0
- package/code-tool-worker.d.ts +5 -0
- package/code-tool-worker.d.ts.map +1 -0
- package/code-tool-worker.js +45 -0
- package/code-tool-worker.js.map +1 -0
- package/code-tool-worker.mjs +40 -0
- package/code-tool-worker.mjs.map +1 -0
- package/code-tool.d.mts +12 -0
- package/code-tool.d.mts.map +1 -0
- package/code-tool.d.ts +12 -0
- package/code-tool.d.ts.map +1 -0
- package/code-tool.js +158 -0
- package/code-tool.js.map +1 -0
- package/code-tool.mjs +122 -0
- package/code-tool.mjs.map +1 -0
- package/compat.d.mts +58 -0
- package/compat.d.mts.map +1 -0
- package/compat.d.ts +58 -0
- package/compat.d.ts.map +1 -0
- package/compat.js +387 -0
- package/compat.js.map +1 -0
- package/compat.mjs +378 -0
- package/compat.mjs.map +1 -0
- package/docs-search-tool.d.mts +44 -0
- package/docs-search-tool.d.mts.map +1 -0
- package/docs-search-tool.d.ts +44 -0
- package/docs-search-tool.d.ts.map +1 -0
- package/docs-search-tool.js +43 -0
- package/docs-search-tool.js.map +1 -0
- package/docs-search-tool.mjs +39 -0
- package/docs-search-tool.mjs.map +1 -0
- package/dynamic-tools.d.mts +12 -0
- package/dynamic-tools.d.mts.map +1 -0
- package/dynamic-tools.d.ts +12 -0
- package/dynamic-tools.d.ts.map +1 -0
- package/dynamic-tools.js +135 -0
- package/dynamic-tools.js.map +1 -0
- package/dynamic-tools.mjs +132 -0
- package/dynamic-tools.mjs.map +1 -0
- package/filtering.d.mts +2 -0
- package/filtering.d.mts.map +1 -0
- package/filtering.d.ts +2 -0
- package/filtering.d.ts.map +1 -0
- package/filtering.js +20 -0
- package/filtering.js.map +1 -0
- package/filtering.mjs +13 -0
- package/filtering.mjs.map +1 -0
- package/headers.d.mts +4 -0
- package/headers.d.mts.map +1 -0
- package/headers.d.ts +4 -0
- package/headers.d.ts.map +1 -0
- package/headers.js +13 -0
- package/headers.js.map +1 -0
- package/headers.mjs +9 -0
- package/headers.mjs.map +1 -0
- package/http.d.mts +9 -0
- package/http.d.mts.map +1 -0
- package/http.d.ts +9 -0
- package/http.d.ts.map +1 -0
- package/http.js +108 -0
- package/http.js.map +1 -0
- package/http.mjs +100 -0
- package/http.mjs.map +1 -0
- package/index.d.mts +3 -0
- package/index.d.mts.map +1 -0
- package/index.d.ts +3 -0
- package/index.d.ts.map +1 -0
- package/index.js +91 -0
- package/index.js.map +1 -0
- package/index.mjs +89 -0
- package/index.mjs.map +1 -0
- package/options.d.mts +20 -0
- package/options.d.mts.map +1 -0
- package/options.d.ts +20 -0
- package/options.d.ts.map +1 -0
- package/options.js +424 -0
- package/options.js.map +1 -0
- package/options.mjs +417 -0
- package/options.mjs.map +1 -0
- package/package.json +216 -0
- package/server.d.mts +35 -0
- package/server.d.mts.map +1 -0
- package/server.d.ts +35 -0
- package/server.d.ts.map +1 -0
- package/server.js +175 -0
- package/server.js.map +1 -0
- package/server.mjs +161 -0
- package/server.mjs.map +1 -0
- package/src/code-tool-paths.cts +3 -0
- package/src/code-tool-types.ts +14 -0
- package/src/code-tool-worker.ts +46 -0
- package/src/code-tool.ts +147 -0
- package/src/compat.ts +483 -0
- package/src/docs-search-tool.ts +48 -0
- package/src/dynamic-tools.ts +153 -0
- package/src/filtering.ts +14 -0
- package/src/headers.ts +14 -0
- package/src/http.ts +127 -0
- package/src/index.ts +108 -0
- package/src/options.ts +466 -0
- package/src/server.ts +208 -0
- package/src/stdio.ts +13 -0
- package/src/tools/cart/create-checkout-cart.ts +49 -0
- package/src/tools/cart/items/add-cart-items.ts +93 -0
- package/src/tools/cart/items/clear-cart-items.ts +47 -0
- package/src/tools/cart/items/list-cart-items.ts +47 -0
- package/src/tools/cart/items/remove-cart-items.ts +50 -0
- package/src/tools/checkout/session/confirm-checkout-checkout-session.ts +101 -0
- package/src/tools/checkout/session/create-quote-checkout-session.ts +96 -0
- package/src/tools/checkout/session/list-products-checkout-session.ts +47 -0
- package/src/tools/checkout/session/retrieve-shipping-info-checkout-session.ts +49 -0
- package/src/tools/index.ts +105 -0
- package/src/tools/merchants/check-status-merchants.ts +56 -0
- package/src/tools/merchants/get-shipping-info-merchants.ts +60 -0
- package/src/tools/merchants/list-supported-merchants.ts +52 -0
- package/src/tools/orders/retrieve-status-orders.ts +47 -0
- package/src/tools/products/retrieve-details-products.ts +48 -0
- package/src/tools/products/search-products.ts +78 -0
- package/src/tools/products/variant-check/create-products-variant-check.ts +85 -0
- package/src/tools/products/variant-check/retrieve-status-products-variant-check.ts +50 -0
- package/src/tools/types.ts +103 -0
- package/src/tools/wallet/create-card-collection-wallet.ts +49 -0
- package/src/tools.ts +1 -0
- package/src/tsconfig.json +11 -0
- package/stdio.d.mts +3 -0
- package/stdio.d.mts.map +1 -0
- package/stdio.d.ts +3 -0
- package/stdio.d.ts.map +1 -0
- package/stdio.js +14 -0
- package/stdio.js.map +1 -0
- package/stdio.mjs +10 -0
- package/stdio.mjs.map +1 -0
- package/tools/cart/create-checkout-cart.d.mts +45 -0
- package/tools/cart/create-checkout-cart.d.mts.map +1 -0
- package/tools/cart/create-checkout-cart.d.ts +45 -0
- package/tools/cart/create-checkout-cart.d.ts.map +1 -0
- package/tools/cart/create-checkout-cart.js +44 -0
- package/tools/cart/create-checkout-cart.js.map +1 -0
- package/tools/cart/create-checkout-cart.mjs +40 -0
- package/tools/cart/create-checkout-cart.mjs.map +1 -0
- package/tools/cart/items/add-cart-items.d.mts +45 -0
- package/tools/cart/items/add-cart-items.d.mts.map +1 -0
- package/tools/cart/items/add-cart-items.d.ts +45 -0
- package/tools/cart/items/add-cart-items.d.ts.map +1 -0
- package/tools/cart/items/add-cart-items.js +86 -0
- package/tools/cart/items/add-cart-items.js.map +1 -0
- package/tools/cart/items/add-cart-items.mjs +82 -0
- package/tools/cart/items/add-cart-items.mjs.map +1 -0
- package/tools/cart/items/clear-cart-items.d.mts +45 -0
- package/tools/cart/items/clear-cart-items.d.mts.map +1 -0
- package/tools/cart/items/clear-cart-items.d.ts +45 -0
- package/tools/cart/items/clear-cart-items.d.ts.map +1 -0
- package/tools/cart/items/clear-cart-items.js +42 -0
- package/tools/cart/items/clear-cart-items.js.map +1 -0
- package/tools/cart/items/clear-cart-items.mjs +38 -0
- package/tools/cart/items/clear-cart-items.mjs.map +1 -0
- package/tools/cart/items/list-cart-items.d.mts +45 -0
- package/tools/cart/items/list-cart-items.d.mts.map +1 -0
- package/tools/cart/items/list-cart-items.d.ts +45 -0
- package/tools/cart/items/list-cart-items.d.ts.map +1 -0
- package/tools/cart/items/list-cart-items.js +42 -0
- package/tools/cart/items/list-cart-items.js.map +1 -0
- package/tools/cart/items/list-cart-items.mjs +38 -0
- package/tools/cart/items/list-cart-items.mjs.map +1 -0
- package/tools/cart/items/remove-cart-items.d.mts +45 -0
- package/tools/cart/items/remove-cart-items.d.mts.map +1 -0
- package/tools/cart/items/remove-cart-items.d.ts +45 -0
- package/tools/cart/items/remove-cart-items.d.ts.map +1 -0
- package/tools/cart/items/remove-cart-items.js +45 -0
- package/tools/cart/items/remove-cart-items.js.map +1 -0
- package/tools/cart/items/remove-cart-items.mjs +41 -0
- package/tools/cart/items/remove-cart-items.mjs.map +1 -0
- package/tools/checkout/session/confirm-checkout-checkout-session.d.mts +45 -0
- package/tools/checkout/session/confirm-checkout-checkout-session.d.mts.map +1 -0
- package/tools/checkout/session/confirm-checkout-checkout-session.d.ts +45 -0
- package/tools/checkout/session/confirm-checkout-checkout-session.d.ts.map +1 -0
- package/tools/checkout/session/confirm-checkout-checkout-session.js +94 -0
- package/tools/checkout/session/confirm-checkout-checkout-session.js.map +1 -0
- package/tools/checkout/session/confirm-checkout-checkout-session.mjs +90 -0
- package/tools/checkout/session/confirm-checkout-checkout-session.mjs.map +1 -0
- package/tools/checkout/session/create-quote-checkout-session.d.mts +45 -0
- package/tools/checkout/session/create-quote-checkout-session.d.mts.map +1 -0
- package/tools/checkout/session/create-quote-checkout-session.d.ts +45 -0
- package/tools/checkout/session/create-quote-checkout-session.d.ts.map +1 -0
- package/tools/checkout/session/create-quote-checkout-session.js +91 -0
- package/tools/checkout/session/create-quote-checkout-session.js.map +1 -0
- package/tools/checkout/session/create-quote-checkout-session.mjs +87 -0
- package/tools/checkout/session/create-quote-checkout-session.mjs.map +1 -0
- package/tools/checkout/session/list-products-checkout-session.d.mts +45 -0
- package/tools/checkout/session/list-products-checkout-session.d.mts.map +1 -0
- package/tools/checkout/session/list-products-checkout-session.d.ts +45 -0
- package/tools/checkout/session/list-products-checkout-session.d.ts.map +1 -0
- package/tools/checkout/session/list-products-checkout-session.js +42 -0
- package/tools/checkout/session/list-products-checkout-session.js.map +1 -0
- package/tools/checkout/session/list-products-checkout-session.mjs +38 -0
- package/tools/checkout/session/list-products-checkout-session.mjs.map +1 -0
- package/tools/checkout/session/retrieve-shipping-info-checkout-session.d.mts +45 -0
- package/tools/checkout/session/retrieve-shipping-info-checkout-session.d.mts.map +1 -0
- package/tools/checkout/session/retrieve-shipping-info-checkout-session.d.ts +45 -0
- package/tools/checkout/session/retrieve-shipping-info-checkout-session.d.ts.map +1 -0
- package/tools/checkout/session/retrieve-shipping-info-checkout-session.js +42 -0
- package/tools/checkout/session/retrieve-shipping-info-checkout-session.js.map +1 -0
- package/tools/checkout/session/retrieve-shipping-info-checkout-session.mjs +38 -0
- package/tools/checkout/session/retrieve-shipping-info-checkout-session.mjs.map +1 -0
- package/tools/index.d.mts +10 -0
- package/tools/index.d.mts.map +1 -0
- package/tools/index.d.ts +10 -0
- package/tools/index.d.ts.map +1 -0
- package/tools/index.js +89 -0
- package/tools/index.js.map +1 -0
- package/tools/index.mjs +82 -0
- package/tools/index.mjs.map +1 -0
- package/tools/merchants/check-status-merchants.d.mts +45 -0
- package/tools/merchants/check-status-merchants.d.mts.map +1 -0
- package/tools/merchants/check-status-merchants.d.ts +45 -0
- package/tools/merchants/check-status-merchants.d.ts.map +1 -0
- package/tools/merchants/check-status-merchants.js +48 -0
- package/tools/merchants/check-status-merchants.js.map +1 -0
- package/tools/merchants/check-status-merchants.mjs +44 -0
- package/tools/merchants/check-status-merchants.mjs.map +1 -0
- package/tools/merchants/get-shipping-info-merchants.d.mts +45 -0
- package/tools/merchants/get-shipping-info-merchants.d.mts.map +1 -0
- package/tools/merchants/get-shipping-info-merchants.d.ts +45 -0
- package/tools/merchants/get-shipping-info-merchants.d.ts.map +1 -0
- package/tools/merchants/get-shipping-info-merchants.js +55 -0
- package/tools/merchants/get-shipping-info-merchants.js.map +1 -0
- package/tools/merchants/get-shipping-info-merchants.mjs +51 -0
- package/tools/merchants/get-shipping-info-merchants.mjs.map +1 -0
- package/tools/merchants/list-supported-merchants.d.mts +45 -0
- package/tools/merchants/list-supported-merchants.d.mts.map +1 -0
- package/tools/merchants/list-supported-merchants.d.ts +45 -0
- package/tools/merchants/list-supported-merchants.d.ts.map +1 -0
- package/tools/merchants/list-supported-merchants.js +47 -0
- package/tools/merchants/list-supported-merchants.js.map +1 -0
- package/tools/merchants/list-supported-merchants.mjs +43 -0
- package/tools/merchants/list-supported-merchants.mjs.map +1 -0
- package/tools/orders/retrieve-status-orders.d.mts +45 -0
- package/tools/orders/retrieve-status-orders.d.mts.map +1 -0
- package/tools/orders/retrieve-status-orders.d.ts +45 -0
- package/tools/orders/retrieve-status-orders.d.ts.map +1 -0
- package/tools/orders/retrieve-status-orders.js +42 -0
- package/tools/orders/retrieve-status-orders.js.map +1 -0
- package/tools/orders/retrieve-status-orders.mjs +38 -0
- package/tools/orders/retrieve-status-orders.mjs.map +1 -0
- package/tools/products/retrieve-details-products.d.mts +45 -0
- package/tools/products/retrieve-details-products.d.mts.map +1 -0
- package/tools/products/retrieve-details-products.d.ts +45 -0
- package/tools/products/retrieve-details-products.d.ts.map +1 -0
- package/tools/products/retrieve-details-products.js +43 -0
- package/tools/products/retrieve-details-products.js.map +1 -0
- package/tools/products/retrieve-details-products.mjs +39 -0
- package/tools/products/retrieve-details-products.mjs.map +1 -0
- package/tools/products/search-products.d.mts +45 -0
- package/tools/products/search-products.d.mts.map +1 -0
- package/tools/products/search-products.d.ts +45 -0
- package/tools/products/search-products.d.ts.map +1 -0
- package/tools/products/search-products.js +73 -0
- package/tools/products/search-products.js.map +1 -0
- package/tools/products/search-products.mjs +69 -0
- package/tools/products/search-products.mjs.map +1 -0
- package/tools/products/variant-check/create-products-variant-check.d.mts +45 -0
- package/tools/products/variant-check/create-products-variant-check.d.mts.map +1 -0
- package/tools/products/variant-check/create-products-variant-check.d.ts +45 -0
- package/tools/products/variant-check/create-products-variant-check.d.ts.map +1 -0
- package/tools/products/variant-check/create-products-variant-check.js +79 -0
- package/tools/products/variant-check/create-products-variant-check.js.map +1 -0
- package/tools/products/variant-check/create-products-variant-check.mjs +75 -0
- package/tools/products/variant-check/create-products-variant-check.mjs.map +1 -0
- package/tools/products/variant-check/retrieve-status-products-variant-check.d.mts +45 -0
- package/tools/products/variant-check/retrieve-status-products-variant-check.d.mts.map +1 -0
- package/tools/products/variant-check/retrieve-status-products-variant-check.d.ts +45 -0
- package/tools/products/variant-check/retrieve-status-products-variant-check.d.ts.map +1 -0
- package/tools/products/variant-check/retrieve-status-products-variant-check.js +43 -0
- package/tools/products/variant-check/retrieve-status-products-variant-check.js.map +1 -0
- package/tools/products/variant-check/retrieve-status-products-variant-check.mjs +39 -0
- package/tools/products/variant-check/retrieve-status-products-variant-check.mjs.map +1 -0
- package/tools/types.d.mts +51 -0
- package/tools/types.d.mts.map +1 -0
- package/tools/types.d.ts +51 -0
- package/tools/types.d.ts.map +1 -0
- package/tools/types.js +46 -0
- package/tools/types.js.map +1 -0
- package/tools/types.mjs +42 -0
- package/tools/types.mjs.map +1 -0
- package/tools/wallet/create-card-collection-wallet.d.mts +45 -0
- package/tools/wallet/create-card-collection-wallet.d.mts.map +1 -0
- package/tools/wallet/create-card-collection-wallet.d.ts +45 -0
- package/tools/wallet/create-card-collection-wallet.d.ts.map +1 -0
- package/tools/wallet/create-card-collection-wallet.js +44 -0
- package/tools/wallet/create-card-collection-wallet.js.map +1 -0
- package/tools/wallet/create-card-collection-wallet.mjs +40 -0
- package/tools/wallet/create-card-collection-wallet.mjs.map +1 -0
- package/tools.d.mts +2 -0
- package/tools.d.mts.map +1 -0
- package/tools.d.ts +2 -0
- package/tools.d.ts.map +1 -0
- package/tools.js +18 -0
- package/tools.js.map +1 -0
- package/tools.mjs +2 -0
- package/tools.mjs.map +1 -0
package/src/server.ts
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
4
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
|
+
import { Endpoint, endpoints, HandlerFunction, query } from './tools';
|
|
6
|
+
import {
|
|
7
|
+
CallToolRequestSchema,
|
|
8
|
+
ListToolsRequestSchema,
|
|
9
|
+
SetLevelRequestSchema,
|
|
10
|
+
Implementation,
|
|
11
|
+
Tool,
|
|
12
|
+
} from '@modelcontextprotocol/sdk/types.js';
|
|
13
|
+
import { ClientOptions } from '@henrylabs/sdk';
|
|
14
|
+
import HenrySDK from '@henrylabs/sdk';
|
|
15
|
+
import {
|
|
16
|
+
applyCompatibilityTransformations,
|
|
17
|
+
ClientCapabilities,
|
|
18
|
+
defaultClientCapabilities,
|
|
19
|
+
knownClients,
|
|
20
|
+
parseEmbeddedJSON,
|
|
21
|
+
} from './compat';
|
|
22
|
+
import { dynamicTools } from './dynamic-tools';
|
|
23
|
+
import { codeTool } from './code-tool';
|
|
24
|
+
import docsSearchTool from './docs-search-tool';
|
|
25
|
+
import { McpOptions } from './options';
|
|
26
|
+
|
|
27
|
+
export { McpOptions } from './options';
|
|
28
|
+
export { ClientType } from './compat';
|
|
29
|
+
export { Filter } from './tools';
|
|
30
|
+
export { ClientOptions } from '@henrylabs/sdk';
|
|
31
|
+
export { endpoints } from './tools';
|
|
32
|
+
|
|
33
|
+
export const newMcpServer = () =>
|
|
34
|
+
new McpServer(
|
|
35
|
+
{
|
|
36
|
+
name: 'henrylabs_sdk_api',
|
|
37
|
+
version: '0.2.0',
|
|
38
|
+
},
|
|
39
|
+
{ capabilities: { tools: {}, logging: {} } },
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
// Create server instance
|
|
43
|
+
export const server = newMcpServer();
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Initializes the provided MCP Server with the given tools and handlers.
|
|
47
|
+
* If not provided, the default client, tools and handlers will be used.
|
|
48
|
+
*/
|
|
49
|
+
export function initMcpServer(params: {
|
|
50
|
+
server: Server | McpServer;
|
|
51
|
+
clientOptions?: ClientOptions;
|
|
52
|
+
mcpOptions?: McpOptions;
|
|
53
|
+
}) {
|
|
54
|
+
const server = params.server instanceof McpServer ? params.server.server : params.server;
|
|
55
|
+
const mcpOptions = params.mcpOptions ?? {};
|
|
56
|
+
|
|
57
|
+
let providedEndpoints: Endpoint[] | null = null;
|
|
58
|
+
let endpointMap: Record<string, Endpoint> | null = null;
|
|
59
|
+
|
|
60
|
+
const initTools = async (implementation?: Implementation) => {
|
|
61
|
+
if (implementation && (!mcpOptions.client || mcpOptions.client === 'infer')) {
|
|
62
|
+
mcpOptions.client =
|
|
63
|
+
implementation.name.toLowerCase().includes('claude') ? 'claude'
|
|
64
|
+
: implementation.name.toLowerCase().includes('cursor') ? 'cursor'
|
|
65
|
+
: undefined;
|
|
66
|
+
mcpOptions.capabilities = {
|
|
67
|
+
...(mcpOptions.client && knownClients[mcpOptions.client]),
|
|
68
|
+
...mcpOptions.capabilities,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
providedEndpoints ??= await selectTools(endpoints, mcpOptions);
|
|
72
|
+
endpointMap ??= Object.fromEntries(providedEndpoints.map((endpoint) => [endpoint.tool.name, endpoint]));
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const logAtLevel =
|
|
76
|
+
(level: 'debug' | 'info' | 'warning' | 'error') =>
|
|
77
|
+
(message: string, ...rest: unknown[]) => {
|
|
78
|
+
void server.sendLoggingMessage({
|
|
79
|
+
level,
|
|
80
|
+
data: { message, rest },
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
const logger = {
|
|
84
|
+
debug: logAtLevel('debug'),
|
|
85
|
+
info: logAtLevel('info'),
|
|
86
|
+
warn: logAtLevel('warning'),
|
|
87
|
+
error: logAtLevel('error'),
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
let client = new HenrySDK({
|
|
91
|
+
...{ environment: (readEnv('HENRY_SDK_ENVIRONMENT') || undefined) as any },
|
|
92
|
+
logger,
|
|
93
|
+
...params.clientOptions,
|
|
94
|
+
defaultHeaders: {
|
|
95
|
+
...params.clientOptions?.defaultHeaders,
|
|
96
|
+
'X-Stainless-MCP': 'true',
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
101
|
+
if (providedEndpoints === null) {
|
|
102
|
+
await initTools(server.getClientVersion());
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
tools: providedEndpoints!.map((endpoint) => endpoint.tool),
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
110
|
+
if (endpointMap === null) {
|
|
111
|
+
await initTools(server.getClientVersion());
|
|
112
|
+
}
|
|
113
|
+
const { name, arguments: args } = request.params;
|
|
114
|
+
const endpoint = endpointMap![name];
|
|
115
|
+
if (!endpoint) {
|
|
116
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return executeHandler(endpoint.tool, endpoint.handler, client, args, mcpOptions.capabilities);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
server.setRequestHandler(SetLevelRequestSchema, async (request) => {
|
|
123
|
+
const { level } = request.params;
|
|
124
|
+
switch (level) {
|
|
125
|
+
case 'debug':
|
|
126
|
+
client = client.withOptions({ logLevel: 'debug' });
|
|
127
|
+
break;
|
|
128
|
+
case 'info':
|
|
129
|
+
client = client.withOptions({ logLevel: 'info' });
|
|
130
|
+
break;
|
|
131
|
+
case 'notice':
|
|
132
|
+
case 'warning':
|
|
133
|
+
client = client.withOptions({ logLevel: 'warn' });
|
|
134
|
+
break;
|
|
135
|
+
case 'error':
|
|
136
|
+
client = client.withOptions({ logLevel: 'error' });
|
|
137
|
+
break;
|
|
138
|
+
default:
|
|
139
|
+
client = client.withOptions({ logLevel: 'off' });
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
return {};
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Selects the tools to include in the MCP Server based on the provided options.
|
|
148
|
+
*/
|
|
149
|
+
export async function selectTools(endpoints: Endpoint[], options?: McpOptions): Promise<Endpoint[]> {
|
|
150
|
+
const filteredEndpoints = query(options?.filters ?? [], endpoints);
|
|
151
|
+
|
|
152
|
+
let includedTools = filteredEndpoints.slice();
|
|
153
|
+
|
|
154
|
+
if (includedTools.length > 0) {
|
|
155
|
+
if (options?.includeDynamicTools) {
|
|
156
|
+
includedTools = dynamicTools(includedTools);
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
if (options?.includeAllTools) {
|
|
160
|
+
includedTools = endpoints.slice();
|
|
161
|
+
} else if (options?.includeDynamicTools) {
|
|
162
|
+
includedTools = dynamicTools(endpoints);
|
|
163
|
+
} else if (options?.includeCodeTools) {
|
|
164
|
+
includedTools = [await codeTool()];
|
|
165
|
+
} else {
|
|
166
|
+
includedTools = endpoints.slice();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (options?.includeDocsTools ?? true) {
|
|
170
|
+
includedTools.push(docsSearchTool);
|
|
171
|
+
}
|
|
172
|
+
const capabilities = { ...defaultClientCapabilities, ...options?.capabilities };
|
|
173
|
+
return applyCompatibilityTransformations(includedTools, capabilities);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Runs the provided handler with the given client and arguments.
|
|
178
|
+
*/
|
|
179
|
+
export async function executeHandler(
|
|
180
|
+
tool: Tool,
|
|
181
|
+
handler: HandlerFunction,
|
|
182
|
+
client: HenrySDK,
|
|
183
|
+
args: Record<string, unknown> | undefined,
|
|
184
|
+
compatibilityOptions?: Partial<ClientCapabilities>,
|
|
185
|
+
) {
|
|
186
|
+
const options = { ...defaultClientCapabilities, ...compatibilityOptions };
|
|
187
|
+
if (!options.validJson && args) {
|
|
188
|
+
args = parseEmbeddedJSON(args, tool.inputSchema);
|
|
189
|
+
}
|
|
190
|
+
return await handler(client, args || {});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export const readEnv = (env: string): string | undefined => {
|
|
194
|
+
if (typeof (globalThis as any).process !== 'undefined') {
|
|
195
|
+
return (globalThis as any).process.env?.[env]?.trim();
|
|
196
|
+
} else if (typeof (globalThis as any).Deno !== 'undefined') {
|
|
197
|
+
return (globalThis as any).Deno.env?.get?.(env)?.trim();
|
|
198
|
+
}
|
|
199
|
+
return;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export const readEnvOrError = (env: string): string => {
|
|
203
|
+
let envValue = readEnv(env);
|
|
204
|
+
if (envValue === undefined) {
|
|
205
|
+
throw new Error(`Environment variable ${env} is not set`);
|
|
206
|
+
}
|
|
207
|
+
return envValue;
|
|
208
|
+
};
|
package/src/stdio.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
2
|
+
import { initMcpServer, newMcpServer } from './server';
|
|
3
|
+
import { McpOptions } from './options';
|
|
4
|
+
|
|
5
|
+
export const launchStdioServer = async (options: McpOptions) => {
|
|
6
|
+
const server = newMcpServer();
|
|
7
|
+
|
|
8
|
+
initMcpServer({ server, mcpOptions: options });
|
|
9
|
+
|
|
10
|
+
const transport = new StdioServerTransport();
|
|
11
|
+
await server.connect(transport);
|
|
12
|
+
console.error('MCP Server running on stdio');
|
|
13
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { maybeFilter } from '@henrylabs/mcp/filtering';
|
|
4
|
+
import { Metadata, asTextContentResult } from '@henrylabs/mcp/tools/types';
|
|
5
|
+
|
|
6
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
7
|
+
import HenrySDK from '@henrylabs/sdk';
|
|
8
|
+
|
|
9
|
+
export const metadata: Metadata = {
|
|
10
|
+
resource: 'cart',
|
|
11
|
+
operation: 'write',
|
|
12
|
+
tags: [],
|
|
13
|
+
httpMethod: 'post',
|
|
14
|
+
httpPath: '/cart/checkout',
|
|
15
|
+
operationId: 'createHostedCheckoutPage',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const tool: Tool = {
|
|
19
|
+
name: 'create_checkout_cart',
|
|
20
|
+
description:
|
|
21
|
+
"When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nGenerates a hosted checkout URL for the user's cart that can be embedded in an iframe or modal. The page walks the buyer through reviewing the order, entering shipping and payment information, and confirming the purchase.\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/cart_create_checkout_response',\n $defs: {\n cart_create_checkout_response: {\n type: 'object',\n properties: {\n message: {\n type: 'string'\n },\n status: {\n type: 'string'\n },\n success: {\n type: 'boolean'\n },\n data: {\n type: 'object',\n properties: {\n checkout_url: {\n type: 'string'\n }\n },\n required: [ 'checkout_url'\n ]\n }\n },\n required: [ 'message',\n 'status',\n 'success'\n ]\n }\n }\n}\n```",
|
|
22
|
+
inputSchema: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
'x-user-id': {
|
|
26
|
+
type: 'string',
|
|
27
|
+
},
|
|
28
|
+
auth: {
|
|
29
|
+
type: 'boolean',
|
|
30
|
+
description: 'Whether authentication is required for checkout (default: true)',
|
|
31
|
+
},
|
|
32
|
+
jq_filter: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
title: 'jq Filter',
|
|
35
|
+
description:
|
|
36
|
+
'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
required: ['x-user-id'],
|
|
40
|
+
},
|
|
41
|
+
annotations: {},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const handler = async (client: HenrySDK, args: Record<string, unknown> | undefined) => {
|
|
45
|
+
const { jq_filter, ...body } = args as any;
|
|
46
|
+
return asTextContentResult(await maybeFilter(jq_filter, await client.cart.createCheckout(body)));
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default { metadata, tool, handler };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { maybeFilter } from '@henrylabs/mcp/filtering';
|
|
4
|
+
import { Metadata, asTextContentResult } from '@henrylabs/mcp/tools/types';
|
|
5
|
+
|
|
6
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
7
|
+
import HenrySDK from '@henrylabs/sdk';
|
|
8
|
+
|
|
9
|
+
export const metadata: Metadata = {
|
|
10
|
+
resource: 'cart.items',
|
|
11
|
+
operation: 'write',
|
|
12
|
+
tags: [],
|
|
13
|
+
httpMethod: 'post',
|
|
14
|
+
httpPath: '/cart/items',
|
|
15
|
+
operationId: 'addCartItems',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const tool: Tool = {
|
|
19
|
+
name: 'add_cart_items',
|
|
20
|
+
description:
|
|
21
|
+
"When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nAdds product data to existing cart or create a new one.\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/item_add_response',\n $defs: {\n item_add_response: {\n type: 'object',\n properties: {\n message: {\n type: 'string'\n },\n status: {\n type: 'string'\n },\n success: {\n type: 'boolean'\n },\n data: {\n type: 'object',\n properties: {\n added_products: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n name: {\n type: 'string'\n },\n price: {\n type: 'string'\n },\n productId: {\n type: 'string'\n },\n quantity: {\n type: 'number'\n }\n },\n required: [ 'name',\n 'price',\n 'productId',\n 'quantity'\n ]\n }\n },\n cart_summary: {\n type: 'object',\n properties: {\n total_items: {\n type: 'number'\n },\n total_unique_products: {\n type: 'number'\n }\n },\n required: [ 'total_items',\n 'total_unique_products'\n ]\n },\n updated_products: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n addedQuantity: {\n type: 'number'\n },\n name: {\n type: 'string'\n },\n previousQuantity: {\n type: 'number'\n },\n price: {\n type: 'string'\n },\n productId: {\n type: 'string'\n },\n quantity: {\n type: 'number'\n }\n },\n required: [ 'addedQuantity',\n 'name',\n 'previousQuantity',\n 'price',\n 'productId',\n 'quantity'\n ]\n }\n },\n variant_checks: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n productId: {\n type: 'string'\n },\n status: {\n type: 'string'\n },\n variantCheckRequestId: {\n type: 'string'\n }\n },\n required: [ 'productId',\n 'status',\n 'variantCheckRequestId'\n ]\n }\n }\n },\n required: [ 'added_products',\n 'cart_summary',\n 'updated_products'\n ]\n }\n },\n required: [ 'message',\n 'status',\n 'success'\n ]\n }\n }\n}\n```",
|
|
22
|
+
inputSchema: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
productsDetails: {
|
|
26
|
+
type: 'array',
|
|
27
|
+
items: {
|
|
28
|
+
type: 'object',
|
|
29
|
+
properties: {
|
|
30
|
+
name: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
description: 'Product name',
|
|
33
|
+
},
|
|
34
|
+
price: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
description: 'Product price',
|
|
37
|
+
},
|
|
38
|
+
productLink: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
description: 'Product link',
|
|
41
|
+
},
|
|
42
|
+
quantity: {
|
|
43
|
+
type: 'number',
|
|
44
|
+
description: 'Quantity',
|
|
45
|
+
},
|
|
46
|
+
affiliateProductLink: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
description:
|
|
49
|
+
'Affiliate product link (if provided, will be used instead of productLink for order fulfillment)',
|
|
50
|
+
},
|
|
51
|
+
metadata: {
|
|
52
|
+
type: 'object',
|
|
53
|
+
description: 'Product metadata',
|
|
54
|
+
additionalProperties: true,
|
|
55
|
+
},
|
|
56
|
+
productId: {
|
|
57
|
+
type: 'string',
|
|
58
|
+
description: 'Product Id',
|
|
59
|
+
},
|
|
60
|
+
productImageLink: {
|
|
61
|
+
type: 'string',
|
|
62
|
+
description: 'Product image link (thumbnail)',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
required: ['name', 'price', 'productLink', 'quantity'],
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
'x-user-id': {
|
|
69
|
+
type: 'string',
|
|
70
|
+
},
|
|
71
|
+
checkVariantAvailability: {
|
|
72
|
+
type: 'boolean',
|
|
73
|
+
description:
|
|
74
|
+
'Whether to check variant availability after adding to cart. If true, variant check requests will be created for products with metadata and requestIds returned.',
|
|
75
|
+
},
|
|
76
|
+
jq_filter: {
|
|
77
|
+
type: 'string',
|
|
78
|
+
title: 'jq Filter',
|
|
79
|
+
description:
|
|
80
|
+
'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).',
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
required: ['productsDetails', 'x-user-id'],
|
|
84
|
+
},
|
|
85
|
+
annotations: {},
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const handler = async (client: HenrySDK, args: Record<string, unknown> | undefined) => {
|
|
89
|
+
const { jq_filter, ...body } = args as any;
|
|
90
|
+
return asTextContentResult(await maybeFilter(jq_filter, await client.cart.items.add(body)));
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export default { metadata, tool, handler };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { maybeFilter } from '@henrylabs/mcp/filtering';
|
|
4
|
+
import { Metadata, asTextContentResult } from '@henrylabs/mcp/tools/types';
|
|
5
|
+
|
|
6
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
7
|
+
import HenrySDK from '@henrylabs/sdk';
|
|
8
|
+
|
|
9
|
+
export const metadata: Metadata = {
|
|
10
|
+
resource: 'cart.items',
|
|
11
|
+
operation: 'write',
|
|
12
|
+
tags: [],
|
|
13
|
+
httpMethod: 'delete',
|
|
14
|
+
httpPath: '/cart/items',
|
|
15
|
+
operationId: 'deleteAllCartItems',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const tool: Tool = {
|
|
19
|
+
name: 'clear_cart_items',
|
|
20
|
+
description:
|
|
21
|
+
"When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nDelete all products from the cart\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/item_clear_response',\n $defs: {\n item_clear_response: {\n type: 'object',\n properties: {\n message: {\n type: 'string'\n },\n status: {\n type: 'string'\n },\n success: {\n type: 'boolean'\n }\n },\n required: [ 'message',\n 'status',\n 'success'\n ]\n }\n }\n}\n```",
|
|
22
|
+
inputSchema: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
'x-user-id': {
|
|
26
|
+
type: 'string',
|
|
27
|
+
},
|
|
28
|
+
jq_filter: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
title: 'jq Filter',
|
|
31
|
+
description:
|
|
32
|
+
'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
required: ['x-user-id'],
|
|
36
|
+
},
|
|
37
|
+
annotations: {
|
|
38
|
+
idempotentHint: true,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const handler = async (client: HenrySDK, args: Record<string, unknown> | undefined) => {
|
|
43
|
+
const { jq_filter, ...body } = args as any;
|
|
44
|
+
return asTextContentResult(await maybeFilter(jq_filter, await client.cart.items.clear(body)));
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default { metadata, tool, handler };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { maybeFilter } from '@henrylabs/mcp/filtering';
|
|
4
|
+
import { Metadata, asTextContentResult } from '@henrylabs/mcp/tools/types';
|
|
5
|
+
|
|
6
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
7
|
+
import HenrySDK from '@henrylabs/sdk';
|
|
8
|
+
|
|
9
|
+
export const metadata: Metadata = {
|
|
10
|
+
resource: 'cart.items',
|
|
11
|
+
operation: 'read',
|
|
12
|
+
tags: [],
|
|
13
|
+
httpMethod: 'get',
|
|
14
|
+
httpPath: '/cart/items',
|
|
15
|
+
operationId: 'getCartItems',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const tool: Tool = {
|
|
19
|
+
name: 'list_cart_items',
|
|
20
|
+
description:
|
|
21
|
+
"When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nGet all products from the cart\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/item_list_response',\n $defs: {\n item_list_response: {\n type: 'object',\n properties: {\n message: {\n type: 'string'\n },\n status: {\n type: 'string'\n },\n success: {\n type: 'boolean'\n },\n data: {\n type: 'object',\n properties: {\n products: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n name: {\n type: 'string',\n description: 'Product name'\n },\n price: {\n type: 'string',\n description: 'Product price'\n },\n productLink: {\n type: 'string',\n description: 'Product link'\n },\n quantity: {\n type: 'number',\n description: 'Quantity'\n },\n affiliateProductLink: {\n type: 'string',\n description: 'Affiliate product link (if provided, will be used instead of productLink for order fulfillment)'\n },\n metadata: {\n type: 'object',\n description: 'Product metadata',\n additionalProperties: true\n },\n productId: {\n type: 'string',\n description: 'Product Id'\n },\n productImageLink: {\n type: 'string',\n description: 'Product image link (thumbnail)'\n }\n },\n required: [ 'name',\n 'price',\n 'productLink',\n 'quantity'\n ]\n }\n }\n },\n required: [ 'products'\n ]\n }\n },\n required: [ 'message',\n 'status',\n 'success'\n ]\n }\n }\n}\n```",
|
|
22
|
+
inputSchema: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
'x-user-id': {
|
|
26
|
+
type: 'string',
|
|
27
|
+
},
|
|
28
|
+
jq_filter: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
title: 'jq Filter',
|
|
31
|
+
description:
|
|
32
|
+
'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
required: ['x-user-id'],
|
|
36
|
+
},
|
|
37
|
+
annotations: {
|
|
38
|
+
readOnlyHint: true,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const handler = async (client: HenrySDK, args: Record<string, unknown> | undefined) => {
|
|
43
|
+
const { jq_filter, ...body } = args as any;
|
|
44
|
+
return asTextContentResult(await maybeFilter(jq_filter, await client.cart.items.list(body)));
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default { metadata, tool, handler };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { maybeFilter } from '@henrylabs/mcp/filtering';
|
|
4
|
+
import { Metadata, asTextContentResult } from '@henrylabs/mcp/tools/types';
|
|
5
|
+
|
|
6
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
7
|
+
import HenrySDK from '@henrylabs/sdk';
|
|
8
|
+
|
|
9
|
+
export const metadata: Metadata = {
|
|
10
|
+
resource: 'cart.items',
|
|
11
|
+
operation: 'write',
|
|
12
|
+
tags: [],
|
|
13
|
+
httpMethod: 'delete',
|
|
14
|
+
httpPath: '/cart/items/{productId}',
|
|
15
|
+
operationId: 'deleteCartItem',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const tool: Tool = {
|
|
19
|
+
name: 'remove_cart_items',
|
|
20
|
+
description:
|
|
21
|
+
"When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nDelete a product from the cart\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/item_remove_response',\n $defs: {\n item_remove_response: {\n type: 'object',\n properties: {\n message: {\n type: 'string'\n },\n status: {\n type: 'string'\n },\n success: {\n type: 'boolean'\n }\n },\n required: [ 'message',\n 'status',\n 'success'\n ]\n }\n }\n}\n```",
|
|
22
|
+
inputSchema: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
productId: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
},
|
|
28
|
+
'x-user-id': {
|
|
29
|
+
type: 'string',
|
|
30
|
+
},
|
|
31
|
+
jq_filter: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
title: 'jq Filter',
|
|
34
|
+
description:
|
|
35
|
+
'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
required: ['productId', 'x-user-id'],
|
|
39
|
+
},
|
|
40
|
+
annotations: {
|
|
41
|
+
idempotentHint: true,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const handler = async (client: HenrySDK, args: Record<string, unknown> | undefined) => {
|
|
46
|
+
const { productId, jq_filter, ...body } = args as any;
|
|
47
|
+
return asTextContentResult(await maybeFilter(jq_filter, await client.cart.items.remove(productId, body)));
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default { metadata, tool, handler };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { maybeFilter } from '@henrylabs/mcp/filtering';
|
|
4
|
+
import { Metadata, asTextContentResult } from '@henrylabs/mcp/tools/types';
|
|
5
|
+
|
|
6
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
7
|
+
import HenrySDK from '@henrylabs/sdk';
|
|
8
|
+
|
|
9
|
+
export const metadata: Metadata = {
|
|
10
|
+
resource: 'checkout.session',
|
|
11
|
+
operation: 'write',
|
|
12
|
+
tags: [],
|
|
13
|
+
httpMethod: 'post',
|
|
14
|
+
httpPath: '/checkout/session/confirm',
|
|
15
|
+
operationId: 'confirmCheckoutSession',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const tool: Tool = {
|
|
19
|
+
name: 'confirm_checkout_checkout_session',
|
|
20
|
+
description:
|
|
21
|
+
"When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nConfirms the checkout session and creates an order\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/session_confirm_checkout_response',\n $defs: {\n session_confirm_checkout_response: {\n type: 'object',\n properties: {\n message: {\n type: 'string'\n },\n status: {\n type: 'string'\n },\n success: {\n type: 'boolean'\n },\n data: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n currency: {\n type: 'string'\n },\n grandTotal: {\n type: 'string'\n },\n products: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n productName: {\n type: 'string'\n },\n quantity: {\n type: 'number'\n },\n productMetadata: {\n type: 'object',\n additionalProperties: true\n }\n },\n required: [ 'productName',\n 'quantity'\n ]\n }\n },\n shipping: {\n type: 'string'\n },\n shippingDetails: {\n type: 'object',\n properties: {\n addressLine1: {\n type: 'string',\n description: 'Address line 1'\n },\n city: {\n type: 'string',\n description: 'City'\n },\n countryCode: {\n type: 'string',\n description: 'Country code'\n },\n email: {\n type: 'string',\n description: 'Email'\n },\n fullName: {\n type: 'string',\n description: 'Full name'\n },\n phoneNumber: {\n type: 'string',\n description: 'Phone number'\n },\n postalCode: {\n type: 'string',\n description: 'Postal code'\n },\n stateOrProvince: {\n type: 'string',\n description: 'State or province'\n },\n addressLine2: {\n type: 'string',\n description: 'Address line 2'\n }\n },\n required: [ 'addressLine1',\n 'city',\n 'countryCode',\n 'email',\n 'fullName',\n 'phoneNumber',\n 'postalCode',\n 'stateOrProvince'\n ]\n },\n status: {\n type: 'string'\n },\n statusMessage: {\n type: 'string'\n },\n subtotal: {\n type: 'string'\n },\n tax: {\n type: 'string'\n },\n cardLast4: {\n type: 'string'\n }\n },\n required: [ 'id',\n 'currency',\n 'grandTotal',\n 'products',\n 'shipping',\n 'shippingDetails',\n 'status',\n 'statusMessage',\n 'subtotal',\n 'tax'\n ]\n }\n },\n required: [ 'message',\n 'status',\n 'success'\n ]\n }\n }\n}\n```",
|
|
22
|
+
inputSchema: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
'x-session-token': {
|
|
26
|
+
type: 'string',
|
|
27
|
+
},
|
|
28
|
+
shippingDetails: {
|
|
29
|
+
type: 'object',
|
|
30
|
+
properties: {
|
|
31
|
+
addressLine1: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
description: 'Address line 1',
|
|
34
|
+
},
|
|
35
|
+
city: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
description: 'City',
|
|
38
|
+
},
|
|
39
|
+
countryCode: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
description: 'Country code',
|
|
42
|
+
},
|
|
43
|
+
email: {
|
|
44
|
+
type: 'string',
|
|
45
|
+
description: 'Email',
|
|
46
|
+
},
|
|
47
|
+
fullName: {
|
|
48
|
+
type: 'string',
|
|
49
|
+
description: 'Full name',
|
|
50
|
+
},
|
|
51
|
+
phoneNumber: {
|
|
52
|
+
type: 'string',
|
|
53
|
+
description: 'Phone number',
|
|
54
|
+
},
|
|
55
|
+
postalCode: {
|
|
56
|
+
type: 'string',
|
|
57
|
+
description: 'Postal code',
|
|
58
|
+
},
|
|
59
|
+
stateOrProvince: {
|
|
60
|
+
type: 'string',
|
|
61
|
+
description: 'State or province',
|
|
62
|
+
},
|
|
63
|
+
addressLine2: {
|
|
64
|
+
type: 'string',
|
|
65
|
+
description: 'Address line 2',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
required: [
|
|
69
|
+
'addressLine1',
|
|
70
|
+
'city',
|
|
71
|
+
'countryCode',
|
|
72
|
+
'email',
|
|
73
|
+
'fullName',
|
|
74
|
+
'phoneNumber',
|
|
75
|
+
'postalCode',
|
|
76
|
+
'stateOrProvince',
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
'x-user-id': {
|
|
80
|
+
type: 'string',
|
|
81
|
+
},
|
|
82
|
+
jq_filter: {
|
|
83
|
+
type: 'string',
|
|
84
|
+
title: 'jq Filter',
|
|
85
|
+
description:
|
|
86
|
+
'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).',
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
required: ['x-session-token'],
|
|
90
|
+
},
|
|
91
|
+
annotations: {},
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const handler = async (client: HenrySDK, args: Record<string, unknown> | undefined) => {
|
|
95
|
+
const { jq_filter, ...body } = args as any;
|
|
96
|
+
return asTextContentResult(
|
|
97
|
+
await maybeFilter(jq_filter, await client.checkout.session.confirmCheckout(body)),
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export default { metadata, tool, handler };
|