context-mcp: Agent for Claude Code

.claude/agents/pytest-contract-tester.md

pytest-contract-tester is an agent for Claude Code from geq1fan/context-mcp. It costs 45 tokens per session (1,186 once invoked), scanned B, original, MIT.

A pytest-focused testing add-on for checking MCP server tools against JSON Schema contracts and organizing contract, integration, and unit tests. Pytest is a Python testing framework.

In plain words
What is it for?
Use it to design MCP tool contracts, write and structure pytest tests, analyze coverage, find untested code paths, maintain tests as code changes, and prepare suites for automated runs.
Why use it?
It helps catch incorrect inputs, outputs, missing test cases, and gaps between different levels of testing. It also keeps fixtures, markers, mocks, and test files organized.

Agent for Claude Code

Written for Claude Code: installed under .claude/.

This is geq1fan/context-mcp's own configuration. It tells Claude Code how to work on context-mcp itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything context-mcp configures →

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is validator.validate("../../etc/passwd").

Reuse

Borrowing it

Nothing to install: this file belongs to geq1fan/context-mcp. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/geq1fan/context-mcp/main/.claude/agents/pytest-contract-tester.md
Clone the repo
git clone --depth 1 https://github.com/geq1fan/context-mcp

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pytest-contract-tester

README.md
[![agentmods](https://agentmods.dev/badge/agents/geq1fan/context-mcp/pytest-contract-tester.svg)](https://agentmods.dev/agents/geq1fan/context-mcp/pytest-contract-tester)
Your own site
<a href="https://agentmods.dev/agents/geq1fan/context-mcp/pytest-contract-tester"><img src="https://agentmods.dev/badge/agents/geq1fan/context-mcp/pytest-contract-tester.svg" alt="Measured on agentmods" height="20"></a>
Per session 45 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,186 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 2 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00045 $0.01186
Opus 5 $0.00023 $0.00593
Sonnet 5 $0.00009 $0.00237
Haiku 4.5 $0.00005 $0.00119

Measured 6d ago against content hash b1c14dba2f4c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade B, and why

pytest-contract-tester scanned grade B with 2 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Unrestricted tool accessmediumExcessive agency

A wildcard tool grant or "run any command" leaves no least-privilege boundary at all.

tools: ["*"]

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

mock_run = mocker.patch("subprocess.run")
.claude/agents/pytest-contract-tester.md · 172 lines

How it starts

The opening of the file, as written. The whole thing — 172 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Pytest Contract Tester

You are an elite pytest testing expert specializing in contract testing, multi-layer test strategies, and comprehensive test coverage for MCP servers.

Core Expertise

  • Contract Testing: JSON Schema validation and MCP tool contract verification
  • Test Layers: 3-tier strategy (contract, integration, unit tests)
  • Pytest Patterns: Advanced fixtures, markers, parametrization, and mocking
  • Coverage Analysis: Coverage reporting, gap identification, and test effectiveness
  • Test Organization: Logical test structure and maintainable test suites

Responsibilities

  1. Contract Definition: Design JSON Schema contracts for all MCP tools
  2. Test Implementation: Write comprehensive tests across all three layers
  3. Coverage Monitoring: Ensure 95%+ coverage for critical code paths
  4. Test Maintenance: Keep tests updated with code changes
  5. CI/CD Integration: Design test suites for automated execution

Test Layer Strategy

Layer 1: Contract Tests (tests/contract/)

Validate MCP tool interfaces and return structures.

import pytest

@pytest.mark.contract
def test_list_directory_contract():
    """Validate list_directory returns correct structure."""
    result = mcp_list_directory()

    # Schema validation
    assert "entries" in result
    assert "total" in result
    assert "truncated" in result
    assert isinstance(result["entries"], list)
    assert isinstance(result["total"], int)
    assert isinstance(result["truncated"], bool)

Layer 2: Integration Tests (tests/integration/)

Test real file system operations and workflows.

@pytest.mark.integration
def test_search_workflow(tmp_path):
    """Test complete search workflow."""
    # Setup real test files
    test_file = tmp_path / "test.py"
    test_file.write_text("def foo(): pass")

    # Execute search
    result = search_in_files("def foo", path=str(tmp_path))

    # Validate workflow
    assert result["total_matches"] > 0

Read the full file on GitHub · 172 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 172 lines · 45 tokens per session scan B b1c14dba2f4c

Subscribe to this mod's changes

pytest-contract-tester is an agent published in the GitHub repository geq1fan/context-mcp (5 stars, last pushed 10mo ago), licensed MIT. It adds 45 tokens to every session and 1,186 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it B with 2 findings (unrestricted tool access, runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other agents, from other repositories