Skip to content

CRITICAL: azure-prepare deleted user workspace when adding MCP support #998

@paulyuk

Description

@paulyuk

Severity: CRITICAL

User's existing project was deleted when asking to add MCP support to an existing function.

What Happened

  1. User had working Azure Function deployed at ~/random-func/
  2. User asked: "make this an MCP server and redeploy"
  3. Agent ran: rm -rf random-funcDELETED USER'S PROJECT
  4. Agent created new project from template at ~/random-mcp/
  5. User's original code was permanently lost

Expected Behavior

Agent should have:

  1. Modified ~/random-func/src/functions/httpTrigger.js to add MCP support
  2. Added any required dependencies to existing package.json
  3. Redeployed the modified project
  4. NEVER deleted the existing workspace

Root Cause

The MCP recipe at references/services/functions/templates/mcp.md shows template commands like:

azd init -t remote-mcp-functions-typescript

This suggests starting fresh from a template rather than modifying existing code. The agent interpreted "use the recipe" as "use the template" which led to destructive behavior.

Suggested Fixes

  1. Add explicit warning in SKILL.md:

    ## ⛔ NEVER DELETE USER CODE
    
    When adding features to existing projects:
    - MODIFY existing files, do not replace the project
    - Templates are for NEW projects only
    - Use recipe SOURCE CODE snippets for existing projects
  2. Clarify MCP recipe for existing projects:

    • Add section: "Adding MCP to Existing Functions"
    • Reference recipes/mcp/source/{lang}.md for code snippets
    • Explicitly state: "Do NOT use azd init on existing projects"
  3. Global rules enforcement:

    • rm -rf on user project directories should require explicit ask_user confirmation
    • The existing global-rules.md mentions destructive actions but this wasn't enforced

Impact

  • Data Loss: User's custom function code permanently deleted
  • Trust: User cannot rely on agent to safely modify projects
  • Time Lost: Must recreate original implementation

Files Involved

  • plugin/skills/azure-prepare/references/services/functions/templates/mcp.md - shows templates without warning
  • plugin/skills/azure-prepare/references/global-rules.md - has destructive action rules but not enforced
  • plugin/skills/azure-prepare/SKILL.md - needs explicit "never delete user code" guidance

Metadata

Metadata

Labels

bugSomething isn't workingskills

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions