### Setup Development Environment - Bash Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/README.md Commands to clone the repository, navigate into the directory, install development dependencies using pip, and install pre-commit hooks for maintaining code quality. ```bash # Clone and enter directory git clone https://github.com/tosin2013/ansible-collection-mcp-audit.git cd ansible-collection-mcp-audit # Install development dependencies pip install -r requirements-dev.txt # Install pre-commit hooks pre-commit install ``` -------------------------------- ### Initial Setup for antsibull-changelog Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/docs/adrs/0010-changelog-management.md This section covers the initial setup required to start using `antsibull-changelog` in a project. It includes installing the tool, initializing the changelog directory structure, and customizing the configuration. ```bash # 1. Install antsibull-changelog pip install antsibull-changelog # 2. Initialize changelog mkdir -p changelogs/fragments antsibull-changelog init . # 3. Customize config # Edit changelogs/config.yaml to match project ``` -------------------------------- ### Initialize Ansible Collection with Setup Commands Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/docs/context/research/perform-research-2025-10-30T14-17-45-808Z.md Bash commands to initialize a new Ansible collection structure, configure a Python virtual environment, and install required development dependencies. These commands establish the foundation for the ansible-collection-mcp-audit project. ```bash # 1. Initialize collection structure ansible-galaxy collection init mcp_audit --init-path /Users/tosinakinosho/workspaces/ansible-collection-mcp-audit # 2. Setup development environment python -m venv venv source venv/bin/activate pip install ansible ansible-lint pytest-ansible # 3. Establish quality gates touch .pre-commit-config.yaml echo "Quality gates established" ``` -------------------------------- ### Build and Install Ansible Collection Tarball Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/AGENTS.md Create a distributable tarball of the Ansible collection and install it locally for testing. The build command packages the collection, and install command deploys it with --force to override existing versions. ```bash # Build tarball for distribution ansible-galaxy collection build # Install locally for testing ansible-galaxy collection install mcp-audit-1.0.0.tar.gz --force ``` -------------------------------- ### Install Ansible Collection from Source Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/README.md Clone the repository, install dependencies, build the collection, and install it locally. This method is useful for development and testing purposes. ```bash # Clone the repository git clone https://github.com/tosin2013/ansible-collection-mcp-audit.git cd ansible-collection-mcp-audit # Install dependencies pip install -r requirements.txt # Build the collection ansible-galaxy collection build # Install locally ansible-galaxy collection install mcp-audit-*.tar.gz ``` -------------------------------- ### Integration Test Setup Script Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/docs/adrs/0007-real-mcp-servers-for-integration-testing.md A bash script to set up dependencies for the MCP test servers. It installs requirements for the calculator, prompts, and resources servers using pip. This script is crucial for ensuring the testing environment is correctly configured before running integration tests. ```bash #!/bin/bash set -e echo "Setting up MCP test servers..." # Install dependencies for all servers pip install -r calculator/requirements.txt pip install -r prompts/requirements.txt pip install -r resources/requirements.txt echo "Test servers ready!" ``` -------------------------------- ### Initial GitHub Actions Setup Steps Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/docs/adrs/0012-ci-cd-strategy.md Provides the bash commands required to set up the GitHub Actions CI/CD workflow. This includes creating the workflow directory, adding workflow files, configuring secrets, setting up branch protection rules, and performing an initial PR to test the setup. ```bash # 1. Create workflow directory mkdir -p .github/workflows # 2. Add workflow files (test.yml, quality.yml, etc.) # [Copy workflow definitions from above] # 3. Set up GitHub secrets # Settings → Secrets → Actions → New repository secret # GALAXY_API_KEY: [Your Galaxy API key] # 4. Configure branch protection # Settings → Branches → Add rule # Branch name pattern: main # [Enable protection settings as documented above] # 5. Initial PR to test workflows git checkout -b test-ci git push origin test-ci # Open PR, verify all checks run ``` -------------------------------- ### Security Setup and Configuration - Bash Commands Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/docs/adrs/0015-security-policy.md Bash script commands for initial security setup including SECURITY.md creation, GitHub security features enablement, Dependabot configuration, security workflows, and vulnerability reporting setup. Provides step-by-step implementation for hardening the repository. ```bash # 1. Create SECURITY.md cp [content above] SECURITY.md # 2. Enable GitHub Security Features # Repository Settings → Security → Configure # 3. Enable Dependabot cp [dependabot.yml content] .github/dependabot.yml # 4. Add security workflow cp [security.yml content] .github/workflows/security.yml # 5. Enable Private Vulnerability Reporting # Repository Settings → Security → Vulnerability reporting → Enable # 6. Configure Security Advisories # Repository Settings → Security → Advisories → Configure # 7. Add security contact to README echo "Security issues: tosin.akinosho@gmail.com" >> README.md ``` -------------------------------- ### Build and Install Ansible Collection - Bash Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/CONTRIBUTING.md Commands to build the Ansible collection into a tarball and then install it. This is a prerequisite for running Ansible sanity tests and ensures the collection is correctly packaged. ```bash # Build collection ansible-galaxy collection build # Install collection ansible-galaxy collection install mcp-audit-*.tar.gz ``` -------------------------------- ### YAML Integration Testing Example for MCP Test Tool Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/docs/adrs/0005-testing-strategy.md An example of integration testing using Ansible YAML. This snippet demonstrates starting a sample calculator server, waiting for it to become ready, and then using the 'mcp_test_tool' module to perform an 'add' operation, verifying the result. ```yaml # Example: tests/integration/targets/mcp_test_tool/tasks/main.yml --- - name: Start sample calculator server shell: python {{ playbook_dir }}/sample_servers/calculator_server.py & async: 60 poll: 0 register: calculator_server - name: Wait for server to be ready wait_for: timeout: 5 - name: Test calculator add tool mcp.audit.mcp_test_tool: server_command: "python" server_args: - "{{ playbook_dir }}/sample_servers/calculator_server.py" tool_name: "add" tool_arguments: a: 5 b: 3 expected_result: result: 8 register: tool_result - name: Verify tool test succeeded assert: that: - tool_result.success is true - tool_result.response.result == 8 ``` -------------------------------- ### REUSE Lint Output Example Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/docs/adrs/0008-licensing-strategy.md Example output from the 'reuse lint' command, indicating a compliant project with no license errors or missing information. It summarizes the number of files with copyright and license information, and lists the used licenses. ```text # SUMMARY * Bad licenses: 0 * Deprecated licenses: 0 * Licenses without file extension: 0 * Missing licenses: 0 * Unused licenses: 0 * Used licenses: GPL-3.0-or-later, BSD-2-Clause * Read errors: 0 * Files with copyright information: 42 / 42 * Files with license information: 42 / 42 Congratulations! Your project is compliant with version 3.0 of the REUSE Specification :-) ``` -------------------------------- ### Bash Example Git Commit Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/AGENTS.md An example of a Git commit using the specified format, including a 'fix' type, a description, and details about the changes made. It also incorporates AI-generated content attribution. ```bash git commit -m "fix: Add missing SPDX headers to sanity ignore files Files tests/sanity/ignore-*.txt were missing license headers causing reuse lint failures. Added GPL-3.0-or-later headers. Fixes #7 🤖 Generated with Claude Code Co-Authored-By: Claude " ``` -------------------------------- ### Changelog Content Guidelines and Examples Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/docs/adrs/0010-changelog-management.md Provides guidelines for writing effective changelog entries, focusing on clarity, audience (end-users), completeness, and action-oriented language. Includes examples of good and bad entries for different change types. ```yaml minor_changes: - mcp_test_tool - Added ``timeout`` parameter to prevent hanging on slow servers (https://github.com/tosin2013/ansible-collection-mcp-audit/pull/123). bugfixes: - mcp_server_info - Fixed connection error when server closes stdio stream unexpectedly (https://github.com/tosin2013/ansible-collection-mcp-audit/issues/45). breaking_changes: - mcp_test_suite - The ``report_format`` parameter now defaults to ``json`` instead of ``yaml``. Update playbooks that rely on YAML output (https://github.com/tosin2013/ansible-collection-mcp-audit/pull/67). ``` ```yaml # Too vague minor_changes: - Improved error handling # Too technical bugfixes: - Fixed NoneType exception in _validate_response() method # Missing context deprecated_features: - old_parameter will be removed soon ``` -------------------------------- ### Python Code Attribution Example Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/AGENTS.md This snippet demonstrates how to include SPDX headers and copyright information in Python files, as required for third-party code attribution. It ensures compliance with licensing requirements. ```python # Example: tests/integration/sample_servers/calculator/server.py # SPDX-License-Identifier: MIT # SPDX-FileCopyrightText: Original work from battula417/calculator-server ``` -------------------------------- ### EXAMPLES Block - MCP Server Info Module Usage Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/docs/adrs/0009-documentation-strategy.md Provides copy-pasteable example tasks demonstrating how to use the mcp_server_info module with different transport protocols (stdio and HTTP), how to register and display output, and how to use conditional logic based on server capabilities. These examples are displayed by ansible-doc. ```yaml EXAMPLES = r''' # Gather server info via stdio transport - name: Get MCP server information mcp.audit.mcp_server_info: server_command: python server_args: - /path/to/server.py transport: stdio register: server_info - name: Display server capabilities ansible.builtin.debug: msg: "Server {{ server_info.server_name }} supports: {{ server_info.capabilities }}" # Gather server info via HTTP transport - name: Get MCP server info from HTTP endpoint mcp.audit.mcp_server_info: transport: http url: http://localhost:8080/mcp register: server_info # Conditional task based on server capabilities - name: Test tools only if server supports them mcp.audit.mcp_test_tool: server_command: python server_args: - /path/to/server.py tool_name: calculate tool_arguments: a: 5 b: 3 when: "'tools' in server_info.capabilities" ''' ``` -------------------------------- ### Example Ansible Playbook for Sequential MCP Module Calls Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/docs/CONNECTION_REUSE_FIXES.md Demonstrates the usage of Ansible modules from the `tosin2013.mcp_audit` collection in a sequential manner. The 'Before Phase 1' example shows a scenario that would fail due to connection issues, while the 'After Phase 1' example illustrates the successful execution after the connection reuse fixes have been implemented. ```yaml - name: Test tool 1 (Before Phase 1) tosin2013.mcp_audit.mcp_test_tool: tool_name: analyze_project_ecosystem # Works - name: Test tool 2 (Before Phase 1 - FAILS) tosin2013.mcp_audit.mcp_test_tool: tool_name: read_file # FAILS with TaskGroup error # --- After Phase 1 Fixes --- - name: Test tool 1 (After Phase 1) tosin2013.mcp_audit.mcp_test_tool: tool_name: analyze_project_ecosystem # Works - name: Test tool 2 (After Phase 1 - Works) tosin2013.mcp_audit.mcp_test_tool: tool_name: read_file # Works! Automatically retries if needed ``` -------------------------------- ### Bash Release Process Commands Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/AGENTS.md Commands for the release process starting from v1.0.0, including updating version, creating changelog fragments, generating the changelog, building the collection, testing, and publishing to Ansible Galaxy and GitHub. ```bash # 1. Update version in galaxy.yml vi galaxy.yml # Change version: 1.0.0 → 1.1.0 # 2. Create changelog fragment vi changelogs/fragments/1.1.0-release.yml # 3. Generate CHANGELOG.rst antsibull-changelog release --version 1.1.0 # 4. Build collection tarball ansible-galaxy collection build # 5. Test installation locally ansible-galaxy collection install mcp-audit-1.1.0.tar.gz --force # 6. Publish to Ansible Galaxy (requires API key) ansible-galaxy collection publish mcp-audit-1.1.0.tar.gz --token # 7. Create GitHub release gh release create v1.1.0 mcp-audit-1.1.0.tar.gz \ --title "Release 1.1.0 - LiteLLM Integration" \ --notes-file changelogs/CHANGELOG.rst ``` -------------------------------- ### Ansible Example: Testing MCP Server with OpenRouter Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/docs/adrs/0016-litellm-integration.md Illustrates the usage of the `mcp_test_llm_integration` module for testing MCP servers with OpenRouter, a provider that unifies multiple LLM services. This example highlights the `openrouter` provider and shows how to specify models in OpenRouter's format and securely manage API keys using Ansible Vault variables. ```yaml - name: Test MCP server with OpenRouter mcp.audit.mcp_test_llm_integration: server_command: "{{ python_interpreter }}" server_args: - "{{ test_servers_path }}/calculator/server.py" transport: "stdio" llm_provider: "openrouter" llm_model: "anthropic/claude-3-opus" # OpenRouter model format llm_api_key: "{{ openrouter_api_key }}" # From Ansible Vault test_prompt: "What is 15 multiplied by 3?" ``` -------------------------------- ### Python Unit Testing Example for MCPClient Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/docs/adrs/0005-testing-strategy.md An example of Python unit tests using pytest and unittest.mock for the MCPClient module. It demonstrates testing client initialization and connection logic for the 'stdio' transport, ensuring the client interacts correctly with mocked dependencies. ```python # Example: tests/unit/plugins/module_utils/test_mcp_client.py import pytest from unittest.mock import Mock, patch from ansible_collections.mcp.audit.plugins.module_utils.mcp_client import MCPClient def test_stdio_client_initialization(): """Test MCPClient initialization with stdio transport""" client = MCPClient(transport='stdio', server_command='python', server_args=['server.py']) assert client.transport == 'stdio' assert client.server_command == 'python' @patch('ansible_collections.mcp.audit.plugins.module_utils.mcp_client.StdioMCPClient') def test_connect_success(mock_stdio_client): """Test successful connection to MCP server""" mock_client_instance = Mock() mock_stdio_client.return_value = mock_client_instance client = MCPClient(transport='stdio', server_command='python') result = client.connect() assert result['success'] is True mock_client_instance.connect.assert_called_once() ``` -------------------------------- ### Ansible Module Documentation Structure Template Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/docs/adrs/0009-documentation-strategy.md Template demonstrating the standard DOCUMENTATION, EXAMPLES, and RETURN blocks for Ansible modules. Includes parameter definitions, task examples, and return value specifications following Ansible conventions. ```yaml - name: [Task name] mcp.audit.module_name: parameter_name: value register: result RETURN = r''' field_name: description: [Field description] returned: always type: str sample: "example value" ''' ``` -------------------------------- ### Installing and Running REUSE Compliance Check Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/docs/adrs/0008-licensing-strategy.md Installs the REUSE command-line tool using pip and then executes the 'reuse lint' command to check the project for compliance with licensing and copyright standards. This command analyzes the files and provides a summary of any issues found. ```bash pip install reuse reuse lint ``` -------------------------------- ### Ansible Example: Testing MCP Server with vLLM Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/docs/adrs/0016-litellm-integration.md Demonstrates how to use the `mcp_test_llm_integration` Ansible module to test an MCP server with a self-hosted vLLM model. This example specifies the `vllm` provider, a local model name, and the base URL of the vLLM server, showing how to configure custom endpoints and use dummy API keys when not required. ```yaml - name: Test MCP server with vLLM mcp.audit.mcp_test_llm_integration: server_command: "{{ python_interpreter }}" server_args: - "{{ test_servers_path }}/calculator/server.py" transport: "stdio" llm_provider: "vllm" llm_model: "meta-llama/Llama-2-7b-chat-hf" llm_api_key: "dummy" # vLLM doesn't require API key llm_base_url: "http://localhost:8000" # Your vLLM server test_prompt: "Calculate 42 + 58" ``` -------------------------------- ### Ansible Module Documentation Structure (Python) Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/CONTRIBUTING.md Defines the required documentation blocks for Ansible modules, including metadata, examples of usage, and return values. This structure is crucial for generating module help and ensuring clarity for users. ```python DOCUMENTATION = r''' --- module: mcp_test_tool short_description: Test individual MCP tools description: - Tests a specific MCP tool by invoking it with provided arguments - Validates the tool response against expected results - Reports detailed test results options: server_command: description: Command to start the MCP server type: str required: true # ... more options ''' ``` ```python EXAMPLES = r''' - name: Test calculator add tool mcp.audit.mcp_test_tool: transport: stdio server_command: python server_args: - /path/to/server.py tool_name: add tool_arguments: a: 5 b: 3 register: result ''' ``` ```python RETURN = r''' success: description: Whether the test completed successfully type: bool returned: always # ... more return values ''' ``` -------------------------------- ### Ansible Module Structure with DOCUMENTATION, EXAMPLES, and RETURN Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/AGENTS.md Complete Ansible module template following REUSE compliance with SPDX headers, required DOCUMENTATION/EXAMPLES/RETURN sections, async entry point, and proper exception handling. Includes noqa comments for ruff E402 (imports after DOCUMENTATION). ```python #!/usr/bin/python # SPDX-License-Identifier: GPL-3.0-or-later # SPDX-FileCopyrightText: 2025 Tosin Akinosho DOCUMENTATION = r""" --- module: mcp_example short_description: Brief description here version_added: "1.0.0" description: - Detailed description paragraph 1 - Detailed description paragraph 2 author: - Tosin Akinosho (@tosinakinosho) options: param_name: description: - Parameter description type: str required: true """ EXAMPLES = r""" - name: Example task mcp.audit.mcp_example: param_name: value """ RETURN = r""" result_key: description: What this returns returned: always type: dict """ from ansible.module_utils.basic import AnsibleModule # noqa: E402 import asyncio # noqa: E402 async def async_main(module): """Async logic here - use module_utils""" # Implementation def run_module(): """Sync Ansible module entry point""" module = AnsibleModule( argument_spec=dict( param_name=dict(type='str', required=True), ) ) try: result = asyncio.run(async_main(module)) module.exit_json(**result) except Exception as e: module.fail_json(msg=str(e)) if __name__ == '__main__': run_module() ``` -------------------------------- ### Bash Quick Reference Commands Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/AGENTS.md A collection of essential bash commands for setting up the development environment, running quality checks, executing tests, building the Ansible collection, and managing licenses. ```bash # Setup python3 -m venv venv && . venv/bin/activate pip install -r requirements.txt -r requirements-dev.txt # Quality make quality # All checks ruff check . --fix # Auto-fix linting ansible-lint # Ansible standards # Testing pytest tests/unit/ -v --cov # Unit tests ansible-playbook tests/integration/test-runner.yml # Integration ansible-test sanity --python 3.11 # Sanity tests # Build ansible-galaxy collection build # Create tarball # License reuse lint # Check compliance reuse annotate --license GPL-3.0-or-later --copyright "Tosin Akinosho" file.py ``` -------------------------------- ### Install and Verify Collection - Bash Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/SECURITY.md Commands to install the ansible-collection-mcp-audit and verify its installed version. It emphasizes forcing the installation and then listing installed collections to check for 'mcp.audit'. ```bash # Always verify the collection before installation ansible-galaxy collection install mcp.audit --force # Check the installed version ansible-galaxy collection list | grep mcp.audit ``` -------------------------------- ### Documentation Review Checklist for Completeness and Accuracy Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/docs/adrs/0009-documentation-strategy.md Comprehensive review checklist covering completeness, accuracy, clarity, and style aspects of Ansible module documentation. Verifies parameter documentation, examples, return values, and adherence to Ansible documentation style guide. ```markdown ## Documentation Review Checklist ### Completeness - [ ] All parameters documented with type, required, default - [ ] At least 2 examples provided - [ ] All return values documented - [ ] Error handling documented ### Accuracy - [ ] Examples are copy-pasteable and work - [ ] Parameter types match implementation - [ ] Return value samples are realistic - [ ] version_added is correct ### Clarity - [ ] Short description is clear and concise - [ ] Parameter descriptions explain purpose, not just repeat name - [ ] Examples include explanatory task names - [ ] No jargon without explanation ### Style - [ ] Follows Ansible documentation style guide - [ ] Consistent terminology throughout - [ ] Proper use of I() for option names - [ ] Proper use of M() for module names ``` -------------------------------- ### Initialize MCPClient and Test Connection - Python Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/CONTRIBUTING.md Demonstrates the initialization of the MCPClient with a 'stdio' transport and a server command. It also includes a placeholder for an asynchronous connection test using pytest-asyncio, emphasizing the need for mocking external dependencies in tests. ```python import pytest from unittest.mock import Mock, patch from ansible_collections.mcp.audit.plugins.module_utils.mcp_client import MCPClient def test_client_initialization(): """Test MCPClient initialization with stdio transport""" client = MCPClient(transport='stdio', server_command='python') assert client.transport == 'stdio' @pytest.mark.asyncio async def test_connect_success(): """Test successful connection to MCP server""" # Your async test here pass ``` -------------------------------- ### Install Ansible Collection from Galaxy Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/README.md Install the tosin2013.mcp_audit collection directly from Ansible Galaxy using the ansible-galaxy command. This is the recommended installation method for production environments. ```bash ansible-galaxy collection install tosin2013.mcp_audit ``` -------------------------------- ### Changelog Fragment Examples (YAML) Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/docs/adrs/0010-changelog-management.md Provides examples of changelog fragments categorized by change type: Major Changes, Breaking Changes, Deprecation, and Security Fixes. These fragments are written in YAML and follow the structure expected by antsibull-changelog. ```yaml # changelogs/fragments/150-http-transport.yml --- major_changes: - All modules now support HTTP transport in addition to stdio and SSE, enabling testing of HTTP-based MCP servers (https://github.com/tosin2013/ansible-collection-mcp-audit/pull/150). ``` ```yaml # changelogs/fragments/175-remove-old-param.yml --- breaking_changes: - mcp_test_tool - Removed deprecated ``legacy_mode`` parameter. Use ``transport`` parameter instead. Playbooks using ``legacy_mode`` must be updated (https://github.com/tosin2013/ansible-collection-mcp-audit/pull/175). ``` ```yaml # changelogs/fragments/180-deprecate-yaml.yml --- deprecated_features: - mcp_test_suite - The ``report_format=yaml`` option is deprecated and will be removed in version 3.0.0. Use ``report_format=json`` and convert output if YAML is needed (https://github.com/tosin2013/ansible-collection-mcp-audit/pull/180). ``` ```yaml # changelogs/fragments/200-security-fix.yml --- security_fixes: - mcp_server_info - Fixed command injection vulnerability when using user-supplied ``server_command`` parameter. Always validate and sanitize server commands (https://github.com/tosin2013/ansible-collection-mcp-audit/security/advisories/GHSA-xxxx-xxxx). ``` -------------------------------- ### REUSE License Compliance Check (Bash) Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/CONTRIBUTING.md Demonstrates the command-line usage of the `reuse` tool to verify license compliance within the project. Running `reuse lint` is expected to result in 100% compliance. ```bash # Verify license compliance reuse lint # Should show: 100% compliance ``` -------------------------------- ### Ansible Collection Initialization Command Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/docs/context/research/perform-research-2025-10-30T14-26-27-507Z.md Command to initialize a new Ansible collection. This is a foundational step for creating a new collection and typically involves setting up the basic directory structure and configuration files. ```bash ansible-galaxy collection init ``` -------------------------------- ### Manual Changelog Generation and Release Steps Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/docs/adrs/0010-changelog-management.md This section details the manual steps to generate a changelog for a new version, review it, commit the changes, and create a git tag for release. It serves as a foundational understanding before automating the process. ```bash # 1. Generate changelog for new version antsibull-changelog release --version 1.1.0 # 2. Review generated CHANGELOG.rst cat CHANGELOG.rst # 3. Commit generated files git add changelogs/CHANGELOG.rst changelogs/changelog.yaml git commit -m "chore: generate changelog for 1.1.0" # 4. Create git tag (see ADR-0014) git tag v1.1.0 git push origin v1.1.0 ``` -------------------------------- ### Run All Unit Tests - Bash Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/CONTRIBUTING.md Initiates all unit tests using the pytest framework. This command is essential for verifying the correctness of individual code components and ensuring new code is adequately tested. ```bash # Run all unit tests pytest tests/unit/ ``` -------------------------------- ### RHEL Compatibility Workflow (GitHub Actions) Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/docs/adrs/0012-ci-cd-strategy.md Tests the collection's compatibility with RHEL 9 and RHEL 10 (beta). It sets up containers, installs system and Python dependencies, runs unit tests, and performs integration and SELinux tests. Dependencies include actions/checkout and specific container images. ```yaml name: RHEL Compatibility on: push: branches: [main] pull_request: branches: [main] jobs: rhel9: runs-on: ubuntu-latest container: image: quay.io/centos/centos:stream9 steps: - uses: actions/checkout@v4 - name: Install system dependencies run: | dnf install -y python3.9 python3-pip - name: Install Ansible and dependencies run: | python3.9 -m pip install --user ansible-core mcp python3.9 -m pip install --user -r requirements-dev.txt - name: Run tests run: | python3.9 -m pytest tests/unit/ ansible-test integration - name: Test SELinux run: | # Verify SELinux is enforcing getenforce # Run basic module test ansible-playbook tests/selinux-test.yml rhel10: runs-on: ubuntu-latest container: image: quay.io/centos/centos:stream10 continue-on-error: true # RHEL 10 is still in beta steps: - uses: actions/checkout@v4 - name: Install system dependencies run: dnf install -y python3 python3-pip - name: Run tests run: | python3 -m pip install --user ansible-core mcp python3 -m pytest tests/unit/ ``` -------------------------------- ### Python Function with Modern Type Hints and Async MCP Connection Source: https://github.com/tosin2013/ansible-collection-mcp-audit/blob/main/AGENTS.md Demonstrates best-practice Python function using modern type hints (union syntax), comprehensive docstrings, and async/await pattern for MCP server connections. Includes proper error handling documentation and supports multiple transport protocols (stdio, sse, http). ```python from typing import Any async def connect_server( transport: str, command: str | None = None, args: list[str] | None = None, ) -> dict[str, Any]: """Connect to MCP server with specified transport. Args: transport: Transport protocol ('stdio', 'sse', 'http') command: Server command (required for stdio) args: Server command arguments Returns: dict: Connection info and server capabilities Raises: MCPConnectionError: If connection fails ValueError: If required parameters missing """ # Implementation ```