fix MCP_MIDDLEWARE_* does not set for api session