| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
The MCP `search_documentation` tool currently uses a single bundled Algolia API key for the public Angular documentation index. This works out of the box but gives operators no way to: * substitute a different key for self-hosted documentation indices, * point an internal CI environment at a separate Algolia application to avoid sharing the public rate-limit budget, * test key rotation without rebuilding the CLI. This change adds a `NG_DOCS_SEARCH_API_KEY` environment variable that, when set to a non-empty string, is used verbatim in place of the bundled key. When the variable is absent or empty, behaviour is unchanged — the bundled key continues to be used. The override path is factored into a small `resolveAlgoliaApiKey()` helper so the env-var precedence rules are unit-testable without spinning up the full MCP tool runner. Three Jasmine specs cover: override set, override unset, and override set to empty string. The previous comment block on `ALGOLIA_API_E` is replaced with a short note describing the override mechanism and the operator scenarios it enables.
There was a problem hiding this comment.
This pull request introduces the resolveAlgoliaApiKey function to allow overriding the Algolia API key via the NG_DOCS_SEARCH_API_KEY environment variable, falling back to a bundled default if unset. It also includes unit tests for this new logic. Feedback suggests providing an environment variable override for the Algolia App ID to better support self-hosted documentation and recommends trimming whitespace from the environment variable value to prevent configuration errors.
Sorry, something went wrong.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
PR Checklist
PR Type
What is the current behavior?
The MCP search_documentation tool uses a single bundled Algolia API
key for the public Angular documentation index. Operators have no way
to substitute a different key for self-hosted documentation, internal
CI environments, or rotation testing without rebuilding the CLI.
Issue Number: N/A
What is the new behavior?
A new environment variable, NG_DOCS_SEARCH_API_KEY, takes precedence
over the bundled key when set to a non-empty value. When unset or set
to an empty string, behaviour is unchanged.
The override path is factored into a small resolveAlgoliaApiKey()
helper so the precedence rules are unit-testable without spinning up
the full MCP tool runner. The helper is exported (for testing) and
consumed from createDocSearchHandler:
The bracket-syntax env access matches the existing convention in
mcp-server.ts (process.env['NG_MCP_CODE_EXAMPLES']). The variable
name follows the NG_* prefix used by every other CLI environment
variable (see utilities/environment-options.ts).
Tests
Three Jasmine specs in
packages/angular/cli/src/commands/mcp/tools/doc-search_spec.ts:
The fallback specs assert the resulting key matches the expected
Algolia key format (32 hex chars) without logging the value.
Comment cleanup
The previous comment block on ALGOLIA_API_E is replaced with a
short note describing the new override mechanism and the operator
scenarios it enables. The /#search-only-api-key URL was tied to
that specific phrasing; since the new comment no longer makes that
claim, the URL is dropped to avoid implying a constraint the bundled
key does not necessarily honour.
Does this PR introduce a breaking change?
Default behaviour is unchanged for users who do not set the new
environment variable. Existing ng mcp workflows continue to use the
bundled key with no configuration.
Other information
The variable name choice (NG_DOCS_SEARCH_API_KEY vs alternatives
like NG_ALGOLIA_API_KEY or NG_MCP_DOCS_KEY) is a judgement call;
happy to rename to whatever fits the convention reviewers prefer.