Tutorial: Govern access to models with GRANT policies
Use ABAC GRANT policies to govern access to models, model services, model provider services, and MCP services in the system.ai schema. Instead of maintaining a direct grant on every object, create one policy for each supported securable type and match assets by their governed tags.
By the end of this tutorial, you can:
- Dynamically grant access to models, model services, model provider services, and MCP services using governed tags.
- Remove access to a selected model family while keeping other tagged models and model services available, along with approved model provider services and MCP services.
The walkthrough uses the ai.model_family system tag that Databricks applies to models and model services in system.ai. For model provider services and MCP services, it uses a user-defined governed tag, access_status = approved.
GRANT policies do not support Unity Catalog functions. Removing the default EXECUTE privilege from system.ai also removes access to AI Functions. This tutorial shows how to grant access to required functions with direct grants.
Before you begin
The policies in this tutorial apply to the account users group, which contains every account user and service principal.
You must have:
MANAGEonsystem.ai, or ownership of the schema.- Account admin or metastore admin privileges to remove the default
EXECUTEpermission fromsystem.ai. - To create a GRANT policy with SQL, a classic compute resource running Databricks Runtime 18 LTS or above. See Compute requirements.
- The
CREATEpermission on governed tags,ASSIGNon the governed tag, andAPPLY_TAGon the assets you tag. See Manage permissions on governed tags.
Step 1: Create GRANT policies
Choose a model family to exclude
Models and model services in system.ai have system tags such as ai.model_family and ai.model_creator that are applied automatically. You can reference these tags directly in a policy without creating or assigning them yourself.
To create policy conditions based on additional tags, you can create and assign your own governed tags and reference those tags in GRANT policies.
In Catalog Explorer, inspect the models and model services you want to govern and choose an ai.model_family value to exclude. In the following policies, replace <excluded-model-family> with that value.
GRANT policies grant access only when an asset matches the policy's tag-based condition. In the following policies, a model or model service matches only when it has an ai.model_family tag whose value is not <excluded-model-family>.
Create a governed tag for services
To govern access to model provider services and MCP services, create and assign a governed tag that identifies the services that account users can access. This tutorial uses access_status = approved as an example.
- Create a governed tag named
access_statuswith the allowed valueapproved. See Manage governed tags. - Apply
access_status = approvedto each model provider service and MCP service that account users can use. You can assign tags in Catalog Explorer or through the Unity Catalog entity tag assignments API.
Create policies for models and services
A GRANT policy targets one securable type. Create separate policies for models and model services, using the same condition.
CREATE POLICY grant_allowed_models
ON SCHEMA system.ai
COMMENT 'Grant EXECUTE on models outside the excluded family'
TO `account users`
GRANT EXECUTE FOR MODELS
WHEN has_tag('ai.model_family')
AND NOT has_tag_value('ai.model_family', '<excluded-model-family>');
CREATE POLICY grant_allowed_model_services
ON SCHEMA system.ai
COMMENT 'Grant EXECUTE on model services outside the excluded family'
TO `account users`
GRANT EXECUTE FOR MODEL SERVICES
WHEN has_tag('ai.model_family')
AND NOT has_tag_value('ai.model_family', '<excluded-model-family>');
The policies automatically grant EXECUTE privileges on new models and model services when they have an ai.model_family tag that does not match the excluded value. Users do not receive EXECUTE privileges on assets without that tag through these policies.
The preceding policies automatically grant EXECUTE to models and model services whose ai.model_family value matches the condition. If you prefer to explicitly control which models and model services account users can access, use your own governed tag instead. For example, apply access_status = approved to each approved model or model service, then use has_tag_value('access_status', 'approved') as the policy condition.
For model provider services and MCP services, the policies below grant EXECUTE when an administrator applies access_status = approved.
CREATE POLICY grant_allowed_model_provider_services
ON SCHEMA system.ai
COMMENT 'Grant EXECUTE on approved model provider services'
TO `account users`
GRANT EXECUTE FOR MODEL PROVIDER SERVICES
WHEN has_tag_value('access_status', 'approved');
CREATE POLICY grant_allowed_mcp_services
ON SCHEMA system.ai
COMMENT 'Grant EXECUTE on approved MCP services'
TO `account users`
GRANT EXECUTE FOR MCP SERVICES
WHEN has_tag_value('access_status', 'approved');
Step 2: Grant access to AI Functions
To grant access to an AI Function in system.ai, grant EXECUTE directly on the function. For example, the following statement grants access to the built-in python_exec function:
GRANT EXECUTE ON FUNCTION system.ai.python_exec TO `account users`;
Repeat this direct grant for each AI Function that users need to access. For more information, see AI Functions Unity Catalog permissions.
Step 3: Remove the default schema grant
After you create the GRANT policies, remove the default schema-level EXECUTE grant.
Before you revoke EXECUTE, ensure that account users can still use the catalog and schema:
GRANT USE CATALOG ON CATALOG system TO `account users`;
GRANT USE SCHEMA ON SCHEMA system.ai TO `account users`;
Revoke the default grant:
REVOKE EXECUTE ON SCHEMA system.ai FROM `account users`;
This change affects every account user and every executable asset in system.ai, including models, model services, model provider services, MCP services, and AI Functions.
Step 4: Verify access
Confirm that the policies are attached to system.ai:
SHOW EFFECTIVE POLICIES ON SCHEMA system.ai;
Test as an account user who has no other EXECUTE grants to confirm the following:
- User has
EXECUTEprivileges on a model or model service with a non-excludedai.model_familyvalue. - Users do not have
EXECUTEprivileges on a model or model service with the excluded value. - Users do not have
EXECUTEprivileges on an asset without theai.model_familytag. - Users have
EXECUTEprivileges on a model provider service or MCP service taggedaccess_status = approved. - Users do not have
EXECUTEprivileges on an untagged model provider service or MCP service through these policies. - Users have
EXECUTEprivileges on an AI Function only if you granted them directly.
To exclude a different model family, use CREATE OR REPLACE POLICY to update <excluded-model-family> in the WHEN conditions of both grant_allowed_models and grant_allowed_model_services. The updated policies grant EXECUTE only to models and model services whose ai.model_family value differs from the excluded value.
For model provider services and MCP services, apply or remove access_status = approved to change which services receive EXECUTE.