clishop 1.3.2 → 1.4.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/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,60 @@ 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
+ name: external_exports.string().describe("User's full name")
13830
+ },
13831
+ annotations: {
13832
+ title: "Setup",
13833
+ readOnlyHint: false,
13834
+ openWorldHint: true
13835
+ }
13836
+ }, async (args) => {
13837
+ return safeCall(async () => {
13838
+ const baseUrl = getApiBaseUrl();
13839
+ const res = await axios.post(`${baseUrl}/auth/setup-link`, {
13840
+ email: args.email,
13841
+ name: args.name
13842
+ });
13843
+ return {
13844
+ ...res.data,
13845
+ 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."
13846
+ };
13847
+ });
13848
+ });
13849
+ server.registerTool("setup_status", {
13850
+ title: "Setup Status",
13851
+ 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.",
13852
+ inputSchema: {
13853
+ deviceCode: external_exports.string().describe("The deviceCode returned by the setup tool")
13854
+ },
13855
+ annotations: {
13856
+ title: "Setup Status",
13857
+ readOnlyHint: true
13858
+ }
13859
+ }, async (args) => {
13860
+ return safeCall(async () => {
13861
+ const baseUrl = getApiBaseUrl();
13862
+ const res = await axios.post(`${baseUrl}/auth/device/poll`, {
13863
+ deviceCode: args.deviceCode
13864
+ });
13865
+ const data = res.data;
13866
+ if (data.status === "complete" && data.token) {
13867
+ await storeAuthFromSetup({
13868
+ token: data.token,
13869
+ refreshToken: data.refreshToken,
13870
+ user: data.user
13871
+ });
13872
+ const config2 = getConfig();
13873
+ config2.set("setupCompleted", true);
13874
+ }
13875
+ return data;
13876
+ });
13877
+ });
13821
13878
  server.registerTool("search_products", {
13822
13879
  title: "Search Products",
13823
13880
  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 +13924,7 @@ server.registerTool("search_products", {
13867
13924
  }
13868
13925
  }
13869
13926
  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').");
13927
+ throw new Error("No delivery country available. Add a shipping address first via the add_address tool, or pass the 'country' parameter (e.g. 'US', 'NL', 'BE').");
13871
13928
  }
13872
13929
  const res = await api.get("/products/search", {
13873
13930
  params: {
@@ -13945,10 +14002,10 @@ server.registerTool("buy_product", {
13945
14002
  const addressId = args.addressId || agent.defaultAddressId;
13946
14003
  const paymentId = args.paymentId || agent.defaultPaymentMethodId;
13947
14004
  if (!addressId) {
13948
- throw new Error("No shipping address set. Add one first via the address_add tool or 'clishop address add'.");
14005
+ throw new Error("No shipping address set. Add one first via the add_address tool.");
13949
14006
  }
13950
14007
  if (!paymentId) {
13951
- throw new Error("No payment method set. Add one first via 'clishop payment add'.");
14008
+ throw new Error("No payment method linked. Use the setup tool to onboard the user first.");
13952
14009
  }
13953
14010
  const api = getApiClient();
13954
14011
  let product;
@@ -14284,7 +14341,7 @@ server.registerTool("account_status", {
14284
14341
  return safeCall(async () => {
14285
14342
  const loggedIn = await isLoggedIn();
14286
14343
  if (!loggedIn) {
14287
- return { loggedIn: false, message: "Not logged in. Run 'clishop login' first." };
14344
+ return { loggedIn: false, message: "Not set up yet. Use the setup tool to onboard the user with a payment link." };
14288
14345
  }
14289
14346
  const api = getApiClient();
14290
14347
  const cfg = getConfig();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clishop",
3
- "version": "1.3.2",
3
+ "version": "1.4.0",
4
4
  "mcpName": "io.github.StefDCL/clishop",
5
5
  "description": "CLISHOP — Order anything from your terminal",
6
6
  "main": "dist/index.js",