# MCP Ski Resort


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

## Install

``` bash
pip install -e ".[dev]"

# For async support (httpx)
pip install -e ".[async]"
```

## Architecture

The notebooks are the source of truth for both the library code and
documentation.

    Snowflake-MCP/
    ├── 00_core.ipynb            # Library: JWT auth, SSE streaming, normalization, threads
    ├── 01_async.ipynb           # Library: Async transport (httpx)
    ├── 02_mcp_client.ipynb      # Library: MCP JSON-RPC client & display helpers
    ├── 03_agent_streaming.ipynb  # Demo: Cortex Agent SSE streaming
    ├── 04_see_pattern.ipynb     # Demo: Search-Enrich-Execute pattern
    ├── 05_mcp_client_demo.ipynb # Demo: Full MCP client walkthrough
    ├── index.ipynb              # This file → README.md
    ├── mcp_ski_resort/          # Python package (auto-generated by nbdev-export)
    │   ├── core.py
    │   ├── astream.py
    │   └── mcp_client.py
    ├── sql/                     # DDL scripts for Snowflake setup
    └── tests/                   # Integration test scripts

**Notebooks 00–02** export the `mcp_ski_resort` library via `#| export`
directives.  
**Notebooks 03–04** are demo notebooks that showcase the library API.

## Library Modules

<table>
<colgroup>
<col style="width: 26%" />
<col style="width: 33%" />
<col style="width: 40%" />
</colgroup>
<thead>
<tr>
<th>Module</th>
<th>Notebook</th>
<th>Highlights</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>mcp_ski_resort.core</code></td>
<td><code>00_core</code></td>
<td>JWT auth, <code>SnowflakeSession</code>,
<code>stream_agent_sse</code>, <code>normalize_event</code>,
<code>run_agent</code>, <code>AgentChat</code>,
<code>create_thread</code>, thread-mode conversations</td>
</tr>
<tr>
<td><code>mcp_ski_resort.astream</code></td>
<td><code>01_async</code></td>
<td>Async equivalents via <code>httpx</code>:
<code>async_run_agent</code>, <code>AsyncAgentChat</code>,
<code>async_stream_agent_sse</code>. Install with
<code>pip install mcp-ski-resort[async]</code></td>
</tr>
<tr>
<td><code>mcp_ski_resort.mcp_client</code></td>
<td><code>02_mcp_client</code></td>
<td>MCP JSON-RPC client (<code>MCPClient</code>, <code>mcp_call</code>,
<code>display_mcp_result</code>)</td>
</tr>
</tbody>
</table>

## MCP Server Tools

The Alpine Mountain MCP Server (`SKI_RESORT_MCP`) exposes 10 tools
across 5 Snowflake tool types:

<table>
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr>
<th>Tool Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>daily-summary-analyst</code></td>
<td>CORTEX_ANALYST_TEXT_TO_SQL</td>
<td>Natural-language queries over daily operations</td>
</tr>
<tr>
<td><code>revenue-analyst</code></td>
<td>CORTEX_ANALYST_TEXT_TO_SQL</td>
<td>Revenue and financial analytics</td>
</tr>
<tr>
<td><code>operations-analyst</code></td>
<td>CORTEX_ANALYST_TEXT_TO_SQL</td>
<td>Operational metrics and staffing</td>
</tr>
<tr>
<td><code>resort-executive-agent</code></td>
<td>CORTEX_AGENT_RUN</td>
<td>Executive-level analysis with multi-step reasoning</td>
</tr>
<tr>
<td><code>ski-ops-assistant</code></td>
<td>CORTEX_AGENT_RUN</td>
<td>Operational assistant for ski patrol and lifts</td>
</tr>
<tr>
<td><code>feedback-search</code></td>
<td>CORTEX_SEARCH_SERVICE_QUERY</td>
<td>Semantic search over 3,937 guest feedback records</td>
</tr>
<tr>
<td><code>incident-search</code></td>
<td>CORTEX_SEARCH_SERVICE_QUERY</td>
<td>Semantic search over 2,834 safety incidents</td>
</tr>
<tr>
<td><code>execute-sql</code></td>
<td>SYSTEM_EXECUTE_SQL</td>
<td>Run ad-hoc SQL against AM_SKI_RESORT</td>
</tr>
<tr>
<td><code>resort-kpi-summary</code></td>
<td>GENERIC</td>
<td>KPI dashboard UDF (season parameter)</td>
</tr>
<tr>
<td><code>weather-impact-report</code></td>
<td>GENERIC</td>
<td>Weather impact analysis UDF (date range)</td>
</tr>
<tr>
<td><code>weather-impact-report</code></td>
<td>GENERIC</td>
<td>Weather impact analysis UDF</td>
</tr>
</tbody>
</table>

## Quick Start

### Sync — Agent streaming

``` python
from mcp_ski_resort.core import run_agent, AgentChat

# One-shot call
result = run_agent("RESORT_EXECUTIVE", "How did we perform this season?")
print(result.answer)

# Multi-turn conversation (local history)
chat = AgentChat("RESORT_EXECUTIVE")
chat.ask("What are our top KPIs?")
chat.ask("Compare with last season")  # history sent automatically

# Multi-turn with server-side threads
from mcp_ski_resort.core import create_thread
tid = create_thread()
chat = AgentChat("RESORT_EXECUTIVE", thread_id=tid)
chat.ask("What are our top KPIs?")  # server owns continuity
```

### Async

``` python
from mcp_ski_resort.astream import async_run_agent, AsyncAgentChat

result = await async_run_agent("RESORT_EXECUTIVE", "Season summary")
```

### MCP client

``` python
from mcp_ski_resort.mcp_client import mcp_tools_list, mcp_call, display_mcp_result

tools = mcp_tools_list()
resp = mcp_call("resort-executive-agent", {"message": "Season summary"})
display_mcp_result(resp, label="Executive Summary")
```

## Prerequisites

See [PREREQUISITES.md](PREREQUISITES.md) for full setup instructions
including:

- Snowflake account with Cortex Agents, Search, and Analyst
- RSA key-pair authentication configured
- SQL setup scripts in `sql/` for creating search services, UDFs, and
  the MCP server
