Skip to content

feat(server): asgi_middleware accepts Callable[[ASGIApp], ASGIApp] factories #415

Closed

Description

@bokelley

Context

The current asgi_middleware: Sequence[tuple[type, dict[str, Any]]] parameter is loose-typed and forces adopters to wrap functional middleware in a class just to fit the tuple shape.

Accept callable factories alongside the tuple form. Branch on isinstance(entry, tuple) in _apply_asgi_middleware.

Acceptance Criteria

  • asgi_middleware accepts both tuple[type, dict] (current) and Callable[[ASGIApp], ASGIApp] factories
  • _apply_asgi_middleware branches on isinstance(entry, tuple)
  • Tests cover both shapes
  • Type signature updated to reflect the union

Files

  • src/adcp/server/ (_apply_asgi_middleware)

Activity

  1. added
    enhancement
    claude-triaging
    and removed
    claude-triaging
    on May 3, 2026
  2. bokelley commented on May 3, 2026

    @bokelley
    ContributorAuthor

    Triage

    Classification: Feature request
    Bucket(s): handlers
    Status: drafting-pr
    Milestone: (omitted — no target version specified)

    What the experts said:

    • code-reviewer: approved — no blockers; noted stdio silent-drop (fixed with logger.warning) and that the commit title should reflect this is a net-new param
    • dx-expert: one blocker fixed — widened type → Callable[..., Any] in tuple annotation so functools.partial as the tuple's first element passes mypy; also exported ASGIMiddlewareEntry from adcp.server to mirror SkillMiddleware

    My take: The feature is net-new on the current main (no pre-existing asgi_middleware param). The issue's acceptance criteria map cleanly to the implementation: _apply_asgi_middleware branches on isinstance(entry, tuple), both forms compose outermost-first, type signature uses a named ASGIMiddlewareEntry alias. Non-breaking and fully testable.

    Drafting PR: add asgi_middleware: Sequence[ASGIMiddlewareEntry] | None to serve(), thread it through _serve_mcp → _run_mcp_http and _serve_a2a, add _apply_asgi_middleware helper, 6 new tests.

    → Draft PR: #441


    Triaged by Claude Code. Session: https://claude.ai/code/session_01GttQNCHuVSVUyRW5knbitw


    Generated by Claude Code

  3. added a commit that references this issue on May 3, 2026
    19b0822
  4. added a commit that references this issue on May 3, 2026
    69211a3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claude-triagedenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions