Skip to content

Repository files navigation

Snowflake Cortex Agent MCP Server

A Model Context Protocol (MCP) server that enables seamless integration with Snowflake Cortex Agents and Analysts. This server allows you to query your Snowflake data using natural language through VS Code, Claude Desktop, or any MCP-compatible client.

This repo is specifically designed for VS Code/Copilot version.

🚀 Quick Start

Prerequisites

  • Python 3.11 or higher
  • UV package manager (pip install uv)
  • VS Code with MCP extension (Setup Link)
  • Access to a Snowflake account with Cortex features enabled
  • Cortex Agent created in your Snowflake account

Set up

  1. First install the MCP CLI (uv) and bootstrap your project:
    curl -LsSf https://astral.sh/uv/install.sh | sh
  2. Configure and create your Cortex Agents project:
     git clone https://github.com/xero-internal/snowflake-mcp-hackathon.git
     cd snowflake-mcp-hackathon
    
     # Create and activate venv
     uv venv
     source .venv/bin/activate   # macOS/Linux
    
     # Install MCP SDK and HTTP client
     uv add "mcp[cli]" httpx

Installation

  1. Clone and setup the project:

    uv sync
  2. Configure environment variables:

    cp .env.template .env
    # Edit .env with your Snowflake configuration
  3. Configure VS Code MCP settings:

    1. First follow this page to set up your MCP Client on VS Code: https://xero.atlassian.net/wiki/spaces/EngX/pages/270817986206/Setup+GitHub+Copilot+on+VS+Code

    2. Add to your VS Code mcp.json (Command Palette → "MCP: Edit Configuration"):

    {
      "servers": {
        "cortex-agent": {
         "command": "/opt/homebrew/bin/uv",
         "args": [
           "--directory",
           "<absolute-path-to-snowflake-mcp-hackathon-foloder>",
           "run",
           "python",
           "server.py"
         ]
       }
       }
     }

Logging & Monitoring

The MCP server provides comprehensive logging to help you debug, monitor, and analyze all interactions with Snowflake Cortex Agents.

Log Files

The server automatically generates two types of log files in the utils/logs/ directory:

  1. Protocol Logs (mcp_protocol_YYYYMMDD_HHMMSS.log)

    • Records all MCP tool requests and responses
    • Includes request arguments, response data, and execution times
    • Perfect for debugging and monitoring tool usage
    • Human-readable format with clear separators
  2. Debug Logs (mcp_server_detailed_YYYYMMDD_HHMMSS.log)

    • Detailed technical logs including internal server operations
    • Python stack traces for errors
    • System-level debugging information

Viewing Logs

Option 1: Use log files

View logs directly in terminal:

# View latest protocol log
tail -f utils/logs/mcp_protocol_*.log

# View all logs from today
cat utils/logs/mcp_protocol_$(date +%Y%m%d)_*.log

# Search for specific tool usage
grep -n "run_cortex_agent" utils/logs/mcp_protocol_*.log
Option 2: VS Code

Open log files directly in VS Code for syntax highlighting and search:

code utils/logs/

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages