clishop 1.3.3 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mcp.js CHANGED
@@ -2,11 +2,13 @@
2
2
  import {
3
3
  getApiClient,
4
4
  getUserInfo,
5
- isLoggedIn
6
- } from "./chunk-ML7L6BAH.js";
5
+ isLoggedIn,
6
+ storeAuthFromSetup
7
+ } from "./chunk-EAXPWOMT.js";
7
8
  import {
8
9
  __export,
9
10
  getActiveAgent,
11
+ getApiBaseUrl,
10
12
  getConfig
11
13
  } from "./chunk-X3H7SYR4.js";
12
14
 
@@ -13783,6 +13785,7 @@ function date4(params) {
13783
13785
  config(en_default());
13784
13786
 
13785
13787
  // src/mcp.ts
13788
+ import axios from "axios";
13786
13789
  function formatPrice(cents, currency) {
13787
13790
  return new Intl.NumberFormat("en-US", { style: "currency", currency }).format(
13788
13791
  cents / 100
@@ -13818,6 +13821,58 @@ var server = new McpServer(
13818
13821
  }
13819
13822
  }
13820
13823
  );
13824
+ server.registerTool("setup", {
13825
+ title: "Setup",
13826
+ description: "Onboard a new user by creating their account and generating a Stripe payment setup link. The user must open this link in their browser to link their payment method. This is the ONLY step requiring human interaction. After the user completes the link, call setup_status with the returned deviceCode to get auth tokens. The agent can then use add_address to set up shipping autonomously.",
13827
+ inputSchema: {
13828
+ email: external_exports.string().email().describe("User's email address")
13829
+ },
13830
+ annotations: {
13831
+ title: "Setup",
13832
+ readOnlyHint: false,
13833
+ openWorldHint: true
13834
+ }
13835
+ }, async (args) => {
13836
+ return safeCall(async () => {
13837
+ const baseUrl = getApiBaseUrl();
13838
+ const res = await axios.post(`${baseUrl}/auth/setup-link`, {
13839
+ email: args.email
13840
+ });
13841
+ return {
13842
+ ...res.data,
13843
+ message: "Ask the user to open setupUrl in their browser to link their payment method. Then call setup_status with the deviceCode to check when they're done."
13844
+ };
13845
+ });
13846
+ });
13847
+ server.registerTool("setup_status", {
13848
+ title: "Setup Status",
13849
+ description: "Poll the setup status after the user was given a payment link via the setup tool. Returns 'pending' while waiting, 'complete' with auth tokens when done, or 'expired' if timed out.",
13850
+ inputSchema: {
13851
+ deviceCode: external_exports.string().describe("The deviceCode returned by the setup tool")
13852
+ },
13853
+ annotations: {
13854
+ title: "Setup Status",
13855
+ readOnlyHint: true
13856
+ }
13857
+ }, async (args) => {
13858
+ return safeCall(async () => {
13859
+ const baseUrl = getApiBaseUrl();
13860
+ const res = await axios.post(`${baseUrl}/auth/device/poll`, {
13861
+ deviceCode: args.deviceCode
13862
+ });
13863
+ const data = res.data;
13864
+ if (data.status === "complete" && data.token) {
13865
+ await storeAuthFromSetup({
13866
+ token: data.token,
13867
+ refreshToken: data.refreshToken,
13868
+ user: data.user
13869
+ });
13870
+ const config2 = getConfig();
13871
+ config2.set("setupCompleted", true);
13872
+ }
13873
+ return data;
13874
+ });
13875
+ });
13821
13876
  server.registerTool("search_products", {
13822
13877
  title: "Search Products",
13823
13878
  description: "Search for products across all connected stores. Supports filters for price, category, brand, delivery location, shipping speed, ratings, and more. Returns product listings with pricing, availability, and store info.",
@@ -13867,7 +13922,7 @@ server.registerTool("search_products", {
13867
13922
  }
13868
13923
  }
13869
13924
  if (!country) {
13870
- throw new Error("No delivery country available. Add a shipping address first ('clishop address add') or pass the 'country' parameter (e.g. 'US', 'NL', 'BE').");
13925
+ throw new Error("No delivery country specified. Pass the 'country' parameter with an ISO code (e.g. 'US', 'NL', 'BE', 'GB', 'DE'). You can also add a shipping address via the add_address tool to skip this next time.");
13871
13926
  }
13872
13927
  const res = await api.get("/products/search", {
13873
13928
  params: {
@@ -13945,10 +14000,10 @@ server.registerTool("buy_product", {
13945
14000
  const addressId = args.addressId || agent.defaultAddressId;
13946
14001
  const paymentId = args.paymentId || agent.defaultPaymentMethodId;
13947
14002
  if (!addressId) {
13948
- throw new Error("No shipping address set. Add one first via the address_add tool or 'clishop address add'.");
14003
+ throw new Error("No shipping address set. Add one first via the add_address tool.");
13949
14004
  }
13950
14005
  if (!paymentId) {
13951
- throw new Error("No payment method set. Add one first via 'clishop payment add'.");
14006
+ throw new Error("No payment method linked. Use the setup tool to onboard the user first.");
13952
14007
  }
13953
14008
  const api = getApiClient();
13954
14009
  let product;
@@ -14284,7 +14339,7 @@ server.registerTool("account_status", {
14284
14339
  return safeCall(async () => {
14285
14340
  const loggedIn = await isLoggedIn();
14286
14341
  if (!loggedIn) {
14287
- return { loggedIn: false, message: "Not logged in. Run 'clishop login' first." };
14342
+ return { loggedIn: false, message: "Not set up yet. Use the setup tool to onboard the user with a payment link." };
14288
14343
  }
14289
14344
  const api = getApiClient();
14290
14345
  const cfg = getConfig();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clishop",
3
- "version": "1.3.3",
3
+ "version": "1.4.1",
4
4
  "mcpName": "io.github.StefDCL/clishop",
5
5
  "description": "CLISHOP — Order anything from your terminal",
6
6
  "main": "dist/index.js",