サーバーをテストし、動作を観察する

読了まで約78 分分、8 節 節の 6 例 例。

第2026.11.14版 2026年11月19日時点で例が通過 70 例中 70 例が合格 変更点

AIによる翻訳。英語版は人による検証済みである。 当社の書籍の作り方

英語版の書籍(版2026.11.14)から翻訳した。 原文を読む

この章を終えると、次のことができるようになる。Model Context Protocol サーバーのツールをメモリ内と HTTP の両方でテストする。クライアントを壊すスキーマ変更を、リリース前に検出する。記録したホストの実行を回帰テストとして再生する。OpenTelemetry でツール呼び出しをトレースする。モデルが正しいツールを選ぶ頻度を測定する。そのツールを使うクライアントを壊さずにツールを廃止する。ここで述べるプロトコルに関する主張は仕様のリビジョン 2026-07-28 に対して成り立ち、SDK に関する主張は Python SDK の mcp 2.3.0 に対して成り立つ。

チケットを処理するホストを作るは、ショップのサポートチームが使うホスト lib.ticket_host で終わった。このホストは、ショップのサーバーとパートナーの荷物追跡サーバーという二つのサーバーを相手に、ショップの 48 件のチケットをすべて処理した。モデルの返答は記録 ticket-runs から取り出したものである。記録とは examples/data/recorded/ に保存されたモデルの出力であり、そのためこの実行は、モデルを呼び出さなくても、どのマシンでも同じように再生される。

この実行には二つの問題が残った。一つ目として、ホストが最初に正しいツールを選んだチケットは 36 of 48 件だったが、どのチケットを誤り、それがなぜなのかは、何も示されなかった。二つ目として、返金チケットでは、モデルは返金が完了したかのように顧客へ書いていたが、返金を求めるチケットのうち issue_refund に実際に到達したのは 0 of 7 件だった。ショップのサーバーとホストは変更され続ける。説明文の言い換え、フィールド名の変更、ツールの置き換えなどである。これらはいずれも、サーバー側の呼び出しを一つも失敗させないまま、クライアントを壊すことがある。

チェックを組み立てる土台として、チームは Model Context Protocol(MCP)から次のものを得られる。すべてのツールに付く型付きスキーマ、すべてのリクエストの _meta に入るトレースコンテキスト、そしてツール一覧の変更通知である。この章では、これらを使ってショップのチェックを構築する。セットアップは三つの新しいモジュールにまとめる。lib.testing は pytest モジュールを実行し、テストごとに安定した 1 行を出力する。lib.contract はツールのスキーマの二つのリリースを比較する。lib.queue_replay は第10章のキュー実行を再生し、各返答が約束している内容を、ホストが実際に行った呼び出しと照合する。この章の例のうち二つは記録 ticket-runs を再生し、残りはモデルを使わない。この章自体は、モデルの呼び出しを一切行わない。

この部分はまだ翻訳されていないため、英語で表示している。

Test tools in memory

最終変更:版2026.11.11

A test of a server's tools should run with no port and no subprocess, so that it can run on every change. The Python SDK's Client gives you that: passed a server object instead of a URL or launch parameters, it connects to the server in the same process. The SDK's testing guide calls this the way to test a server, with the line "No subprocess. No port. Nothing on a wire" (testing). In the default mode="auto", the connection is a pair of DirectDispatchers, which hand each request to the server's handler as a Python object, with no streams, no JSON-RPC framing and no initialize handshake (mcp/client/client.py, _connect_inproc; mcp/shared/direct_dispatcher.py).

Two details matter in a test. raise_exceptions=True makes a failure outside a tool's body, such as a bug in a handler, come back with its real message instead of a sanitised "Internal server error". It doesn't change what a tool's own exception does: that is still a result with is_error=True, as it is for any client (testing). The SDK also stamps the server's identity into each result's _meta, so a test that compares whole results has to clear result.meta first (same page). Asserting on the fields a test is about avoids both the stamp and the SDK guide's snapshot library, inline-snapshot, which the book doesn't pin. Async tests need no extra plugin: anyio, which the SDK depends on, ships a pytest plugin that runs any test marked pytest.mark.anyio (AnyIO testing).

What the in-memory path skips matters as much as what it covers. With no HTTP layer, an in-memory test never meets the checks a Streamable HTTP server makes on headers, Origin and Host, never sees a server-sent event, and never carries trace context, as Trace calls with OpenTelemetry shows. The SDK's documentation adds that the in-process path doesn't deliver standalone notifications, such as a change to the tool list (client caching). A suite that is all in memory can pass while every HTTP client fails.

The shop's tests run against chapter 3's server, lib.shop_tools, from Design tools a model can use, with the shop's API on loopback for each test, served by the fixture shop_api_env from lib.testing. Three tests run in memory: an order's status comes back as structured fields, an unknown order comes back as a tool execution error that names find_orders, and an order ID in the wrong form is refused before the tool runs. The fourth serves the same tools over Streamable HTTP on loopback and sends a tools/call whose Mcp-Name header names a different tool from its body: a request the SDK's client never sends, and one an in-memory client can't express. Run as a script, the file runs its own tests with pytest 9.2.0.

test-tools-in-memory.py Python 3.12.15 · cryptography 50.0.2 · httpx2 2.16.2 · jsonschema 4.26.0 · mcp 2.3.0 · mcp-types 2.3.0 · pydantic 2.14.3 · pytest 9.2.0 · starlette 1.10.0 · uvicorn 0.54.0 合格
"""Four pytest tests of the shop's tools: three through the SDK's in-process client, and one over Streamable HTTP onloopback, which reaches a check an in-memory test never makes. The prose's point rests on the unknown-order test'sline and on the last line, which counts the passes."""import pytestfrom mcp import Clientfrom lib import http_mcp, loopback, shop_toolsfrom lib.testing import anyio_backend, run, shop_api_envpytestmark = pytest.mark.anyio                            # runs the async tests on anyio's pytest pluginasync def test_order_status_fields(shop_api_env):        # shop_api_env serves the shop's API on loopback for this test    # raise_exceptions=True: a bug outside a tool's body raises here, with its own message    async with Client(shop_tools.create_server(), raise_exceptions=True) as client:        result = await client.call_tool("get_order_status", {"order_id": "O-1873"})    assert not result.is_error    assert result.structured_content["order_id"] == "O-1873"    assert result.structured_content["status"] == "delivered"async def test_unknown_order_is_a_tool_error(shop_api_env):    async with Client(shop_tools.create_server(), raise_exceptions=True) as client:        result = await client.call_tool("quote_refund", {"order_id": "O-7144"})    assert result.is_error                                    # raise_exceptions doesn't make it raise    assert "find_orders" in result.content[0].text            # the model is told what to do insteadasync def test_malformed_order_id_is_refused(shop_api_env):    async with Client(shop_tools.create_server(), raise_exceptions=True) as client:        result = await client.call_tool("get_order_status", {"order_id": "1873"})    assert result.is_error    text = result.content[0].text                             # only argument validation writes this error:    assert "order_id" in text and "string_pattern_mismatch" in text   # the field and pydantic's pattern checkdef test_http_refuses_a_mismatched_header(shop_api_env):    with loopback.serve(shop_tools.create_server().streamable_http_app()) as base_url:        # the header names check_stock while the body calls get_order_status: the mismatch the server must refuse        reply = http_mcp.post(base_url + "/mcp", "tools/call", {"name": "get_order_status",                              "arguments": {"order_id": "O-1873"}}, headers={"Mcp-Name": "check_stock"})    assert reply.status_code == 400    assert reply.json()["error"]["code"] == -32020        # the JSON-RPC code the server returns for the mismatchif __name__ == "__main__":    run(__file__)
出力python test-tools-in-memory.py
test_order_status_fields: passed
test_unknown_order_is_a_tool_error: passed
test_malformed_order_id_is_refused: passed
test_http_refuses_a_mismatched_header: passed
tests passed: 4 of 4

A failing tool is a result a model can act on. The run reports 4 of 4, and the unknown order's test passed with raise_exceptions=True on: the tool raised ToolError, and the client got an ordinary result with the error flag set and the server's advice in its text, which is what a model needs to correct itself (Report failures as tool results).

The malformed ID never reached the tool. The test asserts that the error names order_id and pydantic's string_pattern_mismatch, which only argument validation writes. The SDK validated the arguments against the tool's parameter model, which its input schema is generated from, before calling the tool (mcp/server/mcpserver/server.py, _handle_call_tool). The HTTP test covers the layer the others skip: the server refused the mismatched header with status 400 and the JSON-RPC error -32020, as Read one HTTP exchange describes, before any tool code ran.

Working rule: Test each tool in memory with Client(server, raise_exceptions=True), and assert on structured_content fields and is_error, not on whole results. Keep at least one test per transport you ship that goes over it on loopback, for the header, origin and streaming checks an in-memory test can't reach, and put the tests of trace propagation and list changes there too.

この部分はまだ翻訳されていないため、英語で表示している。

Check schemas as a contract

最終変更:版2026.11.11

The in-memory tests from the previous section check that a tool does what its own release says. They don't check that the release still fits the clients using the last one. A client depends on a tool through its schemas: it sends arguments that its copy of the inputSchema accepts, and it reads the fields that its copy of the outputSchema promises. When a tool declares an output schema, the server MUST return structured content that conforms to it, and clients SHOULD validate it (tools, "Structured Content").

The Python SDK's client does validate, and it validates against its own copy. It keeps one compiled validator per tool, built from the output schema in the last tools/list it absorbed, and replaces it only when a later listing brings a different schema (mcp/client/session.py, _output_schema_validator and _absorb_tool_listing). A non-error result that doesn't match raises RuntimeError in the caller (mcp/client/session.py, validate_tool_result). So a server that renames an output field breaks every connected client that listed its tools before the release, at the moment each one next calls the tool, and the server sees nothing wrong.

In the shop's case, release 2 of the server renames the per-warehouse on_hand field of check_stock to count. To see the break, a client connects to release 1 in memory and lists the tools. It keeps its connection while the server swaps check_stock for release 2's version, as a rolling deploy would. Then the client calls the tool, lists again and calls once more. Last, a contract test runs the two checks it makes before a release ships: lib.contract.breaking_changes, a diff of the two releases' schemas, and a validation of release 2's real result against release 1's published output schema with jsonschema, the library the client uses.

schema-change-breaks-a-client.py Python 3.12.15 · cryptography 50.0.2 · httpx2 2.16.2 · jsonschema 4.26.0 · mcp 2.3.0 · mcp-types 2.3.0 · pydantic 2.14.3 · pytest 9.2.0 · starlette 1.10.0 · uvicorn 0.54.0 合格
"""What a client connected before a release sees when the release renames check_stock's on_hand to count, and whatthe contract checks report about the same change. The prose's point rests on the client's error line, which namesthe missing field, and on the contract check's line."""import asynciofrom mcp import Clientfrom pydantic import BaseModelfrom lib import confirmations, contract, shop_toolsfrom lib.testing import shop_api_hereclass Warehouse(BaseModel):    warehouse: str    count: int                                            # release 1 called it on_hand    last_counted: strclass StockReport(BaseModel):    sku: str    available: int    warehouses: list[Warehouse]def check_stock(sku: shop_tools.Sku) -> StockReport:    report = confirmations.chapter3_tools()["check_stock"].fn(sku)       # release 1's tool does the reading    return StockReport(sku=sku, available=report.available, warehouses=[Warehouse(        warehouse=w.warehouse, count=w.on_hand, last_counted=str(w.last_counted)) for w in report.warehouses])async def main() -> None:    server = shop_tools.create_server()    with shop_api_here():                                  # the server's tools run in this process        async with Client(server) as client:            listing = await client.list_tools()            print("release 1's tools/list cache hint:", f"ttlMs {listing.ttl_ms}")            server.remove_tool("check_stock")                                  # the release, swapped in while connected            server.add_tool(check_stock, description=shop_tools.DESCRIPTIONS["check_stock"])            try:                await client.call_tool("check_stock", {"sku": "KG-1031"})            except RuntimeError as error:                print("client that listed before the release:", error.args[0].splitlines()[0])  # the message's first line            new = next(tool for tool in (await client.list_tools()).tools if tool.name == "check_stock")  # the release 2 schema            result = await client.call_tool("check_stock", {"sku": "KG-1031"})            print("client after listing again:", "result" if not result.is_error else "tool error")    old = next(tool for tool in listing.tools if tool.name == "check_stock")    print("contract check:", "; ".join(contract.breaking_changes(old, new)) or "no breaking change")    validator = contract.validator(old.output_schema)(old.output_schema)    # by the dialect the schema declares    print("validator for release 1's schema:", type(validator).__name__ + ", as it declares",          old.output_schema.get("$schema", "no $schema"))    # the first error the schema finds in release 2's real result    print("release 2's result against release 1's schema:", next(validator.iter_errors(result.structured_content)).message)asyncio.run(main())
出力python schema-change-breaks-a-client.py
release 1's tools/list cache hint: ttlMs 0
client that listed before the release: Invalid structured content returned by tool check_stock: 'on_hand' is a required property
client after listing again: result
contract check: output warehouses[].on_hand: removed
validator for release 1's schema: Draft202012Validator, as it declares no $schema
release 2's result against release 1's schema: 'on_hand' is a required property

Release 1's tool list carried the SDK's default cache hint, ttlMs 0, so the list was stale the moment it arrived, and the client still validated against it. The call after the release failed inside the client: "Invalid structured content returned by tool check_stock: 'on_hand' is a required property". The server had returned a correct release 2 result. After the client listed the tools again, the same call came back as a result. A zero TTL doesn't protect a connected client, because the validator follows the last listing, not the cache: a client that lists once at startup holds that schema for as long as it runs.

Both contract checks caught the change without a client. The schema diff reported output warehouses[].on_hand: removed, and validating release 2's result against release 1's schema failed with the client's own message: "'on_hand' is a required property". The diff is a reviewer's aid: it compares field paths, types and required inputs, and its docstring lists what it leaves out, such as patterns and enums. The validation is the test to keep, because it checks the server's real output against the exact schema that clients hold.

Breaking changes aren't symmetric. On the output side, removing, renaming or retyping a field breaks clients, and adding an optional field doesn't. On the input side, adding a required argument breaks old callers, and removing one breaks them quietly, because the SDK's server drops arguments it doesn't know without an error, as Treat ticket text as untrusted data shows. The pinned revision allows any JSON Schema 2020-12 keyword in both schemas, and reads a schema with no $schema as 2020-12 (tools). A schema may name another dialect in $schema, and clients and servers MUST validate by the declared dialect, or by 2020-12 when none is declared (base protocol, "JSON Schema Usage"). So choose the validator from the schema, as the SDK's client does with jsonschema's validator_for (mcp/client/session.py, _output_schema_validator). lib.contract.validator does the same for the shop's checks, with 2020-12 as the default. pydantic writes no $schema, so release 1's schema got Draft202012Validator, as it declares no $schema.

Working rule: Keep the last release's tools/list in the repository, and in CI validate every structured result your tests produce against it as well as against the new schema, each by the dialect it declares and by 2020-12 when it declares none. Treat a removed, renamed or retyped output field and a new required input as a breaking change: add the new field beside the old one, or add a new tool, and retire the old shape through a window (Change tools without breaking clients). Don't rely on a short TTL to protect clients that are already connected.

この部分はまだ翻訳されていないため、英語で表示している。

Replay recorded host runs

最終変更:版2026.11.11

Tool tests and contract tests cover the server. The support host from Build a host that works through tickets has logic of its own between the model and the servers: it routes names, asks for consent, sends results back and caps turns, and a change there can make every ticket go wrong without any tool failing. A replay covers that layer. It runs the real host against the real servers, with the model's replies taken from a recording, so a test can assert on what the host did for each ticket.

A replay tests the host and the servers against fixed model outputs. It doesn't test the model: a different model, or the same one with other sampling, needs a new recording. And it holds only while the messages stay as recorded. ReplayModel from lib.host looks each reply up by the SHA-256 of the exact messages, which include every tool definition and every tool result so far, and raises RecordingMismatch when they differ (Run the host loop). So a replay doubles as a tripwire: any change to what the model would see stops it, and a team then decides whether to record again.

The replay also gives the queue's results a second reading. Work through the ticket queue found that the model told customers their refunds were on the way for orders it never refunded. A reply is the model's claim, and the host's call log is the record of what happened, so the host can compare them before a reply reaches a customer. lib.queue_replay holds a small version of that check, built on the phrase check chapter 10 counted with, ticket_host.promises_refund, which looks for phrases such as "will be refunded" or "we'll refund". Reusing it keeps this chapter's counts and chapter 10's the same measurement. Its unbacked_refund is true when a run's last reply makes that promise and no issue_refund call in the run returned a result. The phrase list is a rule of thumb written against this recording's replies, not a classifier, and the module's docstring says what it misses.

queue_replay.replay_queue replays the whole queue, with the support host set up exactly as chapter 10's work-the-ticket-queue sets it up. The run prints one ticket's tool sequence, counts the refunds and the replies that promise one, and replays the first ticket after one sentence has been added to quote_refund's description.

replay-ticket-runs.py Python 3.12.15 · cryptography 50.0.2 · httpx2 2.16.2 · jsonschema 4.26.0 · mcp 2.3.0 · mcp-types 2.3.0 · pydantic 2.14.3 · starlette 1.10.0 · uvicorn 0.54.0 合格
"""Replay chapter 10's queue run, the recording ticket-runs, through the support host, and check each reply's promiseagainst the host's call log. The prose's point rests on the refund lines, which compare refunds issued with repliesthat promise one, and on the last line, which shows what a one-sentence rewording does to the replay."""import asynciofrom lib import queue_replay, shop_tools, ticket_hostfrom lib.host import RecordingMismatchfrom lib.shop_data import load_shopdef reword_quote_refund(host) -> None:              # the server's next release adds a sentence to one description    changed = {**shop_tools.DESCRIPTIONS}    changed["quote_refund"] += " Quotes are in the order's currency."    host.listed["shop"] = shop_tools.with_descriptions(host.listed["shop"], changed)async def main() -> None:    tickets = {ticket.ticket_id: ticket for ticket in load_shop().tickets}    runs = await queue_replay.replay_queue()    print("tickets replayed:", len(runs))    print("T-0009 tools:", " then ".join(turn.tool for turn in runs["T-0009"].calls))   # its calls, in order    print("refunds issued:", sum(queue_replay.refunded(run) for run in runs.values()))    # the phrase check from chapter 10, a rule of thumb: see the module's docstring for what it misses    promised = [ticket_id for ticket_id, run in runs.items() if ticket_host.promises_refund(run.answer)]    # a promise with no refund behind it: no issue_refund call in the run returned a result    unbacked = [ticket_id for ticket_id in promised if queue_replay.unbacked_refund(runs[ticket_id])]    print("replies that promise a refund:", len(promised))    print("of which no call made:", len(unbacked))    for tag in ("issue_refund", "quote_refund"):           # the tickets tagged with each refund tool        group = [t for t in tickets.values() if t.expected_tool == tag]        print(f"{tag} tickets flagged:", f"{sum(t.ticket_id in unbacked for t in group)} of {len(group)}")    print("flagged:", ", ".join(unbacked))    try:        await queue_replay.replay_queue(change=reword_quote_refund, tickets=[tickets["T-0001"]])    except RecordingMismatch:        print("after rewording quote_refund, T-0001 replays:", "no, RecordingMismatch")asyncio.run(main())
出力python replay-ticket-runs.py
tickets replayed: 48
T-0009 tools: shop.quote_refund then shop.find_orders
refunds issued: 0
replies that promise a refund: 11
of which no call made: 11
issue_refund tickets flagged: 6 of 7
quote_refund tickets flagged: 5 of 9
flagged: T-0007, T-0020, T-0029, T-0034, T-0036, T-0037, T-0040, T-0042, T-0045, T-0046, T-0048
after rewording quote_refund, T-0001 replays: no, RecordingMismatch

All 48 tickets replayed, and ticket T-0009 took the path it took in chapter 10: shop.quote_refund then shop.find_orders. An assertion on that sequence is a regression test for the host. If a change to routing or error handling sent the first tool execution error back differently, the model's second turn would no longer match the recording, and the replay would stop.

lib.queue_replay flags the promises that no call backs, and a host should send those replies to a person instead of to the customer. The host issued 0 refunds, yet 11 replies promise one, and 11 of them have no refund behind them.

Of the tickets asking for a refund, 6 of 7 are flagged, and of the tickets asking only what a refund would be, 5 of 9 are, each reply telling the customer the money was on its way. The one refund request not flagged, T-0024, ended with the model asking which product the customer meant, which promises nothing. The flagged tickets are T-0007, T-0020, T-0029, T-0034, T-0036, T-0037, T-0040, T-0042, T-0045, T-0046, T-0048.

The rewording at the end shows the tripwire. After one sentence was added to one description, the first ticket's replay gave no, RecordingMismatch. Every ticket's prompt holds every tool's description, so changing any description changes every prompt. That is the cost of replays, and also their use: a reworded description is the change that can alter what the model chooses, and the replay won't let it through unmeasured.

Working rule: Replay a recorded run of the whole queue in CI, assert on each ticket's tool sequence, and run a check that compares each reply's promises with the calls that returned a result. Keep generated IDs and clocks fixed in the servers a replay runs against, or it stops for reasons that aren't changes. Then treat RecordingMismatch as a signal, not as a flaky test: when you change a description, a prompt or a tool's output, record again with the recording script and compare the new run's scores with the old run's before you ship.

この部分はまだ翻訳されていないため、英語で表示している。

Trace calls with OpenTelemetry

最終変更:版2026.11.11

Tests run before a release; traces show what a server does after it. OpenTelemetry is the common way to get them: an application creates spans, each a named, timed operation with attributes and a parent, and an exporter sends them to a tracing backend. MCP adds one thing of its own. At the pinned revision, the _meta keys traceparent, tracestate and baggage are reserved for trace context, and their values MUST follow the W3C Trace Context and Baggage formats (base protocol). That is how a client's trace and a server's trace join into one, whatever the transport.

The Python SDK traces with no setup in your server's code. Every server installs OpenTelemetryMiddleware, which wraps each inbound message in a SERVER span and does nothing until an OpenTelemetry SDK and exporter are installed (mcp/server/lowlevel/server.py; OpenTelemetry). The source marks the middleware provisional, so its details may change in a 2.x minor release. On the client side, the JSON-RPC paths, which are URLs, stdio and the legacy in-memory mode, open a CLIENT span named MCP send {method} {target} and inject traceparent into the request's _meta, and the server extracts it as the parent of its span (mcp/shared/jsonrpc_dispatcher.py, mcp/shared/_otel.py). The in-process path from Test tools in memory sends no JSON-RPC, so it creates no client span and injects nothing.

The shop wants a trace for each tool call, findable by tool name and showing whether it failed. The script installs OpenTelemetry's SDK, opentelemetry-sdk 1.45.2, with an InMemorySpanExporter, which keeps finished spans in a list that a test can read (opentelemetry/sdk/trace/export/in_memory_span_exporter.py). The script serves chapter 3's tools from Design tools a model can use over Streamable HTTP on loopback in the same process, so the client's and the server's spans land in the same list. It calls find_orders and then quote_refund for an order that doesn't exist. Then it makes the same find_orders call in memory twice, the second time inside a span of the test's own.

trace-a-tool-call.py Python 3.12.15 · cryptography 50.0.2 · httpx2 2.16.2 · jsonschema 4.26.0 · mcp 2.3.0 · mcp-types 2.3.0 · opentelemetry-api 1.45.2 · opentelemetry-sdk 1.45.2 · opentelemetry-semantic-conventions 0.66b2 · pydantic 2.14.3 · pytest 9.2.0 · starlette 1.10.0 · uvicorn 0.54.0 合格
"""The OpenTelemetry spans the SDK emits for the shop's tool calls, over Streamable HTTP on loopback and in memory.The prose's point rests on two printed lines: the HTTP server span, which shows the trace context crossing the wire,and the in-memory server span parents, which show what happens without it."""import asynciofrom mcp import Clientfrom opentelemetry import tracefrom opentelemetry.sdk.trace import TracerProviderfrom opentelemetry.sdk.trace.export import SimpleSpanProcessorfrom opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporterfrom opentelemetry.semconv._incubating.attributes.mcp_attributes import McpMethodNameValuesfrom lib import loopback, shop_toolsfrom lib.testing import shop_api_herespans = InMemorySpanExporter()trace.set_tracer_provider(provider := TracerProvider())provider.add_span_processor(SimpleSpanProcessor(spans))      # each span, as it ends, into memorydef finished(name: str) -> list:                 # every finished span with this name, in the order they ended    return [span for span in spans.get_finished_spans() if span.name == name]def parent(span) -> str:    return next((s.name for s in spans.get_finished_spans() if span.parent and s.context.span_id ==                 span.parent.span_id), "none")      # "none" for a span with no parent, or whose parent never finishedasync def main() -> None:    server = shop_tools.create_server()    with shop_api_here(), loopback.serve(server.streamable_http_app()) as base_url:        async with Client(base_url + "/mcp") as client:            await client.call_tool("find_orders", {"customer_id": "C-0127"})            await client.call_tool("quote_refund", {"order_id": "O-7144"})            # a tool error        print("HTTP spans:", ", ".join(sorted(span.name for span in spans.get_finished_spans())))        # the test makes one call of each, so the first finished span of each name is the call's        call, error = finished("tools/call find_orders")[0], finished("tools/call quote_refund")[0]        print("HTTP server span:", call.name, f"({call.kind.name}), parent: {parent(call)}")        for key in sorted(set(call.attributes) - {"jsonrpc.request.id"}):   # the request ID changes on every run            print(f"attribute {key}:", call.attributes[key])        print("tool error span status:", error.status.status_code.name)        print("tool error span error.type:", error.attributes["error.type"])        spans.clear()        async with Client(server) as client:            await client.call_tool("find_orders", {"customer_id": "C-0127"})            # a span of the test's own, which the in-memory server falls back to as the parent            with trace.get_tracer("shop-tests").start_as_current_span("test find_orders"):                await client.call_tool("find_orders", {"customer_id": "C-0127"})        print("in-memory spans:", ", ".join(sorted(span.name for span in spans.get_finished_spans())))        print("in-memory server span parents:", ", ".join(parent(s) for s in finished("tools/call find_orders")))    # the pinned conventions predate the pinned revision, and this list has no server/discover    assert "server/discover" not in {m.value for m in McpMethodNameValues}asyncio.run(main())
出力python trace-a-tool-call.py
HTTP spans: MCP send server/discover, MCP send tools/call find_orders, MCP send tools/call quote_refund, MCP send tools/list, server/discover, tools/call find_orders, tools/call quote_refund, tools/list
HTTP server span: tools/call find_orders (SERVER), parent: MCP send tools/call find_orders
attribute gen_ai.operation.name: execute_tool
attribute gen_ai.tool.name: find_orders
attribute mcp.method.name: tools/call
attribute mcp.protocol.version: 2026-07-28
tool error span status: ERROR
tool error span error.type: tool_error
in-memory spans: server/discover, test find_orders, tools/call find_orders, tools/call find_orders, tools/list
in-memory server span parents: none, test find_orders

Over HTTP the spans came in pairs, each server span paired with a client span of the same method: MCP send server/discover, MCP send tools/call find_orders, MCP send tools/call quote_refund, MCP send tools/list, server/discover, tools/call find_orders, tools/call quote_refund, tools/list. The client listed the tools before its first call, because it validates the result against the output schema. The trace shows the server's span for the call, tools/call find_orders (SERVER), parent: MCP send tools/call find_orders, so the trace context crossed in _meta.

Its attributes name the method, tools/call, the operation, execute_tool, the tool, find_orders, and the revision (mcp/server/_otel.py).

The failed quote's span has the status ERROR and the error.type tool_error, although the call returned a result and not a JSON-RPC error, so a tracing backend can count tool execution errors without reading result bodies.

A test of trace propagation needs HTTP or stdio, because in memory the server has nothing to extract. In memory there were no client spans, only the server's spans and the test's own test find_orders: server/discover, test find_orders, tools/call find_orders, tools/call find_orders, tools/list. The two server spans' parents were none, test find_orders, in that order. With nothing to extract, the server falls back to whatever span is current, and only the test's own span gave it one (mcp/shared/_otel.py, extract_trace_context).

The names a server emits are the part to treat with care. OpenTelemetry's semantic conventions for MCP have the status Development; they recommend span names of the form {mcp.method.name} {target} and define metrics such as mcp.server.operation.duration (MCP semantic conventions, read 2026-10-31). They have also moved: the page the MCP specification links to shows a notice that the GenAI conventions moved to a repository of their own, which has no tagged release (moved notice). The SDK's server spans follow the recommended naming. Its client span name, MCP send …, doesn't, and the SDK emits no metrics: the source of mcp 2.3.0 never creates a meter. The pinned conventions package, opentelemetry-semantic-conventions 0.66b2, predates the pinned revision. Its list of method names has initialize and logging/setLevel, it still defines mcp.session.id, and it has no server/discover (opentelemetry/semconv/_incubating/attributes/mcp_attributes.py).

For logs, the pinned revision deprecates MCP's own Logging messages, notifications/message, and points servers to standard error on stdio and to OpenTelemetry otherwise (changelog). Replace sampling, roots and logging covers the move.

Working rule: Install an OpenTelemetry SDK and exporter in every server and host you run, and let the SDK's middleware make the server spans. Build dashboards on the attributes the SDK emits, mcp.method.name, gen_ai.tool.name and error.type, and label them as following a Development-status convention at a named version, because the names may change. Don't validate method names against the pinned conventions package. Test propagation over a real transport, and wrap in-memory calls in a span of your own when a test needs a parent.

正しいツールが選ばれる頻度を測る

最終変更:版2026.11.11

記録したホスト実行を再生するの再生では、ホストが以前と同じ動作をするかどうかを確かめた。もう一つの問いは、店が与えるツールと説明を使って、モデルがどのくらいうまく選択するかである。最初の指標としてよく使われるのはツール選択精度である。これは、モデルの最初の呼び出しが、正しいエージェントの使うツールを用いている事例の割合であり、top-1 精度とも呼ばれる。ベンチマークでは引数も採点する。例えば Berkeley Function Calling Leaderboard は、各呼び出しの名前と引数をあわせて、期待される呼び出しと抽象構文木の照合によって検査する(BFCL)。

固定された記録から得た数値が測るものは狭い。測っているのは、店のツール名と説明を、一つのモデル Qwen3-4B-Instruct-2507、量子化 Q4_K_M、温度 0.7 でのサンプリング(チケットキューを処理する)、本書の一つのプロンプトと一つのシード、そして本書が用意した 48 件のチケットに対して見たものにとどまる。

これはその設定からの一回の試行にすぎず、グループも小さい。最小のグループは 8 件のチケットしかなく、1 件がスコアに占める割合が大きい。この数値は一般のモデルについては何も語らない。また、説明を一つでも変更したら、数値に意味を持たせるために新しい記録が必要になる。再生側の RecordingMismatch がこれを強制する。各チケットには、正しいエージェントが最初に呼ぶツールが付いている。スクリプトは第10章と同様に ticket_host.expected_first_tool を使って採点する。返金の依頼は、quote_refund から始まっていれば正解と数える。issue_refund は先に見積もりを必要とするからである。

再生を採点するために、スクリプトは各チケットの最初のツール呼び出しを取り出し、全体の精度、期待されるツールごとの精度、そして各混同を表示する。注文を指定している正しい呼び出しについては、order_id 引数も二通りに採点する。チケットに書かれたとおりの ID との照合と、顧客が意図した注文との照合である。この二つは、顧客が番号を打ち間違えた 5 件のチケットで異なる。

tool-choice-accuracy.py Python 3.12.15 · cryptography 50.0.2 · httpx2 2.16.2 · jsonschema 4.26.0 · mcp 2.3.0 · mcp-types 2.3.0 · pydantic 2.14.3 · starlette 1.10.0 · uvicorn 0.54.0 合格
"""Score the first tool call of every ticket in chapter 10's queue run against the tool each ticket is tagged with,overall, per tag and by confusion, and check the order IDs of the right calls. The prose's point rests on theaccuracy lines, the per-tag line for refunds, and the two order-ID lines, which differ."""import asynciofrom collections import Counterfrom lib import queue_replay, ticket_hostfrom lib.shop_data import load_shopasync def main() -> None:    tickets = load_shop().tickets    runs = await queue_replay.replay_queue()    scored = []                                            # (ticket, expected tool, first tool called)    for ticket in tickets:        calls = runs[ticket.ticket_id].calls        # the first call, or None when the host made none; a refund ticket expects quote_refund first        scored.append((ticket, ticket_host.expected_first_tool(ticket), calls[0] if calls else None))    right = [(t, call) for t, expected, call in scored if call and call.tool == expected]    print("first tool right:", f"{len(right)} of {len(scored)}")    print("top-1 accuracy:", f"{len(right) / len(scored):.2f}")    for expected, count in sorted(Counter(expected for _, expected, _ in scored).items()):        hits = sum(1 for t, e, call in scored if e == expected and call and call.tool == expected)        print(f"expected {expected}:", f"{hits} of {count}")    confusions = Counter((expected, call.tool if call else "no tool") for _, expected, call in scored                         if not call or call.tool != expected)    for (expected, chosen), count in confusions.most_common():        print(f"expected {expected}, called {chosen}:", count)    with_order = [(t, call) for t, call in right if t.order_id and "order_id" in call.arguments]  # right calls naming an order    as_written = sum(call.arguments["order_id"] == t.cited_order_id for t, call in with_order)   # the ID the ticket gave    meant = sum(call.arguments["order_id"] == t.order_id for t, call in with_order)              # the customer's order    print("right tool, order ID as the ticket wrote it:", f"{as_written} of {len(with_order)}")    print("right tool, order the customer meant:", f"{meant} of {len(with_order)}")    # tickets whose cited ID isn't the order the customer meant    typos = [(t, e, call) for t, e, call in scored if t.cited_order_id and t.cited_order_id != t.order_id]    print("tickets with a mistyped order ID:", len(typos))    print("of which the right tool was called:", sum(1 for _, e, call in typos if call and call.tool == e))    for t, _, call in [(t, e, call) for t, e, call in typos if not call or call.tool != e]:        print(f"mistyped {t.ticket_id}, first tool:", call.tool if call else "no tool")    print("smallest expected-tool group, tickets:", min(Counter(e for _, e, _ in scored).values()))    manifest = queue_replay.manifest()    print("recorded model:", manifest["model"].split("/")[-1])   # the model's name, without its publisher's path    print("recorded quantization:", manifest["quantization"])asyncio.run(main())
出力python tool-choice-accuracy.py
first tool right: 36 of 48
top-1 accuracy: 0.75
expected shop.check_stock: 10 of 10
expected shop.find_orders: 8 of 8
expected shop.get_order_status: 12 of 14
expected shop.quote_refund: 6 of 16
expected shop.quote_refund, called shop.get_order_status: 8
expected shop.get_order_status, called partner.track_parcel: 2
expected shop.quote_refund, called shop.find_orders: 2
right tool, order ID as the ticket wrote it: 18 of 18
right tool, order the customer meant: 14 of 18
tickets with a mistyped order ID: 5
of which the right tool was called: 4
mistyped T-0042, first tool: shop.get_order_status
smallest expected-tool group, tickets: 8
recorded model: Qwen3-4B-Instruct-2507
recorded quantization: Q4_K_M

最初のツールが正しかったのは 36 of 48 件のチケットで、top-1 精度は 0.75 であった。これは第10章が数えた 36 of 48 と同じである。

全体の数値は、誤りがどこにあるかを隠す。在庫の質問は 10 of 10、注文検索は 8 of 8 であったが、返金のチケットは 6 of 16 にとどまった。誤りの大半である 8 は get_order_status に向かった。その説明には、返金には quote_refund を使うと書かれており、quote_refund の説明には最初に呼ぶと書かれているにもかかわらずである。この二つの説明が次に手を入れる対象であり、キューは、説明を変更したときに記録し直すチケット集合である。partner.track_parcel に向かった 2 件の状況確認の質問は、第10章の追跡番号の事例である(チケットキューを処理する)。

引数を見ると、基準が重要である理由がわかる。正しいツールを使った場合、モデルがチケットに書かれたとおりの注文 ID を使った呼び出しは 18 of 18 件、顧客が意図した注文を使った呼び出しは 14 of 18 件であった。

外れた呼び出しは顧客の打ち間違いによるものである。打ち間違いのあるチケットのうち、4 件は正しいツールに到達してここで採点されており、残りの T-0042 は最初に shop.get_order_status に向かったため、代わりに誤ったツールの数に入る。顧客の注文を調べずに打ち間違いを見抜けるモデルはない。顧客が意図したものに照らして採点すればモデルは不注意に見え、与えられたものに照らして採点すれば忠実である。この差はホストの流れに属するものであり、ホストは、その注文に基づいて動作する前に、注文がチケットの顧客のものかどうかを確認すべきである。

公表されているベンチマークも同じ方向を示している。ある事前公開論文 RAG-MCP は、モデルが選ぶ前にツールの候補一覧を検索して絞り込むと、そのベンチマークのタスクで選択精度が 13.62% から 43.13% に上がったと報告している。採点は審査役のモデルが行った(RAG-MCP)。MCP-Bench は、28 の稼働中のサーバーと 250 のツールを対象に、指示がツールを名指ししないタスクでは課題が依然として残ると報告している(MCP-Bench)。いずれも自らのタスクに対する単独の事前公開論文であり、どちらも店の数値については何も語らない。

実践ルール: 記録した実行はすべて、全体だけでなくタグごとの最初のツールで採点し、引数は、チケットがモデルに与えたものと真実の両方に照らして別々に採点する。最大の混同の背後にある説明から手を入れ、記録し直し、二つの記録の間でタグごとのスコアを比較する。すべてのスコアの横に、モデル、プロンプト、チケット集合を明記し、異なる設定のスコアどうしは決して比較しない。

この部分はまだ翻訳されていないため、英語で表示している。

Change tools without breaking clients

最終変更:版2026.11.11

The contract test in Check schemas as a contract says when a change breaks clients; it doesn't say how to make the change. The specification doesn't either. A tool definition has no deprecation field, and nothing in the pinned revision marks a tool as on its way out (tools). What follows is practice: the book's recommendation, built from parts the specification does define, not a protocol feature.

There are three such parts. A client asks for tool list changes with subscriptions/listen and hears about each one on that stream (subscriptions), as Tell clients when a resource changes shows for resources. A tools/list result carries a cache hint, ttlMs, and a change notification invalidates a cached list that is still fresh; clients MAY re-fetch early when a call fails as if the tool changed, for example with an unknown method or invalid parameters (caching). And a tool execution error is what clients SHOULD give the model so it can correct itself (tools, "Error Handling"). From those parts, the book recommends this procedure: add the new tool beside the old one; mark the old one "Deprecated: use …" in its description; announce the change; shorten the TTL while the change is under way; keep the old tool working through a window; and after the window, answer it with an execution error that names the replacement.

The shop is replacing find_orders with find_orders_v2, which can also filter by SKU. To walk through the three releases, the script serves chapter 3's tools from Design tools a model can use over Streamable HTTP on loopback, with a TTL of one minute on the tool list, and connects two clients: one that listens for list changes, and one that only caches. Release 2 adds find_orders_v2 and rewords find_orders, and the server publishes the change. Release 3 replaces find_orders with a function that raises ToolError. An in-memory client wouldn't do here, because the in-process path doesn't deliver list changes (Test tools in memory).

deprecate-a-tool.py Python 3.12.15 · cryptography 50.0.2 · httpx2 2.16.2 · jsonschema 4.26.0 · mcp 2.3.0 · mcp-types 2.3.0 · pydantic 2.14.3 · pytest 9.2.0 · starlette 1.10.0 · uvicorn 0.54.0 合格
"""Retire find_orders in favour of find_orders_v2 over three releases, watched by a listening client and a cachingclient. The prose's point rests on the caching client's list and on the last line, the error the old name returnsafter the window."""import asynciofrom mcp import Clientfrom mcp.server.caching import CacheHintfrom mcp.server.mcpserver import MCPServerfrom mcp.server.mcpserver.exceptions import ToolErrorfrom mcp.server.subscriptions import InMemorySubscriptionBus, ToolsListChangedfrom lib import confirmations, loopback, shop_toolsfrom lib.testing import shop_api_herebus, tools = InMemorySubscriptionBus(), confirmations.chapter3_tools()server = MCPServer("shop-support", version="0.11.0", tools=list(tools.values()), subscriptions=bus,                   cache_hints={"tools/list": CacheHint(ttl_ms=60_000, scope="public")})   # a minute: short while a change is under wayold = tools["find_orders"]def find_orders_v2(customer_id: shop_tools.CustomerId, sku: shop_tools.Sku | None = None) -> shop_tools.OrderList:    """Search one customer's orders, newest first, optionally only those with one product's SKU."""    found = old.fn(customer_id, limit=50)    return found.model_copy(update={"orders": [o for o in found.orders if sku is None or sku in o.skus]})def retired(customer_id: shop_tools.CustomerId) -> shop_tools.OrderList:    raise ToolError("find_orders was retired. Call find_orders_v2 with the same customer_id.")async def replace_find_orders(fn, description: str) -> None:    server.remove_tool("find_orders")    server.add_tool(fn, name="find_orders", title=old.title, description=description, annotations=old.annotations)    await bus.publish(ToolsListChanged())                     # to every client listening for list changesasync def main() -> None:    with shop_api_here(), loopback.serve(server.streamable_http_app()) as base_url:        async with Client(base_url + "/mcp") as listening, Client(base_url + "/mcp") as cached:            listing, _ = await cached.list_tools(), await listening.list_tools()     # both cache release 1's list            print("release 1:", f"{len(listing.tools)} tools, ttlMs {listing.ttl_ms}")            async with listening.listen(tools_list_changed=True) as changes:   # a stream that carries list-change events                server.add_tool(find_orders_v2)                                       # release 2: the replacement first                await replace_find_orders(old.fn, "Deprecated: use find_orders_v2. " + old.description)                print("event:", type(await anext(changes)).__name__)            print("listening client sees:", ", ".join(t.name for t in (await listening.list_tools()).tools))            print("cached client sees:", ", ".join(t.name for t in (await cached.list_tools()).tools))            during = await cached.call_tool("find_orders", {"customer_id": "C-0127"})            print("find_orders during the window:", "tool error" if during.is_error else "result")            await replace_find_orders(retired, "Retired: use find_orders_v2.")         # release 3: the old name now errors            after = await cached.call_tool("find_orders", {"customer_id": "C-0127"})            print("find_orders after the window:", after.content[0].text)asyncio.run(main())
出力python deprecate-a-tool.py
release 1: 5 tools, ttlMs 60000
event: ToolsListChanged
listening client sees: get_order_status, quote_refund, issue_refund, check_stock, find_orders_v2, find_orders
cached client sees: find_orders, get_order_status, quote_refund, issue_refund, check_stock
find_orders during the window: result
find_orders after the window: Error executing tool find_orders: find_orders was retired. Call find_orders_v2 with the same customer_id.

Release 1 listed 5 tools, ttlMs 60000. When release 2 shipped, the listening client received ToolsListChanged. The SDK drops a cached list before it hands the client such an event (mcp/client/client.py), so the listening client's next listing showed both tools: get_order_status, quote_refund, issue_refund, check_stock, find_orders_v2, find_orders.

The caching client heard nothing and served release 1's list from its cache: find_orders, get_order_status, quote_refund, issue_refund, check_stock. Its call to find_orders during the window still returned a result. A model behind a caching client doesn't learn about find_orders_v2 until the TTL runs out or the client re-fetches, which is why the TTL should be short while a change is under way, and why the old tool has to keep working.

After release 3, the caching client's call to find_orders came back as an execution error the model can act on: "Error executing tool find_orders: find_orders was retired. Call find_orders_v2 with the same customer_id.". A removed tool would have produced the SDK's unknown-tool error instead, which tells the model the name was wrong but not what to call (Report failures as tool results). The SDK returns that error as a tool execution error, although the specification makes an unknown tool a protocol error (mcp/server/mcpserver/tools/tool_manager.py; tools, "Error Handling").

The listening client's list also shows a side effect: find_orders moved to the end. MCPServer lists tools in the order they were added, so the release's live swap, which removes the tool and adds it back, moves it (Cache list results). A changed order changes the start of every prompt that renders the list, which is what a model provider's prompt cache matches on. A server that restarts with the new code lists tools in the order its code registers them, so add new tools at the end and leave the existing ones where they are.

Working rule: Retire a tool in three releases: add the replacement and mark the old tool deprecated in its description, keep both working through a window you announce, then answer the old name with an execution error that names the replacement. Shorten ttlMs on tools/list while the change is under way, publish a list change at each release, and open a subscriptions/listen stream in every host you control. Say in your changelog that the window is your policy, since the protocol defines none.

本番環境で起こる問題

最終変更:版2026.11.11

ここで行った確認は、1台のマシン上の1つのプロセスを対象としている。本番環境では、同じシグナルが多数のレプリカとクライアントから届き、それぞれが固有の形で誤解を招くことがある。

スパンが増えすぎて、バックエンドが索引付けできなくなる。 SDK はサーバースパンにメソッド名とツール名を付けるので、異なる名前の数はツールの一覧と同程度に抑えられる。スパン名に注文 ID、リソース URI、顧客 ID を含めると、値ごとに1つの名前が生まれる。MCP の規約がリソース URI を属性に入れているのは、このためである(MCP セマンティック規約)。兆候は、機能の数ではなくトラフィックに比例して増えるトレースの課金である。

トレースが店舗のデータを運ぶ。 SDK はスパンにツールの引数も結果も記録しない(mcp/server/_otel.py)。また、規約は gen_ai.tool.call.arguments をオプトインとしている(同じ出典)。この店舗の引数には顧客 ID と注文 ID が含まれ、引数が示すのは呼び出し側が送った内容だけである。誰が操作したかを記録するには、検証済みトークンのサブジェクトを使う。サポートホストでは、これは担当スタッフにあたる。顧客については、サーバーが確認したチケットレコードから取る(サーバーが混乱した代理人として動くのを防ぐ)。引数をスパンに加えるのは設定で許可した場合に限り、店舗のデータ取り扱い方針の対象外であるバックエンドには送らない。

規約はダッシュボードの足元で変わる。 MCP の規約は Development ステータスにあり、リポジトリが一度移動している(移動の通知)。また、SDK のミドルウェアは暫定版とされている(mcp/server/lowlevel/server.py)。属性名を変更する SDK リリースが出ると、エラーが出ないままダッシュボードが空になる。属性名は設定の1か所にまとめ、他の更新トリガーと同様に、SDK をアップグレードするたびに確認する。

デプロイ中にレプリカの内容が食い違う。 ローリングデプロイでは、あるレプリカがリリース1のスキーマを提供している一方で、次のレプリカはすでにリリース2のスキーマを提供している。一方から一覧を取得し、もう一方を呼び出したクライアントは、スキーマを契約として検査するで扱った RuntimeError に遭遇する。兆候は、デプロイ中に増え、終わると減るクライアント側の検証エラーである。まず追加のみの変更を出荷し、すべてのレプリカが新しい形を提供し、移行期間が過ぎてから、古い形を削除する。

記録は古くなる。 本番ホストの背後のモデルが変わっても、リプレイは通り続けるので、記録から得たスコアは顧客が目にする結果から乖離していく。チケットキューを処理するが勧めるとおり、モデルを変更するたびに記録し直す。また、記録時のモデルが起こさなかった失敗はリプレイでは見つけられないので、本番の実行からサンプルを抽出し、同じ根拠のない約束の検査をそれに対して行う。

実践ルール: トレースやスコアに頼る前に、それが何を対象としているかを確認する。確認すべきは、どのトランスポートか、どのモデルか、各スキーマのどのリリースかである。スパン名の種類は有限に保ち、引数は既定ではスパンに入れない。ダッシュボードが使う属性名は、名前の付いた規約のバージョンに固定する。どのリリースも、レプリカに届く前に契約テストとリプレイを実行する。

本章での決定事項

  • ツールはメモリ内でテストする。 テストには Client(server, raise_exceptions=True) を用い、フィールドを対象に検証する。インプロセスの経路が省略する部分については、トランスポートごとに1つのループバックテストを置く。
  • pytest は anyio 自身のプラグインで実行する。 本書が固定しない inline-snapshot は使わない。lib.testing はテストごとに1行を出力するため、出力は安定する。
  • 直前のリリースのスキーマを契約とする。 CI は、新しい結果を各スキーマが宣言する方言のバリデータで検証する。既定は 2020-12 である。lib.contract はレビューのためにスキーマの差分を取る。
  • 第10章の記録済み ticket-runs は、再記録せずに再生する。 説明文の変更後に RecordingMismatch が出た場合は、再記録が必要であることを意味する。
  • ホストは返信を呼び出しログと照合する。 どの呼び出しも行っていない返金を約束する返信は、人に回す。lib.queue_replay のキーワードチェックは経験則である。
  • トレースは SDK のミドルウェアから得る。 ミドルウェアが出力する属性には、Development ステータスの規約に基づくものであるとラベルを付ける。伝播は HTTP 上でテストする。
  • ツール選択はタグごとに採点し、引数は別に採点する。 採点には expected_first_tool を用いる。これは第10章での採点と同じである。注文 ID は、チケットの本文に照らした採点と、顧客が意図した注文に照らした採点の両方で行う。
  • ツールは3回のリリースをかけて廃止する。 各リリースで短い TTL を設定し、リストの変更を行う。猶予期間の後は、後継の名前を示す実行エラーを返す。この手順は本書の実践であり、仕様によるものではない。

この版における本章

第2026.11.14版2026年11月19日時点で例が通過この章の6 例件のうち6件が合格

英語版の書籍(版2026.11.14)から翻訳した。

この節を引用する

形式

いずれの形式も、本訳書が従う英語版の書籍を出典として示す。

いずれの形式もこの版を明示している。そのリンクは現行版を開き、節の見出しには本文が最後に変更された日付が示される。アクセス日と取得日は、これを開いた日である。

このページの内容

全12章中の第11章: サーバーをテストし、動作を観察する

  1. Test tools in memory
  2. Check schemas as a contract
  3. Replay recorded host runs
  4. Trace calls with OpenTelemetry
  5. 正しいツールが選ばれる頻度を測る
  6. Change tools without breaking clients
  7. 本番環境で起こる問題
  8. 本章での決定事項

ページの先頭に戻るすべての章