Skip to content

Instantly share code, notes, and snippets.

@franchb
Created January 18, 2026 08:10
Show Gist options
  • Select an option

  • Save franchb/3e2c0a215f31ba4b57a0bec268393eaf to your computer and use it in GitHub Desktop.

Select an option

Save franchb/3e2c0a215f31ba4b57a0bec268393eaf to your computer and use it in GitHub Desktop.
~/.local/bin/glab-mcp-filtered.py
#!/bin/bash
# Filtered glab MCP proxy - filters tools/list response to reduce context
ALLOWED_TOOLS='["glab_api","glab_auth_status","glab_changelog_generate","glab_ci_artifact","glab_ci_cancel_job","glab_ci_cancel_pipeline","glab_ci_ci_lint","glab_ci_ci_trace","glab_ci_ci_view","glab_ci_config_compile","glab_ci_delete","glab_ci_get","glab_ci_lint","glab_ci_list","glab_ci_retry","glab_ci_run","glab_ci_run-trig","glab_ci_status","glab_ci_trace","glab_ci_trigger","glab_ci_view","glab_issue_board_create","glab_issue_board_view","glab_issue_close","glab_issue_create","glab_issue_delete","glab_issue_list","glab_issue_note","glab_issue_reopen","glab_issue_update","glab_issue_view","glab_job_artifact","glab_label_create","glab_label_delete","glab_label_edit","glab_label_get","glab_label_list","glab_mr_checkout","glab_mr_close","glab_mr_create","glab_mr_delete","glab_mr_diff","glab_mr_for","glab_mr_issues","glab_mr_list","glab_mr_merge","glab_mr_note","glab_mr_rebase","glab_mr_reopen","glab_mr_subscribe","glab_mr_todo","glab_mr_update","glab_mr_view","glab_release_download","glab_release_list","glab_release_view","glab_repo_create","glab_repo_list","glab_repo_search","glab_stack_amend","glab_stack_create","glab_stack_first","glab_stack_last","glab_stack_list","glab_stack_move","glab_stack_next","glab_stack_prev","glab_stack_reorder","glab_stack_save","glab_stack_switch","glab_stack_sync","glab_version"]'
coproc GLAB { glab mcp serve; }
# Read from stdin and write to glab
while IFS= read -r input_line; do
echo "$input_line" >&${GLAB[1]}
# Read response from glab
if IFS= read -r -u ${GLAB[0]} output_line; then
# Check if this is a tools/list response
if echo "$output_line" | jq -e '.result.tools' >/dev/null 2>&1; then
# Filter tools
echo "$output_line" | jq -c --argjson allowed "$ALLOWED_TOOLS" \
'.result.tools = [.result.tools[] | select(.name as $n | $allowed | index($n))]'
else
echo "$output_line"
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment