snippy

Azure-Samples/snippy

3.5

If you are the rightful owner of snippy and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

Snippy is a serverless code snippet management service using Azure Functions, Durable Functions, Azure OpenAI, Microsoft Fabric, and Azure AI Agents.

Tools
4
Resources
0
Prompts
0


Snippy Ā· Intelligent Code-Snippet Service with MCP Tools

Open in GitHub Codespaces Open in Dev Containers

Snippy is an Azure Functions-based reference application that demonstrates how to build MCP (Model Context Protocol) tools that integrate with AI assistants like GitHub Copilot. The sample implements an intelligent code-snippet service featuring:

  • MCP Tool Integration – expose Azure Functions as discoverable tools for AI assistants
  • Durable Agents – create stateful AI agents using Microsoft Agent Framework with automatic state management
  • Multi-Agent Orchestration – coordinate DeepWiki and CodeStyle agents using Durable Task Scheduler
  • Vector Search – semantic retrieval using Cosmos DB DiskANN with Azure OpenAI embeddings
  • Monitoring & Observability – track orchestrations in real-time with DTS dashboard (local & cloud)

The project ships with reproducible azd infrastructure, so azd up will stand up the entire stack – Functions, Cosmos DB, Azure OpenAI, and Durable Task Scheduler – in a single command.

Important Security Notice This repository is intended for learning and demonstration purposes. Do not deploy it to production without a thorough security review. At a minimum you should:

  • Swap connection strings for Managed Identity + AzureĀ Key Vault
  • Restrict network access to Azure services via PrivateĀ Endpoints or service‑tags
  • Enable GitHub secret‑scanning andĀ CI security tools

Features • Architecture • GettingĀ Started • Guidance


Recent Updates

  • Durable Task Scheduler (DTS) integration for cloud orchestration and monitoring
  • DTS dashboard scripts: Quickly generate monitoring URLs for Azure deployments (scripts/get-dts-dashboard-url.sh and .ps1)
  • Multi-agent orchestration: Coordinate DeepWiki and CodeStyle agents with Durable Functions
  • Enhanced monitoring: View orchestration state in local DTS emulator or Azure DTS dashboard

Features

  • MCP Tool Integration – expose Azure Functions as discoverable MCP tools for AI assistants
  • Durable Agents with Microsoft Agent Framework – build stateful AI agents using ChatAgent with automatic conversation history management
  • Multi-Agent Orchestration – coordinate specialized agents (DeepWiki, CodeStyle) using Durable Task Scheduler with fan-out/fan-in patterns
  • Vector Search on Cosmos DB DiskANN – semantic code retrieval using Azure OpenAI embeddings and low-latency vector indexing
  • Monitoring & Observability – track orchestrations in real-time using DTS dashboard (localhost:8082 local, Azure portal for cloud)
  • One-click Deploy – azd up provisions and deploys complete infrastructure including Functions, Cosmos DB, Azure OpenAI, and DTS
  • Codespaces & Dev Containers – fully configured development environment in your browser or local VS Code

Tool Matrix

Tool NamePurpose
save_snippetSave code snippets with vector embeddings for semantic search
get_snippetRetrieve previously saved code snippets by their unique name
code_styleGenerate language-specific code style guides from saved snippets
deep_wikiCreate comprehensive wiki documentation by analyzing code snippets
generate_comprehensive_documentationOrchestrate multi-agent workflow to produce deep wiki and style guide

Architecture Diagram

Snippy Architecture


GettingĀ Started

You can run Snippy in GitHubĀ Codespaces, VSĀ CodeĀ DevĀ Containers, or your local environment. The fastest path is Codespaces.

Snippy requires an Azure region that supports text‑embedding‑3‑small (or a compatible embeddings model) and AzureĀ AIĀ Agents. The azd workflow prompts you for a region; we recommend eastus for best availability.

GitHubĀ Codespaces

  1. Click Open inĀ Codespaces above (first badge) – the container build may take a few minutes.

  2. When the terminal appears, sign in:

    azd auth login --use-device-code
    
  3. Launch the stack:

    azd up
    
  4. Once deployment completes, copy the printed MCP URL and open GitHubĀ CopilotĀ Chat → Agent mode to try commands like ā€œSave this snippet as hello‑worldā€.

VSĀ CodeĀ DevĀ Containers

Prerequisites: DockerĀ Desktop + the DevĀ Containers extension.

  1. Click the DevĀ Containers badge (second badge) or run Remote‑Containers:Ā OpenĀ Repository inĀ Container from VSĀ Code.

  2. SignĀ in and launch as shown for Codespaces:

    azd auth login
    azd up
    

LocalĀ Environment

Prerequisites
  • azdĀ CLI
  • PythonĀ 3.11 + uv
  • NodeĀ 18+ (for Functions CoreĀ Tools)
  • Azure FunctionsĀ CoreĀ ToolsĀ v4 (npmĀ iĀ -gĀ azure-functions-core-tools@4Ā --unsafe-perm)
Quickstart
# 1. Clone & init
azd init --template Azure-Samples/snippy

# 2. Sign in
azd auth login

# 3. Provision & deploy
azd up

The CLI will automatically:

  • Create an Azure AD app registration for OAuth authentication
  • Provision all Azure resources (Functions, Cosmos DB, OpenAI, etc.)
  • Deploy the application code

The CLI prints the Function App URL, MCP endpoint and system key when finished. To remove all resources later:

azd down --purge

Note: The first run automatically creates an Azure AD app registration with OAuth2 scope access_as_user for authentication.

Local Development with Emulators

For local development, Snippy uses the Durable Task Scheduler (DTS) emulator and Azurite for storage.

With Docker (Recommended)

The easiest way to run both emulators:

# Start both emulators
docker compose up -d

# Generate local.settings.json from your Azure environment
./scripts/generate-settings.sh

# Run the Functions app
```mermaid
flowchart LR
  subgraph mcphosts["MCP Hosts & Clients (Your Computer)"]
    Host["Host (VS Code / IDE)"]
    Client["Client (GitHub Copilot)"]
  end
  Host --"MCP Protocol"--> Client
  Client --"Tool Discovery"--> FunctionApp["Function App (MCP Server)"]
  FunctionApp --"Orchestrate"--> DTS["Durable Task Scheduler"]
  DTS --"Agent Calls"--> Agents["Durable Agents<br/>DeepWiki Ā· CodeStyle"]
  FunctionApp --"Vector Search"--> CosmosDB
  Agents --"Vector Search"--> CosmosDB
  FunctionApp --"Embeddings"--> OpenAI["Azure OpenAI"]
  Agents --"LLM Calls"--> OpenAI
  DTS --"Dashboard"--> User["Developer/Monitor"]

Monitoring & Orchestration

  • Local development: Monitor orchestrations at http://localhost:8082/ when using the DTS emulator
  • Azure deployment: Use the DTS dashboard scripts to generate monitoring URLs:
    • Bash: ./scripts/get-dts-dashboard-url.sh
    • PowerShell: .\scripts\get-dts-dashboard-url.ps1
  • View multi-agent orchestration execution, including DeepWiki and CodeStyle agent calls
  • Track tool invocations, state transitions, and execution timelines


To switch back to DTS when Docker becomes available:

```bash
./scripts/switch-storage-backend.sh dts

For detailed setup instructions and troubleshooting, see .


Guidance

RegionĀ Availability

AzureĀ OpenAI model support varies by region. Verify availability here and choose the same region for all Azure resources. eastus and swedencentral are good default choices.

Security

Snippy uses User-Assigned Managed Identity for secure service-to-service authentication. The infrastructure is configured with:

  • User-Assigned Managed Identity on the Function App with appropriate RBAC roles:
    • Cosmos DB Data Contributor
    • Storage Blob Data Owner and Queue Data Contributor
    • Application Insights Monitoring Metrics Publisher
    • Azure AI Project Developer

For production deployments, we recommend:

  • Restrict inbound traffic with Private Endpoints + VNet integration
  • Enable network security features like service endpoints and firewall rules

Contributing

Standard fork → branch → PR workflow. Use ConventionalĀ Commits (feat:, fix:) in commit messages.


License

MIT © Microsoft Corporation