mirror of
https://github.com/hanzoai/mcp.git
synced 2026-10-15 12:30:12 +00:00
- Consolidate testing documentation into a single TESTING.md file - Enhance IDE_INTEGRATION.md with more complete information - Move redundant/outdated files to archive directory - Clean up documentation structure for better maintainability
2.9 KiB
2.9 KiB
Testing Guide for Hanzo MCP
Running Tests
To run the standard test suite:
make test
To run tests with coverage reports:
make test-cov
For a quicker test run without reinstalling dependencies:
make test-quick
Testing Framework
The project uses pytest for testing with a structured approach in the /tests directory. Tests are organized by component:
test_agent- Tests for agent functionalitytest_common- Tests for common utilitiestest_filesystem- Tests for filesystem operationstest_jupyter- Tests for Jupyter notebook handlingtest_project- Tests for project analysis toolstest_shell- Tests for shell command execution
Handling Asyncio Tests
Many tests use the @pytest.mark.asyncio decorator and require the pytest-asyncio plugin:
- Install the pytest-asyncio plugin:
# Using uv (recommended)
uv pip install pytest-asyncio>=0.25.3
- Make sure your pyproject.toml has the proper configuration:
[tool.pytest.ini_options]
asyncio_mode = "strict"
asyncio_default_fixture_loop_scope = "function"
Test Dependencies
All testing dependencies are defined in pyproject.toml:
test = [
"pytest>=7.0.0",
"pytest-cov>=4.1.0",
"pytest-mock>=3.10.0",
"pytest-asyncio>=0.25.3",
"twisted",
]
To install all test dependencies:
make install-test
Debugging Tests
If you encounter skipped tests, there are several common reasons:
- Missing Dependencies: Install the required packages using
make install-test - External Services: Some tests may require API keys for services like OpenAI
- Platform-Specific: Some tests may only run on certain platforms
- Resource Intensive: Some tests may require significant resources
Debugging with MCP Inspector
To debug your MCP project using the inspector tool:
npx @modelcontextprotocol/inspector \
uv \
--directory ~/project/hanzo-mcp \
run \
hanzo-mcp \
--allow-path \
{allow path} \
"--agent-model" \
"openrouter/google/gemini-2.0-flash-001" \
"--agent-max-tokens" \
"100000" \
"--agent-api-key" \
"{api key}" \
"--enable-agent-tool" \
"--agent-max-iterations" \
"30" \
"--agent-max-tool-uses" \
"100" \
Best Practices
- Always use the Makefile for operations rather than running Python scripts or pytest directly
- When running tests, use
make testormake test-quickrather than invoking pytest directly - If specific tests are failing, isolate them with
-koption through the Makefile - When adding new tools, follow the existing patterns for validation and permission checks
- Add appropriate mocks for external dependencies like ripgrep or subprocess calls
- If a test is too complex to mock properly, use
@pytest.mark.skipwith a clear reason - Ensure the virtual environment is properly set up with all dependencies before running tests