Connect Qwen Code to Agent Authority
Connect Alibaba's Qwen Code to SecureAuth Agent Authority so every MCP tool call is checked and audited
When you finish, every MCP tool call Qwen Code makes is checked against your policies and recorded in the audit log. Alibaba's Qwen Code reaches your approved tools through one SecureAuth Agent Authority gateway URL, and each developer signs in as themselves.
Setup
-
Add the MCP server. Add the following to
~/.qwen/settings.json:{ "mcpServers": { "secureauth": { "httpUrl": "https://your-gateway-url/gateway/mcp", "oauth": { "scopes": ["mcp_gateway", "profile", "email"] } } } }Qwen Code reads
httpUrlas a streamable HTTP server. A plainurlmeans the older SSE transport, which the gateway doesn't serve. -
Authenticate. Start Qwen Code (
qwen), type/mcp, select secureauth, and choose Authenticate. A browser window opens for sign-in. -
Start using. Qwen Code picks up the tools on the next turn.
The agent is auto-registered on first connect.
Connecting to just one MCP? To stay under an agent's tool limit, point the URL at a single MCP —
/gateway/mcp/{slug}instead of/gateway/mcp. Grab the exact URL from the resource's detail page; see Scope a connection.
Send model calls through the gateway
If you don't see the LLM Gateway page in your console, ask your SecureAuth
contact to enable the llm_gateway feature flag for your organization.

Qwen Code also sends its model calls through the gateway when you point an OpenAI-compatible provider at it.
Get an agent token, export it as SECUREAUTH_AGENT_TOKEN, and merge these keys into the same top-level object in ~/.qwen/settings.json, beside mcpServers, with the OpenAI-compatible base URL from Enforcement Points › LLM Gateway and a model your gateway serves:
{
"modelProviders": {
"openai": [
{
"id": "gpt-4.1-mini",
"baseUrl": "https://your-gateway-url/gateway/llm/openai/v1",
"envKey": "SECUREAUTH_AGENT_TOKEN"
}
]
},
"security": { "auth": { "selectedType": "openai" } },
"model": { "name": "gpt-4.1-mini" }
}Each model call then appears in Agent Trail as a Model Call, and your model access rules decide it.
Next steps
Qwen Code now reaches your tools through the secureauth server in ~/.qwen/settings.json, and its model calls too if you added modelProviders.
Next, write the policy that decides which tools it can call.
- Create a policy – control which tools Qwen Code can call.
- Monitor activity – watch its tool calls appear in the dashboard and audit log.
- Audit log – filter and search every tool call Qwen Code makes.
