atxtechbro / atxtechbro/dotfiles

feat[mcp]: Create test harness for MCP server development

Open
#589 0 comments 0 reactions 0 assignees View on GitHub
developer-experience enhancement mcp testing
Dominant language
Shell
Stars
27
Forks
2
PR merge metrics
No merged PRs in 30d

Description

## User Story
As an AI agent working on MCP server improvements, I would like a standardized test harness that allows me to quickly test changes without dealing with dependency setup complexities, so that testing becomes the default path rather than an obstacle.

## Context
During implementation of #584 (git branch safety rule), we attempted to create an ad-hoc test script but encountered several friction points:
- MCP server dependencies (click, mcp, pydantic) needed for imports
- Virtual environment setup requirements
- Module path resolution complexities
- Even with PEP 723 inline dependencies, the interconnected nature of MCP servers made isolated testing difficult

This friction led to skipping tests for a simple 5-line change - which was the right pragmatic decision, but highlights a gap in our testing infrastructure.

## Proposed Solution
Create a lightweight test harness for MCP servers that:
1. Provides a minimal test environment without full server initialization
2. Allows testing individual functions in isolation
3. Uses PEP 723 or similar for self-contained test scripts
4. Includes common test utilities (temp git repos, mock MCP contexts, etc.)
5. Works with `uv run` for zero-setup execution

## Example Usage
```python
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.10"
# dependencies = ["mcp-test-harness"]
# ///

from mcp_test_harness import mock_repo, test_git_function
from server import git_branch_delete

def test_branch_safety():
with mock_repo() as repo:
result = test_git_function(git_branch_delete, repo, "main")
assert "protected branch" in result
```

## Benefits
- Lower barrier to testing = more tested code
- Faster feedback loops during development
- Better confidence in changes
- Enables TDD approach for MCP server features

## References
- PR #587 - Where this friction was encountered
- Related discussion about testing vs code review trade-offs

Principle: systems-stewardship
Principle: tracer-bullets

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing PR #587 and the related testing-versus-code-review discussion to understand the dependency and module-resolution friction. Define the harness around isolated MCP function tests, temporary Git repositories, mock MCP contexts, and zero-setup `uv run` execution; done means these utilities provide a repeatable minimal test environment without full server initialization.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.