Labsco
sfc-gh-tgordonjr logo

Snowflake Cortex AI

from sfc-gh-tgordonjr

An MCP server for Snowflake providing tools for Cortex AI features like Search, Analyst, and Complete.

πŸ”₯πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeQuick setup

Snowflake Cortex AI Model Context Protocol (MCP) Server

<a href="https://emerging-solutions-toolbox.streamlit.app/"> <img src="https://github.com/user-attachments/assets/aa206d11-1d86-4f32-8a6d-49fe9715b098" alt="image" width="150" align="right";"> </a>

This Snowflake MCP server provides tooling for Snowflake Cortex AI features, bringing these capabilities to the MCP ecosystem. When connected to an MCP Client (e.g. Claude for Desktop, fast-agent, Agentic Orchestration Framework), users can leverage these Cortex AI features.

The MCP server currently supports the below Cortex AI capabilities:

  • Cortex Search: Query unstructured data in Snowflake as commonly used in Retrieval Augmented Generation (RAG) applications.
  • Cortex Analyst: Query structured data in Snowflake via rich semantic modeling.
  • Cortex Complete: Simple chat-completion with optional parameters using a number of available LLMs
  • Cortex Agent: (Coming Soon) Agentic orchestrator across structured and unstructured data retrieval

Getting Started

Snowflake Account Identifier

A Snowflake username and account identifier will be necessary to connect. From Snowsight, select your user name and Connect a tool to Snowflake to obtain your Snowflake account identifier. This will be passed to the server at startup.

Programmatic Access Token Authentication

The MCP server uses Snowflake Programmatic Access Token (PAT) for authentication. Follow the instructions to generate a new PAT for a given user. Be sure to copy the token - it will be passed to the server at startup.

[!IMPORTANT] PATs do not use secondary roles. Either select a specific role that has access to all desired services and their related objects OR select Any of my roles.

Using with MCP Clients

The MCP server is client-agnostic and will work with most MCP Clients that support basic functionality for MCP tools and (optionally) resources. Below are some examples.

Cursor

Register the MCP server in cursor by opening Cursor and navigating to Settings -> Cursor Settings -> MCP. Add the below.

{
  "mcpServers": {
    "mcp-server-snowflake": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/Snowflake-Labs/mcp",
        "mcp-server-snowflake",
        "--service-config-file",
        "<path to file>/service_config.yaml",
        "--account-identifier",
        "<account-identifier>",
        "--username",
        "<username>",
        "--pat",
        "<programmatic_access_token>"
      ]
    }
  }
}

Add the MCP server as context in the chat.

<img src="./images/Cursor.gif" width="800" height="500"/>

For troubleshooting Cursor server issues, view the logs by opening the Output panel and selecting Cursor MCP from the dropdown menu.

fast-agent

Update the fastagent.config.yaml mcp server section with an updated path to the configuration file.

# MCP Servers
mcp:
    servers:
        mcp-server-snowflake:
            command: "uvx"
            args: ["--from", "git+https://github.com/Snowflake-Labs/mcp", "mcp-server-snowflake", "--service-config-file", "<path to file>/service_config.yaml"]

Update the fastagent.secrets.yaml mcp server section with environment variables.

mcp:
    servers:
        mcp-server-snowflake:
            env:
                SNOWFLAKE_PAT: <add-PAT>
                SNOWFLAKE_ACCOUNT: <add-snowflake-account-identifier>
                SNOWFLAKE_USER: <add-snowflake-username>
<img src="./images/fast-agent.gif" width="800" height="500"/>

Troubleshooting