Forum Discussion
Azure AI Foundry Agent Unable to Use Credentials Stored in Key Vault Through Playwright MCP Tool
Hello everyone,
I am trying to understand how Azure AI Foundry agents interact with Azure Key Vault when using custom MCP tools, and I would appreciate any guidance from the community.
My Setup
- Created an Azure AI Foundry agent.
- Created an Azure Key Vault and configured all permissions according to Microsoft's official documentation.
- Stored the required website credentials (username and password) in the Key Vault.
- Deployed the official Playwright MCP Docker image.
- Exposed the MCP server using ngrok and verified that the endpoint is accessible.
- Connected the MCP endpoint as a Custom MCP Tool in Azure AI Foundry.
- Performed all configuration through the Azure portal, Foundry UI, and Playground only (no SDK or custom application code involved).
The Issue
The agent can access and use the Playwright MCP tool. However, when I ask it to log in to a website using credentials that are already stored in Key Vault, it does not populate the username and password fields.
My expectation was that the agent would be able to retrieve the secrets from Key Vault and provide them to the Playwright tool during execution.
Questions
- Is there currently a supported mechanism for Azure AI Foundry agents to automatically retrieve Key Vault secrets and pass them to a Custom MCP tool?
- Does the Playwright MCP Docker image have any built-in integration with Azure Key Vault?
- When using only the Foundry UI (without SDK code), can a Foundry agent securely inject Key Vault secrets into MCP tool calls?
- Are additional configurations required beyond Key Vault permissions and agent connections?
- Has anyone successfully implemented a similar setup where a Foundry agent uses credentials stored in Key Vault to perform browser automation through Playwright MCP?
Any clarification on the expected architecture and whether this scenario is currently supported in Azure AI Foundry would be greatly appreciated.
Thank you.
2 Replies
- JonEricEubanksBrass Contributor
Key Vault permissions alone won’t automatically inject secrets into a Custom MCP tool. The secure pattern is still for the MCP server/tool to retrieve the secret server-side, ideally with managed identity, and perform the login without exposing credentials to the prompt or model.
For Playwright MCP specifically, I would not expect built-in Key Vault integration unless the server has been customized to do that. Also worth watching is Microsoft’s Browser Automation Tool / BAT in Foundry Agent Service, which is designed for browser-based automation using Playwright Workspaces. It may become the cleaner native option for these workflows, but the credential handling should still remain server-side and not be passed through the agent conversation.
Connecting Key Vault to the Azure resource does not automatically pass those secrets into the Playwright MCP tool. The MCP server still needs to retrieve the secret itself, ideally with managed identity and only for the specific action it performs. I would keep the password out of prompts and let the tool do the login step server-side.