@udondan/marktguru 1.1.0 → 1.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/README.md CHANGED
@@ -1,20 +1,49 @@
1
1
  # marktguru 🧘‍♂️
2
2
 
3
- [![Test](https://github.com/udondan/marktguru/actions/workflows/test.yml/badge.svg)](https://github.com/udondan/marktguru/actions/workflows/test.yml)
4
- [![npm](https://img.shields.io/npm/v/@udondan/marktguru.svg)](https://www.npmjs.com/package/@udondan/marktguru)
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/udondan/marktguru/main/.github/assets/banner-dark.webp">
5
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/udondan/marktguru/main/.github/assets/banner-light.webp">
6
+ <img alt="marktguru – Supermarket deals, programmable. CLI / HTTP API / MCP" src="https://raw.githubusercontent.com/udondan/marktguru/main/.github/assets/banner-light.webp">
7
+ </picture>
8
+
9
+ [![npm](https://img.shields.io/npm/v/@udondan/marktguru)](https://www.npmjs.com/package/@udondan/marktguru)
10
+ [![Docker](https://img.shields.io/docker/v/udondan/marktguru?sort=semver&label=docker)](https://hub.docker.com/r/udondan/marktguru)
11
+ [![Node.js](https://img.shields.io/node/v/@udondan/marktguru)](https://www.npmjs.com/package/@udondan/marktguru)
12
+ [![Test](https://github.com/udondan/marktguru/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/udondan/marktguru/actions/workflows/test.yml)
5
13
  [![codecov](https://codecov.io/gh/udondan/marktguru/graph/badge.svg)](https://codecov.io/gh/udondan/marktguru)
6
14
  [![Maintainability](https://qlty.sh/gh/udondan/projects/marktguru/maintainability.svg)](https://qlty.sh/gh/udondan/projects/marktguru)
7
- [![license](https://img.shields.io/github/license/udondan/marktguru.svg)](https://github.com/udondan/marktguru/blob/main/LICENSE)
15
+ [![License](https://img.shields.io/github/license/udondan/marktguru)](https://github.com/udondan/marktguru/blob/main/LICENSE)
8
16
 
9
17
  > [!NOTE]
10
18
  > Unofficial community project. Not affiliated with, endorsed or authorized by marktguru.
11
19
 
12
- Marktguru supermarket deals in Austria and Germany, as a CLI, a local HTTP
20
+ Marktguru supermarket deals in Germany and Austria, as a CLI, a local HTTP
13
21
  API and an MCP server.
14
22
 
15
23
  This is a maintained fork of [manmal/marktguru-cli](https://github.com/manmal/marktguru-cli), published as [`@udondan/marktguru`](https://www.npmjs.com/package/@udondan/marktguru)
16
24
  (formerly [`@udondan/marktguru-cli`](https://www.npmjs.com/package/@udondan/marktguru-cli)).
17
25
 
26
+ ## Table of Contents
27
+
28
+ - [AI Agent Skill](#ai-agent-skill)
29
+ - [Quick Start (Recommended)](#quick-start-recommended)
30
+ - [Requirements](#requirements)
31
+ - [Commands](#commands)
32
+ - [Also Working (Install Locally)](#also-working-install-locally)
33
+ - [Search Options](#search-options)
34
+ - [HTTP API](#http-api)
35
+ - [MCP Server](#mcp-server)
36
+ - [Claude Code](#claude-code)
37
+ - [Claude Desktop and other clients](#claude-desktop-and-other-clients)
38
+ - [Docker](#docker)
39
+ - [Docker MCP Toolkit](#docker-mcp-toolkit)
40
+ - [Query Syntax (Observed)](#query-syntax-observed)
41
+ - [Notes on `login`](#notes-on-login)
42
+ - [Config Location](#config-location)
43
+ - [Disclaimer](#disclaimer)
44
+
45
+ ---
46
+
18
47
  ## AI Agent Skill
19
48
 
20
49
  Install into your coding agent with the [`skills`](https://skills.sh) CLI:
@@ -23,7 +52,7 @@ Install into your coding agent with the [`skills`](https://skills.sh) CLI:
23
52
  npx skills add udondan/marktguru
24
53
  ```
25
54
 
26
- Or read [skills/marktguru-grocery-deals/SKILL.md](skills/marktguru-grocery-deals/SKILL.md) directly — a comprehensive reference designed for AI coding agents.
55
+ Or read [skills/marktguru-grocery-deals/SKILL.md](https://github.com/udondan/marktguru/blob/main/skills/marktguru-grocery-deals/SKILL.md) directly — a comprehensive reference designed for AI coding agents.
27
56
 
28
57
  ## Quick Start (Recommended)
29
58
 
@@ -37,7 +66,7 @@ npx --yes @udondan/marktguru search build --term milch --or soja
37
66
 
38
67
  ## Requirements
39
68
 
40
- - Node.js 18+ (built-in `fetch`)
69
+ - Node.js 22.12+
41
70
  - Works with `npm`, `pnpm`, and `bun`
42
71
 
43
72
  ## Commands
@@ -69,13 +98,13 @@ marktguru search syntax
69
98
  Set a default ZIP code:
70
99
 
71
100
  ```bash
72
- marktguru set-zip 1010
101
+ marktguru set-zip 80331
73
102
  ```
74
103
 
75
- Set a default country (`at` or `de`, default: `at`):
104
+ Set a default country (`de` or `at`, default: `de`):
76
105
 
77
106
  ```bash
78
- marktguru set-country de
107
+ marktguru set-country at
79
108
  ```
80
109
 
81
110
  Show config:
@@ -252,7 +281,7 @@ With the [Docker MCP Toolkit](https://docs.docker.com/ai/mcp-catalog-and-toolkit
252
281
  of Docker Desktop, the server runs as a container behind the MCP Gateway,
253
282
  which starts it on demand and passes its tools on to the connected clients.
254
283
 
255
- 1. Download the server definition [`docker-mcp.yml`](docker-mcp.yml) and add it
284
+ 1. Download the server definition [`docker-mcp.yml`](https://github.com/udondan/marktguru/blob/main/docker-mcp.yml) and add it
256
285
  to a Toolkit profile. The Toolkit only reads such files from its catalogs
257
286
  directory:
258
287
 
@@ -271,7 +300,7 @@ which starts it on demand and passes its tools on to the connected clients.
271
300
  `make docker` builds the image locally and does the same
272
301
  (`make docker-register PROFILE=<id>` for another profile).
273
302
 
274
- 2. Optionally set the default country and ZIP code (Austria and 1010
303
+ 2. Optionally set the default country and ZIP code (Germany and 10115
275
304
  otherwise):
276
305
 
277
306
  ```bash
@@ -322,6 +351,10 @@ override the country and default ZIP code of the config file for `search`,
322
351
  country in the config file; searches in another country fetch a key for it
323
352
  and keep it in memory only.
324
353
 
354
+ Without a ZIP code, searches use 10115 (Berlin) in Germany and 1010 (Vienna)
355
+ in Austria. Germany is the default country since version 1.2.0; config files
356
+ of older versions that don't name a country keep Austria.
357
+
325
358
  ## Disclaimer
326
359
 
327
360
  This is an unofficial, independent open-source project and is not affiliated with marktguru Deutschland GmbH or its
package/dist/api.js CHANGED
@@ -1,4 +1,4 @@
1
- import { getConfig, DEFAULT_ZIP_CODE, VALID_COUNTRIES } from './config.js';
1
+ import { getConfig, defaultZipCode, VALID_COUNTRIES } from './config.js';
2
2
  export function getApiBase(country) {
3
3
  if (!VALID_COUNTRIES.includes(country)) {
4
4
  throw new Error(`Unsupported country "${country}". Valid options: ${VALID_COUNTRIES.join(', ')}`);
@@ -11,8 +11,8 @@ export async function search(options) {
11
11
  if (!apiKey) {
12
12
  throw new Error("No API key configured. Run 'marktguru login' first.");
13
13
  }
14
- const zipCode = options.zipCode ?? config.zipCode ?? DEFAULT_ZIP_CODE;
15
14
  const country = options.country ?? config.country;
15
+ const zipCode = options.zipCode ?? config.zipCode ?? defaultZipCode(country);
16
16
  const params = new URLSearchParams({
17
17
  as: 'web',
18
18
  q: options.query,
package/dist/auth.js CHANGED
@@ -1,5 +1,4 @@
1
- import { VALID_COUNTRIES } from './config.js';
2
- const DEFAULT_ZIP_CODE = '1010';
1
+ import { DEFAULT_COUNTRY, VALID_COUNTRIES, defaultZipCode } from './config.js';
3
2
  const MAX_SCRIPTS = 20;
4
3
  const TIMEOUT_MS = 15000;
5
4
  const BROWSER_HEADERS = {
@@ -65,8 +64,8 @@ function findCandidates(text) {
65
64
  }
66
65
  return [...candidates];
67
66
  }
68
- async function validateKey(apiKey, apiBase) {
69
- const url = `${apiBase}/offers/search?as=web&q=test&limit=1&zipCode=${DEFAULT_ZIP_CODE}`;
67
+ async function validateKey(apiKey, apiBase, zipCode) {
68
+ const url = `${apiBase}/offers/search?as=web&q=test&limit=1&zipCode=${zipCode}`;
70
69
  const res = await fetch(url, {
71
70
  headers: {
72
71
  'x-apikey': apiKey,
@@ -78,7 +77,7 @@ async function validateKey(apiKey, apiBase) {
78
77
  }
79
78
  export async function extractApiKey(options = {}) {
80
79
  const log = options.log;
81
- const country = options.country ?? 'at';
80
+ const country = options.country ?? DEFAULT_COUNTRY;
82
81
  if (!VALID_COUNTRIES.includes(country)) {
83
82
  throw new Error(`Unsupported country "${country}". Valid options: ${VALID_COUNTRIES.join(', ')}`);
84
83
  }
@@ -113,7 +112,7 @@ export async function extractApiKey(options = {}) {
113
112
  }
114
113
  }
115
114
  for (const candidate of candidates) {
116
- if (await validateKey(candidate, apiBase)) {
115
+ if (await validateKey(candidate, apiBase, defaultZipCode(country))) {
117
116
  return candidate;
118
117
  }
119
118
  }
@@ -1,4 +1,4 @@
1
- import { getConfig, getFileConfig, saveConfig, DEFAULT_ZIP_CODE, VALID_COUNTRIES, } from '../config.js';
1
+ import { getConfig, getFileConfig, saveConfig, defaultZipCode, VALID_COUNTRIES, } from '../config.js';
2
2
  function truncateKey(apiKey) {
3
3
  return `${apiKey.substring(0, 10)}...`;
4
4
  }
@@ -37,7 +37,7 @@ function printConfigJson(config) {
37
37
  console.log(JSON.stringify({
38
38
  apiKey: config.apiKey ? truncateKey(config.apiKey) : null,
39
39
  apiKeySet: !!config.apiKey,
40
- zipCode: config.zipCode ?? DEFAULT_ZIP_CODE,
40
+ zipCode: config.zipCode ?? defaultZipCode(config.country),
41
41
  country: config.country,
42
42
  configPath: config.configPath,
43
43
  }));
@@ -45,7 +45,7 @@ function printConfigJson(config) {
45
45
  function printConfigText(config) {
46
46
  console.log('Configuration:');
47
47
  console.log(' API Key:', config.apiKey ? truncateKey(config.apiKey) : '(not set)');
48
- console.log(' ZIP Code:', config.zipCode ?? `(default: ${DEFAULT_ZIP_CODE})`);
48
+ console.log(' ZIP Code:', config.zipCode ?? `(default: ${defaultZipCode(config.country)})`);
49
49
  console.log(' Country:', config.country);
50
50
  console.log(' Config file:', config.configPath);
51
51
  }
@@ -6,7 +6,7 @@ import { QUERY_SYNTAX_HELP } from '../query.js';
6
6
  import { formatResultsText, performSearch, simplifyOffer, toJsonFull, } from './search.js';
7
7
  const INSTRUCTIONS = [
8
8
  'Searches current supermarket deals (offers from weekly leaflets) on',
9
- 'Marktguru in Austria (at) and Germany (de). The API key is fetched',
9
+ 'Marktguru in Germany (de) and Austria (at). The API key is fetched',
10
10
  'automatically. Country and ZIP code default to the configuration',
11
11
  '(MARKTGURU_COUNTRY, MARKTGURU_ZIP, or ~/.marktguru/config.json) and can be',
12
12
  'set per search.',
@@ -42,7 +42,7 @@ const searchInput = {
42
42
  country: z
43
43
  .enum(VALID_COUNTRIES)
44
44
  .optional()
45
- .describe('Country: at (Austria) or de (Germany)'),
45
+ .describe('Country: de (Germany) or at (Austria)'),
46
46
  retailer: z
47
47
  .string()
48
48
  .optional()
@@ -71,7 +71,7 @@ export function createServer(version) {
71
71
  const server = new McpServer({ name: 'marktguru', version }, { instructions: INSTRUCTIONS });
72
72
  server.registerTool('search_offers', {
73
73
  title: 'Search supermarket deals',
74
- description: 'Search current supermarket deals on Marktguru (AT/DE) with the Marktguru query syntax.',
74
+ description: 'Search current supermarket deals on Marktguru (DE/AT) with the Marktguru query syntax.',
75
75
  inputSchema: searchInput,
76
76
  annotations: {
77
77
  readOnlyHint: true,
package/dist/config.d.ts CHANGED
@@ -4,10 +4,10 @@ export interface Config {
4
4
  country?: string;
5
5
  configPath: string;
6
6
  }
7
- export declare const DEFAULT_ZIP_CODE = "1010";
8
- export declare const DEFAULT_COUNTRY = "at";
7
+ export declare const DEFAULT_COUNTRY = "de";
9
8
  export declare const VALID_COUNTRIES: readonly ["at", "de"];
10
9
  export type Country = (typeof VALID_COUNTRIES)[number];
10
+ export declare function defaultZipCode(country: string): string;
11
11
  export type LoadedConfig = Config & {
12
12
  country: string;
13
13
  };
package/dist/config.js CHANGED
@@ -1,9 +1,19 @@
1
1
  import { homedir } from 'os';
2
2
  import { join } from 'path';
3
3
  import { readFile, writeFile, mkdir } from 'fs/promises';
4
- export const DEFAULT_ZIP_CODE = '1010'; // Vienna
5
- export const DEFAULT_COUNTRY = 'at';
4
+ export const DEFAULT_COUNTRY = 'de';
6
5
  export const VALID_COUNTRIES = ['at', 'de'];
6
+ // ZIP codes of searches that set none: Berlin and Vienna.
7
+ const DEFAULT_ZIP_CODES = { de: '10115', at: '1010' };
8
+ export function defaultZipCode(country) {
9
+ return DEFAULT_ZIP_CODES[country] ?? DEFAULT_ZIP_CODES[DEFAULT_COUNTRY];
10
+ }
11
+ // Austria was the default country before, and the country was only written to
12
+ // the config file by set-country. A config file without a country therefore
13
+ // belongs to Austria, including its API key; a missing file to the default.
14
+ function fallbackCountry(file) {
15
+ return Object.keys(file).length > 0 ? 'at' : DEFAULT_COUNTRY;
16
+ }
7
17
  const CONFIG_DIR = join(homedir(), '.marktguru');
8
18
  const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
9
19
  // Empty or null values in a hand-edited config file count as unset.
@@ -31,17 +41,29 @@ function fromEnvironment() {
31
41
  // to: login and set-country keep the two in sync, the environment doesn't.
32
42
  export async function getFileConfig() {
33
43
  const parsed = await readConfigFile();
34
- return { country: DEFAULT_COUNTRY, ...parsed, configPath: CONFIG_FILE };
44
+ return {
45
+ country: fallbackCountry(parsed),
46
+ ...parsed,
47
+ configPath: CONFIG_FILE,
48
+ };
35
49
  }
36
50
  // The config file with the environment overrides applied.
37
51
  export async function getConfig() {
38
- const parsed = { ...(await readConfigFile()), ...fromEnvironment() };
39
- return { country: DEFAULT_COUNTRY, ...parsed, configPath: CONFIG_FILE };
52
+ const file = await readConfigFile();
53
+ return {
54
+ country: fallbackCountry(file),
55
+ ...file,
56
+ ...fromEnvironment(),
57
+ configPath: CONFIG_FILE,
58
+ };
40
59
  }
41
60
  // Writes only to the config file, environment overrides are not persisted.
61
+ // The country is always written, so it stays the same when the default
62
+ // changes.
42
63
  export async function saveConfig(config) {
43
64
  await mkdir(CONFIG_DIR, { recursive: true });
44
- const merged = { ...(await readConfigFile()), ...config };
65
+ const file = await readConfigFile();
66
+ const merged = { country: fallbackCountry(file), ...file, ...config };
45
67
  const { configPath: _configPath, ...persisted } = merged;
46
68
  await writeFile(CONFIG_FILE, JSON.stringify(persisted, null, 2));
47
69
  }
package/dist/program.js CHANGED
@@ -130,8 +130,8 @@ export function createProgram() {
130
130
  const program = new Command();
131
131
  program
132
132
  .name('marktguru')
133
- .description('Marktguru supermarket deals (AT/DE): CLI, HTTP API and MCP server')
134
- .version('1.1.0') // x-release-please-version
133
+ .description('Marktguru supermarket deals (DE/AT): CLI, HTTP API and MCP server')
134
+ .version('1.2.0') // x-release-please-version
135
135
  .option('-j, --json', 'Output JSON (for all commands)');
136
136
  program.addHelpText('afterAll', [
137
137
  '',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@udondan/marktguru",
3
- "version": "1.1.0",
4
- "description": "Marktguru supermarket deals in Austria and Germany: CLI, HTTP API and MCP server",
3
+ "version": "1.2.0",
4
+ "description": "Marktguru supermarket deals in Germany and Austria: CLI, HTTP API and MCP server",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "Daniel Schroeder",
@@ -30,6 +30,9 @@
30
30
  "germany"
31
31
  ],
32
32
  "type": "module",
33
+ "engines": {
34
+ "node": ">=22.12.0"
35
+ },
33
36
  "bin": {
34
37
  "marktguru": "dist/cli.js"
35
38
  },