Skip to content

feat(integrations): add a Gemini CLI extension for the MCP server - #2289

Closed
cihan-gyk wants to merge 2 commits into
ansvisor:mainfrom
cihan-gyk:feature/gemini-cli-extension
Closed

cihan-gyk wants to merge 2 commits into
ansvisor:mainfrom
cihan-gyk:feature/gemini-cli-extension

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

This stays a draft until ansvisor/gemini-cli-extension exists. The README, docs page and Help article all point their install command there. See "What someone must do outside the code".

This adds a Gemini CLI extension for Ansvisor's MCP server. Gemini CLI users can install it with one command, and it can be listed in the Gemini CLI extensions gallery.

  • integrations/gemini-cli/gemini-extension.json: the manifest.
    • One remote server, ansvisor, at https://app.ansvisor.com/api/mcp.
    • It uses url with type: "http". That is the form current Gemini CLI writes, and the one its code doesn't mark deprecated.
    • GEMINI.md is the context file. The manifest declares no auth.
  • integrations/gemini-cli/GEMINI.md: context for the model.
    • What Ansvisor is and which engines it tracks: ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode and Bing AI Mode.
    • All 65 tools, grouped by area, with when to use each. Only list_* / get_* tools read.
    • The plan rules: plan_required below Growth, subscription_inactive on an ended plan, and oauth_plan_required for a sign-in connection in the trial or on an ended plan. Also the shopping analytics and Improve features.
    • The admin/manager-only tools.
    • Every claim was checked against the tool registry, subscription-gate.ts and role-gate.ts.
  • integrations/gemini-cli/README.md: install, sign in, API key, what you can ask, self-hosted, update and remove.
  • docs/guides/gemini-cli.mdx: added to the Platform Guides nav after the MCP server guide.
  • help/settings/gemini-cli.md: a new Help article with approved: false. It isn't in approved-articles.json, so Chat doesn't answer from it yet.

Sign-in and API keys. Gemini CLI does OAuth for remote HTTP servers on its own. When the server answers 401 with WWW-Authenticate: Bearer resource_metadata=…, it:

  • reads the protected resource and authorization server metadata;
  • registers itself by dynamic client registration (token_endpoint_auth_method: none, a http://localhost:<random port>/oauth/callback redirect);
  • signs in with PKCE S256 and the resource parameter, and checks iss (RFC 9207);
  • stores and refreshes the tokens.

/mcp auth ansvisor starts it by hand.

Ansvisor's authorization server matches all of this:

  • dynamic registration stays on next to CIMD (Gemini CLI doesn't use CIMD);
  • a loopback redirect matches on any port;
  • the resource equals the MCP URL;
  • iss is sent.

So the extension works:

  • with API keys today. A server named ansvisor in the user's Gemini settings takes the extension server's place. The README and docs give a gemini mcp add --scope user … command that keeps the key in an environment variable. Tested: the key reaches the server even though the variable's name contains TOKEN.
  • with sign-in once MCP app sign-in is on. Until then, /mcp auth ansvisor can't discover how to sign in, and the README says to use an API key.

The extension has no API key setting on purpose. Gemini CLI sends a header the extension declares in place of the sign-in token, even when that header is empty, so a key setting would break signing in.

Why a second repository. Gemini CLI installs a GitHub extension only from owner/repo with gemini-extension.json at the repository root; a subfolder URL is refused. The gallery needs the manifest at the root too. integrations/gemini-cli stays the source, and a public ansvisor/gemini-cli-extension carries a copy (see below).

Related issue

None. Builds on MCP over OAuth (#2141).

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/): not run, no web code changed
  • yarn typecheck passes (run from web/): not run, no web code changed
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR
  • Help article updated under help/ (or no user-visible change) — see help/README.md

Also run:

  • yarn test src/lib/help: 12 tests pass, including the new article.
  • Prettier on the new manifest, README, GEMINI.md, docs page and mint.json.
  • gemini extensions validate with Gemini CLI 0.67.0.

How to test

From a checkout of this branch, with Gemini CLI installed (npm install -g @google/gemini-cli):

  1. Validate the manifest:

    gemini extensions validate ./integrations/gemini-cli
  2. Install it from the folder. Gemini CLI asks whether you trust the folder, then asks you to confirm the extension:

    gemini extensions install ./integrations/gemini-cli
    gemini extensions list
    gemini mcp list

    gemini mcp list shows ansvisor (from ansvisor): https://app.ansvisor.com/api/mcp (http).

  3. API key: create a key in Settings › MCP & API Keys, then:

    export ANSVISOR_TOKEN=ans_...
    gemini mcp add --scope user --transport http \
      --header 'Authorization: Bearer $ANSVISOR_TOKEN' \
      ansvisor https://app.ansvisor.com/api/mcp

    Start gemini in a trusted folder and run /mcp: the server is connected with its tools. Ask "List my Ansvisor brands". Ask for a change on Starter: the tool answers plan_required.

  4. Sign-in, on a deploy where MCP app sign-in is on:

    • Run gemini mcp remove --scope user ansvisor, start gemini and accept the sign-in prompt (or run /mcp auth ansvisor).
    • The consent page names the app "Gemini CLI MCP Client", marks it Not checked by Ansvisor and says it goes back to this computer.
    • After Allow, the tools load and the connection is listed under Connected apps.
    • On a workspace in its free trial, every tool answers oauth_plan_required.

Once the separate repository exists, the install command is:

gemini extensions install https://github.com/ansvisor/gemini-cli-extension

What someone must do outside the code

  1. Create the public repository ansvisor/gemini-cli-extension, MIT.
    • Put these files at its root: gemini-extension.json, GEMINI.md and README.md from integrations/gemini-cli, and the repository's LICENSE. A ready copy has been prepared.
    • Create it before this docs page goes live. Until it exists, the install command in the README, the docs page and the Help article doesn't work.
  2. Add the gemini-cli-extension topic in the repository's About section. The gallery's crawler finds extensions by this topic, through GitHub Code Search, once a day. There is no submission form.
  3. Check that GitHub has indexed the manifest: gh api 'search/code?q=repo:ansvisor/gemini-cli-extension+filename:gemini-extension.json' --jq .total_count.
    • If it says 0, sign in to GitHub and open https://github.com/search?q=repo%3Aansvisor%2Fgemini-cli-extension+gemini-extension.json&type=code until the manifest shows.
    • If it passes validation, the extension then appears in the gallery within a day or two.
  4. Choose how to release.
    • Without GitHub Releases, Gemini CLI clones the default branch, and every new commit there shows as an update.
    • With releases, it checks the Latest release. Tag them v0.1.0 and so on, and keep the manifest's version the same as the tag, because Gemini CLI shows the manifest version.
    • Bump version on every change.
  5. Keep the copy in sync. Change integrations/gemini-cli first, then copy the three files to the extension repository. If the extension ever moves, migratedTo in the old manifest sends users to the new repository.
  6. MCP app sign-in must be on for sign-in to work. The coming MCP launch PR (PR 7 of feat(mcp): connect over OAuth, and list Ansvisor in Claude Connectors and the ChatGPT apps directory #2141) turns it on by default. Until it merges, set MCP_OAUTH_ENABLED=true or use an API key.

Generated by Claude Code

Adds integrations/gemini-cli: a Gemini CLI extension that adds
Ansvisor's remote MCP server (streamable HTTP) and a GEMINI.md context
file that says what each tool is for, which ones change data, and what
the plans and roles allow. Gemini CLI signs in by itself when the server
answers 401 with a WWW-Authenticate challenge (discovery, dynamic client
registration, PKCE), so the extension declares no auth. An API key stays
an option through a user-settings server of the same name, which takes
the extension server's place; the extension has no key setting, because
a header it declares would replace the sign-in token.

Also a docs guide (docs/guides/gemini-cli.mdx, in the nav) and an
unapproved Help article (help/settings/gemini-cli.md).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
@mintlify

mintlify Bot commented Nov 10, 2026

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit dc21b59.

Approve preview

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.

2 participants