Skip to main content
Glama

mcnemar_test

Read-onlyIdempotent

Test whether two paired proportions are equal (e.g., before/after intervention or two raters on same items) and get chi-squared, p-value, and confidence interval for the difference.

Instructions

Test whether two paired proportions are equal -- e.g. the same subjects' yes/no answers before and after an intervention, or two raters' calls on the same items. Use this instead of two_proportion_z_test whenever the "two groups" are actually the same subjects measured twice; two_proportion_z_test assumes independent groups and gets the standard error wrong for paired data. Yates continuity-corrected chi-squared, 1 df -- use mcnemar_exact_test instead when there are few discordant pairs (this warns when there are). Returns that chi-squared statistic, a p-value, and a confidence interval for the difference in marginal proportions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
alphaNosignificance level for the test (and any confidence interval); default 0.05
tableYes2x2 table as [[a, b], [c, d]]: a/d are pairs that agree both times, b/c are the discordant pairs (b: positive then negative, c: negative then positive) -- raw non-negative integer counts

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.5.0

TDQS

A4.6/5.0
Behavior5/5

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

The description discloses the test method (Yates continuity-corrected chi-squared, 1 df) and the return values (chi-squared statistic, p-value, confidence interval). It also notes the warning behavior from mcnemar_exact_test. Annotations (readOnlyHint, idempotentHint, destructiveHint) are consistent; no contradiction found.

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

Conciseness4/5

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

The description is moderately long but each sentence serves a purpose: purpose, usage guidance, and technical detail. It is front-loaded with the core purpose and avoids redundancy. Slightly verbose but justified.

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?

For a two-parameter tool with no output schema, the description fully explains what it does, when to use it, what it returns, and the alternative. An agent can correctly select and invoke this tool without missing information.

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 schema covers 100% of parameters with clear descriptions, including the exact table format. The description adds contextual value about the test but does not need to compensate for schema gaps. Baseline of 3 is appropriate because the schema already provides sufficient parameter meaning.

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 states a specific statistical test (McNemar's) with clear examples of paired proportions. It explicitly differentiates itself from two_proportion_z_test by noting the paired nature of the data, making its purpose unambiguous and distinct from siblings.

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?

It provides explicit when-to-use guidance: 'Use this instead of two_proportion_z_test whenever the two groups are actually the same subjects measured twice' and names the alternative mcnemar_exact_test for few discordant pairs. This is clear and actionable.

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