feat(toolbox): sync TOOLBOX_<NAME>_MCP_ENDPOINT env var on create/delete#8677
Conversation
azd ai toolbox create now writes the new toolbox's versioned MCP endpoint to the active azd environment under the TOOLBOX_<NORMALIZED_NAME>_MCP_ENDPOINT key (the same convention agents consume), and azd ai toolbox delete clears it when the whole toolbox is removed. The key builder is duplicated from azure.ai.agents into internal/foundry/envkey since the extensions are separate Go modules. Env writes are best-effort: a missing azd daemon is skipped rather than failing the toolbox operation. Closes #8672.
📋 Prioritization NoteThanks for the contribution! The linked issue isn't in the current milestone yet. |
There was a problem hiding this comment.
Pull request overview
This PR updates the azure.ai.toolboxes extension to persist each toolbox’s version-scoped MCP endpoint into the active azd environment on azd ai toolbox create, and to clear that stored endpoint on whole-toolbox azd ai toolbox delete, enabling downstream agents/tools to consume the endpoint without re-running commands.
Changes:
- Persist the created toolbox version’s MCP endpoint to the active
azdenvironment underTOOLBOX_<NORMALIZED_NAME>_MCP_ENDPOINT. - Clear the persisted endpoint value on whole-toolbox delete (leaving version-delete behavior unchanged).
- Add a shared env-var key normalizer (
internal/foundry/envkey) plus unit tests and update extension changelog.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| cli/azd/extensions/azure.ai.toolboxes/internal/foundry/envkey/envkey.go | Adds toolbox-name normalization and env-var key builder for TOOLBOX_<NAME>_MCP_ENDPOINT. |
| cli/azd/extensions/azure.ai.toolboxes/internal/foundry/envkey/envkey_test.go | Adds test cases to keep key normalization aligned with the agents extension. |
| cli/azd/extensions/azure.ai.toolboxes/internal/cmd/toolbox_test_helpers_test.go | Adds test seams to stub/record env sync calls from create/delete flows. |
| cli/azd/extensions/azure.ai.toolboxes/internal/cmd/toolbox_env.go | Introduces helper that writes/clears the endpoint in the active azd environment via gRPC. |
| cli/azd/extensions/azure.ai.toolboxes/internal/cmd/toolbox_env_test.go | Adds tests asserting endpoint env sync on create and clearing on whole-toolbox delete. |
| cli/azd/extensions/azure.ai.toolboxes/internal/cmd/toolbox_delete.go | Clears the stored endpoint value after successful whole-toolbox deletion. |
| cli/azd/extensions/azure.ai.toolboxes/internal/cmd/toolbox_create.go | Writes the computed versioned MCP endpoint to the env and updates emitted output accordingly. |
| cli/azd/extensions/azure.ai.toolboxes/internal/cmd/toolbox_commands_test.go | Extends create tests to assert the endpoint env sync is invoked with the versioned URL. |
| cli/azd/extensions/azure.ai.toolboxes/CHANGELOG.md | Documents the new env sync behavior under Unreleased. |
…pell GetCurrent returns codes.Unknown 'default environment not found' (not Unavailable) when no default environment is selected, which previously hard-failed create/delete. Match the message text (as azure.ai.agents does) so the env write is skipped. Add envkey/Alphanum to the extension cspell word list.
Review — Approve ✅Clean, well-tested, and consistent with the extension conventions. No blocking issues. What it doesAfter Strengths
Minor observations (non-blocking)
Verification performed
|
…int-env # Conflicts: # cli/azd/extensions/azure.ai.toolboxes/CHANGELOG.md
Summary
Closes #8672. After
azd ai toolbox create, the toolbox's versioned MCP endpoint is now persisted to the active azd environment instead of only printed, so developers and agents can consume it without re-running a command.azd ai toolbox deleteclears it when the whole toolbox is removed.Changes
toolbox_create.go/toolbox_delete.go: write the endpoint underTOOLBOX_<NAME>_MCP_ENDPOINTon create and blank it on whole-toolbox delete (version delete is intentionally untouched).toolbox_env.go: newsetToolboxEndpointEnvhelper (gRPCGetCurrent+SetValue); best-effort — a missing azd daemon is skipped rather than failing the operation.internal/foundry/envkey: key builder duplicated fromazure.ai.agents(separate Go modules) so both extensions agree on the key; test mirrors the agents cases to guard drift.