Contextual links for a custom module
To be able to add your custom contextual link, you first need to check the Contextual links module is enabled. Even though you define everything correctly, it would not show, if it is disabled. Also, you need to set context to MENU_CONTEXT_INLINE in your menu items.

/**
 * Implements hook_block_view().
 */
function example_block_view($delta = '') {
  $block = array();
  switch($delta) {
    case 'my_custom_block':
      $block['subject'] = t('Example Block');
      $block['content'] = array(
      '#markup' =&gt; _get_markup(),
      '#contextual_links' =&gt; array(
          'add content' =&gt; array('add', array('node')),
      ));
      break;
    default:
      break;
  }

  return $block;
}

/**
 * Implements hook_menu().
 */
function example_menu() {
    $items['add/%/content'] = array(
        'title' =&gt; 'Add Content',
        'type' =&gt; MENU_LOCAL_ACTION,
        'context' =&gt; MENU_CONTEXT_INLINE,
        'page callback' =&gt; 'contextual_node_page',
        'page arguments' =&gt; array(1),
        'access callback' =&gt; TRUE,
    );

    // To use local task menu items, there must be a parent page.
    $items['add'] = array(
        'title' =&gt; 'Contextual Link Page',
        'page callback' =&gt; 'contextual_node_page',
        'page arguments' =&gt; array(1),
        'access callback' =&gt; TRUE,
    );
    return $items;
}


Additional resources


https://www.drupal.org/docs/7/administering-drupal-7-site/working-with-contextual-links
http://dominiquedecooman.com/blog/drupal-7-tip-add-contextual-links-anything