Skip to main content
Glama
nicktcode

Swissgroceries MCP

health_check

Probe each registered Swiss retailer adapter with a trivial query to diagnose health, latency, and capabilities. Quickly identify why a specific chain is missing from search or plan results.

Instructions

Probe each registered chain adapter with a trivial query and report status, latency, and capability flags. Use this when a chain seems missing from results or when debugging adapter problems.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chainsNoChains to probe. Default: all configured.
timeoutMsNoPer-chain timeout in milliseconds. Default 5000.

Implementation Reference

  • The handler function that executes the health check logic. It iterates over requested chains, calls each adapter's searchProducts with a trivial query ('milch'), measures latency, and returns health status, capabilities, and a summary.
    export async function healthCheckHandler(
      registry: AdapterRegistry,
      input: HealthCheckInput,
    ): Promise<{ chains: HealthCheckResult[]; summary: { healthy: number; unhealthy: number; unregistered: number } }> {
      const all: Chain[] = ['migros', 'coop', 'aldi', 'denner', 'lidl'];
      const requested = input.chains ?? all;
      const timeout = input.timeoutMs ?? 5000;
    
      const results = await Promise.all(requested.map(async (chain): Promise<HealthCheckResult> => {
        const adapter = registry.get(chain);
        if (!adapter) return { chain, registered: false, ok: false };
        const start = Date.now();
        try {
          const r = await Promise.race([
            adapter.searchProducts({ query: TRIVIAL_QUERY, limit: 1 }),
            new Promise<never>((_, reject) => setTimeout(() => reject(new Error('timeout')), timeout)),
          ]);
          const latencyMs = Date.now() - start;
          if (r.ok) {
            return {
              chain, registered: true, ok: true, latencyMs,
              capabilities: { ...adapter.capabilities },
            };
          }
          return {
            chain, registered: true, ok: false, latencyMs,
            error: { code: r.error.code, reason: 'reason' in r.error ? r.error.reason : undefined },
            capabilities: { ...adapter.capabilities },
          };
        } catch (e) {
          const msg = e instanceof Error ? e.message : String(e);
          return {
            chain, registered: true, ok: false,
            error: { code: msg === 'timeout' ? 'timeout' : 'unavailable', reason: msg },
            capabilities: { ...adapter.capabilities },
          };
        }
      }));
    
      const summary = {
        healthy: results.filter((r) => r.ok).length,
        unhealthy: results.filter((r) => r.registered && !r.ok).length,
        unregistered: results.filter((r) => !r.registered).length,
      };
    
      return { chains: results, summary };
    }
  • Zod schema defining the input: optional chains array (enum of known chains) and optional timeoutMs (1-30000).
    export const healthCheckSchema = z.object({
      chains: z.array(z.enum(['migros', 'coop', 'aldi', 'denner', 'lidl', 'farmy', 'volgshop', 'ottos']))
        .optional()
        .describe('Chains to probe. Default: all configured.'),
      timeoutMs: z.number().int().positive().max(30000).optional()
        .describe('Per-chain timeout in milliseconds. Default 5000.'),
    }).describe('Probe each registered chain adapter with a trivial query and report which are healthy. Useful for diagnosing why a particular chain is missing from search/plan results.');
  • TypeScript interface for the per-chain health check result, including registration status, ok flag, latency, error info, and capabilities.
    export interface HealthCheckResult {
      chain: Chain;
      registered: boolean;
      ok: boolean;
      latencyMs?: number;
      error?: { code: string; reason?: string };
      capabilities?: Record<string, boolean>;
    }
  • src/index.ts:29-29 (registration)
    Import of healthCheckHandler and healthCheckSchema in the main index.ts file where tools are registered.
    import { healthCheckHandler, healthCheckSchema } from './tools/health_check.js';
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. It explains the probe action and outputs, but does not explicitly state it is read-only or non-destructive.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded with action and output, no superfluous information. Every sentence adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, so description should detail return structure more. It mentions fields (status, latency, capability flags) but lacks format, making it slightly incomplete for a diagnostic tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. Description does not add extra meaning beyond schema for parameters; only briefly mentions 'trivial query'.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states it probes chain adapters with a trivial query and reports status, latency, and capability flags. It distinguishes from siblings by focusing on health diagnosis.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly says 'Use this when a chain seems missing from results or when debugging adapter problems,' providing clear context for when to invoke.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nicktcode/swissgroceries-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server