mwclient's Site constructor accepts connection_options for its underlying Requests calls. Put the proxy there when creating the Site:

import mwclient

site = mwclient.Site(
    'wiki.example',
    path='/w/',
    connection_options={
        'proxies': {
            'https': 'http://proxy.example:8080',
        },
        'timeout': (5, 20),
    },
)

The host argument identifies the wiki without a URL scheme. The path is its script path; adjust it for that installation. The HTTPS mapping directs the wiki connection through the example HTTP proxy. For a publicly reachable wiki on a route allowing unauthenticated public intermediaries, use a candidate from the HTTP proxy list for that proxy URL.

By default, Site performs initialization requests. Providing the options in the constructor means those early API calls receive the route too, before the application starts querying or editing pages.

Use the Requests option name proxies for the mapping. The same connection_options interface can pass other supported request options, such as the connection and read timeout tuple shown here.

For a specially configured connection pool, Site also accepts a custom Requests Session through its pool parameter. The ordinary proxy case needs no edits to mwclient's internal http implementation.

Allakkat attuumassuteqartut