Skip to main content
Glama
nicktcode

Swissgroceries MCP

health_check

Probe grocery chain adapters to verify health and diagnose missing results. Reports status, latency, and capabilities.

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 chain adapter with a trivial query ('milch') and reports health status, latency, and capabilities. Accepts an AdapterRegistry and HealthCheckInput, returns health results per chain plus 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 health_check input: optional 'chains' array (enum of chain names) 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.');
  • src/index.ts:105-110 (registration)
    Registration of the 'health_check' tool in the TOOLS array, mapping name, description, schema (healthCheckSchema), and handler (healthCheckHandler).
    {
      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,
    },
  • src/index.ts:130-136 (registration)
    The ListToolsRequestSchema handler that exposes tool metadata, including health_check, to the MCP client via zodToJsonSchema conversion.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: TOOLS.map((t) => ({
        name: t.name,
        description: t.description,
        inputSchema: zodToJsonSchema(t.schema),
      })),
    }));
  • Standalone probe script that invokes healthCheckHandler directly with an empty input and prints per-chain status and summary. Useful for CLI debugging.
    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);
Behavior4/5

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

No annotations are provided, so the description bears full burden. It states that the tool performs a trivial probe and reports status, latency, and capability flags. While it does not explicitly declare non-destructiveness, the nature of health checking implies no side effects. The description adds sufficient transparency beyond structured fields.

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?

The description consists of two well-structured sentences. The first defines functionality and output, the second provides usage guidance. No extraneous words or redundancy.

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

Completeness5/5

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

Given the tool's simplicity (2 optional parameters, no output schema, no annotations), the description adequately covers purpose, usage, and behavioral details. The agent can correctly infer what the tool does and when to use it.

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?

The input schema has 100% description coverage, detailing both parameters (chains and timeoutMs) including their defaults. The description does not add additional meaning beyond the schema, meeting the baseline for high coverage.

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 a specific verb 'Probe' and resource 'chain adapter', clearly distinguishing it from sibling tools like search_products or find_stock. The output includes status, latency, and capability flags, making the purpose precise.

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?

The description explicitly states when to use this tool: 'when a chain seems missing from results or when debugging adapter problems.' This provides clear guidance on when to select this tool over alternatives.

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