chore: import upstream snapshot with attribution
Deploy Docs / deploy-docs (push) Failing after 1s
Conformance Tests / client-conformance (push) Failing after 3s
Conformance Tests / server-conformance (push) Failing after 1s
GitHub Actions Security Analysis / zizmor (push) Failing after 1s
CI / checks (push) Failing after 59m20s
CI / all-green (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 12:10:27 +08:00
commit 49b9bb6724
992 changed files with 161690 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
"""One MCPServer factory that serves both the 2025 handshake era and the 2026 stateless era."""
from mcp_types.version import MODERN_PROTOCOL_VERSIONS
from mcp.server.mcpserver import Context, MCPServer
from stories._hosting import run_server_from_args
def build_server() -> MCPServer:
# The same factory serves both eras with no configuration. Which era a request is
# on is decided by the entry point / transport, never by the server.
mcp = MCPServer("dual-era-example", instructions="A small dual-era demo server.")
@mcp.tool()
async def greet(name: str, ctx: Context) -> str:
"""Greet the caller and report which protocol era served the request."""
pv = ctx.request_context.protocol_version
era = "modern" if pv in MODERN_PROTOCOL_VERSIONS else "legacy"
return f"Hello, {name}! (served on the {era} era at {pv})"
return mcp
if __name__ == "__main__":
run_server_from_args(build_server)