Sponsored by Deepsite.site

Snippy

Created By
Azure-Samples8 months ago
🧩 Demo: Build AI-powered MCP Tools for GitHub Copilot using Azure Functions, OpenAI, AI Agents & Cosmos DB. Manages code snippets w/ vector search.
Content

Snippy logo
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 turns any function into an MCP (Model Context Protocol) tool consumable by GitHub Copilot Chat and other MCP‑aware clients. The sample implements a production‑style code‑snippet service with AI‑powered analysis:

  • Save snippets – persists code, metadata and OpenAI embeddings in Cosmos DB DiskANN
  • Semantic retrieve – vector search over embeddings
  • AI Agents – generate a deep wiki or language‑specific code style guide from stored snippets
  • Durable fan‑out/fan‑in with Blueprintsin experimental branch for large‑scale processing
  • Microsoft Fabric integrationin gk/fabric branch demonstrating how to build Agents with Fabric Data Agents

The project ships with reproducible azd infrastructure, so azd up will stand up the entire stack – Functions, Cosmos DB, Azure OpenAI and Azure AI Agents – 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


Features

  • Remote MCP trigger – expose Functions as real‑time SSE tools
  • AI‑assisted documentation – "deep‑wiki" and "code‑style" agents create rich Markdown (Mermaid, diagrams, etc.)
  • Vector search on Cosmos DB DiskANN – low‑latency semantic retrieval
  • One‑click deployazd up provisions and deploys code & infra
  • Codespaces & Dev Containers – fully configured dev 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

Architecture Diagram

Snippy Architecture

flowchart LR
    %% ─── MCP Hosts & Clients (local) ──────────────────────────────
    subgraph mcphosts["MCP Hosts & Clients (Your Computer)"]
        Host["Host<br/>(VS Code / IDE)"]
        Client["Client<br/>(GitHub Copilot)"]
    end

    %% ─── Application on Azure (remote) ────────────────────────────
    subgraph app["Application (Azure)"]
        Snippy["MCP Server<br/>Snippy Triggers<br/>(Function App)"]:::dashed
        Foundry["Foundry Agent<br/>Deep Wiki · Code Style"]
        Cosmos["Cosmos DB<br/>Operational + Vector DB"]:::datasource
        AOAI["Azure OpenAI<br/>text‑embedding‑3‑small"]
        FabricDA["Fabric – Data Agent"]
        VectorTool["Tools – Vector Search"]
    end

    %% ─── Local interactions ───────────────────────────────────────
    Host <--> Client

    %% ─── MCP protocol to Azure ────────────────────────────────────
    Client <-- "MCP Protocol (SSE)" --> Snippy

    %% ─── Bindings & data flow inside Azure ────────────────────────
    Snippy -- Bindings --> AOAI
    Snippy --> Cosmos
    Snippy --> Foundry
    Foundry --> FabricDA
    Foundry --> VectorTool

    %% ─── Styling ──────────────────────────────────────────────────
    classDef datasource stroke-width:2,stroke-dasharray:5 5
    classDef dashed stroke-width:2,stroke-dasharray:5 5,fill:transparent
    class Cosmos datasource
    class Snippy dashed
    style mcphosts fill:transparent
    style app fill:transparent

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 prints the Function App URL, MCP endpoint and system key when finished. To remove all resources later:

azd down --purge

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.

Costs

Estimate monthly cost using the Azure Pricing Calculator. Major components:

  • Azure Functions – Consumption / Flex tiers
  • Cosmos DB – Serverless or provisioned throughput
  • Azure OpenAI – pay‑as‑you‑go per 1K tokens
  • Azure AI Agents – per‑execution billing (preview)

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

Resources


Contributing

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


License

MIT © Microsoft Corporation

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
CursorThe AI Code Editor
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Playwright McpPlaywright MCP server
Tavily Mcp
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
WindsurfThe new purpose-built IDE to harness magic
DeepChatYour AI Partner on Desktop
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
ChatWiseThe second fastest AI chatbot™
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Amap Maps高德地图官方 MCP Server
Serper MCP ServerA Serper MCP Server
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.