|
| 1 | +# Quick Reference |
| 2 | + |
| 3 | +Essential commands and tips for working with Snippy. |
| 4 | + |
| 5 | +## Setup Commands |
| 6 | + |
| 7 | +### Initial Setup |
| 8 | + |
| 9 | +```bash |
| 10 | +# Clone the repository |
| 11 | +git clone https://github.com/Azure-Samples/snippy.git |
| 12 | +cd snippy |
| 13 | + |
| 14 | +# Login to Azure |
| 15 | +az login |
| 16 | + |
| 17 | +# Login to Azure Developer CLI |
| 18 | +azd auth login |
| 19 | +``` |
| 20 | + |
| 21 | +### Create Environment |
| 22 | + |
| 23 | +```bash |
| 24 | +# Create a unique azd environment |
| 25 | +azd env new snippymcplab-<unique-suffix> --subscription <your-subscription-id> |
| 26 | + |
| 27 | +# Set name suffix |
| 28 | +azd env set NAME_SUFFIX <unique-suffix> |
| 29 | + |
| 30 | +# Provision Azure resources (takes 5-10 minutes) |
| 31 | +azd provision |
| 32 | +``` |
| 33 | + |
| 34 | +### Python Setup |
| 35 | + |
| 36 | +```bash |
| 37 | +# Navigate to src directory |
| 38 | +cd src |
| 39 | + |
| 40 | +# Create virtual environment with uv |
| 41 | +uv venv .venv |
| 42 | + |
| 43 | +# Activate virtual environment |
| 44 | +source .venv/bin/activate # macOS/Linux |
| 45 | +.venv\Scripts\Activate.ps1 # Windows PowerShell |
| 46 | +.venv\Scripts\activate.bat # Windows CMD |
| 47 | + |
| 48 | +# Install dependencies |
| 49 | +uv pip install -r requirements.txt |
| 50 | +``` |
| 51 | + |
| 52 | +### Start Local Development |
| 53 | + |
| 54 | +```bash |
| 55 | +# Start Docker services (from root directory) |
| 56 | +docker compose up -d |
| 57 | + |
| 58 | +# Start Functions host (from src directory) |
| 59 | +cd src |
| 60 | +func start |
| 61 | +``` |
| 62 | + |
| 63 | +## Common Tasks |
| 64 | + |
| 65 | +### Regenerate Settings |
| 66 | + |
| 67 | +```bash |
| 68 | +# From repository root |
| 69 | +./scripts/generate-settings.sh # macOS/Linux |
| 70 | +.\scripts\generate-settings.ps1 # Windows |
| 71 | +``` |
| 72 | + |
| 73 | +### Deploy to Azure |
| 74 | + |
| 75 | +```bash |
| 76 | +# From repository root |
| 77 | +azd deploy |
| 78 | +``` |
| 79 | + |
| 80 | +### Get Function App Details |
| 81 | + |
| 82 | +```bash |
| 83 | +# Get function app name |
| 84 | +azd env get-value AZURE_FUNCTION_NAME |
| 85 | + |
| 86 | +# Get resource group |
| 87 | +azd env get-value AZURE_RESOURCE_GROUP |
| 88 | + |
| 89 | +# Get MCP system key |
| 90 | +az functionapp keys list \ |
| 91 | + -n $(azd env get-value AZURE_FUNCTION_NAME) \ |
| 92 | + -g $(azd env get-value AZURE_RESOURCE_GROUP) \ |
| 93 | + --query "systemKeys.mcp_extension" \ |
| 94 | + --output tsv |
| 95 | +``` |
| 96 | + |
| 97 | +### View Logs |
| 98 | + |
| 99 | +```bash |
| 100 | +# Local function logs |
| 101 | +# (visible in terminal where `func start` is running) |
| 102 | + |
| 103 | +# Docker container logs |
| 104 | +docker compose logs |
| 105 | + |
| 106 | +# Azure function logs |
| 107 | +func azure functionapp logstream <function-app-name> |
| 108 | +``` |
| 109 | + |
| 110 | +## MCP Configuration |
| 111 | + |
| 112 | +### Local MCP Server |
| 113 | + |
| 114 | +In `.vscode/mcp.json`: |
| 115 | + |
| 116 | +```json |
| 117 | +{ |
| 118 | + "mcpServers": { |
| 119 | + "local-snippy": { |
| 120 | + "type": "sse", |
| 121 | + "url": "http://localhost:7071/runtime/webhooks/mcp" |
| 122 | + } |
| 123 | + } |
| 124 | +} |
| 125 | +``` |
| 126 | + |
| 127 | +### Remote MCP Server |
| 128 | + |
| 129 | +After deployment, update `.vscode/mcp.json`: |
| 130 | + |
| 131 | +```json |
| 132 | +{ |
| 133 | + "mcpServers": { |
| 134 | + "remote-snippy": { |
| 135 | + "type": "sse", |
| 136 | + "url": "https://<function-app-name>.azurewebsites.net/runtime/webhooks/mcp", |
| 137 | + "headers": { |
| 138 | + "x-functions-key": "<mcp-system-key>" |
| 139 | + } |
| 140 | + } |
| 141 | + } |
| 142 | +} |
| 143 | +``` |
| 144 | + |
| 145 | +## Copilot Commands |
| 146 | + |
| 147 | +### Using MCP Tools |
| 148 | + |
| 149 | +``` text |
| 150 | +# Save a snippet |
| 151 | +#local-snippy save this snippet as my-snippet-name |
| 152 | +
|
| 153 | +# Retrieve a snippet |
| 154 | +#local-snippy get the snippet named my-snippet-name |
| 155 | +
|
| 156 | +# Generate documentation |
| 157 | +#local-snippy generate a deep wiki for all snippets |
| 158 | +
|
| 159 | +# Create style guide |
| 160 | +#local-snippy create a code style guide based on saved snippets |
| 161 | +
|
| 162 | +# Multi-agent orchestration |
| 163 | +#local-snippy generate comprehensive documentation |
| 164 | +``` |
| 165 | + |
| 166 | +## Testing Endpoints |
| 167 | + |
| 168 | +### Using VS Code REST Client |
| 169 | + |
| 170 | +Open `src/tests/test.http` and click "Send Request" above any request. |
| 171 | + |
| 172 | +### Using curl |
| 173 | + |
| 174 | +```bash |
| 175 | +# Save a snippet |
| 176 | +curl -X POST http://localhost:7071/api/snippets \ |
| 177 | + -H "Content-Type: application/json" \ |
| 178 | + -d '{"name":"test","code":"print(\"hello\")","projectId":"default"}' |
| 179 | + |
| 180 | +# Get a snippet |
| 181 | +curl http://localhost:7071/api/snippets/test |
| 182 | +``` |
| 183 | + |
| 184 | +## Troubleshooting Quick Fixes |
| 185 | + |
| 186 | +### Port Already in Use |
| 187 | + |
| 188 | +```bash |
| 189 | +# Kill process on port 7071 |
| 190 | +lsof -ti:7071 | xargs kill -9 # macOS/Linux |
| 191 | +Get-Process -Id (Get-NetTCPConnection -LocalPort 7071).OwningProcess | Stop-Process # Windows |
| 192 | +``` |
| 193 | + |
| 194 | +### Docker Not Running |
| 195 | + |
| 196 | +```bash |
| 197 | +# Check Docker status |
| 198 | +docker ps |
| 199 | + |
| 200 | +# Restart Docker Desktop app if needed |
| 201 | +``` |
| 202 | + |
| 203 | +### Virtual Environment Issues |
| 204 | + |
| 205 | +```bash |
| 206 | +# Deactivate and recreate |
| 207 | +deactivate |
| 208 | +rm -rf .venv |
| 209 | +uv venv .venv |
| 210 | +source .venv/bin/activate # or Windows equivalent |
| 211 | +uv pip install -r requirements.txt |
| 212 | +``` |
| 213 | + |
| 214 | +### MCP Not Connecting |
| 215 | + |
| 216 | +1. Command Palette → `MCP Tools: Reset Cached Tools` |
| 217 | +2. Restart VS Code |
| 218 | +3. Check `.vscode/mcp.json` configuration |
| 219 | +4. View logs: Command Palette → `MCP: List Servers` → Show Output |
| 220 | + |
| 221 | +## Cleanup |
| 222 | + |
| 223 | +### Full Cleanup |
| 224 | + |
| 225 | +```bash |
| 226 | +# Delete all Azure resources |
| 227 | +azd down --purge --force |
| 228 | + |
| 229 | +# Stop Docker containers |
| 230 | +docker compose down -v |
| 231 | + |
| 232 | +# Remove local config |
| 233 | +rm -rf .azure |
| 234 | +``` |
| 235 | + |
| 236 | +### Verify Cleanup |
| 237 | + |
| 238 | +```bash |
| 239 | +# Check resource group is deleted |
| 240 | +az group list --output table |
| 241 | + |
| 242 | +# Check Docker containers stopped |
| 243 | +docker ps |
| 244 | +``` |
| 245 | + |
| 246 | +## Useful Links |
| 247 | + |
| 248 | +- **Azure Portal**: https://portal.azure.com |
| 249 | +- **Microsoft Foundry**: https://ai.azure.com |
| 250 | +- **MCP Inspector**: `npx @modelcontextprotocol/inspector` |
| 251 | +- **DTS Dashboard** (local): http://localhost:8082 |
| 252 | +- **Azurite Blob Storage** (local): http://127.0.0.1:10000 |
| 253 | + |
| 254 | +## File Locations |
| 255 | + |
| 256 | +- **Function code**: `src/function_app.py` |
| 257 | +- **Agent code**: `src/durable_agents.py` |
| 258 | +- **Tools**: `src/tools/vector_search.py` |
| 259 | +- **Settings**: `src/local.settings.json` |
| 260 | +- **MCP config**: `.vscode/mcp.json` |
| 261 | +- **Docker config**: `docker-compose.yml` |
| 262 | +- **Infrastructure**: `infra/main.bicep` |
| 263 | + |
| 264 | +## Next Steps |
| 265 | + |
| 266 | +1. **Complete the tutorial**: See [TUTORIAL.md](./TUTORIAL.md) |
| 267 | +2. **Having issues?**: Check [TROUBLESHOOTING.md](./TROUBLESHOOTING.md) |
0 commit comments