continentept-mcp 0.1.0 → 0.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/CHANGELOG.md CHANGED
@@ -6,7 +6,26 @@ All notable changes to this project are documented here. The format follows
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
- ## [0.1.0]
9
+ ## [0.3.0] - 2026-10-15
10
+
11
+ ### Added
12
+
13
+ - One-click Claude Desktop extension (`continentept-mcp.mcpb`) attached to every release. It asks for your email and password at install time.
14
+ - Chromium downloads automatically the first time it is needed; `install-browser` is now optional. While it downloads, tools return a retryable `browser_unavailable` error explaining the wait.
15
+
16
+ ## [0.2.0] - 2026-10-15
17
+
18
+ ### Added
19
+
20
+ - Server instructions: assistants receive the cart rules (exact totals, one change at a time, check the cart after an uncertain change) as soon as they connect.
21
+ - A `basket-planner` prompt with the full shopping workflow, with an optional request to plan for. No skill install is needed.
22
+ - Documentation for supplying credentials from 1Password with `op run`.
23
+
24
+ ### Changed
25
+
26
+ - The `basket-planner` skill links to the online tool reference, so it also works when uploaded on its own.
27
+
28
+ ## [0.1.0] - 2026-10-15
10
29
 
11
30
  ### Added
12
31
 
@@ -16,5 +35,7 @@ All notable changes to this project are documented here. The format follows
16
35
  - Automatic sign-in from environment variables or a private credentials file, and a `login` command.
17
36
  - The `basket-planner` skill for planning a shopping list and updating the basket.
18
37
 
19
- [Unreleased]: https://github.com/andredelgado/continente-mcp/compare/v0.1.0...HEAD
38
+ [Unreleased]: https://github.com/andredelgado/continente-mcp/compare/v0.3.0...HEAD
39
+ [0.3.0]: https://github.com/andredelgado/continente-mcp/compare/v0.2.0...v0.3.0
40
+ [0.2.0]: https://github.com/andredelgado/continente-mcp/compare/v0.1.0...v0.2.0
20
41
  [0.1.0]: https://github.com/andredelgado/continente-mcp/releases/tag/v0.1.0
package/README.md CHANGED
@@ -23,25 +23,33 @@ on the website.
23
23
  of retrying.
24
24
  - **Your account**: favorites, order history and a ranking of the products you buy most.
25
25
  - **Runs locally** over stdio. Credentials and cookies stay on your machine.
26
- - **Bundled skill** ([`basket-planner`](skills/basket-planner/SKILL.md)) that teaches an
27
- assistant to plan a shopping list and update the basket.
26
+ - **Built-in guidance.** The server tells the assistant the cart rules as soon as it
27
+ connects, and offers a `basket-planner` prompt with the full shopping workflow. Nothing
28
+ extra to install; the same guide also ships as a [skill](skills/basket-planner/SKILL.md).
28
29
 
29
30
  ## Requirements
30
31
 
31
- - Node.js 22 or newer
32
32
  - A Continente.pt account for account features (search and product details work without one)
33
+ - Claude Desktop on macOS or Windows for the one-click install, or Node.js 22 or newer for
34
+ any other MCP client
33
35
 
34
- ## Quick start
36
+ The server drives the website with Chromium, which it downloads automatically the first time
37
+ it needs it (about 150 MB, once).
35
38
 
36
- **1. Install the browser** the server uses to talk to the website (one-time download):
39
+ ## Install in Claude Desktop (one click)
37
40
 
38
- ```sh
39
- npx -y continentept-mcp install-browser
40
- ```
41
+ 1. Download [**continentept-mcp.mcpb**](https://github.com/andredelgado/continente-mcp/releases/latest/download/continentept-mcp.mcpb)
42
+ from the latest release.
43
+ 2. Open it. Claude Desktop shows an install dialog; click **Install**.
44
+ 3. Enter your Continente email and password when asked. Claude Desktop keeps the password
45
+ in its secure settings storage.
41
46
 
42
- On Linux, append `--with-deps` to also install the required system libraries.
47
+ That's it. The extension updates when you install a newer `.mcpb`. To use 1Password instead
48
+ of storing the password in Claude Desktop, use the manual setup below.
43
49
 
44
- **2. Save your credentials** in `~/.continentept-mcp/credentials.env` (see
50
+ ## Manual setup (any MCP client)
51
+
52
+ **1. Save your credentials** in `~/.continentept-mcp/credentials.env` (see
45
53
  [configuration](docs/configuration.md) for other options):
46
54
 
47
55
  ```sh
@@ -50,13 +58,16 @@ printf 'CONTINENTE_EMAIL=you@example.com\nCONTINENTE_PASSWORD=your-password\n' >
50
58
  chmod 600 ~/.continentept-mcp/credentials.env
51
59
  ```
52
60
 
61
+ Using 1Password? Skip the file and pass secret references through `op run` instead; see
62
+ [Using 1Password](docs/configuration.md#using-1password).
63
+
53
64
  Optionally check that login works:
54
65
 
55
66
  ```sh
56
67
  npx -y continentept-mcp login
57
68
  ```
58
69
 
59
- **3. Add the server to your MCP client.**
70
+ **2. Add the server to your MCP client.**
60
71
 
61
72
  Claude Code:
62
73
 
@@ -80,6 +91,10 @@ Claude Desktop, Cursor and other clients (`claude_desktop_config.json`, `mcp.jso
80
91
  To keep the credentials file elsewhere, add
81
92
  `"env": { "CONTINENTE_CREDENTIALS_FILE": "/absolute/path/to/credentials.env" }`.
82
93
 
94
+ Chromium downloads itself on first use. To fetch it ahead of time, run
95
+ `npx -y continentept-mcp install-browser` (on Linux, add `--with-deps` for the system
96
+ libraries it needs).
97
+
83
98
  Then ask your assistant something like *"Add semi-skimmed milk and a dozen eggs to my
84
99
  Continente cart"* or *"What do I usually buy? Build me a list for this week."*
85
100
 
@@ -108,12 +123,24 @@ In that case the result has `mutation.outcome: "unknown"` and asks the client to
108
123
  `get_cart` before doing anything else. The server never retries such a change on its own,
109
124
  and clients should not either: repeating an `add_cart_item` could add the item twice.
110
125
 
126
+ ### Guidance for the assistant
127
+
128
+ When a client connects, the server sends short instructions with these cart rules, so the
129
+ assistant follows them without any setup. For planning a shopping list, pick the
130
+ **basket-planner** prompt from your client's prompt or attachment menu, optionally with a
131
+ request such as "weekly basket for two".
132
+
133
+ The same guide is available as a skill in
134
+ [`skills/basket-planner`](skills/basket-planner/SKILL.md). Clients that support skills, such
135
+ as Claude Desktop (Settings → Capabilities → Skills) or Claude Code (`~/.claude/skills/`),
136
+ then apply it automatically whenever you ask about groceries.
137
+
111
138
  ## Command line
112
139
 
113
140
  ```text
114
141
  continentept-mcp Start the MCP server on stdio
115
142
  continentept-mcp login Sign in and save the session (--show-browser to watch)
116
- continentept-mcp install-browser Download Chromium (extra arguments go to Playwright)
143
+ continentept-mcp install-browser Download Chromium now instead of on first use (extra arguments go to Playwright)
117
144
  continentept-mcp --version
118
145
  ```
119
146
 
@@ -1,8 +1,10 @@
1
1
  import { ContinenteMcpServer } from './mcp/server.js';
2
- import type { ToolHandler } from './mcp/server.js';
2
+ import type { PromptHandler, ToolHandler } from './mcp/server.js';
3
3
  export interface ApplicationOptions {
4
4
  readonly version: string;
5
5
  readonly tools?: readonly ToolHandler[];
6
+ readonly prompts?: readonly PromptHandler[];
7
+ readonly instructions?: string;
6
8
  readonly closeResources?: () => Promise<void>;
7
9
  readonly requestTimeoutMs?: number;
8
10
  }
package/dist/cli.js CHANGED
@@ -1,12 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import { readFileSync } from 'node:fs';
3
- import { createRequire } from 'node:module';
4
- import { dirname, join } from 'node:path';
5
- import { spawnSync } from 'node:child_process';
6
3
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
7
4
  import { createShoppingApplication } from './runtime.js';
8
5
  import { runAutoLogin } from './auto-login.js';
9
6
  import { isMainModule } from './main-module.js';
7
+ import { runChromiumInstall } from './session/chromium.js';
10
8
  const USAGE = `Usage: continentept-mcp [command]
11
9
 
12
10
  Commands:
@@ -57,11 +55,6 @@ export async function connectStdioApplication(application) {
57
55
  throw error;
58
56
  }
59
57
  }
60
- function installBrowser(extra) {
61
- const playwright = dirname(createRequire(import.meta.url).resolve('playwright/package.json'));
62
- const result = spawnSync(process.execPath, [join(playwright, 'cli.js'), 'install', 'chromium', ...extra], { stdio: 'inherit' });
63
- return result.status ?? 1;
64
- }
65
58
  export async function main(args) {
66
59
  const [command, ...rest] = args;
67
60
  switch (command) {
@@ -78,7 +71,7 @@ export async function main(args) {
78
71
  return 1;
79
72
  }
80
73
  case 'install-browser':
81
- return installBrowser(rest);
74
+ return runChromiumInstall(rest);
82
75
  case '-v':
83
76
  case '--version':
84
77
  console.log(packageVersion());
@@ -7,7 +7,7 @@ export interface HttpResponse {
7
7
  }
8
8
  /** Only known authentication evidence triggers recovery; arbitrary upstream failures do not. */
9
9
  export declare function responseStatus(response: HttpResponse | null, finalUrl: string): import("../domain/result.js").Result<undefined, {
10
- code: "cache_unavailable" | "cancelled" | "cart_change_rejected" | "cart_change_unconfirmed" | "deadline_exceeded" | "invalid_data" | "invalid_input" | "not_authenticated" | "not_found" | "order_details_unavailable" | "quantity_below_minimum" | "queue_full" | "sale_rules_unknown" | "server_closed" | "upstream_unavailable";
10
+ code: "browser_unavailable" | "cache_unavailable" | "cancelled" | "cart_change_rejected" | "cart_change_unconfirmed" | "deadline_exceeded" | "invalid_data" | "invalid_input" | "not_authenticated" | "not_found" | "order_details_unavailable" | "quantity_below_minimum" | "queue_full" | "sale_rules_unknown" | "server_closed" | "upstream_unavailable";
11
11
  message: string;
12
12
  retryable: boolean;
13
13
  issues?: {
@@ -16,7 +16,7 @@ export declare function responseStatus(response: HttpResponse | null, finalUrl:
16
16
  }[] | undefined;
17
17
  }>;
18
18
  export declare function authenticatedPayload(input: unknown): import("../domain/result.js").Result<unknown, {
19
- code: "cache_unavailable" | "cancelled" | "cart_change_rejected" | "cart_change_unconfirmed" | "deadline_exceeded" | "invalid_data" | "invalid_input" | "not_authenticated" | "not_found" | "order_details_unavailable" | "quantity_below_minimum" | "queue_full" | "sale_rules_unknown" | "server_closed" | "upstream_unavailable";
19
+ code: "browser_unavailable" | "cache_unavailable" | "cancelled" | "cart_change_rejected" | "cart_change_unconfirmed" | "deadline_exceeded" | "invalid_data" | "invalid_input" | "not_authenticated" | "not_found" | "order_details_unavailable" | "quantity_below_minimum" | "queue_full" | "sale_rules_unknown" | "server_closed" | "upstream_unavailable";
20
20
  message: string;
21
21
  retryable: boolean;
22
22
  issues?: {
@@ -1,4 +1,5 @@
1
1
  import { requestIO, requestTimeout, checkRequest, RequestStopped, reportProgress } from '../session/request.js';
2
+ import { BrowserUnavailable } from '../session/chromium.js';
2
3
  import { failure, success } from '../domain/index.js';
3
4
  import { parseProductSearchPage, parseSearchPagination, parseFavoritesPageData, STOREFRONT_ORIGIN, storefrontUrl } from '../parsers/catalog.js';
4
5
  import { responseStatus, authenticatedPayload } from './policy.js';
@@ -6,6 +7,12 @@ import { orderHistoryUrl } from '../parsers/orders.js';
6
7
  import { field } from '../parsers/records.js';
7
8
  export const CART_SUMMARY_URL = `${STOREFRONT_ORIGIN}/on/demandware.store/Sites-continente-Site/default/Cart-MiniCartShow`;
8
9
  const ORDER_DETAIL_PATHS = ['/conta/detalhe-encomenda/', '/detalhe-encomenda'];
10
+ /** Map an error from starting or using the browser; cancellation keeps propagating. */
11
+ function browserFailure(error) {
12
+ if (error instanceof RequestStopped)
13
+ throw error;
14
+ return error instanceof BrowserUnavailable ? { ok: false, error: error.toolError } : failure('upstream_unavailable');
15
+ }
9
16
  const productPath = (reference) => `/produto/${reference.endsWith('.html') ? reference : `${reference}.html`}`;
10
17
  export class StorefrontClient {
11
18
  session;
@@ -30,9 +37,7 @@ export class StorefrontClient {
30
37
  return success(lease);
31
38
  }
32
39
  catch (error) {
33
- if (error instanceof RequestStopped)
34
- throw error;
35
- return failure('upstream_unavailable');
40
+ return browserFailure(error);
36
41
  }
37
42
  }
38
43
  async html(path, marker = 'main, [role="main"], .product-line, a[href*="/produto/"]') {
@@ -125,7 +130,7 @@ async function readContinuation(site, url) {
125
130
  return status.ok ? success(await site.io(lease, () => response.text())) : status;
126
131
  }
127
132
  catch (error) {
128
- return failure(error instanceof RequestStopped ? error.code : 'upstream_unavailable');
133
+ return error instanceof RequestStopped ? failure(error.code) : browserFailure(error);
129
134
  }
130
135
  }
131
136
  export class FavoritesClient {
@@ -196,9 +201,7 @@ export class CartClient {
196
201
  return authenticatedPayload(data);
197
202
  }
198
203
  catch (error) {
199
- if (error instanceof RequestStopped)
200
- throw error;
201
- return failure('upstream_unavailable');
204
+ return browserFailure(error);
202
205
  }
203
206
  }
204
207
  async fetchProductForm(reference) {
@@ -264,9 +267,7 @@ export class CartClient {
264
267
  });
265
268
  }
266
269
  catch (error) {
267
- if (error instanceof RequestStopped)
268
- throw error;
269
- return failure('upstream_unavailable');
270
+ return browserFailure(error);
270
271
  }
271
272
  }
272
273
  }
@@ -288,9 +289,7 @@ export class OrdersClient {
288
289
  return success(await this.site.io(response.value, () => page.content()));
289
290
  }
290
291
  catch (error) {
291
- if (error instanceof RequestStopped)
292
- throw error;
293
- return failure('upstream_unavailable');
292
+ return browserFailure(error);
294
293
  }
295
294
  }
296
295
  async fetchOrderLines(url) {
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  export declare const ToolErrorCodeSchema: z.ZodEnum<{
3
+ browser_unavailable: "browser_unavailable";
3
4
  cache_unavailable: "cache_unavailable";
4
5
  cancelled: "cancelled";
5
6
  cart_change_rejected: "cart_change_rejected";
@@ -18,6 +19,7 @@ export declare const ToolErrorCodeSchema: z.ZodEnum<{
18
19
  }>;
19
20
  export declare const ToolErrorSchema: z.ZodObject<{
20
21
  code: z.ZodEnum<{
22
+ browser_unavailable: "browser_unavailable";
21
23
  cache_unavailable: "cache_unavailable";
22
24
  cancelled: "cancelled";
23
25
  cart_change_rejected: "cart_change_rejected";
@@ -4,7 +4,7 @@ export const ToolErrorCodeSchema = z.enum([
4
4
  'not_found', 'sale_rules_unknown', 'quantity_below_minimum',
5
5
  'cart_change_rejected', 'cart_change_unconfirmed', 'cache_unavailable',
6
6
  'order_details_unavailable',
7
- 'cancelled', 'deadline_exceeded', 'server_closed', 'queue_full',
7
+ 'cancelled', 'deadline_exceeded', 'server_closed', 'queue_full', 'browser_unavailable',
8
8
  ]);
9
9
  export const ToolErrorSchema = z.strictObject({
10
10
  code: ToolErrorCodeSchema,
@@ -176,6 +176,7 @@ export declare const OrderSchema: z.ZodObject<{
176
176
  status: z.ZodLiteral<"unavailable">;
177
177
  error: z.ZodObject<{
178
178
  code: z.ZodEnum<{
179
+ browser_unavailable: "browser_unavailable";
179
180
  cache_unavailable: "cache_unavailable";
180
181
  cancelled: "cancelled";
181
182
  cart_change_rejected: "cart_change_rejected";
@@ -317,6 +318,7 @@ export declare const ProductDetailsSchema: z.ZodObject<{
317
318
  status: z.ZodLiteral<"unavailable">;
318
319
  error: z.ZodObject<{
319
320
  code: z.ZodEnum<{
321
+ browser_unavailable: "browser_unavailable";
320
322
  cache_unavailable: "cache_unavailable";
321
323
  cancelled: "cancelled";
322
324
  cart_change_rejected: "cart_change_rejected";
@@ -42,6 +42,7 @@ export declare const CartMutationResultSchema: z.ZodDiscriminatedUnion<[z.ZodObj
42
42
  outcome: z.ZodLiteral<"not_applied">;
43
43
  error: z.ZodObject<{
44
44
  code: z.ZodEnum<{
45
+ browser_unavailable: "browser_unavailable";
45
46
  cache_unavailable: "cache_unavailable";
46
47
  cancelled: "cancelled";
47
48
  cart_change_rejected: "cart_change_rejected";
@@ -80,6 +81,7 @@ export declare const CartMutationResultSchema: z.ZodDiscriminatedUnion<[z.ZodObj
80
81
  outcome: z.ZodLiteral<"unknown">;
81
82
  error: z.ZodObject<{
82
83
  code: z.ZodEnum<{
84
+ browser_unavailable: "browser_unavailable";
83
85
  cache_unavailable: "cache_unavailable";
84
86
  cancelled: "cancelled";
85
87
  cart_change_rejected: "cart_change_rejected";
@@ -119,6 +121,7 @@ export declare function pageResultSchema<T extends z.ZodType>(item: T): z.ZodObj
119
121
  }>;
120
122
  failures: z.ZodArray<z.ZodObject<{
121
123
  code: z.ZodEnum<{
124
+ browser_unavailable: "browser_unavailable";
122
125
  cache_unavailable: "cache_unavailable";
123
126
  cancelled: "cancelled";
124
127
  cart_change_rejected: "cart_change_rejected";
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  export { createApplication } from './application.js';
2
2
  export type { ApplicationOptions } from './application.js';
3
3
  export { ContinenteMcpServer } from './mcp/server.js';
4
- export type { McpServerOptions, ToolHandler } from './mcp/server.js';
4
+ export type { McpServerOptions, PromptHandler, ToolHandler } from './mcp/server.js';
5
+ export { BASKET_PLANNER_GUIDE, SERVER_INSTRUCTIONS, basketPlannerPrompt } from './mcp/guide.js';
5
6
  export * from './domain/index.js';
6
7
  export { createShoppingApplication, createShoppingServices } from './runtime.js';
7
8
  export type { RuntimeOptions } from './runtime.js';
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { createApplication } from './application.js';
2
2
  export { ContinenteMcpServer } from './mcp/server.js';
3
+ export { BASKET_PLANNER_GUIDE, SERVER_INSTRUCTIONS, basketPlannerPrompt } from './mcp/guide.js';
3
4
  export * from './domain/index.js';
4
5
  export { createShoppingApplication, createShoppingServices } from './runtime.js';
@@ -44,6 +44,7 @@ export declare const PublicErrorSchema: z.ZodObject<{
44
44
  code: z.ZodString;
45
45
  }, z.core.$strict>>>;
46
46
  code: z.ZodUnion<readonly [z.ZodEnum<{
47
+ browser_unavailable: "browser_unavailable";
47
48
  cache_unavailable: "cache_unavailable";
48
49
  cancelled: "cancelled";
49
50
  cart_change_rejected: "cart_change_rejected";
@@ -74,6 +75,7 @@ export declare const ErrorResultSchema: z.ZodObject<{
74
75
  code: z.ZodString;
75
76
  }, z.core.$strict>>>;
76
77
  code: z.ZodUnion<readonly [z.ZodEnum<{
78
+ browser_unavailable: "browser_unavailable";
77
79
  cache_unavailable: "cache_unavailable";
78
80
  cancelled: "cancelled";
79
81
  cart_change_rejected: "cart_change_rejected";
@@ -115,6 +117,7 @@ export declare const ExecutionErrorSchema: z.ZodObject<{
115
117
  code: z.ZodString;
116
118
  }, z.core.$strict>>>;
117
119
  code: z.ZodUnion<readonly [z.ZodEnum<{
120
+ browser_unavailable: "browser_unavailable";
118
121
  cache_unavailable: "cache_unavailable";
119
122
  cancelled: "cancelled";
120
123
  cart_change_rejected: "cart_change_rejected";
@@ -164,6 +167,7 @@ export declare function outputSchema<T extends z.ZodType>(data: T, extra?: z.Zod
164
167
  code: z.ZodString;
165
168
  }, z.core.$strict>>>;
166
169
  code: z.ZodUnion<readonly [z.ZodEnum<{
170
+ browser_unavailable: "browser_unavailable";
167
171
  cache_unavailable: "cache_unavailable";
168
172
  cancelled: "cancelled";
169
173
  cart_change_rejected: "cart_change_rejected";
@@ -220,6 +224,7 @@ export declare const SearchData: z.ZodObject<{
220
224
  }>;
221
225
  failures: z.ZodArray<z.ZodObject<{
222
226
  code: z.ZodEnum<{
227
+ browser_unavailable: "browser_unavailable";
223
228
  cache_unavailable: "cache_unavailable";
224
229
  cancelled: "cancelled";
225
230
  cart_change_rejected: "cart_change_rejected";
@@ -314,6 +319,7 @@ export declare const OrdersData: z.ZodObject<{
314
319
  status: z.ZodLiteral<"unavailable">;
315
320
  error: z.ZodObject<{
316
321
  code: z.ZodEnum<{
322
+ browser_unavailable: "browser_unavailable";
317
323
  cache_unavailable: "cache_unavailable";
318
324
  cancelled: "cancelled";
319
325
  cart_change_rejected: "cart_change_rejected";
@@ -348,6 +354,7 @@ export declare const OrdersData: z.ZodObject<{
348
354
  }>;
349
355
  failures: z.ZodArray<z.ZodObject<{
350
356
  code: z.ZodEnum<{
357
+ browser_unavailable: "browser_unavailable";
351
358
  cache_unavailable: "cache_unavailable";
352
359
  cancelled: "cancelled";
353
360
  cart_change_rejected: "cart_change_rejected";
@@ -384,6 +391,7 @@ export declare const OrdersData: z.ZodObject<{
384
391
  orderNumber: z.ZodNullable<z.core.$ZodBranded<z.ZodString, "OrderNumber", "out">>;
385
392
  error: z.ZodObject<{
386
393
  code: z.ZodEnum<{
394
+ browser_unavailable: "browser_unavailable";
387
395
  cache_unavailable: "cache_unavailable";
388
396
  cancelled: "cancelled";
389
397
  cart_change_rejected: "cart_change_rejected";
@@ -445,6 +453,7 @@ export declare const FrequencyData: z.ZodObject<{
445
453
  orderNumber: z.ZodNullable<z.core.$ZodBranded<z.ZodString, "OrderNumber", "out">>;
446
454
  error: z.ZodObject<{
447
455
  code: z.ZodEnum<{
456
+ browser_unavailable: "browser_unavailable";
448
457
  cache_unavailable: "cache_unavailable";
449
458
  cancelled: "cancelled";
450
459
  cart_change_rejected: "cart_change_rejected";
@@ -508,6 +517,7 @@ export declare const SearchOutput: z.ZodObject<{
508
517
  }>;
509
518
  failures: z.ZodArray<z.ZodObject<{
510
519
  code: z.ZodEnum<{
520
+ browser_unavailable: "browser_unavailable";
511
521
  cache_unavailable: "cache_unavailable";
512
522
  cancelled: "cancelled";
513
523
  cart_change_rejected: "cart_change_rejected";
@@ -543,6 +553,7 @@ export declare const SearchOutput: z.ZodObject<{
543
553
  code: z.ZodString;
544
554
  }, z.core.$strict>>>;
545
555
  code: z.ZodUnion<readonly [z.ZodEnum<{
556
+ browser_unavailable: "browser_unavailable";
546
557
  cache_unavailable: "cache_unavailable";
547
558
  cancelled: "cancelled";
548
559
  cart_change_rejected: "cart_change_rejected";
@@ -621,6 +632,7 @@ export declare const FavoritesOutput: z.ZodObject<{
621
632
  code: z.ZodString;
622
633
  }, z.core.$strict>>>;
623
634
  code: z.ZodUnion<readonly [z.ZodEnum<{
635
+ browser_unavailable: "browser_unavailable";
624
636
  cache_unavailable: "cache_unavailable";
625
637
  cancelled: "cancelled";
626
638
  cart_change_rejected: "cart_change_rejected";
@@ -715,6 +727,7 @@ export declare const CartOutput: z.ZodObject<{
715
727
  code: z.ZodString;
716
728
  }, z.core.$strict>>>;
717
729
  code: z.ZodUnion<readonly [z.ZodEnum<{
730
+ browser_unavailable: "browser_unavailable";
718
731
  cache_unavailable: "cache_unavailable";
719
732
  cancelled: "cancelled";
720
733
  cart_change_rejected: "cart_change_rejected";
@@ -792,6 +805,7 @@ export declare const MutationOutput: z.ZodObject<{
792
805
  code: z.ZodString;
793
806
  }, z.core.$strict>>>;
794
807
  code: z.ZodUnion<readonly [z.ZodEnum<{
808
+ browser_unavailable: "browser_unavailable";
795
809
  cache_unavailable: "cache_unavailable";
796
810
  cancelled: "cancelled";
797
811
  cart_change_rejected: "cart_change_rejected";
@@ -869,6 +883,7 @@ export declare const OrdersOutput: z.ZodObject<{
869
883
  status: z.ZodLiteral<"unavailable">;
870
884
  error: z.ZodObject<{
871
885
  code: z.ZodEnum<{
886
+ browser_unavailable: "browser_unavailable";
872
887
  cache_unavailable: "cache_unavailable";
873
888
  cancelled: "cancelled";
874
889
  cart_change_rejected: "cart_change_rejected";
@@ -903,6 +918,7 @@ export declare const OrdersOutput: z.ZodObject<{
903
918
  }>;
904
919
  failures: z.ZodArray<z.ZodObject<{
905
920
  code: z.ZodEnum<{
921
+ browser_unavailable: "browser_unavailable";
906
922
  cache_unavailable: "cache_unavailable";
907
923
  cancelled: "cancelled";
908
924
  cart_change_rejected: "cart_change_rejected";
@@ -939,6 +955,7 @@ export declare const OrdersOutput: z.ZodObject<{
939
955
  orderNumber: z.ZodNullable<z.core.$ZodBranded<z.ZodString, "OrderNumber", "out">>;
940
956
  error: z.ZodObject<{
941
957
  code: z.ZodEnum<{
958
+ browser_unavailable: "browser_unavailable";
942
959
  cache_unavailable: "cache_unavailable";
943
960
  cancelled: "cancelled";
944
961
  cart_change_rejected: "cart_change_rejected";
@@ -974,6 +991,7 @@ export declare const OrdersOutput: z.ZodObject<{
974
991
  code: z.ZodString;
975
992
  }, z.core.$strict>>>;
976
993
  code: z.ZodUnion<readonly [z.ZodEnum<{
994
+ browser_unavailable: "browser_unavailable";
977
995
  cache_unavailable: "cache_unavailable";
978
996
  cancelled: "cancelled";
979
997
  cart_change_rejected: "cart_change_rejected";
@@ -1051,6 +1069,7 @@ export declare const SingleOrderOutput: z.ZodObject<{
1051
1069
  status: z.ZodLiteral<"unavailable">;
1052
1070
  error: z.ZodObject<{
1053
1071
  code: z.ZodEnum<{
1072
+ browser_unavailable: "browser_unavailable";
1054
1073
  cache_unavailable: "cache_unavailable";
1055
1074
  cancelled: "cancelled";
1056
1075
  cart_change_rejected: "cart_change_rejected";
@@ -1090,6 +1109,7 @@ export declare const SingleOrderOutput: z.ZodObject<{
1090
1109
  code: z.ZodString;
1091
1110
  }, z.core.$strict>>>;
1092
1111
  code: z.ZodUnion<readonly [z.ZodEnum<{
1112
+ browser_unavailable: "browser_unavailable";
1093
1113
  cache_unavailable: "cache_unavailable";
1094
1114
  cancelled: "cancelled";
1095
1115
  cart_change_rejected: "cart_change_rejected";
@@ -1164,6 +1184,7 @@ export declare const FrequencyOutput: z.ZodObject<{
1164
1184
  orderNumber: z.ZodNullable<z.core.$ZodBranded<z.ZodString, "OrderNumber", "out">>;
1165
1185
  error: z.ZodObject<{
1166
1186
  code: z.ZodEnum<{
1187
+ browser_unavailable: "browser_unavailable";
1167
1188
  cache_unavailable: "cache_unavailable";
1168
1189
  cancelled: "cancelled";
1169
1190
  cart_change_rejected: "cart_change_rejected";
@@ -1205,6 +1226,7 @@ export declare const FrequencyOutput: z.ZodObject<{
1205
1226
  code: z.ZodString;
1206
1227
  }, z.core.$strict>>>;
1207
1228
  code: z.ZodUnion<readonly [z.ZodEnum<{
1229
+ browser_unavailable: "browser_unavailable";
1208
1230
  cache_unavailable: "cache_unavailable";
1209
1231
  cancelled: "cancelled";
1210
1232
  cart_change_rejected: "cart_change_rejected";
@@ -1290,6 +1312,7 @@ export declare const SessionStatusOutput: z.ZodObject<{
1290
1312
  code: z.ZodString;
1291
1313
  }, z.core.$strict>>>;
1292
1314
  code: z.ZodUnion<readonly [z.ZodEnum<{
1315
+ browser_unavailable: "browser_unavailable";
1293
1316
  cache_unavailable: "cache_unavailable";
1294
1317
  cancelled: "cancelled";
1295
1318
  cart_change_rejected: "cart_change_rejected";
@@ -1406,6 +1429,7 @@ export declare const ProductDetailsOutput: z.ZodObject<{
1406
1429
  status: z.ZodLiteral<"unavailable">;
1407
1430
  error: z.ZodObject<{
1408
1431
  code: z.ZodEnum<{
1432
+ browser_unavailable: "browser_unavailable";
1409
1433
  cache_unavailable: "cache_unavailable";
1410
1434
  cancelled: "cancelled";
1411
1435
  cart_change_rejected: "cart_change_rejected";
@@ -1441,6 +1465,7 @@ export declare const ProductDetailsOutput: z.ZodObject<{
1441
1465
  code: z.ZodString;
1442
1466
  }, z.core.$strict>>>;
1443
1467
  code: z.ZodUnion<readonly [z.ZodEnum<{
1468
+ browser_unavailable: "browser_unavailable";
1444
1469
  cache_unavailable: "cache_unavailable";
1445
1470
  cancelled: "cancelled";
1446
1471
  cart_change_rejected: "cart_change_rejected";
@@ -0,0 +1,5 @@
1
+ import type { PromptHandler } from './server.js';
2
+ export declare const BASKET_PLANNER_GUIDE = "# Basket planner\n\nTurn the user's shopping intent into a product list or a verified basket using the **continentept-mcp** tools. A request for a plan authorizes research only; a request to add, remove or set items authorizes those basket changes. Keep the user's existing choices and constraints. Ask only about choices that change the result, such as an unspecified substitute or whether a quantity means \"more\" or \"in total\".\n\n## Choose products and quantities\n\n1. Use `search_products` with `query` (and `limit` when useful). Treat results as candidates: match size, brand, dietary constraints and intended use before choosing. Keep `productId` as a string, including leading zeros.\n2. Use `get_product` when price, availability or sale rules matter. Quantities are in the returned sale unit. Respect minimum, maximum and step; never assume a weighted product is sold by the kilogram and never silently round a requested amount.\n3. Before changing the basket, read `get_cart` for current quantities and line identities. If several lines share a product ID, use the intended line's `cartItemId`, or ask the user which line they mean.\n4. Show unresolved choices. Missing prices, availability, quantities or sale rules stay unknown. Money is EUR in integer `minorUnits` (129 means \u20AC1.29). Keep product prices, basket totals and estimated list costs distinct.\n\nSearches read a bounded number of result pages; respect `completeness` and `failures` and do not claim a search was exhaustive.\n\n## Change the basket\n\n- `set_cart_item_quantity({ productId, quantity, cartItemId? })` makes the basket hold exactly `quantity`, adding the product if needed. Zero removes it. Prefer this whenever the user states a desired total; repeating it is safe.\n- `add_cart_item({ productId, quantity, cartItemId? })` adds `quantity` on top of what is already there (default one sale unit). Use it only for \"add more\".\n- `remove_cart_item({ productId, cartItemId? })` removes a line. An already absent item is confirmed without a write.\n\nIf the basket holds two units, \"add two more\" is `add_cart_item` with 2, while \"I need two\" is `set_cart_item_quantity` with 2 (which changes nothing). Process a list one item at a time and read each result before continuing. There is no batch, checkout or payment tool; checkout happens on the website.\n\n## Read outcomes before reporting success\n\nRead `structuredContent.result` rather than inferring success from prose.\n\n- `status: success`, `empty` or `partial` carries `data`. Report partial-result warnings and unavailable data.\n- A confirmed change has `data.outcome: \"confirmed\"` and `confirmedQuantity`, the quantity now in the basket. Report that observed quantity.\n- `status: error` carries `error`. For basket changes also read `mutation`: `not_applied` means nothing was submitted or the change was rejected; fix the reported cause before trying again.\n- `mutation.outcome: \"unknown\"` means the change may have happened. Stop dependent basket changes, call `get_cart`, and compare with the state before the change. Never repeat the original request just because the response was lost. If the basket state cannot settle the intent, explain the uncertainty and ask the user.\n\nA timeout, cancellation or lost connection during a change is not evidence that the basket stayed the same. Apply the same reconciliation when no structured result arrives.\n\n## Use account context when it helps\n\nFor \"my usual items\", `list_favorites` and `list_frequently_bought_products` can inform a proposed list. Past purchases are evidence, not permission to buy them again.\n\n`list_favorites` returns a local snapshot with `source` and `freshness`; pass `refresh: true` when the user wants the current website list or the snapshot is stale. An empty list is a valid result, and a failed refresh does not mean favorites disappeared.\n\n`list_orders` supports `limit`, `includeLines`, `detailLimit` and `cursor` (the returned `nextCursor`). Use the internal `orderId` with `get_order`, not the displayed order number. `list_frequently_bought_products` has separate `orderLimit` and `limit`; its scan counts and failures show how representative the ranking is. Never add quantities expressed in different units.\n\n`get_session_status` reports local state only; it does not verify that the login still works. Do not include credentials or account details in summaries.\n\nFinish with the chosen or changed items, confirmed quantities and units, and any unresolved choices or failures. Keep planned items separate from changes the server confirmed.\n\nFor exact schemas and limits, see the [tool reference](https://github.com/andredelgado/continente-mcp/blob/main/docs/tools.md).";
3
+ /** Sent to every client on connect; the essential rules for working with the cart safely. */
4
+ export declare const SERVER_INSTRUCTIONS = "Continente MCP shops at Continente.pt for one account. Checkout and payment always happen on the website.\n\n- Quantities are in the product's sale unit. Call get_product before choosing a quantity for weighted or bulk products, and respect its minimum, maximum and step.\n- set_cart_item_quantity sets an exact total (adding the product if needed; 0 removes it). add_cart_item adds on top of what is already there. When the user says how many they need, use set_cart_item_quantity.\n- Change the cart one item at a time and read structuredContent.result before reporting success. confirmedQuantity is what the cart now holds.\n- If a cart change returns mutation.outcome \"unknown\", the cart may have changed. Call get_cart and decide from its contents. Never repeat the change automatically.\n- Money is EUR in integer minorUnits (129 means \u20AC1.29). Missing prices, quantities or completeness stay unknown; do not guess them.\n- For planning a shopping list or basket, use the basket-planner prompt for the full workflow.";
5
+ export declare const basketPlannerPrompt: PromptHandler;
@@ -0,0 +1,67 @@
1
+ // The basket-planner guide, served as the `basket-planner` prompt. Keep it identical to the body of
2
+ // skills/basket-planner/SKILL.md; a test fails when they differ.
3
+ export const BASKET_PLANNER_GUIDE = `# Basket planner
4
+
5
+ Turn the user's shopping intent into a product list or a verified basket using the **continentept-mcp** tools. A request for a plan authorizes research only; a request to add, remove or set items authorizes those basket changes. Keep the user's existing choices and constraints. Ask only about choices that change the result, such as an unspecified substitute or whether a quantity means "more" or "in total".
6
+
7
+ ## Choose products and quantities
8
+
9
+ 1. Use \`search_products\` with \`query\` (and \`limit\` when useful). Treat results as candidates: match size, brand, dietary constraints and intended use before choosing. Keep \`productId\` as a string, including leading zeros.
10
+ 2. Use \`get_product\` when price, availability or sale rules matter. Quantities are in the returned sale unit. Respect minimum, maximum and step; never assume a weighted product is sold by the kilogram and never silently round a requested amount.
11
+ 3. Before changing the basket, read \`get_cart\` for current quantities and line identities. If several lines share a product ID, use the intended line's \`cartItemId\`, or ask the user which line they mean.
12
+ 4. Show unresolved choices. Missing prices, availability, quantities or sale rules stay unknown. Money is EUR in integer \`minorUnits\` (129 means €1.29). Keep product prices, basket totals and estimated list costs distinct.
13
+
14
+ Searches read a bounded number of result pages; respect \`completeness\` and \`failures\` and do not claim a search was exhaustive.
15
+
16
+ ## Change the basket
17
+
18
+ - \`set_cart_item_quantity({ productId, quantity, cartItemId? })\` makes the basket hold exactly \`quantity\`, adding the product if needed. Zero removes it. Prefer this whenever the user states a desired total; repeating it is safe.
19
+ - \`add_cart_item({ productId, quantity, cartItemId? })\` adds \`quantity\` on top of what is already there (default one sale unit). Use it only for "add more".
20
+ - \`remove_cart_item({ productId, cartItemId? })\` removes a line. An already absent item is confirmed without a write.
21
+
22
+ If the basket holds two units, "add two more" is \`add_cart_item\` with 2, while "I need two" is \`set_cart_item_quantity\` with 2 (which changes nothing). Process a list one item at a time and read each result before continuing. There is no batch, checkout or payment tool; checkout happens on the website.
23
+
24
+ ## Read outcomes before reporting success
25
+
26
+ Read \`structuredContent.result\` rather than inferring success from prose.
27
+
28
+ - \`status: success\`, \`empty\` or \`partial\` carries \`data\`. Report partial-result warnings and unavailable data.
29
+ - A confirmed change has \`data.outcome: "confirmed"\` and \`confirmedQuantity\`, the quantity now in the basket. Report that observed quantity.
30
+ - \`status: error\` carries \`error\`. For basket changes also read \`mutation\`: \`not_applied\` means nothing was submitted or the change was rejected; fix the reported cause before trying again.
31
+ - \`mutation.outcome: "unknown"\` means the change may have happened. Stop dependent basket changes, call \`get_cart\`, and compare with the state before the change. Never repeat the original request just because the response was lost. If the basket state cannot settle the intent, explain the uncertainty and ask the user.
32
+
33
+ A timeout, cancellation or lost connection during a change is not evidence that the basket stayed the same. Apply the same reconciliation when no structured result arrives.
34
+
35
+ ## Use account context when it helps
36
+
37
+ For "my usual items", \`list_favorites\` and \`list_frequently_bought_products\` can inform a proposed list. Past purchases are evidence, not permission to buy them again.
38
+
39
+ \`list_favorites\` returns a local snapshot with \`source\` and \`freshness\`; pass \`refresh: true\` when the user wants the current website list or the snapshot is stale. An empty list is a valid result, and a failed refresh does not mean favorites disappeared.
40
+
41
+ \`list_orders\` supports \`limit\`, \`includeLines\`, \`detailLimit\` and \`cursor\` (the returned \`nextCursor\`). Use the internal \`orderId\` with \`get_order\`, not the displayed order number. \`list_frequently_bought_products\` has separate \`orderLimit\` and \`limit\`; its scan counts and failures show how representative the ranking is. Never add quantities expressed in different units.
42
+
43
+ \`get_session_status\` reports local state only; it does not verify that the login still works. Do not include credentials or account details in summaries.
44
+
45
+ Finish with the chosen or changed items, confirmed quantities and units, and any unresolved choices or failures. Keep planned items separate from changes the server confirmed.
46
+
47
+ For exact schemas and limits, see the [tool reference](https://github.com/andredelgado/continente-mcp/blob/main/docs/tools.md).`;
48
+ /** Sent to every client on connect; the essential rules for working with the cart safely. */
49
+ export const SERVER_INSTRUCTIONS = `Continente MCP shops at Continente.pt for one account. Checkout and payment always happen on the website.
50
+
51
+ - Quantities are in the product's sale unit. Call get_product before choosing a quantity for weighted or bulk products, and respect its minimum, maximum and step.
52
+ - set_cart_item_quantity sets an exact total (adding the product if needed; 0 removes it). add_cart_item adds on top of what is already there. When the user says how many they need, use set_cart_item_quantity.
53
+ - Change the cart one item at a time and read structuredContent.result before reporting success. confirmedQuantity is what the cart now holds.
54
+ - If a cart change returns mutation.outcome "unknown", the cart may have changed. Call get_cart and decide from its contents. Never repeat the change automatically.
55
+ - Money is EUR in integer minorUnits (129 means €1.29). Missing prices, quantities or completeness stay unknown; do not guess them.
56
+ - For planning a shopping list or basket, use the basket-planner prompt for the full workflow.`;
57
+ export const basketPlannerPrompt = {
58
+ name: 'basket-planner',
59
+ title: 'Plan a Continente basket',
60
+ description: 'Workflow for choosing products, checking sale quantities and changing the cart safely.',
61
+ arguments: { request: 'What to plan or buy, for example "weekly basket for two" or "add milk and eggs".' },
62
+ render: ({ request }) => ({
63
+ description: 'Continente basket planning workflow',
64
+ messages: [{ role: 'user', content: { type: 'text',
65
+ text: request?.trim() ? `${BASKET_PLANNER_GUIDE}\n\n## Request\n\n${request.trim()}` : BASKET_PLANNER_GUIDE } }],
66
+ }),
67
+ };
@@ -1,4 +1,4 @@
1
- import type { CallToolResult, ToolAnnotations } from '@modelcontextprotocol/sdk/types.js';
1
+ import type { CallToolResult, GetPromptResult, ToolAnnotations } from '@modelcontextprotocol/sdk/types.js';
2
2
  import type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
3
3
  import { z } from 'zod';
4
4
  import type { RequestOptions } from '../session/request.js';
@@ -14,9 +14,20 @@ export interface ToolHandler {
14
14
  readonly cartMutation?: boolean;
15
15
  execute(input: unknown): Promise<CallToolResult>;
16
16
  }
17
+ /** A prompt template. Every argument is an optional string, as MCP prompt arguments are strings. */
18
+ export interface PromptHandler {
19
+ readonly name: string;
20
+ readonly title?: string;
21
+ readonly description?: string;
22
+ readonly arguments?: Readonly<Record<string, string>>;
23
+ render(args: Readonly<Record<string, string | undefined>>): GetPromptResult;
24
+ }
17
25
  export interface McpServerOptions {
18
26
  readonly version: string;
19
27
  readonly tools: readonly ToolHandler[];
28
+ readonly prompts?: readonly PromptHandler[];
29
+ /** Usage guidance sent to clients when they connect. */
30
+ readonly instructions?: string;
20
31
  readonly closeResources?: () => Promise<void>;
21
32
  readonly requestTimeoutMs?: number;
22
33
  }
@@ -27,6 +38,7 @@ export declare class ContinenteMcpServer {
27
38
  private cleanup;
28
39
  private readonly shutdown;
29
40
  constructor(options: McpServerOptions);
41
+ private registerPrompts;
30
42
  private registerTools;
31
43
  dispatchToolCall(name: string, input?: unknown, options?: RequestOptions): Promise<CallToolResult>;
32
44
  private execute;
@@ -11,7 +11,7 @@ export class ContinenteMcpServer {
11
11
  shutdown = new AbortController();
12
12
  constructor(options) {
13
13
  this.options = options;
14
- this.server = new McpServer({ name: 'continentept-mcp', version: options.version }, { capabilities: { tools: {} } });
14
+ this.server = new McpServer({ name: 'continentept-mcp', version: options.version }, { capabilities: { tools: {} }, ...(options.instructions ? { instructions: options.instructions } : {}) });
15
15
  for (const handler of options.tools) {
16
16
  if (this.handlers.has(handler.definition.name))
17
17
  throw new Error(`Duplicate tool: ${handler.definition.name}`);
@@ -19,6 +19,15 @@ export class ContinenteMcpServer {
19
19
  }
20
20
  this.server.server.onclose = () => { this.shutdown.abort(new RequestStopped('server_closed')); void this.closeResources().catch(() => { }); };
21
21
  this.registerTools();
22
+ this.registerPrompts();
23
+ }
24
+ registerPrompts() {
25
+ for (const prompt of this.options.prompts ?? []) {
26
+ const argsSchema = Object.fromEntries(Object.entries(prompt.arguments ?? {})
27
+ .map(([name, description]) => [name, z.string().optional().describe(description)]));
28
+ this.server.registerPrompt(prompt.name, { ...(prompt.title ? { title: prompt.title } : {}),
29
+ ...(prompt.description ? { description: prompt.description } : {}), argsSchema }, args => prompt.render(args));
30
+ }
22
31
  }
23
32
  registerTools() {
24
33
  if (!this.handlers.size)
@@ -21,7 +21,7 @@ export declare function parseProductForm(input: unknown, expectedId: ProductId):
21
21
  csrf: string;
22
22
  sale: SaleMetadata;
23
23
  }, {
24
- code: "cache_unavailable" | "cancelled" | "cart_change_rejected" | "cart_change_unconfirmed" | "deadline_exceeded" | "invalid_data" | "invalid_input" | "not_authenticated" | "not_found" | "order_details_unavailable" | "quantity_below_minimum" | "queue_full" | "sale_rules_unknown" | "server_closed" | "upstream_unavailable";
24
+ code: "browser_unavailable" | "cache_unavailable" | "cancelled" | "cart_change_rejected" | "cart_change_unconfirmed" | "deadline_exceeded" | "invalid_data" | "invalid_input" | "not_authenticated" | "not_found" | "order_details_unavailable" | "quantity_below_minimum" | "queue_full" | "sale_rules_unknown" | "server_closed" | "upstream_unavailable";
25
25
  message: string;
26
26
  retryable: boolean;
27
27
  issues?: {
@@ -37,7 +37,7 @@ export declare function parseCartControls(html: string, productId: ProductId, ca
37
37
  measureOptions: string;
38
38
  gtmIndex: string;
39
39
  }, {
40
- code: "cache_unavailable" | "cancelled" | "cart_change_rejected" | "cart_change_unconfirmed" | "deadline_exceeded" | "invalid_data" | "invalid_input" | "not_authenticated" | "not_found" | "order_details_unavailable" | "quantity_below_minimum" | "queue_full" | "sale_rules_unknown" | "server_closed" | "upstream_unavailable";
40
+ code: "browser_unavailable" | "cache_unavailable" | "cancelled" | "cart_change_rejected" | "cart_change_unconfirmed" | "deadline_exceeded" | "invalid_data" | "invalid_input" | "not_authenticated" | "not_found" | "order_details_unavailable" | "quantity_below_minimum" | "queue_full" | "sale_rules_unknown" | "server_closed" | "upstream_unavailable";
41
41
  message: string;
42
42
  retryable: boolean;
43
43
  issues?: {
@@ -5,7 +5,7 @@ export declare function productReferenceFromUrl(href: string): Result<{
5
5
  productId: string & import("zod").$brand<"ProductId">;
6
6
  productSlug: (string & import("zod").$brand<"ProductSlug">) | null;
7
7
  }, {
8
- code: "cache_unavailable" | "cancelled" | "cart_change_rejected" | "cart_change_unconfirmed" | "deadline_exceeded" | "invalid_data" | "invalid_input" | "not_authenticated" | "not_found" | "order_details_unavailable" | "quantity_below_minimum" | "queue_full" | "sale_rules_unknown" | "server_closed" | "upstream_unavailable";
8
+ code: "browser_unavailable" | "cache_unavailable" | "cancelled" | "cart_change_rejected" | "cart_change_unconfirmed" | "deadline_exceeded" | "invalid_data" | "invalid_input" | "not_authenticated" | "not_found" | "order_details_unavailable" | "quantity_below_minimum" | "queue_full" | "sale_rules_unknown" | "server_closed" | "upstream_unavailable";
9
9
  message: string;
10
10
  retryable: boolean;
11
11
  issues?: {
package/dist/runtime.d.ts CHANGED
@@ -4,6 +4,7 @@ import type { CookieStore } from './stores/files.js';
4
4
  import type { BrowserLauncher, StorefrontSession } from './session/browser.js';
5
5
  import type { ShoppingServices } from './mcp/shopping.js';
6
6
  export declare const systemClock: Clock;
7
+ /** Launch Playwright's Chromium, downloading it first if this machine does not have it yet. */
7
8
  export declare const launchBrowser: BrowserLauncher;
8
9
  export interface RuntimeOptions {
9
10
  env?: Environment;
package/dist/runtime.js CHANGED
@@ -2,14 +2,24 @@ import { createApplication } from './application.js';
2
2
  import { favoritesScope, loadSettings } from './config.js';
3
3
  import { FileCookieStore, FileFavoritesStore } from './stores/files.js';
4
4
  import { BrowserSession } from './session/browser.js';
5
+ import { ChromiumInstaller, runChromiumInstall } from './session/chromium.js';
5
6
  import { AuthenticationClient } from './clients/authentication.js';
6
7
  import { StorefrontClient, CatalogClient, FavoritesClient, CartClient, OrdersClient } from './clients/storefront.js';
7
8
  import { CatalogService, FavoritesService } from './services/catalog.js';
8
9
  import { CartService } from './services/cart.js';
9
10
  import { OrderService, PurchaseHistoryService } from './services/orders.js';
10
11
  import { registerShoppingTools } from './mcp/shopping.js';
12
+ import { SERVER_INSTRUCTIONS, basketPlannerPrompt } from './mcp/guide.js';
11
13
  export const systemClock = { now: () => new Date() };
12
- export const launchBrowser = async (options) => (await import('playwright')).chromium.launch(options);
14
+ const chromiumInstaller = new ChromiumInstaller(async () => {
15
+ // Skip per-percent progress lines; keep the start, finish and any errors.
16
+ const code = await runChromiumInstall([], line => { if (!line.includes('%'))
17
+ console.error(`[chromium] ${line}`); });
18
+ if (code !== 0)
19
+ throw new Error(`Chromium download exited with code ${code}`);
20
+ }, message => console.error(message));
21
+ /** Launch Playwright's Chromium, downloading it first if this machine does not have it yet. */
22
+ export const launchBrowser = chromiumInstaller.launcher(async (options) => (await import('playwright')).chromium.launch(options));
13
23
  /** Build the shopping services. Nothing is read or launched until this is called. */
14
24
  export function createShoppingServices(options = {}) {
15
25
  const settings = loadSettings(options.env ?? process.env);
@@ -34,5 +44,6 @@ export function createShoppingServices(options = {}) {
34
44
  export function createShoppingApplication(options) {
35
45
  const services = options.services ?? createShoppingServices(options);
36
46
  return createApplication({ version: options.version, tools: registerShoppingTools(services),
47
+ prompts: [basketPlannerPrompt], instructions: SERVER_INSTRUCTIONS,
37
48
  closeResources: () => services.session.shutdown?.() ?? services.session.run(() => services.session.closeBrowserSession()) });
38
49
  }
@@ -67,7 +67,7 @@ export declare class CatalogService {
67
67
  } | {
68
68
  status: "unavailable";
69
69
  error: {
70
- code: "cache_unavailable" | "cancelled" | "cart_change_rejected" | "cart_change_unconfirmed" | "deadline_exceeded" | "invalid_data" | "invalid_input" | "not_authenticated" | "not_found" | "order_details_unavailable" | "quantity_below_minimum" | "queue_full" | "sale_rules_unknown" | "server_closed" | "upstream_unavailable";
70
+ code: "browser_unavailable" | "cache_unavailable" | "cancelled" | "cart_change_rejected" | "cart_change_unconfirmed" | "deadline_exceeded" | "invalid_data" | "invalid_input" | "not_authenticated" | "not_found" | "order_details_unavailable" | "quantity_below_minimum" | "queue_full" | "sale_rules_unknown" | "server_closed" | "upstream_unavailable";
71
71
  message: string;
72
72
  retryable: boolean;
73
73
  issues?: {
@@ -77,7 +77,7 @@ export declare class CatalogService {
77
77
  };
78
78
  };
79
79
  }, {
80
- code: "cache_unavailable" | "cancelled" | "cart_change_rejected" | "cart_change_unconfirmed" | "deadline_exceeded" | "invalid_data" | "invalid_input" | "not_authenticated" | "not_found" | "order_details_unavailable" | "quantity_below_minimum" | "queue_full" | "sale_rules_unknown" | "server_closed" | "upstream_unavailable";
80
+ code: "browser_unavailable" | "cache_unavailable" | "cancelled" | "cart_change_rejected" | "cart_change_unconfirmed" | "deadline_exceeded" | "invalid_data" | "invalid_input" | "not_authenticated" | "not_found" | "order_details_unavailable" | "quantity_below_minimum" | "queue_full" | "sale_rules_unknown" | "server_closed" | "upstream_unavailable";
81
81
  message: string;
82
82
  retryable: boolean;
83
83
  issues?: {
@@ -0,0 +1,25 @@
1
+ import type { ToolError } from '../domain/index.js';
2
+ import type { Logger } from '../ports.js';
3
+ import type { BrowserLauncher } from './browser.js';
4
+ /** The browser cannot be used yet; carries the message to show instead of a generic failure. */
5
+ export declare class BrowserUnavailable extends Error {
6
+ readonly toolError: ToolError;
7
+ constructor(toolError: ToolError);
8
+ }
9
+ export declare const isMissingBrowserError: (error: unknown) => boolean;
10
+ /** Run Playwright's installer for Chromium. With `onOutput`, its output is captured instead of inherited. */
11
+ export declare function runChromiumInstall(extraArgs?: readonly string[], onOutput?: (line: string) => void): Promise<number>;
12
+ /**
13
+ * Downloads Chromium the first time a launch finds it missing. Concurrent requests share one
14
+ * download, and a request that would run past its budget gets a "try again shortly" error.
15
+ */
16
+ export declare class ChromiumInstaller {
17
+ private readonly install;
18
+ private readonly logger;
19
+ private readonly maxWaitMs;
20
+ private pending;
21
+ constructor(install: () => Promise<void>, logger: Logger, maxWaitMs?: number);
22
+ private start;
23
+ private waitForInstall;
24
+ launcher(launch: BrowserLauncher): BrowserLauncher;
25
+ }
@@ -0,0 +1,74 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { createRequire } from 'node:module';
3
+ import { dirname, join } from 'node:path';
4
+ import { requestTimeout } from './request.js';
5
+ /** The browser cannot be used yet; carries the message to show instead of a generic failure. */
6
+ export class BrowserUnavailable extends Error {
7
+ toolError;
8
+ constructor(toolError) {
9
+ super(toolError.message);
10
+ this.toolError = toolError;
11
+ this.name = 'BrowserUnavailable';
12
+ }
13
+ }
14
+ const unavailable = (message) => new BrowserUnavailable({ code: 'browser_unavailable', message, retryable: true });
15
+ export const isMissingBrowserError = (error) => error instanceof Error && /Executable doesn't exist/i.test(error.message);
16
+ /** Run Playwright's installer for Chromium. With `onOutput`, its output is captured instead of inherited. */
17
+ export function runChromiumInstall(extraArgs = [], onOutput) {
18
+ const cli = join(dirname(createRequire(import.meta.url).resolve('playwright/package.json')), 'cli.js');
19
+ const child = spawn(process.execPath, [cli, 'install', 'chromium', ...extraArgs], { stdio: onOutput ? ['ignore', 'pipe', 'pipe'] : 'inherit' });
20
+ if (onOutput) {
21
+ const forward = (chunk) => chunk.toString().split(/\r?\n|\r/).map(line => line.trim()).filter(Boolean).forEach(onOutput);
22
+ child.stdout?.on('data', forward);
23
+ child.stderr?.on('data', forward);
24
+ }
25
+ return new Promise(resolve => { child.on('error', () => resolve(1)); child.on('close', code => resolve(code ?? 1)); });
26
+ }
27
+ /**
28
+ * Downloads Chromium the first time a launch finds it missing. Concurrent requests share one
29
+ * download, and a request that would run past its budget gets a "try again shortly" error.
30
+ */
31
+ export class ChromiumInstaller {
32
+ install;
33
+ logger;
34
+ maxWaitMs;
35
+ pending;
36
+ constructor(install, logger, maxWaitMs = 25000) {
37
+ this.install = install;
38
+ this.logger = logger;
39
+ this.maxWaitMs = maxWaitMs;
40
+ }
41
+ start() {
42
+ this.pending ??= this.install().then(() => this.logger('Chromium is ready.'), error => { this.pending = undefined; throw error; });
43
+ return this.pending;
44
+ }
45
+ async waitForInstall() {
46
+ const pending = this.start();
47
+ // Leave time to launch the browser and do the actual work within the same request.
48
+ const budget = Math.max(0, requestTimeout(this.maxWaitMs + 10000) - 10000);
49
+ let timer;
50
+ const outcome = await Promise.race([pending.then(() => 'ready', () => 'failed'),
51
+ new Promise(resolve => { timer = setTimeout(() => resolve('waiting'), budget); })]);
52
+ clearTimeout(timer);
53
+ if (outcome === 'failed')
54
+ throw unavailable('Chromium could not be downloaded. Check the internet connection, or run `continentept-mcp install-browser`.');
55
+ if (outcome === 'waiting')
56
+ throw unavailable('Chromium is being downloaded for first use (about 150 MB). Try again in a minute.');
57
+ }
58
+ launcher(launch) {
59
+ return async (options) => {
60
+ if (this.pending)
61
+ await this.waitForInstall();
62
+ try {
63
+ return await launch(options);
64
+ }
65
+ catch (error) {
66
+ if (!isMissingBrowserError(error))
67
+ throw error;
68
+ this.logger('Chromium is not installed; downloading it now. This happens once.');
69
+ await this.waitForInstall();
70
+ return launch(options);
71
+ }
72
+ };
73
+ }
74
+ }
@@ -1,7 +1,9 @@
1
1
  # Configuration
2
2
 
3
3
  Settings come from environment variables and an optional private credentials file. They are
4
- read when the server starts.
4
+ read when the server starts. The Claude Desktop extension asks for your email and password
5
+ when you install it and passes them to the server for you; the rest of this page is for
6
+ manual setups.
5
7
 
6
8
  ## Variables
7
9
 
@@ -40,6 +42,49 @@ chmod 600 ~/.continentept-mcp/credentials.env
40
42
 
41
43
  On Windows, limit the folder's permissions to your user account.
42
44
 
45
+ ## Using 1Password
46
+
47
+ With the [1Password CLI](https://developer.1password.com/docs/cli/get-started/), the
48
+ credentials never need to be written to a file. Put secret references in the MCP client
49
+ configuration and start the server through `op run`, which swaps them for the real values:
50
+
51
+ ```json
52
+ {
53
+ "mcpServers": {
54
+ "continente": {
55
+ "command": "op",
56
+ "args": ["run", "--no-masking", "--", "npx", "-y", "continentept-mcp"],
57
+ "env": {
58
+ "CONTINENTE_EMAIL": "op://Personal/Continente/username",
59
+ "CONTINENTE_PASSWORD": "op://Personal/Continente/password"
60
+ }
61
+ }
62
+ }
63
+ }
64
+ ```
65
+
66
+ For Claude Code:
67
+
68
+ ```sh
69
+ claude mcp add continente \
70
+ -e CONTINENTE_EMAIL=op://Personal/Continente/username \
71
+ -e CONTINENTE_PASSWORD=op://Personal/Continente/password \
72
+ -- op run --no-masking -- npx -y continentept-mcp
73
+ ```
74
+
75
+ - Replace `Personal/Continente` with your vault and item. In 1Password, right-click a field
76
+ and choose **Copy Secret Reference** to get the exact reference.
77
+ - Turn on **Settings → Developer → Integrate with 1Password CLI** in the 1Password app so
78
+ `op` unlocks with Touch ID or your system password. You are asked when the client starts
79
+ the server.
80
+ - Keep `--no-masking`. Without it, `op run` filters the server's output, which carries the MCP
81
+ protocol.
82
+ - The same works for the login command:
83
+ `CONTINENTE_EMAIL=op://… CONTINENTE_PASSWORD=op://… op run -- npx -y continentept-mcp login`.
84
+
85
+ Only the credentials come from 1Password. The website session the server saves after signing
86
+ in still lives in the data directory, as described below.
87
+
43
88
  ## Sign-in and saved session
44
89
 
45
90
  Account tools reuse the saved session. When the website reports that it has expired, the
package/docs/tools.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # Tool reference
2
2
 
3
- Continente MCP exposes 11 tools. Every tool has a strict input schema (unknown fields are
4
- rejected), an output schema, a title and the four MCP behaviour annotations.
3
+ Continente MCP exposes 11 tools, server instructions and one prompt. Every tool has a strict
4
+ input schema (unknown fields are rejected), an output schema, a title and the four MCP
5
+ behaviour annotations.
5
6
 
6
7
  | Tool | Login | Changes the cart | Inputs |
7
8
  | --- | --- | --- | --- |
@@ -194,11 +195,23 @@ credentials, cookies or file paths.
194
195
  | `cart_change_rejected` | The website rejected the cart change. |
195
196
  | `cart_change_unconfirmed` | The cart change could not be confirmed. |
196
197
  | `cache_unavailable` | The local favorites snapshot could not be read or written. |
198
+ | `browser_unavailable` | Chromium is still downloading for first use, or the download failed. Retryable. |
197
199
  | `cancelled`, `deadline_exceeded`, `server_closed`, `queue_full` | The request stopped before completing. |
198
200
  | `internal_error`, `invalid_result` | Unexpected server failure. Details are not exposed. |
199
201
 
200
202
  Invalid arguments and unknown tools are JSON-RPC errors (`-32602`), not tool results.
201
203
 
204
+ ## Instructions and prompt
205
+
206
+ The server sends **instructions** when a client connects: the quantity, cart-change and
207
+ uncertain-outcome rules described above, in a few lines. Clients such as Claude include them
208
+ in the assistant's context automatically.
209
+
210
+ It also offers one **prompt**, `basket-planner` ("Plan a Continente basket"). It returns the
211
+ full shopping workflow as a user message. Its optional `request` argument, such as
212
+ `weekly basket for two`, is appended to the workflow. The text is the same as the
213
+ [`basket-planner` skill](../skills/basket-planner/SKILL.md).
214
+
202
215
  ## Limits and lifecycle
203
216
 
204
217
  - Calls run one at a time. Each call has a 45-second budget, including time spent waiting.
@@ -5,7 +5,8 @@ without contacting the website.
5
5
 
6
6
  | Symptom | What to do |
7
7
  | --- | --- |
8
- | `Executable doesn't exist` or the browser fails to start | Run `npx -y continentept-mcp install-browser`. On Linux, add `--with-deps` to install system libraries. |
8
+ | `browser_unavailable`: Chromium is being downloaded | The first use downloads Chromium (about 150 MB). Wait a minute and try again. |
9
+ | `browser_unavailable`: Chromium could not be downloaded | Check the internet connection, then run `npx -y continentept-mcp install-browser` to see the download output. On Linux, add `--with-deps` to install system libraries. |
9
10
  | `not_authenticated` | Check that `get_session_status` reports credentials as configured, then run `continentept-mcp login` to test them. See [configuration](configuration.md). |
10
11
  | Sign-in keeps failing | Run `continentept-mcp login --show-browser` to watch the browser and complete any extra verification the website asks for. |
11
12
  | Status shows `authentication: unknown` | Nothing has been observed since the server started or since the saved session changed. Any account tool will establish it. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "continentept-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "MCP server for Continente.pt: search products, check sale rules, read favorites and orders, and make verified cart changes.",
5
5
  "keywords": [
6
6
  "mcp",
@@ -62,7 +62,8 @@
62
62
  "test": "node build/tools/run-tests.js",
63
63
  "test:browser": "npm run build && tsc -p tsconfig.tests.json && node build/tools/run-tests.js --browser",
64
64
  "test:package": "npm run build:tools && node build/tools/package-smoke.js",
65
- "prepack": "npm run build"
65
+ "prepack": "npm run build",
66
+ "build:bundle": "npm run build && node build/tools/build-bundle.js"
66
67
  },
67
68
  "dependencies": {
68
69
  "@modelcontextprotocol/sdk": "^1.32.1",
@@ -71,6 +72,7 @@
71
72
  "zod": "4.6.7"
72
73
  },
73
74
  "devDependencies": {
75
+ "@anthropic-ai/mcpb": "2.1.2",
74
76
  "@types/node": "^22.18.0",
75
77
  "typescript": "^7.0.2"
76
78
  }
@@ -47,4 +47,4 @@ For "my usual items", `list_favorites` and `list_frequently_bought_products` can
47
47
 
48
48
  Finish with the chosen or changed items, confirmed quantities and units, and any unresolved choices or failures. Keep planned items separate from changes the server confirmed.
49
49
 
50
- For exact schemas and limits, see the [tool reference](../../docs/tools.md).
50
+ For exact schemas and limits, see the [tool reference](https://github.com/andredelgado/continente-mcp/blob/main/docs/tools.md).