Snowflake can extract structured data from documents natively with
AI_EXTRACT. This guide routes that workload to Unsiloed by setting up two
pieces, in order:- A UDF that extracts documents from a Snowflake stage in SQL. This is the foundation.
- A Cortex Agent that extracts those same staged documents in natural language, by running the UDF through Snowflake’s Managed MCP server.
Why Call Unsiloed from Snowflake
Unsiloed adds schema-driven extraction with per-field confidence scores and source citations, so you can route uncertain values to a review queue instead of trusting every extracted value equally. Both pieces fit the Snowflake architecture you already have and keep the API key in a Snowflake-managed credential.Extract in SQL with a UDF
A Python user-defined function (UDF) over an External Access Integration reads a staged file and sends it to Unsiloed’s/v2/extract, returning typed
fields with confidence scores and citations. It works on any file in a stage.
For an internal stage, create the stage with
ENCRYPTION = (TYPE = 'SNOWFLAKE_SSE'). The UDF reads files through
SnowflakeFile, which can’t open client-side-encrypted stages.
A ready-to-run setup (network rule, secret, integration, and the UDF) is in the
Unsiloed cookbook.
To install it:
1
Open a SQL worksheet
In Snowsight, select + (Create) in the top left, then SQL File.

2
Paste the setup script
Copy
setup.sql from the cookbook into the worksheet. Set your database and
schema at the top, and paste your Unsiloed API key into the secret’s
SECRET_STRING.3
Run it
Open the Run dropdown next to the Run button and choose Run All. This
creates the network rule, secret, external access integration, and the

unsiloed_extract function.
bbox array holds [x0, y0, x1, y1] in points, measured against the
page_width and page_height in the same object, so you can scale it to
whatever size you render the page at.
To process a whole stage in one query, join to DIRECTORY(@stage), which gives
you relative_path for both the URL and the name:
Extract with a Cortex Agent
With the UDF in place, a Snowflake Cortex Agent (the engine behind Snowflake CoWork) can extract your staged documents in natural language. The agent runs the UDF through Snowflake’s Managed MCP server: itsexecute_sql tool
lets the agent call unsiloed_extract on any file in your stage, so it reaches
documents inside Snowflake without a URL.
Prerequisites for the Cortex Agent
- A Snowflake account with Cortex Agents and Snowflake CoWork available.
- A role that can create MCP servers and agents (
ACCOUNTADMINworks). - The
unsiloed_extractUDF from the previous section.
Set Up the Agent
1
Create a Managed MCP server
Expose a read-only
execute_sql tool through Snowflake’s Managed MCP. The
server runs queries under your default warehouse, so make sure one is set
(ALTER USER <you> SET DEFAULT_WAREHOUSE = '<warehouse>').2
Create the agent
Reference the Managed MCP server in a top-level
mcp_servers block, and tell
the agent how to call the UDF. Fully-qualify unsiloed_extract, since
execute_sql runs without a database or schema context. The orchestration
model must be on the agent allowlist (for example claude-sonnet-4-5,
claude-sonnet-5, or auto).Use the Agent
1
Select the agent
Open Snowflake CoWork at ai.snowflake.com, start
a new chat, and pick your agent from the selector in the message box.

2
Name a staged document
Ask in natural language, naming a file in your stage:The agent runs the UDF through 
execute_sql and reports the fields, each
with a confidence score:
Troubleshoot the Cortex Agent
'Unknown function UNSILOED_EXTRACT'
'Unknown function UNSILOED_EXTRACT'
execute_sql runs without a database or schema context. Fully-qualify the
function in the agent’s instructions: MY_DB.MY_SCHEMA.unsiloed_extract(...).'Tool type mcp_server is not valid' when creating the agent
'Tool type mcp_server is not valid' when creating the agent
Reference the MCP server in a top-level
mcp_servers block, not under
tools/tool_spec. Also confirm the orchestration model is on the agent
allowlist (for example claude-sonnet-4-5, claude-sonnet-5, or auto;
claude-4-sonnet is not valid).The agent doesn't call the UDF, or picks the wrong file
The agent doesn't call the UDF, or picks the wrong file
Make the orchestration instruction explicit: give the exact
SELECT unsiloed_extract(BUILD_SCOPED_FILE_URL(@stage, '<filename>'), '<filename>', '<schema>')
template and the stage name, so the agent maps the document name to a stage
path.'Invalid argument types for function UNSILOED_EXTRACT'
'Invalid argument types for function UNSILOED_EXTRACT'
The agent dropped an argument, usually the file name. The function takes the
scoped URL, the file name, and the schema, so the filename appears twice in
the template. Restate it in the orchestration instruction.
The agent's query returns no warehouse error
The agent's query returns no warehouse error
The Managed MCP runs queries under your default warehouse. Set one with
ALTER USER <you> SET DEFAULT_WAREHOUSE = '<warehouse>' and make sure it can
resume.See Also
Snowflake UDF recipe
Ready-to-run
setup.sql for the in-SQL UDF path.Extraction API Reference
The
/v2/extract endpoint, schema options, and response format.
