Skip to content

fix(gstack-gbrain-detect): include 'url' in Tier 1 $mtype case for Streamable HTTP MCP#1373

Closed
marko-durasic wants to merge 1 commit intogarrytan:mainfrom
marko-durasic:fix/gbrain-detect-tier1-include-url-transport
Closed

fix(gstack-gbrain-detect): include 'url' in Tier 1 $mtype case for Streamable HTTP MCP#1373
marko-durasic wants to merge 1 commit intogarrytan:mainfrom
marko-durasic:fix/gbrain-detect-tier1-include-url-transport

Conversation

@marko-durasic
Copy link
Copy Markdown

@marko-durasic marko-durasic commented May 8, 2026

Problem

bin/gstack-gbrain-detect runs a 3-tier fallback to determine gbrain_mcp_mode. Tier 1 calls claude mcp get gbrain --json and matches $mtype:

case "$mtype" in
  http|sse) gbrain_mcp_mode="remote-http" ;;
  stdio)    gbrain_mcp_mode="local-stdio" ;;
  *)
    # Newer claude versions may emit just url + command; infer.
    if [ -n "$murl" ]; then gbrain_mcp_mode="remote-http"
    elif [ -n "$mcommand" ]; then gbrain_mcp_mode="local-stdio"
    fi ;;
esac

Tier 3 (~/.claude.json jq fallback) — and every SKILL.md preamble that documents the same logic — correctly match url|http|sse:

case "$mtype" in
  url|http|sse) gbrain_mcp_mode="remote-http" ;;
  stdio)        gbrain_mcp_mode="local-stdio" ;;
  ...
esac

Anthropic's "Streamable HTTP" MCP transport reports type: "url". When claude mcp get gbrain --json returns {"type": "url", ...} without a top-level url field (some claude CLI versions omit it when the URL is implicit in the config), Tier 1 falls through to *, sees $murl is empty, and returns none. Tier 3 — looking at the same ~/.claude.json — would correctly say remote-http.

So the detect script's output can disagree with what the SKILL.md preambles tell skills to expect, and /setup-gbrain (and any downstream skill that branches on gbrain_mcp_mode) can misread the current mode.

Fix

Add url to the Tier 1 case branch, matching Tier 3 and the SKILL.md preambles. The stdio arm is re-aligned in the same case block to keep the visual columns intact (cosmetic only):

       case "$mtype" in
-        http|sse) gbrain_mcp_mode="remote-http" ;;
-        stdio)    gbrain_mcp_mode="local-stdio" ;;
+        url|http|sse) gbrain_mcp_mode="remote-http" ;;
+        stdio)        gbrain_mcp_mode="local-stdio" ;;
         *)

Diff is +2/-2 lines, fully scoped to bin/gstack-gbrain-detect.

Test plan

  • bash -n bin/gstack-gbrain-detect — clean parse.
  • Tier 3 in the same file (line 146) and SKILL.md preambles already match url|http|sse, so this PR brings Tier 1 in line with established convention rather than introducing a new behavior.
  • gstack-gbrain-detect | jq .gbrain_mcp_mode against an Anthropic CLI configured with the url transport — best verified by maintainer with a real claude install.

Discovery context

Found while reconciling DuReef's vendored gstack mirror at db9447c3 (which predates the 3-tier detect block) against upstream HEAD 443bde05. The Tier 1 / Tier 3 mismatch was visible immediately because Tier 3 was already correct in the same file.

Companion DuReef-side bookkeeping: DuReef/workspace#49 — read-only watch entry in our PORT-CANDIDATES.md so reviewers know to refuse this regression on the next chore(inspiration) sync if this upstream PR isn't merged first.

Out of scope

  • No VERSION / CHANGELOG.md bump (left to maintainer's release cadence).
  • No tests added — Tier 1 needs a real claude CLI fixture; the existing 3-tier defense-in-depth chain (commented "Fallback chain logged because if Anthropic moves the file or renames keys, the third tier breaks silently; the first two tiers should catch it") is the live test surface.
  • No related changes to gstack-gbrain-sync.ts's lock keepalive (filed separately as a sibling PR).

Made with Cursor


View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

…treamable HTTP MCP

`bin/gstack-gbrain-detect` runs a 3-tier fallback to determine
`gbrain_mcp_mode`. Tier 1 calls `claude mcp get gbrain --json` and
matches `\$mtype` against `http|sse`. Tier 3 (`~/.claude.json` jq
fallback) and every `SKILL.md` preamble in this repo correctly match
`url|http|sse`.

Anthropic's "Streamable HTTP" MCP transport reports `type: "url"`. So
when `claude mcp get gbrain --json` returns `{"type": "url", ...}`
without a top-level `url` field, Tier 1 falls through to the `*`
wildcard, finds `\$murl` empty, and returns `none` while Tier 3 (and
the SKILL.md preambles consumers rely on) would correctly return
`remote-http`. Result: `/setup-gbrain` and downstream skills can
misread the current MCP mode for users on the `url` transport.

This is a one-line fix bringing Tier 1 in line with Tier 3 — the
`stdio` arm is also re-aligned in the same case block to keep the
visual columns intact.

Verified with `bash -n bin/gstack-gbrain-detect` (clean parse).

Discovery context: surfaced while comparing DuReef's vendored gstack
mirror at db9447c (which predates the 3-tier detect block) against
upstream HEAD 443bde0; the inconsistency showed up immediately
because Tier 3 in the same file was already correct.

Co-authored-by: Cursor <cursoragent@cursor.com>
@marko-durasic
Copy link
Copy Markdown
Author

Sibling PR: #1372 (restore startLockKeepalive in gstack-gbrain-sync) — both surfaced together while reconciling DuReef's vendored gstack mirror. Independently mergeable; no shared files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant