How do I avoid leaking Magento admin tokens to the LLM?

Treat tokens like Kubernetes secrets, not like configuration. The admin token lives in the Docker container’s env file (/run/secrets/magento_admin_token or .env.mcp), is read once at startup, and is never passed as a tool argument. The LLM sees tool inputs (SKU, query, date range) and outputs (the data), it does not see the token. Common mistakes to avoid: (a) making admin_token a tool parameter so the model can “help” with auth; (b) logging the Authorization header; (c) returning the integration object verbatim from a tool. Use the narrowest integration scope possible, if the LLM only needs to read orders, the token should only grant that.

Kishan Savaliya
Kishan Savaliya
Adobe Certified Magento Commerce Developer
Ahmedabad [IN]working hours, replies within four hours
When do you need it

Read personally. Never shared. Or email the brief.

More on build a magento 2 mcp server in python, faqs

Need it fixed, not just explained?

Send the brief with your store URL; the written quote comes back within 24 hours.