Skip to main content
Glama
nicktcode

Swissgroceries MCP

health_check

Probe all registered Swiss grocery chain adapters with a trivial query to report their health status, latency, and capability flags. Use this to diagnose why a chain is missing from search results or plan.

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 main handler function that probes each requested chain adapter with a trivial search query ('milch') and reports health status, latency, capabilities, and errors.
    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 parameters: optional chains array and optional timeout in milliseconds.
    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 describing the result structure returned per chain.
    export interface HealthCheckResult {
      chain: Chain;
      registered: boolean;
      ok: boolean;
      latencyMs?: number;
      error?: { code: string; reason?: string };
      capabilities?: Record<string, boolean>;
    }
  • src/index.ts:105-110 (registration)
    Tool registration in the TOOLS array, mapping name 'health_check' to its schema and handler.
    {
      name: 'health_check',
      description: '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.',
      schema: healthCheckSchema,
      handler: healthCheckHandler,
    },
  • Standalone probe script that runs the health check against all chains and prints results.
    import { buildRegistry } from '../src/index.js';
    import { healthCheckHandler } from '../src/tools/health_check.js';
    
    const r = buildRegistry();
    const out = await healthCheckHandler(r, {});
    for (const c of out.chains) {
      const status = !c.registered ? 'UNREGISTERED' : c.ok ? `OK ${c.latencyMs}ms` : `FAIL (${c.error?.code}: ${c.error?.reason ?? ''})`;
      console.log(`${c.chain}: ${status}`);
    }
    console.log('\nSummary:', out.summary);
Behavior3/5

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

No annotations provided, so description carries full burden. It describes the operation as 'probe with a trivial query' and reports status/latency/capability flags, implying a read-only health check. However, it does not explicitly confirm no side effects, auth requirements, or rate limits. The description is adequate but not rich.

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: first states functionality, second provides usage guidance. No wasted words, front-loaded with key action.

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?

For a simple diagnostic tool with 2 optional params and no output schema, the description covers purpose, trigger, and high-level output. Could be slightly more detailed on output format, but sufficient.

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 description coverage is 100% with both parameters documented. The description adds no new meaning beyond the schema, so baseline 3 is appropriate.

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?

The description uses specific verb 'probe' and resources 'chain adapters' and states outputs: status, latency, and capability flags. It also positions it for debugging missing chains, distinguishing it from sibling data tools like search_products or find_stock.

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

Usage Guidelines4/5

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

Explicitly states when to use: 'chain seems missing from results' or 'debugging adapter problems'. Does not mention when not to use or contrast with alternatives, but the context with sibling tools makes the purpose distinct.

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