Skip to content

testing: forward lifespan and MCP session settings from build_asgi_app #1054

Description

@bokelley

Problem

Beta.5's adcp.testing.build_asgi_app(transport="both") solves the combined
MCP+A2A topology gap from #1047, but it still cannot replace production app
composition for adopters that configure lifespan hooks or stateful MCP
sessions.

The public helper does not accept or forward these production serve() /
_build_mcp_and_a2a_app() inputs:

on_startup
on_shutdown
stateless_http
session_idle_timeout
max_active_sessions

Passing any of them through **factory_kwargs does not work: those kwargs are
forwarded to create_adcp_server_from_platform(), where they are unexpected.

Our in-process app must run cleanup hooks for database-backed proposal/task
stores and must exercise the same MCP session configuration as production.
Consequently, even on beta.5 it still has to import:

from adcp.server.serve import _apply_asgi_middleware, _build_mcp_and_a2a_app

This leaves the private-API dependency #1047 was intended to remove.

Requested API

Add explicit, typed kwargs to build_asgi_app() (and where appropriate
build_test_client()):

build_asgi_app(
    platform,
    transport="both",
    on_startup=(open_resources,),
    on_shutdown=(close_resources,),
    stateless_http=False,
    session_idle_timeout=1800.0,
    max_active_sessions=1000,
)

For transport="both", forward them to the existing production composition
path. Tests should verify that startup/shutdown hooks run under an ASGI lifespan
manager and that the MCP server receives the three session settings.

This is an additive production-parity follow-up to #1047; the beta.5 transport
selection and auth/discovery behavior are otherwise working well.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions