Files
Max Isbey 1b74b06753 Tighten comments and docstrings repo-wide
Cut comment and docstring volume roughly in half across src, tests,
examples, and docs_src: removed comments that restate the adjacent code,
leftover development narration, section banners, and self-evident
Args/Returns blocks, and compressed the remaining docstrings to a
Google-style summary line plus only the detail that earns its place.

Kept (and tightened) the load-bearing content: Raises sections,
deprecation and version-availability notes, spec/RFC/issue references,
why-comments for non-obvious decisions, and all coverage pragmas. The
generated mcp_types.v* wire modules are untouched.
2026-06-29 15:10:27 +00:00

27 lines
933 B
Python

"""Serve over Streamable HTTP with JSON responses (no SSE stream); HTTP-only, so this exports `build_app()`.
The 2026-07-28 path is stateless and JSON-only by construction; `json_response=True` also forces
JSON for the legacy (2025-era) branch on the same endpoint. Mid-call notifications are dropped.
"""
from starlette.applications import Starlette
from mcp.server.mcpserver import Context, MCPServer
from stories._hosting import NO_DNS_REBIND, run_app_from_args
def build_app() -> Starlette:
mcp = MCPServer("json-response-example")
@mcp.tool()
async def greet(name: str, ctx: Context) -> str:
"""Report progress mid-call, then return a greeting."""
await ctx.report_progress(0.5, total=1.0, message="halfway")
return f"Hello, {name}!"
return mcp.streamable_http_app(json_response=True, transport_security=NO_DNS_REBIND)
if __name__ == "__main__":
run_app_from_args(build_app)