This project implements a Model Context Protocol (MCP) server for seamless integration with Snowflake Cortex APIs. It enables developers to access Snowflake Cortex insights directly within their development environments, such as Visual Studio Code (VSCode).
If you do not have VSCode installed, you can download it here.
Important
- Disclaimer: This project is experimental and intended for development and evaluation purposes only. It is not officially supported by Snowflake.
- This is still a work in progress and may not be suitable for production use. Use at your own risk.
- Python 3.12+
- Docker Desktop (ensure MCP is enabled)
- Snowflake Account
Ensure you have Snowflake CLI installed and configured with your account details. Preferred to have user with ACCOUNTADMIN
role to create the required database objects, before strip down to fine-grained access control for the MCP demo.
Important
Edit the scripts/data/support_tickets.yaml
and update the KAMESH_MCP_DEMO
to match your DB that you will be using for the demo i.e $SNOWFLAKE_MCP_DEMO_DATABASE
.
Run the following SQL commands in your Snowflake account to create the necessary database objects:
./scripts/setup.sh
We will be using a programmatic access token to authenticate with the Snowflake Cortex APIs. You can create a token by following these steps:
./scripts/pat.sh
Verify if the programmatic access token is created successfully and working:
snow connection test -x \
--user "$SA_USER" \
--role "$SNOWFLAKE_MCP_DEMO_ROLE"
Verify if the service user is able to access the database objects created in the previous step:
curl --location \
"https://$SNOWFLAKE_ACCOUNT.snowflakecomputing.com/api/v2/databases/$SNOWFLAKE_MCP_DEMO_DATABASE/schemas/data/cortex-search-services/invoice_search_service:query" \
--header 'X-Snowflake-Authorization-Token-Type: PROGRAMMATIC_ACCESS_TOKEN' \
--header 'Content-Type: application/json' --header 'Accept: application/json' \
--header "Authorization: Bearer $SNOWFLAKE_PASSWORD" \
--data '{ "query": "What kind of service does Gregory have?","columns": ["CHUNK",
"FILE_NAME"],"limit": 1}'
Click "Install Cortex Agent Server" badge
(OR)
Run the Snowflake Cortex MCP Server using Docker, follow these steps:
-
Pull the Docker image:
docker pull ghcr.io/kameshsampath/snowflake-cortex-mcp/server:latest
-
Run the Docker container:
There is a
.env.template
file in the repository that you can copy to.env
and fill in the required values for your Snowflake account, user, password, warehouse, semantic model file, Cortex search service, and LLM model. This will help you avoid typing them directly in the command line.docker run -it --rm --name snowflake-cortex-agent \ --env-file .env \ ghcr.io/kameshsampath/snowflake-cortex-mcp/server:latest
This command will start the Snowflake Cortex MCP Server in a Docker container, allowing you to interact with it using the Model Context Protocol.
Now from any MCP compatible client, such as VSCode or Claude Desktop, add the following MCP server configuration:
{
"mcpServers": {
"snowflake-cortex-agent": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--name",
"snowflake-cortex-agent",
"-e",
"SNOWFLAKE_ACCOUNT_URL",
"-e",
"SNOWFLAKE_USER",
"-e",
"SNOWFLAKE_PASSWORD",
"-e",
"SEMANTIC_MODEL_FILE",
"-e",
"CORTEX_SEARCH_SERVICE",
"-e",
"SNOWFLAKE_WAREHOUSE",
"-e",
"CORTEX_AGENT_LLM_MODEL",
"ghcr.io/kameshsampath/snowflake-cortex-mcp/server:latest"
],
"env": {
"SNOWFLAKE_ACCOUNT_URL": "https://${input:snowflake_account}.snowflakecomputing.com",
"SNOWFLAKE_USER": "${input:snowflake_user}",
"SNOWFLAKE_PASSWORD": "${input:snowflake_password}",
"SEMANTIC_MODEL_FILE": "${input:semantic_model_file}",
"CORTEX_SEARCH_SERVICE": "${input:cortex_search_service}",
"SNOWFLAKE_WAREHOUSE": "${input:snowflake_warehouse}",
"CORTEX_AGENT_LLM_MODEL": "${input:cortex_agent_llm_model}"
}
}
}
}
Tip
The repo already has one .vscode/mcp.json that helps you get started with the MCP server configuration in VSCode.
To build and run the Snowflake Cortex MCP Server locally using uv:
-
Clone the repository:
git clone https://github.com/kameshsampath/snowflake-cortex-mcp-server.git cd snowflake-cortex-mcp-server
-
Create and activate a Python virtual environment:
uv venv source .venv/bin/activate
-
Install dependencies with uv:
uv sync
-
Set required environment variables:
export SNOWFLAKE_ACCOUNT_URL="https://<your_account>.snowflakecomputing.com" export SNOWFLAKE_USER="<your_username>" export SNOWFLAKE_PASSWORD="<your_password>" export SNOWFLAKE_WAREHOUSE="<your_warehouse>" export SEMANTIC_MODEL_FILE="<stage_path_to_semantic_model>" export CORTEX_SEARCH_SERVICE="<cortex_search_service_name>" export CORTEX_AGENT_LLM_MODEL="<llm_model_name>"
-
Run the MCP server:
uv run snowflake_cortex_mcp_server
The server should now be running locally and ready to accept MCP requests.