Conversation
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix sys___init requirement for MCP client compatibility
Add --disable-difc flag to bypass sys___init requirement for standard MCP clients
Jan 6, 2026
Collaborator
|
@copilot instead of disabling difc with a flag, difc should be disabled by default and enabled with the flag --enable-difc. |
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Contributor
Author
Done. Changed to |
Copilot
AI
changed the title
Add --disable-difc flag to bypass sys___init requirement for standard MCP clients
Make DIFC disabled by default with --enable-difc flag for standard MCP client compatibility
Jan 6, 2026
lpcox
added a commit
that referenced
this pull request
Jan 8, 2026
…t-issue Make DIFC disabled by default with --enable-difc flag for standard MCP client compatibility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Standard MCP clients (MCP Inspector, Claude Desktop, Copilot CLI) expect to call tools immediately after
initializewithout a customsys___inithandshake. This breaks compatibility with the gateway's DIFC session requirement.Changes
--enable-difcflag: When set, enables DIFC enforcement and requires explicitsys___initcall before tool accessrequireSession()to prevent race conditions during concurrent session creationNewSession()for consistent initialization across codebaseBehavior
Default (DIFC disabled): Sessions auto-created on first tool access, compatible with standard MCP clients - no flags needed:
./flowguard-go --routed --listen 127.0.0.1:8000 --config-stdin < config.jsonWith
--enable-difc: DIFC enforcement enabled -sys___initrequired before tool calls:./flowguard-go --routed --enable-difc --listen 127.0.0.1:8000 --config-stdin < config.jsonMCP Inspector now works out of the box:
Previously required manual
sys___initcall and returned:sys___init must be called before any other tool callsNow works immediately without
sys___initby default.Original prompt
This section details on the original issue you should resolve
<issue_title>sys___init requirement breaks standard MCP client compatibility</issue_title>
<issue_description>## Problem
When testing the MCP gateway locally, tool calls fail with the error:
This happens because FlowGuard requires a
sys___initcall to create a session before any other tool can be invoked.Environment Setup
Step 1: Build the gateway
cd gh-aw-mcpg go mod tidy go build -o flowguard-goStep 2: Create config file (
/tmp/mcpg-config.json){ "mcpServers": { "github": { "type": "local", "container": "ghcr.io/github/github-mcp-server:v0.19.0", "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "" } } } }Note: The config requires
"type": "local"and usescontainerfield (not rawcommand/args).Step 3: Run the gateway
Server starts successfully with 46 GitHub tools registered:
Step 4: Health check works
curl http://127.0.0.1:8000/health # Returns: OKSteps to Reproduce the Issue
Using MCP Inspector (FAILS)
npx @modelcontextprotocol/inspector --cli http://127.0.0.1:8000/mcp/github \ --transport http \ --method tools/call \ --header "Authorization: Bearer test-token" \ --tool-name list_issues \ --tool-arg owner=containerd \ --tool-arg repo=runwasi \ --tool-arg state=OPENResult:
{ "content": [{ "type": "text", "text": "sys___init must be called before any other tool calls" }], "isError": true }Listing tools works fine
npx @modelcontextprotocol/inspector --cli http://127.0.0.1:8000/mcp/github \ --transport http \ --method tools/list \ --header "Authorization: Bearer test-token"This returns all 46 tools successfully.
Root Cause
In
internal/server/unified.go:510-525, therequireSession()function checks if a session exists:This session is only created when
sys___initis called first.Impact
Standard MCP clients (MCP Inspector, Claude Desktop, Copilot CLI, etc.) expect to:
initializeJSON-RPC method)They don't expect a custom
sys___inittool call as a prerequisite. This breaks compatibility with standard MCP tooling.Workaround (curl with manual session handling)
This multi-step curl approach works:
Note: The
stateparameter must be uppercase (`OP...✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.