Skip to content

if_not_exists=false emits CREATE OR REPLACE, which Snowflake rejects for external_mcp API integrations #36

Description

@mattsenicksigma

Summary

With if_not_exists=false, the cortex_mcp_api_integration materialization (#34) and the create_mcp_api_integration run-operation emit CREATE OR REPLACE API INTEGRATION ... API_PROVIDER = EXTERNAL_MCP. Snowflake doesn't support OR REPLACE for this integration type, so the only documented way to rotate or reconfigure an integration fails every time:

003535 (0A000): The OR REPLACE option is not supported for external_mcp API integrations.

The run-operation defaults to if_not_exists=false, so a plain dbt run-operation create_mcp_api_integration ... against an integration that already exists also hits this error.

Repro

  1. Build a cortex_mcp_api_integration model once so the integration exists.
  2. Change a property (e.g. allowed_prefixes / oauth_resource_url), set if_not_exists = false, and rebuild.
  3. The build fails with the error above.

Generated DDL (macros/operations/create_mcp_api_integration.sql, _mcp_api_integration_ddl):

create {% if if_not_exists %}api integration if not exists{% else %}or replace api integration{% endif %} {{ integration_name }}

Current workaround

Keep the default if_not_exists=true and add a temporary pre-hook:

pre_hook = "drop api integration if exists {{ this.identifier }}"

Suggested fix

When if_not_exists=false, emit DROP API INTEGRATION IF EXISTS <name> followed by a plain CREATE API INTEGRATION <name> (two statements) instead of CREATE OR REPLACE. Also:

  • Update the docs/comments in the materialization and operation that describe if_not_exists=false as "replace-in-place" / OR REPLACE semantics.
  • Call out that dropping an integration invalidates every EXTERNAL MCP SERVER that references it (those need to be recreated) and wipes users' stored OAuth tokens.
  • Optionally, rename the flag to something like recreate so the drop-and-create behavior is explicit.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions