Skip to content

[BUG] MCP server reports llm_available=false and skips the LLM pass when only the OpenAI fallback credential is set #200

Closed

Description

@wernerkasselman-au

What I'm seeing

I was reading through the MCP server's "honest accounting" fields (the ones added so a caller can tell a static-only scan from a full semantic one), and I think the availability check is wired to the wrong resolver, so it misreports availability, and it disables the LLM pass in a configuration where the CLI would happily run it.

run_scan() decides whether the semantic pass can run by calling resolve_provider_credentials(), which only ever resolves the active provider's credentials (mcp_server.py:77-83). The model the graph actually constructs, though, comes from create_chat_model(), and that one falls back to a plain OpenAI client (OPENAI_API_KEY / OPENAI_BASE_URL) when the active provider is not configured (providers/__init__.py:120-148). So the gate and the construction path disagree, and the gate is the stricter of the two.

Walking the code (commit 7bc9c0f)

  • src/skillspector/mcp_server.py:77-83, the gate, which feeds straight into the state the graph runs on:
    llm_available = resolve_provider_credentials() is not None
    llm_used = use_llm and llm_available
    state = {..., "use_llm": llm_used}
  • resolve_provider_credentials() is active-provider-only (providers/__init__.py:95-101).
  • The default NVIDIA provider reads only NVIDIA_INFERENCE_KEY (providers/nv_build/provider.py:49-54), so with just OPENAI_API_KEY set it returns None, and llm_available comes out false.
  • There is already a resolver that mirrors the real fallback, resolve_chat_model_credentials() (providers/__init__.py:111-117), which falls through to the OpenAI provider exactly the way create_chat_model() does. The gate just is not using it.

Reproduction

With SKILLSPECTOR_PROVIDER unset (the default NVIDIA path), NVIDIA_INFERENCE_KEY unset, and OPENAI_API_KEY set, call scan_skill (or run_scan(target, use_llm=True)) on any skill.

  • What I get: "llm_available": false, "llm_used": false, "scan_mode": "static-only", and the semantic pass never runs, even though the equivalent CLI scan on the same environment does run it.
  • What I expected: the OpenAI fallback credential is usable, so llm_available should be true and the pass should run.

Why it matters

The accounting fields quietly tell an agent that a clean static-only result was the best available, when a full scan was right there. An agent gating installs on the verdict acts on a weaker scan than it could have had.

What I think the fix is

Gate availability on resolve_chat_model_credentials() rather than resolve_provider_credentials(), so the MCP server's llm_available lines up with what create_chat_model() will actually do. I might be missing a reason the MCP path was deliberately scoped to the active provider only, so if that gating is intentional please say so on the issue; otherwise I am happy to put up the one-line change with a test.

Related

Activity

  1. wernerkasselman-au commented on Jul 24, 2026

    @wernerkasselman-au
    ContributorAuthor

    Closing: the gate defect reported here is fixed on main (fd25398), though by a different route than the one I proposed in #204.

    What fixed it

    run_scan() no longer gates on resolve_provider_credentials(). It now uses llm_available, _ = is_llm_available() (src/skillspector/mcp_server.py:76, imported at :36), and that value flows into llm_used, the graph state, and the reported llm_available / llm_used / scan_mode.

    llm_utils.is_llm_available() (src/skillspector/llm_utils.py:90) is capability-aware and strictly broader than what #204 proposed:

    • CLI providers (claude_cli, codex_cli, gemini_cli) are checked via provider.is_available(), so an authenticated binary with no API key is correctly reported available. resolve_chat_model_credentials() alone would have reported those unavailable.
    • Otherwise it falls through to _resolve_llm_credentials() -> resolve_chat_model_credentials() (llm_utils.py:113-117), which is the OpenAI-fallback path this issue asked for.

    The reason the fallback fires in the environment I reported is that has_provider_binding() (src/skillspector/providers/__init__.py:92-94) keys off the _INJECTED_PROVIDER ContextVar, which is set only by use_provider(), not off SKILLSPECTOR_PROVIDER. So with SKILLSPECTOR_PROVIDER unset the environment is unbound, resolve_chat_model_credentials() (:188-197) skips its early return and reaches _openai_fallback_provider().

    Re-running the exact repro from this issue on fd25398 (SKILLSPECTOR_PROVIDER unset, NVIDIA_INFERENCE_KEY unset, OPENAI_API_KEY set):

    active provider      : NvBuildProvider
    has_provider_binding : False
    resolve_provider     : None
    resolve_chat_model   : ('sk-test-200-repro', None)
    is_llm_available     : (True, None)
    
    run_scan(...) -> {"llm_available": true, "llm_requested": false,
                      "llm_used": false, "scan_mode": "static-only"}
    

    llm_available is now true where it was false. Regression coverage for the resolver lives at tests/unit/test_llm_utils.py:260-265. Note that no test pins this at the MCP boundary: the tests at tests/unit/test_mcp_server.py:39/57/72 monkeypatch is_llm_available, and the two at :83/:139 use injected providers, which is the has_provider_binding() == True branch rather than this one. A run_scan-level test with real env vars would be worth adding.

    Caveat worth recording: the semantic pass still yields nothing here

    Anyone retesting this environment should know that llm_available: true does not yet mean the LLM pass works. It does not, for a reason unrelated to the gate.

    build_context unconditionally sets "model_config": build_model_config() (src/skillspector/nodes/build_context.py:249). build_model_config() (src/skillspector/constants.py:70-73) resolves every slot from get_metadata_provider(), which in this environment is NvBuildProvider, and it is credential-blind: it never consults which client will actually be constructed. The analyzers then pass those labels explicitly into get_chat_model(model=...), which short-circuits the OpenAI-aware default in _resolve_default_chat_model().

    Observed on fd25398 in the same environment:

    build_model_config(): {'meta_analyzer': 'deepseek-ai/deepseek-v4-pro',
                           'default': 'deepseek-ai/deepseek-v4-flash', ...}
    label='deepseek-ai/deepseek-v4-flash' -> ChatOpenAI model='deepseek-ai/deepseek-v4-flash' base=None
    

    That is a DeepSeek model ID on a client pointed at api.openai.com. A bare get_chat_model() correctly returns gpt-5.4, but the graph never takes that path, so the OpenAI-aware default is effectively unreachable for analyzer calls.

    This is the same class of defect as #38 ("OpenAI fallback uses active provider default model"), which is closed. Its fix covered _resolve_default_chat_model() and does not cover the model_config path, so this variant is currently untracked. It deserves its own issue rather than reopening this one, since the gate bug reported here is genuinely resolved.

    Two smaller observations from the same investigation, also unrelated to the gate:

    • run_scan computes llm_available / llm_used / scan_mode from the pre-scan gate and never reconciles them against what the run actually did. With OPENAI_BASE_URL pointed at a dead port it still returned llm_used: true, scan_mode: "static+llm".
    • _build_metadata sets llm_degraded only when every logged call fails (src/skillspector/nodes/report.py:497), so a partially failed LLM stage reports llm_available: true and meta_analysis_applied: true.

    Thanks to everyone who looked at this.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions