Skip to content

feat(core): add support for admin-forced MCP server installations#23163

Merged
gsquared94 merged 1 commit intogoogle-gemini:mainfrom
gsquared94:agent-registry
Mar 19, 2026
Merged

feat(core): add support for admin-forced MCP server installations#23163
gsquared94 merged 1 commit intogoogle-gemini:mainfrom
gsquared94:agent-registry

Conversation

@gsquared94
Copy link
Copy Markdown
Contributor

@gsquared94 gsquared94 commented Mar 19, 2026

Summary

Adds the ability for enterprise administrators to force specific MCP server installations through admin controls. Required servers are always injected regardless of user-local configurations and cannot be disabled by the user.

Changes

Core (packages/core)

  • types.ts: Added RequiredMcpServerConfigSchema (Zod schema for admin-required servers with remote transport fields only) and updated McpConfigDefinitionSchema / AdminControlsSettingsSchema to include requiredMcpServers/requiredMcpConfig.
  • admin_controls.ts: Updated sanitizeAdminSettings() to parse requiredMcpServers from mcpConfigJson and sort tool lists for stable deep-equality comparison.
  • mcpUtils.ts: Added applyRequiredServers() function that converts RequiredMcpServerConfigMCPServerConfig, defaulting trust to true and completely overriding any local config with the same server name.

CLI (packages/cli)

  • config.ts: Calls applyRequiredServers() after applyAdminAllowlist() to inject admin-required servers.
  • settings.ts: Maps requiredMcpConfig from admin settings to settings.admin.mcp.requiredConfig.
  • settingsSchema.ts: Added requiredConfig field and RequiredMcpServerConfig JSON schema definition.

Design Decisions

  • Separate field: Uses requiredMcpServers (distinct from existing mcpServers allowlist) for backward compatibility — older clients ignore the new field.
  • Remote-only: The schema excludes stdio fields (command, args, env, cwd) since admin-pushed servers are always remote.
  • Single source of truth: Uses z.nativeEnum(AuthProviderType) instead of duplicating enum values.
  • Precedence: Admin-required servers override local configs and coexist with allowlisted servers.

Tests Added

  • 10 new tests in mcpUtils.test.ts covering injection, overrides, auth preservation, tool filtering, trust defaults, and coexistence with allowlisted servers.
  • 3 new tests in admin_controls.test.ts for requiredMcpServers parsing, tool list sorting, and required-only configs.
  • 1 new test in settings.test.ts for requiredMcpConfig mapping through setRemoteAdminSettings.
  • Fixed type in list.test.ts test fixture.

Verification


Fixes https://github.com/google-gemini/maintainers-gemini-cli/issues/1586

@gsquared94 gsquared94 requested a review from a team as a code owner March 19, 2026 21:44
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant feature that empowers enterprise administrators to enforce specific MCP server configurations across their organization. By allowing administrators to define 'required' servers, the system ensures that these critical services are always available to users, overriding any conflicting local settings and preventing user-side disabling. This enhancement provides a robust mechanism for centralized control over the MCP server landscape, improving compliance and consistency within managed environments.

Highlights

  • Admin-Forced MCP Server Installations: Introduced the capability for enterprise administrators to force specific MCP server installations, which are always injected and cannot be disabled by users.
  • New Configuration Schema: Defined RequiredMcpServerConfigSchema (Zod schema) for admin-required servers, focusing on remote transport fields, and updated McpConfigDefinitionSchema and AdminControlsSettingsSchema to include requiredMcpServers and requiredMcpConfig.
  • Core Logic for Server Injection: Added the applyRequiredServers() function which converts RequiredMcpServerConfig to MCPServerConfig, defaults trust to true, and completely overrides any local configuration with the same server name.
  • CLI Integration: The CLI now calls applyRequiredServers() after applyAdminAllowlist() to inject admin-required servers and maps requiredMcpConfig from admin settings to settings.admin.mcp.requiredConfig.
  • Design Decisions: Key design choices include using a separate field (requiredMcpServers) for backward compatibility, restricting the schema to remote-only fields, leveraging z.nativeEnum for consistency, and ensuring admin-required servers take precedence over local configurations.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-cli gemini-cli bot added the status/need-issue Pull requests that need to have an associated issue. label Mar 19, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request introduces support for admin-forced MCP server installations, allowing enterprise administrators to inject specific MCP server configurations that override local user settings. The changes are well-tested with new unit tests covering various scenarios, including injection, overrides, and tool filtering. The implementation correctly handles the precedence of admin-required servers and ensures proper logging of injected servers. The use of z.nativeEnum(AuthProviderType) in packages/core/src/code_assist/types.ts aligns with the stated design decision for a single source of truth for enum values.

Note: Security Review did not run due to the size of the PR.

Comment thread packages/cli/src/config/settingsSchema.ts Outdated
@gsquared94 gsquared94 requested a review from adamfweidman March 19, 2026 21:51
@gsquared94 gsquared94 requested a review from a team as a code owner March 19, 2026 21:52
Add the ability for enterprise administrators to force specific MCP
server installations through admin controls. These required servers
are always injected regardless of user-local configurations and cannot
be disabled.

Changes:
- Add RequiredMcpServerConfigSchema and RequiredMcpServerConfig type
- Parse requiredMcpServers from mcpConfigJson in sanitizeAdminSettings
- Add applyRequiredServers() to inject admin-required MCP servers
- Wire applyRequiredServers into CLI config loading pipeline
- Add requiredConfig to admin MCP settings schema
- Map requiredMcpConfig through setRemoteAdminSettings
- Add RequiredMcpServerConfig JSON schema definition
- Add comprehensive tests for all new code paths
Copy link
Copy Markdown
Contributor

@adamfweidman adamfweidman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM w a few questions

Comment thread packages/core/src/code_assist/admin/admin_controls.ts
Comment thread packages/core/src/code_assist/admin/mcpUtils.ts
@gsquared94 gsquared94 enabled auto-merge March 19, 2026 22:21
@gsquared94 gsquared94 added this pull request to the merge queue Mar 19, 2026
Merged via the queue into google-gemini:main with commit 8615315 Mar 19, 2026
27 of 28 checks passed
@gsquared94 gsquared94 deleted the agent-registry branch March 19, 2026 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants