AI Agent based Playwright MCP using credentials

I’d like to ask for some help please. After hours of playing and google/chatbot/forums, I’ve coome here for help :blush:

I have a working workflow using an AI agent with OpenAI/Gemini Chat model and a Playwright MCP Tool. I am hosting my own n8n and Playwright MCP servers.

I am using it for web crawling/automation and can type requests into the chat window and the AI/Playwright MCP server can crawl / scrape web pages successfully.

I can type “Login to www.domain.com with username:MrBlobby and password:dontshare and the AI uses this just fine to login to the website.

However, I dont want to pass the credentials to the AI Chat as this feels very insecure. I have been trying and failing to find a way to save n8n credentials that I can pass on more securely.

Does anyone have any tips or code I can use to make this happen please?

This is my simple workflow:

Hi. Anyone have any idea how I can achieve this please?

I have looked into the getcredentials method but it seems to not be available for me to use:

async function main() {
  try {
    // Replace 'genericCredentials' with your credential type and 'WebsiteLogin' with your credential name
    const credentials = await $.getCredentials('stored-creds');
    return [{ json: { email: credentials.email, password: credentials.password } }];
  } catch (error) {
    throw new Error(`Failed to fetch credentials: ${error.message}`);
  }
}
return main();

Hey can you tell me how did you get the MCP working. I am trying but unable to call as playwright mcp needs proxy for http calling. Adding MCP only supporting http streamable