LocalAI icon indicating copy to clipboard operation
LocalAI copied to clipboard

[ui] Fix MCP toggle not shown for models without gallery config

Open Copilot opened this issue 5 months ago • 1 comments

Description

This PR fixes the MCP/Agent toggle not appearing in the chat UI when users create model configurations that share the same model file. The toggle was incorrectly gated behind a gallery config check, which only exists for gallery-installed models.

Changes

  • UI Template (chat.html): Removed {{ if $galleryConfig }} wrapper around MCP toggle logic. The toggle now displays for any model with MCP configuration, regardless of installation source.

  • Test Coverage (model_config_test.go): Added test verifying multiple configs pointing to the same model file maintain independent MCP settings.

Example Scenario

# model-base.yaml (from gallery, has ._gallery_model-base.yaml)
name: model-base
parameters:
  model: shared-model.gguf

# model-agent.yaml (user-created, no gallery file)
name: model-agent
parameters:
  model: shared-model.gguf  # same file
mcp:
  stdio: |
    mcpServers:
      test:
        command: mcp-server-test

Before: /chat/model-agent showed no MCP toggle (missing gallery file)
After: /chat/model-agent shows MCP toggle (checks model config directly)

Notes for Reviewers

The fix is a 2-line change in the template. Gallery configs are metadata for gallery-installed models and should not gate feature availability.

Signed commits

  • [x] Yes, I signed my commits.
Original prompt

This section details on the original issue you should resolve

<issue_title>MCP / Agent mode is not working when model file is shared</issue_title> <issue_description>LocalAI version: v3.7.0

Describe the bug

If you configure model twice using same model file, and one configuration spec'ed for MCP / Agent mode, LocalAI fails to recognize that and MCP / Agent feature is not working.

To Reproduce

  1. Download model from gallery
  2. Copy configuration file for downloaded model
  3. Import model by pasting copied configuration file, adding MCP and Agent sections, and changing name (but not changing filename!)
  4. Try to chat with model configured for MCP / Agent mode (Chat view is not showing option to enable MCP)
  5. (optional) Verify logs in debug mode to see no MCP activity happens
  6. (optional) Verify configuration of MCP / Agent mode by downloading yet another model from gallery and editing it's original configuration file by pasting MCP and Agent sections.

Expected behavior One of configurations works in Agent mode (uses MCP), another works in standard way.</issue_description>

Comments on the Issue (you are @copilot in this section)

  • Fixes mudler/LocalAI#7143

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Nov 19 '25 21:11 Copilot

Deploy Preview for localai ready!

Name Link
Latest commit eae90caface31980e90e08fea66b62923afd0511
Latest deploy log https://app.netlify.com/projects/localai/deploys/691e41c861f5760007901e58
Deploy Preview https://deploy-preview-7318--localai.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

netlify[bot] avatar Nov 19 '25 21:11 netlify[bot]