Extension SDK Core & MCP Framework — Critical Items
This work unit covers all P0 (Critical) proposals from the parent issue. These are the foundational framework improvements that eliminate the most boilerplate and benefit every extension author.
Extension SDK Base
P0-1: Extension Base Command Builder
Provide NewExtensionRootCommand() that auto-registers azd's global flags, sets up OpenTelemetry trace context, calls WithAccessToken(), and provides a structured ExtensionContext.
Current duplication (identical code in every extension):
Identical trace context extraction in every extension:
P0-2: Global Flags Propagation via Environment Variables
Modify runner.go and middleware/extensions.go to export AZD_DEBUG, AZD_NO_PROMPT, AZD_CWD, AZD_ENVIRONMENT when spawning extensions.
Framework only passes 4 env vars today:
P0-3: BaseServiceTargetProvider with No-Op Defaults
Add BaseServiceTargetProvider so extensions embed it and only override needed methods.
P0-4: Standard Command Scaffolding (listen, metadata, version, mcp)
Provide NewListenCommand(), NewMetadataCommand(), NewVersionCommand(), NewMCPServeCommand().
Identical listen commands:
Identical metadata commands:
Identical version commands:
MCP Server Framework
P0-5: MCP Server Builder with Middleware
Wrap mark3labs/mcp-go with rate limiting, path validation, and security middleware applied automatically.
Rate limiter duplicated in every MCP extension:
Manual rate limit checks in every tool handler:
P0-6: Typed MCP Argument Parsing
Add ParseToolArgs(), RequireString(), OptionalBool(), OptionalInt().
Duplicate arg parsing helpers:
P0-7: MCP Result Marshaling Helpers
Add MCPTextResult(), MCPJSONResult(), MCPErrorResult().
P0-8: MCP Security Middleware
Centralize SSRF protection, path validation, header redaction as pluggable middleware.
Hardcoded blocklists in azd-rest:
Path validation in azd-core:
Estimated Impact
- ~300-500 lines of boilerplate eliminated per extension
- All 8 P0 proposals addressed
- Every current and future extension benefits
Extension SDK Core & MCP Framework — Critical Items
This work unit covers all P0 (Critical) proposals from the parent issue. These are the foundational framework improvements that eliminate the most boilerplate and benefit every extension author.
Extension SDK Base
P0-1: Extension Base Command Builder
Provide
NewExtensionRootCommand()that auto-registers azd's global flags, sets up OpenTelemetry trace context, callsWithAccessToken(), and provides a structuredExtensionContext.Current duplication (identical code in every extension):
Identical trace context extraction in every extension:
P0-2: Global Flags Propagation via Environment Variables
Modify
runner.goandmiddleware/extensions.goto exportAZD_DEBUG,AZD_NO_PROMPT,AZD_CWD,AZD_ENVIRONMENTwhen spawning extensions.Framework only passes 4 env vars today:
P0-3: BaseServiceTargetProvider with No-Op Defaults
Add
BaseServiceTargetProviderso extensions embed it and only override needed methods.P0-4: Standard Command Scaffolding (listen, metadata, version, mcp)
Provide
NewListenCommand(),NewMetadataCommand(),NewVersionCommand(),NewMCPServeCommand().Identical listen commands:
Identical metadata commands:
Identical version commands:
MCP Server Framework
P0-5: MCP Server Builder with Middleware
Wrap
mark3labs/mcp-gowith rate limiting, path validation, and security middleware applied automatically.Rate limiter duplicated in every MCP extension:
var globalRateLimiter = azdextutil.NewRateLimiter(10, 1.0)Manual rate limit checks in every tool handler:
if !globalRateLimiter.Allow()repeated 4 timesP0-6: Typed MCP Argument Parsing
Add
ParseToolArgs(),RequireString(),OptionalBool(),OptionalInt().Duplicate arg parsing helpers:
getArgsMap()+getStringParam()GetArgsMap()+GetStringParam()(azd-exec doesn't use these)P0-7: MCP Result Marshaling Helpers
Add
MCPTextResult(),MCPJSONResult(),MCPErrorResult().marshalExecResult()+marshalToolResult()P0-8: MCP Security Middleware
Centralize SSRF protection, path validation, header redaction as pluggable middleware.
Hardcoded blocklists in azd-rest:
blockedHeaders,blockedHosts,blockedCIDRsisBlockedIP(),isBlockedURL()with DNS + CIDR checkingPath validation in azd-core:
ValidatePath(),ValidatePathWithinBases()Estimated Impact