get_module_version_compatibility
Verify Ansible module compatibility with specific collection versions to ensure correct functionality and avoid version conflicts.
Instructions
Check module compatibility across collection versions
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collection_name | Yes | Name of the Ansible collection | |
| module_name | Yes | Name of the module to check | |
| version | Yes | Target collection version to check compatibility against |
Implementation Reference
- The async handler function that implements the core logic of the 'get_module_version_compatibility' tool. It queries the database using 'get_module_compatibility', handles errors, and formats the output with compatibility status, issues, breaking changes, and version history.async def handle_get_module_version_compatibility( db: Any, arguments: Dict[str, Any], operation_id: str ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]: """Handle get_module_version_compatibility tool.""" try: logger.info( "Getting module version compatibility", extra={ "collection_name": arguments["collection_name"], "module_name": arguments["module_name"], "version": arguments["version"], "operation_id": operation_id, }, ) try: # Get compatibility info result = get_module_compatibility( db, arguments["collection_name"], arguments["module_name"], arguments["version"], ) except Exception as db_error: error_msg = str(db_error) logger.error(error_msg, extra={"operation_id": operation_id}) return [TextContent(type="text", text=error_msg)] # Format output output = [ "Module Compatibility Check:", f"Module: {result['module_name']}", f"Collection: {result['collection_name']}", f"Target Version: {result['target_version']}", f"Current Version: {result['current_version']}", f"Is Compatible: {'Yes' if result['is_compatible'] else 'No'}", "\nCompatibility Issues:", ] if not result["compatibility_issues"]: output.append("- No issues found") else: for issue in result["compatibility_issues"]: output.append(f"- {issue}") if result["breaking_changes"]: output.extend( [ "\nBreaking Changes:", *[f"- {change}" for change in result["breaking_changes"]], ] ) output.extend( [ "\nVersion History:", *[ f"- {v['collection_version']} (Module v{v['module_version']}) - {v['released']}" for v in result["version_history"] ], ] ) return [TextContent(type="text", text="\n".join(output))] except Exception as e: error_msg = f"Failed to check module version compatibility: {str(e)}" logger.error(error_msg, extra={"operation_id": operation_id}) raise McpError( types.ErrorData( code=types.INTERNAL_ERROR, message=error_msg, data={ "tool": "get_module_version_compatibility", "operation_id": operation_id, }, ) )
- JSON schema defining the input parameters and validation rules for the 'get_module_version_compatibility' tool."get_module_version_compatibility": { "type": "object", "description": "Check module compatibility across collection versions", "required": ["collection_name", "module_name", "version"], "properties": { "collection_name": { "type": "string", "description": "Name of the Ansible collection", }, "module_name": { "type": "string", "description": "Name of the module to check", }, "version": { "type": "string", "description": "Target collection version to check compatibility against", }, }, },
- src/iac_memory_mcp_server/tools/ansible.py:559-570 (registration)Registration of the tool handler in the 'ansible_tool_handlers' dictionary, which maps tool names to their handler functions for Ansible-related tools.ansible_tool_handlers = { "get_ansible_collection_info": handle_get_ansible_collection_info, "list_ansible_collections": handle_list_ansible_collections, "get_collection_version_history": handle_get_collection_version_history, "get_ansible_module_info": handle_get_ansible_module_info, "list_collection_modules": handle_list_collection_modules, "get_module_version_compatibility": handle_get_module_version_compatibility, "add_ansible_collection": handle_add_ansible_collection, "add_ansible_module": handle_add_ansible_module, "update_collection_version": handle_update_collection_version, "update_module_version": handle_update_module_version, }