How to add contextual links to the main content block? The main content block has no contextual links. I believe this is related to _block_get_renderable_array but I'm not really sure. I'm using Custom Contextual Links module to add contextual links to blocks, but of course it doesn't work with system-main (the main content block).
Contextual module (core) will preprocess the block renderable array and turn $block-&gt;content['#contextual_links'] into the block template $title_suffix using the contextual_links element type (see contextual_element_info). See contextual_preprocess for the implementation of this behavior.

While block module relies on _block_get_renderable_array for performance reasons, contextual links example module (from the examples package) shows an example of setting #contextual_links on hook_block_view.

As for CCL, it relies on hook_contextual_links_view_alter which will only alter or add links if there is already a #contextual_links element in the renderable array. The main content block doesn't get the default 'Configure block' contextual link (see _block_get_renderable_array), and therefore CCL doesn't affect it by default. Let's just add the default contextual link:

/**
 * Implements hook_block_view_MODULE_DELTA_alter().
 */
function MYMODULE_block_view_system_main_alter(&amp;$data, $block) {
  if (user_access('access contextual links')) {
    $data['content']['#contextual_links']['block'] = array(
      'admin/structure/block/manage',
      array('system', 'main'),
    );
  }
}