Skip to content

Extension SDK Core & MCP Framework — Critical Improvements #6855

@jongio

Description

@jongio

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions