aiml

Lesson 29 of 37Module 10

Connect retrieval tools through MCP

Execute search and read across a real SDK process boundary

Expose documentation search and reads through an MCP client and server. Discover tool schemas and keep issued passage handles in the same session.

Prerequisites

Python, JSON and the preceding search/read, query-policy and action-admission contracts.

By the end, you can

  • Initialize and discover tools through an actual SDK stdio session.
  • Preserve issued search handles across read calls in the same server registry.
  • Validate returned source metadata and distinguish tool errors from startup failure.
Runtime
Python 3.12+
Dependencies
MCP SDK; pinned in requirements.txt and requirements.lock

Lab code, tests and fixtures (ZIP, 1.8 MB)Quiz check your understanding

Progress is saved in this browser.

A tool client needs to discover available operations and know how to call them. The Model Context Protocol (MCP) supplies that discovery and call boundary. It does not decide when a model should use a tool or whether a returned passage answers a question.

This lab uses stdio transport: a client starts a server subprocess and exchanges protocol messages through standard input and output. The server wraps the existing search/read implementation. The client must keep the same server instance alive between searching and reading because that instance owns the issued handles.

When you need this. Use this adapter when a tool client needs a standardized discovery and call boundary around the same retrieval implementation, with actual argument validation and source metadata.

Follow one example. Initialize the SDK session, discover the tool schemas and search the pinned corpus. Choose a returned handle and read it in that same session. Inspect the structured source result and its binding fields. Starting a fresh server and reusing the old handle fails because the new process has no record of issuing it.

You run a real SDK client and server and capture the protocol messages and argument checks between them. The client code chooses each call; no model chooses tools or generates an answer.

Expose search and read through an MCP session

MCP clientsessionSDK client overstdioMCP serverValidate toolrequestsSearch handlesMetadata onlyRead selectedhandleSame serverregistrySource textWith sourcemetadataRefuse therequestNo source readMCP clientsessionSDK client overstdioMCP serverValidate toolrequestsSearch handlesMetadata onlyRead selectedhandleSame serverregistrySource textWith sourcemetadataRefuse therequestNo source read
The client and server share the issued-handle contract. Returning a search handle is different from returning source text. Dashed arrows show conditional paths.
  1. Call the stdio MCP server.
  2. Issue validated search handles.
  3. Resolve a selected handle in the same registry.
  4. Return the exact source text.
  5. Reject invalid tool requests.
  6. Refuse unknown or invalid handles.

Initialize before discovering and calling tools

The pinned SDK server uses MCPServer. The client uses its compatibility session initialization path, then requests tool discovery and invokes the discovered operations. In this run the client and server negotiate protocol 2025-11-25. The lab does not use the SDK’s newer discovery-only client path, and it does not claim to negotiate the newest protocol revision.

The client relays each SDK message between its session streams and the child-process transport, and the run records a copy of each message. Server lifecycle diagnostics go to stderr, because stdout carries the protocol messages. In a stdio server, write logs to stderr only; any other output on stdout corrupts the protocol stream.

Keep the issued search record alive for the read call

The discovered tools are search_documentation and read_documentation. Search accepts the bounded literal term, requested version and result limit. It returns metadata-only handles from the same pinned corpus used by the HTTP boundary.

One registry inside the running server keeps the issued search records. The client sends a selected handle to the read tool on that same server process. The server checks the handle, finds the exact paragraph and checks the read result before it returns structured output.

Unissued handle. A fresh child process does not inherit another process’s search records, so it rejects that process’s handle with unissued_search_receipt. An unknown, stale or edited handle also fails; it cannot select arbitrary source text. Keep a search and its reads in one session. If the server restarts, run the search again before you read.

Invalid arguments. The generated tool schemas are strict. They reject extra fields and invalid values, such as k set to true or 11, before the search runs.

Validate the SDK result as source data

The client checks structured output against the declared model and compares it with the JSON text content returned by the SDK. Search results must match the caller’s query, version, result limit, corpus and request digest. Read results must preserve the issued handle, text hash, UTF-8 byte count and result digest.

Changed result. A test changes the first character of the read text and recomputes the result digest. The client still rejects the result, because the text no longer matches text_sha256. The same test checks a search result against a different expected query, and the request binding fails. A valid MCP transport and schema do not make altered source data acceptable, so run the source checks in the client as well as in the server.

Each invalid call in the run returns an SDK tool-error result. A call to an unknown tool also returns a tool result with isError true in this run. Do not assume that every MCP implementation reports an unknown tool this way.

Recorded caseToolTool error
searchsearch_documentationfalse
read-issued-handleread_documentationfalse
empty-searchsearch_documentationfalse
absent-versionsearch_documentationfalse
version-3-13search_documentationfalse
invalid-argumentssearch_documentationtrue
extra-argumentsearch_documentationtrue
unissued-receiptread_documentationtrue
stale-corpusread_documentationtrue
changed-handleread_documentationtrue

Changed pinned source. When the startup fixture edits the corpus file, the server fails to load it and initialization never completes. The client sends initialize, and the server sends no response. The raw record keeps the SDK exception category, child stderr with snapshot_file_hash_mismatch and that partial protocol transcript. This is a startup failure, not a tool error from an initialized server.

Execute the SDK client and child server

Download the MCP retrieval lab. It supplies the server, typed schemas, actual SDK client, pinned dependencies, original corpus and subprocess-boundary tests.

The SDK package and its required dependency closure are pinned in the download. Prepare a reader environment before launching the client:

Prepare the pinned environmentTerminal · bash
python -m venv .venv
. .venv/bin/activate
python -m pip install -r requirements.lock
server.pySource · pythonDownload
"""Real MCP SDK stdio server; stdout is reserved for SDK protocol messages."""
from contextlib import asynccontextmanager
import logging
from typing import Annotated
from pydantic import ConfigDict,Field
from mcp.server.mcpserver import MCPServer
from mcp.server.mcpserver.tools import Tool
from mcp.server.mcpserver.exceptions import ToolError as MCPToolError
from schemas import Handle,Query,Version,SearchResult,ReadResult
from tools import DocumentationTools,ToolError,load_snapshot
from version_documents import canonical_hash


def strict_tool(function):
    tool=Tool.from_function(function,structured_output=True)
    # Per-tool generated argument model: publish and enforce the same strict schema.
    tool.fn_metadata.arg_model.model_config=ConfigDict(extra='forbid',strict=True)
    tool.fn_metadata.arg_model.model_rebuild(force=True)
    tool.parameters=tool.fn_metadata.arg_model.model_json_schema()
    return tool


def build_server():
    registry=DocumentationTools(load_snapshot())

    async def search_documentation(query:Query,version:Version,k:Annotated[int,Field(ge=1,le=10,strict=True)]=2)->SearchResult:
        """Search the pinned corpus by one literal term and exact API version; return read handles."""
        try:
            result=registry.search(query=query,version=version,k=k)
            expected=registry.receipts[result['search_request_id']]
            if canonical_hash(result)!=canonical_hash(expected):raise ToolError('invalid_search_result')
            for handle in result['results']:registry.validate_handle(handle)
            return SearchResult.model_validate(result)
        except (ToolError,ValueError) as error:raise MCPToolError(str(error)) from error

    async def read_documentation(handle:Handle)->ReadResult:
        """Read an exact handle issued by this running server; no arbitrary file or URL access."""
        try:
            receipt=handle.model_dump()
            result=registry.read(receipt)
            registry.validate_read(result,receipt)
            return ReadResult.model_validate(result)
        except (ToolError,ValueError) as error:raise MCPToolError(str(error)) from error

    @asynccontextmanager
    async def lifespan(server):
        logging.info('retrieval registry ready')
        try:yield registry
        finally:
            registry.close()
            logging.info('retrieval registry closed')

    return MCPServer('local-documentation-retrieval',version='1.0.0',tools=[strict_tool(search_documentation),strict_tool(read_documentation)],lifespan=lifespan,log_level='WARNING')


if __name__=='__main__':
    logging.basicConfig(level=logging.INFO,format='%(levelname)s %(message)s')
    build_server().run(transport='stdio')

The client implementation checks caller binding and source metadata. From the unpacked lab, run:

Exercise actual MCP discovery and callsTerminal · bash
python run.py --output scratch-result.json
python -m unittest discover -v
Saved CLI outputRecorded output · jsonDownload
{
  "execution_mode": "actual-mcp-sdk-stdio-client-server",
  "model_called": false,
  "protocol_version": "2025-11-25",
  "read_source": "path-read",
  "recorded_calls": 10,
  "tools": [
    "search_documentation",
    "read_documentation"
  ]
}

run.py starts the server as its stdio child process. If you run python server.py by hand, it waits for a protocol client; it does not open an interactive prompt. These calls need no network service, embedding endpoint or model provider.

The registry lives as long as the server process and closes during lifecycle cleanup. It keeps every distinct search for that lifetime and has no memory cap. The lab has no durable replay, remote transport or user authorization, and it measures no production capacity. Wrapping the tools in MCP does not add those policies.

Inspect the complete saved result
Actual local boundary executionRecorded output · jsonDownload
{
  "changed_snapshot_startup": {
    "status": "failed_before_initialize",
    "exception_type": "ExceptionGroup",
    "server_stderr": "Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\n  File \"<frozen runpy>\", line 287, in run_path\n  File \"<frozen runpy>\", line 98, in _run_module_code\n  File \"<frozen runpy>\", line 88, in _run_code\n  File \"/var/folders/8q/3xqw2gjj54vbtxmv1hz753wr0000gn/T/tmplpljwmrn/changed-server/server.py\", line 58, in <module>\n    build_server().run(transport='stdio')\n    ^^^^^^^^^^^^^^\n  File \"/var/folders/8q/3xqw2gjj54vbtxmv1hz753wr0000gn/T/tmplpljwmrn/changed-server/server.py\", line 24, in build_server\n    registry=DocumentationTools(load_snapshot())\n                                ^^^^^^^^^^^^^^^\n  File \"/private/var/folders/8q/3xqw2gjj54vbtxmv1hz753wr0000gn/T/tmplpljwmrn/changed-server/tools.py\", line 17, in load_snapshot\n    if hashlib.sha256(raw).hexdigest()!=SNAPSHOT_SHA256:raise ToolError('snapshot_file_hash_mismatch')\n                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\ntools.ToolError: snapshot_file_hash_mismatch\n",
    "protocol_frames": [
      {
        "direction": "client_to_server",
        "message": {
          "jsonrpc": "2.0",
          "id": 1,
          "method": "initialize",
          "params": {
            "protocolVersion": "2025-11-25",
            "capabilities": {},
            "clientInfo": {
              "name": "mcp",
              "version": "0.1.0"
            }
          }
        }
      }
    ]
  },
  "execution_mode": "actual-mcp-sdk-stdio-client-server",
  "model_called": false,
  "sdk_entrypoints": [
    "MCPServer",
    "stdio_client",
    "ClientSession.initialize",
    "ClientSession.list_tools",
    "ClientSession.call_tool"
  ],
  "initialization": {
    "protocolVersion": "2025-11-25",
    "capabilities": {
      "prompts": {
        "listChanged": false
      },
      "resources": {
        "subscribe": false,
        "listChanged": false
      },
      "tools": {
        "listChanged": false
      }
    },
    "serverInfo": {
      "name": "local-documentation-retrieval",
      "version": "1.0.0"
    }
  },
  "tools": {
    "ttlMs": 0,
    "cacheScope": "private",
    "tools": [
      {
        "name": "search_documentation",
        "description": "Search the pinned corpus by one literal term and exact API version; return read handles.",
        "inputSchema": {
          "properties": {
            "query": {
              "pattern": "^[A-Za-z0-9]{1,64}$",
              "title": "Query",
              "type": "string"
            },
            "version": {
              "maxLength": 16,
              "pattern": "^[0-9]+\\.[0-9]+$",
              "title": "Version",
              "type": "string"
            },
            "k": {
              "default": 2,
              "maximum": 10,
              "minimum": 1,
              "title": "K",
              "type": "integer"
            }
          },
          "required": [
            "query",
            "version"
          ],
          "type": "object",
          "additionalProperties": false,
          "title": "search_documentationArguments"
        },
        "outputSchema": {
          "properties": {
            "corpus_id": {
              "pattern": "^[0-9a-f]{64}$",
              "title": "Corpus Id",
              "type": "string"
            },
            "search_request_id": {
              "pattern": "^[0-9a-f]{64}$",
              "title": "Search Request Id",
              "type": "string"
            },
            "query": {
              "pattern": "^[A-Za-z0-9]{1,64}$",
              "title": "Query",
              "type": "string"
            },
            "version": {
              "maxLength": 16,
              "pattern": "^[0-9]+\\.[0-9]+$",
              "title": "Version",
              "type": "string"
            },
            "k": {
              "maximum": 10,
              "minimum": 1,
              "title": "K",
              "type": "integer"
            },
            "results": {
              "items": {
                "$ref": "#/$defs/Handle"
              },
              "maxItems": 10,
              "title": "Results",
              "type": "array"
            }
          },
          "required": [
            "corpus_id",
            "search_request_id",
            "query",
            "version",
            "k",
            "results"
          ],
          "type": "object",
          "$defs": {
            "Handle": {
              "additionalProperties": false,
              "properties": {
                "corpus_id": {
                  "pattern": "^[0-9a-f]{64}$",
                  "title": "Corpus Id",
                  "type": "string"
                },
                "search_request_id": {
                  "pattern": "^[0-9a-f]{64}$",
                  "title": "Search Request Id",
                  "type": "string"
                },
                "passage_id": {
                  "pattern": "^[0-9a-f]{64}$",
                  "title": "Passage Id",
                  "type": "string"
                },
                "source_id": {
                  "maxLength": 256,
                  "minLength": 1,
                  "title": "Source Id",
                  "type": "string"
                },
                "version": {
                  "maxLength": 16,
                  "pattern": "^[0-9]+\\.[0-9]+$",
                  "title": "Version",
                  "type": "string"
                },
                "document_revision": {
                  "pattern": "^[0-9a-f]{64}$",
                  "title": "Document Revision",
                  "type": "string"
                },
                "source_sha256": {
                  "pattern": "^[0-9a-f]{64}$",
                  "title": "Source Sha256",
                  "type": "string"
                },
                "start_line": {
                  "maximum": 65536,
                  "minimum": 1,
                  "title": "Start Line",
                  "type": "integer"
                },
                "end_line": {
                  "maximum": 65536,
                  "minimum": 1,
                  "title": "End Line",
                  "type": "integer"
                },
                "text_sha256": {
                  "pattern": "^[0-9a-f]{64}$",
                  "title": "Text Sha256",
                  "type": "string"
                },
                "byte_count": {
                  "maximum": 65536,
                  "minimum": 0,
                  "title": "Byte Count",
                  "type": "integer"
                },
                "native_score": {
                  "title": "Native Score",
                  "type": "number"
                },
                "rank": {
                  "maximum": 10,
                  "minimum": 1,
                  "title": "Rank",
                  "type": "integer"
                },
                "read_token": {
                  "pattern": "^[0-9a-f]{64}$",
                  "title": "Read Token",
                  "type": "string"
                }
              },
              "required": [
                "corpus_id",
                "search_request_id",
                "passage_id",
                "source_id",
                "version",
                "document_revision",
                "source_sha256",
                "start_line",
                "end_line",
                "text_sha256",
                "byte_count",
                "native_score",
                "rank",
                "read_token"
              ],
              "title": "Handle",
              "type": "object"
            }
          },
          "additionalProperties": false,
          "title": "SearchResult"
        }
      },
      {
        "name": "read_documentation",
        "description": "Read an exact handle issued by this running server; no arbitrary file or URL access.",
        "inputSchema": {
          "properties": {
            "handle": {
              "$ref": "#/$defs/Handle"
            }
          },
          "required": [
            "handle"
          ],
          "type": "object",
          "$defs": {
            "Handle": {
              "additionalProperties": false,
              "properties": {
                "corpus_id": {
                  "pattern": "^[0-9a-f]{64}$",
                  "title": "Corpus Id",
                  "type": "string"
                },
                "search_request_id": {
                  "pattern": "^[0-9a-f]{64}$",
                  "title": "Search Request Id",
                  "type": "string"
                },
                "passage_id": {
                  "pattern": "^[0-9a-f]{64}$",
                  "title": "Passage Id",
                  "type": "string"
                },
                "source_id": {
                  "maxLength": 256,
                  "minLength": 1,
                  "title": "Source Id",
                  "type": "string"
                },
                "version": {
                  "maxLength": 16,
                  "pattern": "^[0-9]+\\.[0-9]+$",
                  "title": "Version",
                  "type": "string"
                },
                "document_revision": {
                  "pattern": "^[0-9a-f]{64}$",
                  "title": "Document Revision",
                  "type": "string"
                },
                "source_sha256": {
                  "pattern": "^[0-9a-f]{64}$",
                  "title": "Source Sha256",
                  "type": "string"
                },
                "start_line": {
                  "maximum": 65536,
                  "minimum": 1,
                  "title": "Start Line",
                  "type": "integer"
                },
                "end_line": {
                  "maximum": 65536,
                  "minimum": 1,
                  "title": "End Line",
                  "type": "integer"
                },
                "text_sha256": {
                  "pattern": "^[0-9a-f]{64}$",
                  "title": "Text Sha256",
                  "type": "string"
                },
                "byte_count": {
                  "maximum": 65536,
                  "minimum": 0,
                  "title": "Byte Count",
                  "type": "integer"
                },
                "native_score": {
                  "title": "Native Score",
                  "type": "number"
                },
                "rank": {
                  "maximum": 10,
                  "minimum": 1,
                  "title": "Rank",
                  "type": "integer"
                },
                "read_token": {
                  "pattern": "^[0-9a-f]{64}$",
                  "title": "Read Token",
                  "type": "string"
                }
              },
              "required": [
                "corpus_id",
                "search_request_id",
                "passage_id",
                "source_id",
                "version",
                "document_revision",
                "source_sha256",
                "start_line",
                "end_line",
                "text_sha256",
                "byte_count",
                "native_score",
                "rank",
                "read_token"
              ],
              "title": "Handle",
              "type": "object"
            }
          },
          "additionalProperties": false,
          "title": "read_documentationArguments"
        },
        "outputSchema": {
          "properties": {
            "corpus_id": {
              "pattern": "^[0-9a-f]{64}$",
              "title": "Corpus Id",
              "type": "string"
            },
            "search_request_id": {
              "pattern": "^[0-9a-f]{64}$",
              "title": "Search Request Id",
              "type": "string"
            },
            "passage_id": {
              "pattern": "^[0-9a-f]{64}$",
              "title": "Passage Id",
              "type": "string"
            },
            "source_id": {
              "maxLength": 256,
              "minLength": 1,
              "title": "Source Id",
              "type": "string"
            },
            "version": {
              "maxLength": 16,
              "pattern": "^[0-9]+\\.[0-9]+$",
              "title": "Version",
              "type": "string"
            },
            "document_revision": {
              "pattern": "^[0-9a-f]{64}$",
              "title": "Document Revision",
              "type": "string"
            },
            "source_sha256": {
              "pattern": "^[0-9a-f]{64}$",
              "title": "Source Sha256",
              "type": "string"
            },
            "start_line": {
              "maximum": 65536,
              "minimum": 1,
              "title": "Start Line",
              "type": "integer"
            },
            "end_line": {
              "maximum": 65536,
              "minimum": 1,
              "title": "End Line",
              "type": "integer"
            },
            "text_sha256": {
              "pattern": "^[0-9a-f]{64}$",
              "title": "Text Sha256",
              "type": "string"
            },
            "byte_count": {
              "maximum": 65536,
              "minimum": 0,
              "title": "Byte Count",
              "type": "integer"
            },
            "native_score": {
              "title": "Native Score",
              "type": "number"
            },
            "rank": {
              "maximum": 10,
              "minimum": 1,
              "title": "Rank",
              "type": "integer"
            },
            "read_token": {
              "pattern": "^[0-9a-f]{64}$",
              "title": "Read Token",
              "type": "string"
            },
            "text": {
              "maxLength": 65536,
              "title": "Text",
              "type": "string"
            },
            "url": {
              "maxLength": 2048,
              "title": "Url",
              "type": "string"
            },
            "read_request_id": {
              "pattern": "^[0-9a-f]{64}$",
              "title": "Read Request Id",
              "type": "string"
            },
            "result_sha256": {
              "pattern": "^[0-9a-f]{64}$",
              "title": "Result Sha256",
              "type": "string"
            }
          },
          "required": [
            "corpus_id",
            "search_request_id",
            "passage_id",
            "source_id",
            "version",
            "document_revision",
            "source_sha256",
            "start_line",
            "end_line",
            "text_sha256",
            "byte_count",
            "native_score",
            "rank",
            "read_token",
            "text",
            "url",
            "read_request_id",
            "result_sha256"
          ],
          "type": "object",
          "additionalProperties": false,
          "title": "ReadResult"
        }
      }
    ],
    "resultType": "complete"
  },
  "calls": [
    {
      "case_id": "search",
      "tool": "search_documentation",
      "arguments": {
        "query": "text",
        "version": "3.12",
        "k": 2
      },
      "result": {
        "content": [
          {
            "type": "text",
            "text": "{\n  \"corpus_id\": \"0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e\",\n  \"search_request_id\": \"3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f\",\n  \"query\": \"text\",\n  \"version\": \"3.12\",\n  \"k\": 2,\n  \"results\": [\n    {\n      \"corpus_id\": \"0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e\",\n      \"search_request_id\": \"3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f\",\n      \"passage_id\": \"c737db948e8111ae00e3442d8a22c80c876e43446dc1ee176ffe8ce142a41900\",\n      \"source_id\": \"path-read\",\n      \"version\": \"3.12\",\n      \"document_revision\": \"b58385b9bf597a951c16c035653d639929924e53eae3e5ada255afd6ee1592f2\",\n      \"source_sha256\": \"dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0\",\n      \"start_line\": 1,\n      \"end_line\": 1,\n      \"text_sha256\": \"dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0\",\n      \"byte_count\": 154,\n      \"native_score\": -1.4220532319391636e-6,\n      \"rank\": 1,\n      \"read_token\": \"72abbf5e0022ef780447ed8c2322b711cac8b4971d817a440bc02dfa28b07124\"\n    },\n    {\n      \"corpus_id\": \"0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e\",\n      \"search_request_id\": \"3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f\",\n      \"passage_id\": \"c66643a4609c6ee157458bf4353f7446b9c6a200a3ef453846d6a18d5b5069a7\",\n      \"source_id\": \"path-write\",\n      \"version\": \"3.12\",\n      \"document_revision\": \"28c6349eaf80b629322edb310bb871dc45a04af9fad3b752bc75d12f0d7314e7\",\n      \"source_sha256\": \"a48b4b9f763cd6309ebe32af19c5a814adcf810c2259683da9f328ccee46948e\",\n      \"start_line\": 1,\n      \"end_line\": 1,\n      \"text_sha256\": \"a48b4b9f763cd6309ebe32af19c5a814adcf810c2259683da9f328ccee46948e\",\n      \"byte_count\": 224,\n      \"native_score\": -1.3203883495145633e-6,\n      \"rank\": 2,\n      \"read_token\": \"189bf56802f958924691f452106802696dcd22186df4ee9c03bf0efecf1e1f81\"\n    }\n  ]\n}"
          }
        ],
        "structuredContent": {
          "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
          "search_request_id": "3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f",
          "query": "text",
          "version": "3.12",
          "k": 2,
          "results": [
            {
              "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
              "search_request_id": "3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f",
              "passage_id": "c737db948e8111ae00e3442d8a22c80c876e43446dc1ee176ffe8ce142a41900",
              "source_id": "path-read",
              "version": "3.12",
              "document_revision": "b58385b9bf597a951c16c035653d639929924e53eae3e5ada255afd6ee1592f2",
              "source_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
              "start_line": 1,
              "end_line": 1,
              "text_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
              "byte_count": 154,
              "native_score": -1.4220532319391636e-06,
              "rank": 1,
              "read_token": "72abbf5e0022ef780447ed8c2322b711cac8b4971d817a440bc02dfa28b07124"
            },
            {
              "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
              "search_request_id": "3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f",
              "passage_id": "c66643a4609c6ee157458bf4353f7446b9c6a200a3ef453846d6a18d5b5069a7",
              "source_id": "path-write",
              "version": "3.12",
              "document_revision": "28c6349eaf80b629322edb310bb871dc45a04af9fad3b752bc75d12f0d7314e7",
              "source_sha256": "a48b4b9f763cd6309ebe32af19c5a814adcf810c2259683da9f328ccee46948e",
              "start_line": 1,
              "end_line": 1,
              "text_sha256": "a48b4b9f763cd6309ebe32af19c5a814adcf810c2259683da9f328ccee46948e",
              "byte_count": 224,
              "native_score": -1.3203883495145633e-06,
              "rank": 2,
              "read_token": "189bf56802f958924691f452106802696dcd22186df4ee9c03bf0efecf1e1f81"
            }
          ]
        },
        "isError": false,
        "resultType": "complete"
      }
    },
    {
      "case_id": "read-issued-handle",
      "tool": "read_documentation",
      "arguments": {
        "handle": {
          "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
          "search_request_id": "3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f",
          "passage_id": "c737db948e8111ae00e3442d8a22c80c876e43446dc1ee176ffe8ce142a41900",
          "source_id": "path-read",
          "version": "3.12",
          "document_revision": "b58385b9bf597a951c16c035653d639929924e53eae3e5ada255afd6ee1592f2",
          "source_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
          "start_line": 1,
          "end_line": 1,
          "text_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
          "byte_count": 154,
          "native_score": -1.4220532319391636e-06,
          "rank": 1,
          "read_token": "72abbf5e0022ef780447ed8c2322b711cac8b4971d817a440bc02dfa28b07124"
        }
      },
      "result": {
        "content": [
          {
            "type": "text",
            "text": "{\n  \"corpus_id\": \"0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e\",\n  \"search_request_id\": \"3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f\",\n  \"passage_id\": \"c737db948e8111ae00e3442d8a22c80c876e43446dc1ee176ffe8ce142a41900\",\n  \"source_id\": \"path-read\",\n  \"version\": \"3.12\",\n  \"document_revision\": \"b58385b9bf597a951c16c035653d639929924e53eae3e5ada255afd6ee1592f2\",\n  \"source_sha256\": \"dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0\",\n  \"start_line\": 1,\n  \"end_line\": 1,\n  \"text_sha256\": \"dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0\",\n  \"byte_count\": 154,\n  \"native_score\": -1.4220532319391636e-6,\n  \"rank\": 1,\n  \"read_token\": \"72abbf5e0022ef780447ed8c2322b711cac8b4971d817a440bc02dfa28b07124\",\n  \"text\": \"Path.read_text(encoding=None, errors=None) opens a file, returns its text as a string and closes the file. Set encoding=\\\"utf-8\\\" when reading a UTF-8 file.\",\n  \"url\": \"https://docs.python.org/3.12/library/pathlib.html#pathlib.Path.read_text\",\n  \"read_request_id\": \"b2ce4d1e809a197df6c864261264b583737b1f41c59f8a4b6e353911b84c5bfe\",\n  \"result_sha256\": \"2d855cfa0b4f7e90c3711783b7779709f3b964760fd789d0d65b11f9b3604ac5\"\n}"
          }
        ],
        "structuredContent": {
          "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
          "search_request_id": "3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f",
          "passage_id": "c737db948e8111ae00e3442d8a22c80c876e43446dc1ee176ffe8ce142a41900",
          "source_id": "path-read",
          "version": "3.12",
          "document_revision": "b58385b9bf597a951c16c035653d639929924e53eae3e5ada255afd6ee1592f2",
          "source_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
          "start_line": 1,
          "end_line": 1,
          "text_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
          "byte_count": 154,
          "native_score": -1.4220532319391636e-06,
          "rank": 1,
          "read_token": "72abbf5e0022ef780447ed8c2322b711cac8b4971d817a440bc02dfa28b07124",
          "text": "Path.read_text(encoding=None, errors=None) opens a file, returns its text as a string and closes the file. Set encoding=\"utf-8\" when reading a UTF-8 file.",
          "url": "https://docs.python.org/3.12/library/pathlib.html#pathlib.Path.read_text",
          "read_request_id": "b2ce4d1e809a197df6c864261264b583737b1f41c59f8a4b6e353911b84c5bfe",
          "result_sha256": "2d855cfa0b4f7e90c3711783b7779709f3b964760fd789d0d65b11f9b3604ac5"
        },
        "isError": false,
        "resultType": "complete"
      }
    },
    {
      "case_id": "empty-search",
      "tool": "search_documentation",
      "arguments": {
        "query": "zzunmatched",
        "version": "3.12",
        "k": 2
      },
      "result": {
        "content": [
          {
            "type": "text",
            "text": "{\n  \"corpus_id\": \"0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e\",\n  \"search_request_id\": \"0afcd01a3dd4e765c4bab273c25d4239de4d71369b989bbbe25e1e270ef07647\",\n  \"query\": \"zzunmatched\",\n  \"version\": \"3.12\",\n  \"k\": 2,\n  \"results\": []\n}"
          }
        ],
        "structuredContent": {
          "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
          "search_request_id": "0afcd01a3dd4e765c4bab273c25d4239de4d71369b989bbbe25e1e270ef07647",
          "query": "zzunmatched",
          "version": "3.12",
          "k": 2,
          "results": []
        },
        "isError": false,
        "resultType": "complete"
      }
    },
    {
      "case_id": "absent-version",
      "tool": "search_documentation",
      "arguments": {
        "query": "text",
        "version": "9.99",
        "k": 2
      },
      "result": {
        "content": [
          {
            "type": "text",
            "text": "{\n  \"corpus_id\": \"0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e\",\n  \"search_request_id\": \"fefe356a697d65ea81980cd228d12ddde25c3d62fe8a4badbaafc3f385052d97\",\n  \"query\": \"text\",\n  \"version\": \"9.99\",\n  \"k\": 2,\n  \"results\": []\n}"
          }
        ],
        "structuredContent": {
          "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
          "search_request_id": "fefe356a697d65ea81980cd228d12ddde25c3d62fe8a4badbaafc3f385052d97",
          "query": "text",
          "version": "9.99",
          "k": 2,
          "results": []
        },
        "isError": false,
        "resultType": "complete"
      }
    },
    {
      "case_id": "version-3-13",
      "tool": "search_documentation",
      "arguments": {
        "query": "read",
        "version": "3.13",
        "k": 2
      },
      "result": {
        "content": [
          {
            "type": "text",
            "text": "{\n  \"corpus_id\": \"0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e\",\n  \"search_request_id\": \"6644a5007738d93bc51c8c2dc73d8e6d2aa86c6bfa01c1b87cd40d994ff93be0\",\n  \"query\": \"read\",\n  \"version\": \"3.13\",\n  \"k\": 2,\n  \"results\": [\n    {\n      \"corpus_id\": \"0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e\",\n      \"search_request_id\": \"6644a5007738d93bc51c8c2dc73d8e6d2aa86c6bfa01c1b87cd40d994ff93be0\",\n      \"passage_id\": \"bdaeff5ae3ab88b70b12b9b6d4a0a46de45ea14520b971a7756cb03bbd384f35\",\n      \"source_id\": \"path-read-3-13\",\n      \"version\": \"3.13\",\n      \"document_revision\": \"d68df3e7ea1e24af3f40366a61402fc80558fefe2ef5f3eda928de0e01820db9\",\n      \"source_sha256\": \"0dd5becb0c04458ad5f8bbf3fdef4f71034c584ef863bf748793bef7309b9f4f\",\n      \"start_line\": 1,\n      \"end_line\": 1,\n      \"text_sha256\": \"0dd5becb0c04458ad5f8bbf3fdef4f71034c584ef863bf748793bef7309b9f4f\",\n      \"byte_count\": 174,\n      \"native_score\": -1.0374479889042996e-6,\n      \"rank\": 1,\n      \"read_token\": \"d66070e4825f4678515afdebeaf88fc6ac76b52a18688121494689935d16bd67\"\n    }\n  ]\n}"
          }
        ],
        "structuredContent": {
          "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
          "search_request_id": "6644a5007738d93bc51c8c2dc73d8e6d2aa86c6bfa01c1b87cd40d994ff93be0",
          "query": "read",
          "version": "3.13",
          "k": 2,
          "results": [
            {
              "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
              "search_request_id": "6644a5007738d93bc51c8c2dc73d8e6d2aa86c6bfa01c1b87cd40d994ff93be0",
              "passage_id": "bdaeff5ae3ab88b70b12b9b6d4a0a46de45ea14520b971a7756cb03bbd384f35",
              "source_id": "path-read-3-13",
              "version": "3.13",
              "document_revision": "d68df3e7ea1e24af3f40366a61402fc80558fefe2ef5f3eda928de0e01820db9",
              "source_sha256": "0dd5becb0c04458ad5f8bbf3fdef4f71034c584ef863bf748793bef7309b9f4f",
              "start_line": 1,
              "end_line": 1,
              "text_sha256": "0dd5becb0c04458ad5f8bbf3fdef4f71034c584ef863bf748793bef7309b9f4f",
              "byte_count": 174,
              "native_score": -1.0374479889042996e-06,
              "rank": 1,
              "read_token": "d66070e4825f4678515afdebeaf88fc6ac76b52a18688121494689935d16bd67"
            }
          ]
        },
        "isError": false,
        "resultType": "complete"
      }
    },
    {
      "case_id": "invalid-arguments",
      "tool": "search_documentation",
      "arguments": {
        "query": "text",
        "version": "3.12",
        "k": true
      },
      "result": {
        "content": [
          {
            "type": "text",
            "text": "Error executing tool search_documentation: 1 validation error for search_documentationArguments\nk\n  Input should be a valid integer [type=int_type, input_value=True, input_type=bool]\n    For further information visit https://errors.pydantic.dev/2.14/v/int_type"
          }
        ],
        "isError": true,
        "resultType": "complete"
      }
    },
    {
      "case_id": "extra-argument",
      "tool": "search_documentation",
      "arguments": {
        "query": "text",
        "version": "3.12",
        "unexpected": 1
      },
      "result": {
        "content": [
          {
            "type": "text",
            "text": "Error executing tool search_documentation: 1 validation error for search_documentationArguments\nunexpected\n  Extra inputs are not permitted [type=extra_forbidden, input_value=1, input_type=int]\n    For further information visit https://errors.pydantic.dev/2.14/v/extra_forbidden"
          }
        ],
        "isError": true,
        "resultType": "complete"
      }
    },
    {
      "case_id": "unissued-receipt",
      "tool": "read_documentation",
      "arguments": {
        "handle": {
          "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
          "search_request_id": "0000000000000000000000000000000000000000000000000000000000000000",
          "passage_id": "c737db948e8111ae00e3442d8a22c80c876e43446dc1ee176ffe8ce142a41900",
          "source_id": "path-read",
          "version": "3.12",
          "document_revision": "b58385b9bf597a951c16c035653d639929924e53eae3e5ada255afd6ee1592f2",
          "source_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
          "start_line": 1,
          "end_line": 1,
          "text_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
          "byte_count": 154,
          "native_score": -1.4220532319391636e-06,
          "rank": 1,
          "read_token": "72abbf5e0022ef780447ed8c2322b711cac8b4971d817a440bc02dfa28b07124"
        }
      },
      "result": {
        "content": [
          {
            "type": "text",
            "text": "Error executing tool read_documentation: unissued_search_receipt"
          }
        ],
        "isError": true,
        "resultType": "complete"
      }
    },
    {
      "case_id": "stale-corpus",
      "tool": "read_documentation",
      "arguments": {
        "handle": {
          "corpus_id": "0000000000000000000000000000000000000000000000000000000000000000",
          "search_request_id": "3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f",
          "passage_id": "c737db948e8111ae00e3442d8a22c80c876e43446dc1ee176ffe8ce142a41900",
          "source_id": "path-read",
          "version": "3.12",
          "document_revision": "b58385b9bf597a951c16c035653d639929924e53eae3e5ada255afd6ee1592f2",
          "source_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
          "start_line": 1,
          "end_line": 1,
          "text_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
          "byte_count": 154,
          "native_score": -1.4220532319391636e-06,
          "rank": 1,
          "read_token": "72abbf5e0022ef780447ed8c2322b711cac8b4971d817a440bc02dfa28b07124"
        }
      },
      "result": {
        "content": [
          {
            "type": "text",
            "text": "Error executing tool read_documentation: stale_corpus"
          }
        ],
        "isError": true,
        "resultType": "complete"
      }
    },
    {
      "case_id": "changed-handle",
      "tool": "read_documentation",
      "arguments": {
        "handle": {
          "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
          "search_request_id": "3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f",
          "passage_id": "c737db948e8111ae00e3442d8a22c80c876e43446dc1ee176ffe8ce142a41900",
          "source_id": "path-read",
          "version": "3.12",
          "document_revision": "b58385b9bf597a951c16c035653d639929924e53eae3e5ada255afd6ee1592f2",
          "source_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
          "start_line": 1,
          "end_line": 1,
          "text_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
          "byte_count": 155,
          "native_score": -1.4220532319391636e-06,
          "rank": 1,
          "read_token": "72abbf5e0022ef780447ed8c2322b711cac8b4971d817a440bc02dfa28b07124"
        }
      },
      "result": {
        "content": [
          {
            "type": "text",
            "text": "Error executing tool read_documentation: invalid_read_handle"
          }
        ],
        "isError": true,
        "resultType": "complete"
      }
    }
  ],
  "validated_search": {
    "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
    "search_request_id": "3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f",
    "query": "text",
    "version": "3.12",
    "k": 2,
    "results": [
      {
        "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
        "search_request_id": "3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f",
        "passage_id": "c737db948e8111ae00e3442d8a22c80c876e43446dc1ee176ffe8ce142a41900",
        "source_id": "path-read",
        "version": "3.12",
        "document_revision": "b58385b9bf597a951c16c035653d639929924e53eae3e5ada255afd6ee1592f2",
        "source_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
        "start_line": 1,
        "end_line": 1,
        "text_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
        "byte_count": 154,
        "native_score": -1.4220532319391636e-06,
        "rank": 1,
        "read_token": "72abbf5e0022ef780447ed8c2322b711cac8b4971d817a440bc02dfa28b07124"
      },
      {
        "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
        "search_request_id": "3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f",
        "passage_id": "c66643a4609c6ee157458bf4353f7446b9c6a200a3ef453846d6a18d5b5069a7",
        "source_id": "path-write",
        "version": "3.12",
        "document_revision": "28c6349eaf80b629322edb310bb871dc45a04af9fad3b752bc75d12f0d7314e7",
        "source_sha256": "a48b4b9f763cd6309ebe32af19c5a814adcf810c2259683da9f328ccee46948e",
        "start_line": 1,
        "end_line": 1,
        "text_sha256": "a48b4b9f763cd6309ebe32af19c5a814adcf810c2259683da9f328ccee46948e",
        "byte_count": 224,
        "native_score": -1.3203883495145633e-06,
        "rank": 2,
        "read_token": "189bf56802f958924691f452106802696dcd22186df4ee9c03bf0efecf1e1f81"
      }
    ]
  },
  "validated_read": {
    "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
    "search_request_id": "3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f",
    "passage_id": "c737db948e8111ae00e3442d8a22c80c876e43446dc1ee176ffe8ce142a41900",
    "source_id": "path-read",
    "version": "3.12",
    "document_revision": "b58385b9bf597a951c16c035653d639929924e53eae3e5ada255afd6ee1592f2",
    "source_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
    "start_line": 1,
    "end_line": 1,
    "text_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
    "byte_count": 154,
    "native_score": -1.4220532319391636e-06,
    "rank": 1,
    "read_token": "72abbf5e0022ef780447ed8c2322b711cac8b4971d817a440bc02dfa28b07124",
    "text": "Path.read_text(encoding=None, errors=None) opens a file, returns its text as a string and closes the file. Set encoding=\"utf-8\" when reading a UTF-8 file.",
    "url": "https://docs.python.org/3.12/library/pathlib.html#pathlib.Path.read_text",
    "read_request_id": "b2ce4d1e809a197df6c864261264b583737b1f41c59f8a4b6e353911b84c5bfe",
    "result_sha256": "2d855cfa0b4f7e90c3711783b7779709f3b964760fd789d0d65b11f9b3604ac5"
  },
  "unknown_tool": {
    "kind": "tool_result",
    "result": {
      "content": [
        {
          "type": "text",
          "text": "Unknown tool: unknown_documentation_tool"
        }
      ],
      "isError": true,
      "resultType": "complete"
    }
  },
  "fresh_process_read": {
    "content": [
      {
        "type": "text",
        "text": "Error executing tool read_documentation: unissued_search_receipt"
      }
    ],
    "isError": true,
    "resultType": "complete"
  },
  "protocol_transcript": [
    {
      "direction": "client_to_server",
      "message": {
        "jsonrpc": "2.0",
        "id": 1,
        "method": "initialize",
        "params": {
          "protocolVersion": "2025-11-25",
          "capabilities": {},
          "clientInfo": {
            "name": "mcp",
            "version": "0.1.0"
          }
        }
      }
    },
    {
      "direction": "server_to_client",
      "message": {
        "jsonrpc": "2.0",
        "id": 1,
        "result": {
          "capabilities": {
            "prompts": {
              "listChanged": false
            },
            "resources": {
              "listChanged": false,
              "subscribe": false
            },
            "tools": {
              "listChanged": false
            }
          },
          "protocolVersion": "2025-11-25",
          "serverInfo": {
            "name": "local-documentation-retrieval",
            "version": "1.0.0"
          }
        }
      }
    },
    {
      "direction": "client_to_server",
      "message": {
        "jsonrpc": "2.0",
        "method": "notifications/initialized"
      }
    },
    {
      "direction": "client_to_server",
      "message": {
        "jsonrpc": "2.0",
        "id": 2,
        "method": "tools/list"
      }
    },
    {
      "direction": "server_to_client",
      "message": {
        "jsonrpc": "2.0",
        "id": 2,
        "result": {
          "tools": [
            {
              "description": "Search the pinned corpus by one literal term and exact API version; return read handles.",
              "inputSchema": {
                "properties": {
                  "query": {
                    "pattern": "^[A-Za-z0-9]{1,64}$",
                    "title": "Query",
                    "type": "string"
                  },
                  "version": {
                    "maxLength": 16,
                    "pattern": "^[0-9]+\\.[0-9]+$",
                    "title": "Version",
                    "type": "string"
                  },
                  "k": {
                    "default": 2,
                    "maximum": 10,
                    "minimum": 1,
                    "title": "K",
                    "type": "integer"
                  }
                },
                "required": [
                  "query",
                  "version"
                ],
                "type": "object",
                "additionalProperties": false,
                "title": "search_documentationArguments"
              },
              "name": "search_documentation",
              "outputSchema": {
                "properties": {
                  "corpus_id": {
                    "pattern": "^[0-9a-f]{64}$",
                    "title": "Corpus Id",
                    "type": "string"
                  },
                  "search_request_id": {
                    "pattern": "^[0-9a-f]{64}$",
                    "title": "Search Request Id",
                    "type": "string"
                  },
                  "query": {
                    "pattern": "^[A-Za-z0-9]{1,64}$",
                    "title": "Query",
                    "type": "string"
                  },
                  "version": {
                    "maxLength": 16,
                    "pattern": "^[0-9]+\\.[0-9]+$",
                    "title": "Version",
                    "type": "string"
                  },
                  "k": {
                    "maximum": 10,
                    "minimum": 1,
                    "title": "K",
                    "type": "integer"
                  },
                  "results": {
                    "items": {
                      "$ref": "#/$defs/Handle"
                    },
                    "maxItems": 10,
                    "title": "Results",
                    "type": "array"
                  }
                },
                "required": [
                  "corpus_id",
                  "search_request_id",
                  "query",
                  "version",
                  "k",
                  "results"
                ],
                "type": "object",
                "$defs": {
                  "Handle": {
                    "additionalProperties": false,
                    "properties": {
                      "corpus_id": {
                        "pattern": "^[0-9a-f]{64}$",
                        "title": "Corpus Id",
                        "type": "string"
                      },
                      "search_request_id": {
                        "pattern": "^[0-9a-f]{64}$",
                        "title": "Search Request Id",
                        "type": "string"
                      },
                      "passage_id": {
                        "pattern": "^[0-9a-f]{64}$",
                        "title": "Passage Id",
                        "type": "string"
                      },
                      "source_id": {
                        "maxLength": 256,
                        "minLength": 1,
                        "title": "Source Id",
                        "type": "string"
                      },
                      "version": {
                        "maxLength": 16,
                        "pattern": "^[0-9]+\\.[0-9]+$",
                        "title": "Version",
                        "type": "string"
                      },
                      "document_revision": {
                        "pattern": "^[0-9a-f]{64}$",
                        "title": "Document Revision",
                        "type": "string"
                      },
                      "source_sha256": {
                        "pattern": "^[0-9a-f]{64}$",
                        "title": "Source Sha256",
                        "type": "string"
                      },
                      "start_line": {
                        "maximum": 65536,
                        "minimum": 1,
                        "title": "Start Line",
                        "type": "integer"
                      },
                      "end_line": {
                        "maximum": 65536,
                        "minimum": 1,
                        "title": "End Line",
                        "type": "integer"
                      },
                      "text_sha256": {
                        "pattern": "^[0-9a-f]{64}$",
                        "title": "Text Sha256",
                        "type": "string"
                      },
                      "byte_count": {
                        "maximum": 65536,
                        "minimum": 0,
                        "title": "Byte Count",
                        "type": "integer"
                      },
                      "native_score": {
                        "title": "Native Score",
                        "type": "number"
                      },
                      "rank": {
                        "maximum": 10,
                        "minimum": 1,
                        "title": "Rank",
                        "type": "integer"
                      },
                      "read_token": {
                        "pattern": "^[0-9a-f]{64}$",
                        "title": "Read Token",
                        "type": "string"
                      }
                    },
                    "required": [
                      "corpus_id",
                      "search_request_id",
                      "passage_id",
                      "source_id",
                      "version",
                      "document_revision",
                      "source_sha256",
                      "start_line",
                      "end_line",
                      "text_sha256",
                      "byte_count",
                      "native_score",
                      "rank",
                      "read_token"
                    ],
                    "title": "Handle",
                    "type": "object"
                  }
                },
                "additionalProperties": false,
                "title": "SearchResult"
              }
            },
            {
              "description": "Read an exact handle issued by this running server; no arbitrary file or URL access.",
              "inputSchema": {
                "properties": {
                  "handle": {
                    "$ref": "#/$defs/Handle"
                  }
                },
                "required": [
                  "handle"
                ],
                "type": "object",
                "$defs": {
                  "Handle": {
                    "additionalProperties": false,
                    "properties": {
                      "corpus_id": {
                        "pattern": "^[0-9a-f]{64}$",
                        "title": "Corpus Id",
                        "type": "string"
                      },
                      "search_request_id": {
                        "pattern": "^[0-9a-f]{64}$",
                        "title": "Search Request Id",
                        "type": "string"
                      },
                      "passage_id": {
                        "pattern": "^[0-9a-f]{64}$",
                        "title": "Passage Id",
                        "type": "string"
                      },
                      "source_id": {
                        "maxLength": 256,
                        "minLength": 1,
                        "title": "Source Id",
                        "type": "string"
                      },
                      "version": {
                        "maxLength": 16,
                        "pattern": "^[0-9]+\\.[0-9]+$",
                        "title": "Version",
                        "type": "string"
                      },
                      "document_revision": {
                        "pattern": "^[0-9a-f]{64}$",
                        "title": "Document Revision",
                        "type": "string"
                      },
                      "source_sha256": {
                        "pattern": "^[0-9a-f]{64}$",
                        "title": "Source Sha256",
                        "type": "string"
                      },
                      "start_line": {
                        "maximum": 65536,
                        "minimum": 1,
                        "title": "Start Line",
                        "type": "integer"
                      },
                      "end_line": {
                        "maximum": 65536,
                        "minimum": 1,
                        "title": "End Line",
                        "type": "integer"
                      },
                      "text_sha256": {
                        "pattern": "^[0-9a-f]{64}$",
                        "title": "Text Sha256",
                        "type": "string"
                      },
                      "byte_count": {
                        "maximum": 65536,
                        "minimum": 0,
                        "title": "Byte Count",
                        "type": "integer"
                      },
                      "native_score": {
                        "title": "Native Score",
                        "type": "number"
                      },
                      "rank": {
                        "maximum": 10,
                        "minimum": 1,
                        "title": "Rank",
                        "type": "integer"
                      },
                      "read_token": {
                        "pattern": "^[0-9a-f]{64}$",
                        "title": "Read Token",
                        "type": "string"
                      }
                    },
                    "required": [
                      "corpus_id",
                      "search_request_id",
                      "passage_id",
                      "source_id",
                      "version",
                      "document_revision",
                      "source_sha256",
                      "start_line",
                      "end_line",
                      "text_sha256",
                      "byte_count",
                      "native_score",
                      "rank",
                      "read_token"
                    ],
                    "title": "Handle",
                    "type": "object"
                  }
                },
                "additionalProperties": false,
                "title": "read_documentationArguments"
              },
              "name": "read_documentation",
              "outputSchema": {
                "properties": {
                  "corpus_id": {
                    "pattern": "^[0-9a-f]{64}$",
                    "title": "Corpus Id",
                    "type": "string"
                  },
                  "search_request_id": {
                    "pattern": "^[0-9a-f]{64}$",
                    "title": "Search Request Id",
                    "type": "string"
                  },
                  "passage_id": {
                    "pattern": "^[0-9a-f]{64}$",
                    "title": "Passage Id",
                    "type": "string"
                  },
                  "source_id": {
                    "maxLength": 256,
                    "minLength": 1,
                    "title": "Source Id",
                    "type": "string"
                  },
                  "version": {
                    "maxLength": 16,
                    "pattern": "^[0-9]+\\.[0-9]+$",
                    "title": "Version",
                    "type": "string"
                  },
                  "document_revision": {
                    "pattern": "^[0-9a-f]{64}$",
                    "title": "Document Revision",
                    "type": "string"
                  },
                  "source_sha256": {
                    "pattern": "^[0-9a-f]{64}$",
                    "title": "Source Sha256",
                    "type": "string"
                  },
                  "start_line": {
                    "maximum": 65536,
                    "minimum": 1,
                    "title": "Start Line",
                    "type": "integer"
                  },
                  "end_line": {
                    "maximum": 65536,
                    "minimum": 1,
                    "title": "End Line",
                    "type": "integer"
                  },
                  "text_sha256": {
                    "pattern": "^[0-9a-f]{64}$",
                    "title": "Text Sha256",
                    "type": "string"
                  },
                  "byte_count": {
                    "maximum": 65536,
                    "minimum": 0,
                    "title": "Byte Count",
                    "type": "integer"
                  },
                  "native_score": {
                    "title": "Native Score",
                    "type": "number"
                  },
                  "rank": {
                    "maximum": 10,
                    "minimum": 1,
                    "title": "Rank",
                    "type": "integer"
                  },
                  "read_token": {
                    "pattern": "^[0-9a-f]{64}$",
                    "title": "Read Token",
                    "type": "string"
                  },
                  "text": {
                    "maxLength": 65536,
                    "title": "Text",
                    "type": "string"
                  },
                  "url": {
                    "maxLength": 2048,
                    "title": "Url",
                    "type": "string"
                  },
                  "read_request_id": {
                    "pattern": "^[0-9a-f]{64}$",
                    "title": "Read Request Id",
                    "type": "string"
                  },
                  "result_sha256": {
                    "pattern": "^[0-9a-f]{64}$",
                    "title": "Result Sha256",
                    "type": "string"
                  }
                },
                "required": [
                  "corpus_id",
                  "search_request_id",
                  "passage_id",
                  "source_id",
                  "version",
                  "document_revision",
                  "source_sha256",
                  "start_line",
                  "end_line",
                  "text_sha256",
                  "byte_count",
                  "native_score",
                  "rank",
                  "read_token",
                  "text",
                  "url",
                  "read_request_id",
                  "result_sha256"
                ],
                "type": "object",
                "additionalProperties": false,
                "title": "ReadResult"
              }
            }
          ]
        }
      }
    },
    {
      "direction": "client_to_server",
      "message": {
        "jsonrpc": "2.0",
        "id": 3,
        "method": "tools/call",
        "params": {
          "name": "search_documentation",
          "arguments": {
            "query": "text",
            "version": "3.12",
            "k": 2
          }
        }
      }
    },
    {
      "direction": "server_to_client",
      "message": {
        "jsonrpc": "2.0",
        "id": 3,
        "result": {
          "content": [
            {
              "text": "{\n  \"corpus_id\": \"0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e\",\n  \"search_request_id\": \"3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f\",\n  \"query\": \"text\",\n  \"version\": \"3.12\",\n  \"k\": 2,\n  \"results\": [\n    {\n      \"corpus_id\": \"0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e\",\n      \"search_request_id\": \"3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f\",\n      \"passage_id\": \"c737db948e8111ae00e3442d8a22c80c876e43446dc1ee176ffe8ce142a41900\",\n      \"source_id\": \"path-read\",\n      \"version\": \"3.12\",\n      \"document_revision\": \"b58385b9bf597a951c16c035653d639929924e53eae3e5ada255afd6ee1592f2\",\n      \"source_sha256\": \"dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0\",\n      \"start_line\": 1,\n      \"end_line\": 1,\n      \"text_sha256\": \"dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0\",\n      \"byte_count\": 154,\n      \"native_score\": -1.4220532319391636e-6,\n      \"rank\": 1,\n      \"read_token\": \"72abbf5e0022ef780447ed8c2322b711cac8b4971d817a440bc02dfa28b07124\"\n    },\n    {\n      \"corpus_id\": \"0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e\",\n      \"search_request_id\": \"3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f\",\n      \"passage_id\": \"c66643a4609c6ee157458bf4353f7446b9c6a200a3ef453846d6a18d5b5069a7\",\n      \"source_id\": \"path-write\",\n      \"version\": \"3.12\",\n      \"document_revision\": \"28c6349eaf80b629322edb310bb871dc45a04af9fad3b752bc75d12f0d7314e7\",\n      \"source_sha256\": \"a48b4b9f763cd6309ebe32af19c5a814adcf810c2259683da9f328ccee46948e\",\n      \"start_line\": 1,\n      \"end_line\": 1,\n      \"text_sha256\": \"a48b4b9f763cd6309ebe32af19c5a814adcf810c2259683da9f328ccee46948e\",\n      \"byte_count\": 224,\n      \"native_score\": -1.3203883495145633e-6,\n      \"rank\": 2,\n      \"read_token\": \"189bf56802f958924691f452106802696dcd22186df4ee9c03bf0efecf1e1f81\"\n    }\n  ]\n}",
              "type": "text"
            }
          ],
          "isError": false,
          "structuredContent": {
            "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
            "search_request_id": "3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f",
            "query": "text",
            "version": "3.12",
            "k": 2,
            "results": [
              {
                "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
                "search_request_id": "3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f",
                "passage_id": "c737db948e8111ae00e3442d8a22c80c876e43446dc1ee176ffe8ce142a41900",
                "source_id": "path-read",
                "version": "3.12",
                "document_revision": "b58385b9bf597a951c16c035653d639929924e53eae3e5ada255afd6ee1592f2",
                "source_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
                "start_line": 1,
                "end_line": 1,
                "text_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
                "byte_count": 154,
                "native_score": -1.4220532319391636e-06,
                "rank": 1,
                "read_token": "72abbf5e0022ef780447ed8c2322b711cac8b4971d817a440bc02dfa28b07124"
              },
              {
                "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
                "search_request_id": "3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f",
                "passage_id": "c66643a4609c6ee157458bf4353f7446b9c6a200a3ef453846d6a18d5b5069a7",
                "source_id": "path-write",
                "version": "3.12",
                "document_revision": "28c6349eaf80b629322edb310bb871dc45a04af9fad3b752bc75d12f0d7314e7",
                "source_sha256": "a48b4b9f763cd6309ebe32af19c5a814adcf810c2259683da9f328ccee46948e",
                "start_line": 1,
                "end_line": 1,
                "text_sha256": "a48b4b9f763cd6309ebe32af19c5a814adcf810c2259683da9f328ccee46948e",
                "byte_count": 224,
                "native_score": -1.3203883495145633e-06,
                "rank": 2,
                "read_token": "189bf56802f958924691f452106802696dcd22186df4ee9c03bf0efecf1e1f81"
              }
            ]
          }
        }
      }
    },
    {
      "direction": "client_to_server",
      "message": {
        "jsonrpc": "2.0",
        "id": 4,
        "method": "tools/call",
        "params": {
          "name": "read_documentation",
          "arguments": {
            "handle": {
              "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
              "search_request_id": "3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f",
              "passage_id": "c737db948e8111ae00e3442d8a22c80c876e43446dc1ee176ffe8ce142a41900",
              "source_id": "path-read",
              "version": "3.12",
              "document_revision": "b58385b9bf597a951c16c035653d639929924e53eae3e5ada255afd6ee1592f2",
              "source_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
              "start_line": 1,
              "end_line": 1,
              "text_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
              "byte_count": 154,
              "native_score": -1.4220532319391636e-06,
              "rank": 1,
              "read_token": "72abbf5e0022ef780447ed8c2322b711cac8b4971d817a440bc02dfa28b07124"
            }
          }
        }
      }
    },
    {
      "direction": "server_to_client",
      "message": {
        "jsonrpc": "2.0",
        "id": 4,
        "result": {
          "content": [
            {
              "text": "{\n  \"corpus_id\": \"0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e\",\n  \"search_request_id\": \"3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f\",\n  \"passage_id\": \"c737db948e8111ae00e3442d8a22c80c876e43446dc1ee176ffe8ce142a41900\",\n  \"source_id\": \"path-read\",\n  \"version\": \"3.12\",\n  \"document_revision\": \"b58385b9bf597a951c16c035653d639929924e53eae3e5ada255afd6ee1592f2\",\n  \"source_sha256\": \"dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0\",\n  \"start_line\": 1,\n  \"end_line\": 1,\n  \"text_sha256\": \"dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0\",\n  \"byte_count\": 154,\n  \"native_score\": -1.4220532319391636e-6,\n  \"rank\": 1,\n  \"read_token\": \"72abbf5e0022ef780447ed8c2322b711cac8b4971d817a440bc02dfa28b07124\",\n  \"text\": \"Path.read_text(encoding=None, errors=None) opens a file, returns its text as a string and closes the file. Set encoding=\\\"utf-8\\\" when reading a UTF-8 file.\",\n  \"url\": \"https://docs.python.org/3.12/library/pathlib.html#pathlib.Path.read_text\",\n  \"read_request_id\": \"b2ce4d1e809a197df6c864261264b583737b1f41c59f8a4b6e353911b84c5bfe\",\n  \"result_sha256\": \"2d855cfa0b4f7e90c3711783b7779709f3b964760fd789d0d65b11f9b3604ac5\"\n}",
              "type": "text"
            }
          ],
          "isError": false,
          "structuredContent": {
            "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
            "search_request_id": "3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f",
            "passage_id": "c737db948e8111ae00e3442d8a22c80c876e43446dc1ee176ffe8ce142a41900",
            "source_id": "path-read",
            "version": "3.12",
            "document_revision": "b58385b9bf597a951c16c035653d639929924e53eae3e5ada255afd6ee1592f2",
            "source_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
            "start_line": 1,
            "end_line": 1,
            "text_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
            "byte_count": 154,
            "native_score": -1.4220532319391636e-06,
            "rank": 1,
            "read_token": "72abbf5e0022ef780447ed8c2322b711cac8b4971d817a440bc02dfa28b07124",
            "text": "Path.read_text(encoding=None, errors=None) opens a file, returns its text as a string and closes the file. Set encoding=\"utf-8\" when reading a UTF-8 file.",
            "url": "https://docs.python.org/3.12/library/pathlib.html#pathlib.Path.read_text",
            "read_request_id": "b2ce4d1e809a197df6c864261264b583737b1f41c59f8a4b6e353911b84c5bfe",
            "result_sha256": "2d855cfa0b4f7e90c3711783b7779709f3b964760fd789d0d65b11f9b3604ac5"
          }
        }
      }
    },
    {
      "direction": "client_to_server",
      "message": {
        "jsonrpc": "2.0",
        "id": 5,
        "method": "tools/call",
        "params": {
          "name": "search_documentation",
          "arguments": {
            "query": "zzunmatched",
            "version": "3.12",
            "k": 2
          }
        }
      }
    },
    {
      "direction": "server_to_client",
      "message": {
        "jsonrpc": "2.0",
        "id": 5,
        "result": {
          "content": [
            {
              "text": "{\n  \"corpus_id\": \"0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e\",\n  \"search_request_id\": \"0afcd01a3dd4e765c4bab273c25d4239de4d71369b989bbbe25e1e270ef07647\",\n  \"query\": \"zzunmatched\",\n  \"version\": \"3.12\",\n  \"k\": 2,\n  \"results\": []\n}",
              "type": "text"
            }
          ],
          "isError": false,
          "structuredContent": {
            "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
            "search_request_id": "0afcd01a3dd4e765c4bab273c25d4239de4d71369b989bbbe25e1e270ef07647",
            "query": "zzunmatched",
            "version": "3.12",
            "k": 2,
            "results": []
          }
        }
      }
    },
    {
      "direction": "client_to_server",
      "message": {
        "jsonrpc": "2.0",
        "id": 6,
        "method": "tools/call",
        "params": {
          "name": "search_documentation",
          "arguments": {
            "query": "text",
            "version": "9.99",
            "k": 2
          }
        }
      }
    },
    {
      "direction": "server_to_client",
      "message": {
        "jsonrpc": "2.0",
        "id": 6,
        "result": {
          "content": [
            {
              "text": "{\n  \"corpus_id\": \"0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e\",\n  \"search_request_id\": \"fefe356a697d65ea81980cd228d12ddde25c3d62fe8a4badbaafc3f385052d97\",\n  \"query\": \"text\",\n  \"version\": \"9.99\",\n  \"k\": 2,\n  \"results\": []\n}",
              "type": "text"
            }
          ],
          "isError": false,
          "structuredContent": {
            "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
            "search_request_id": "fefe356a697d65ea81980cd228d12ddde25c3d62fe8a4badbaafc3f385052d97",
            "query": "text",
            "version": "9.99",
            "k": 2,
            "results": []
          }
        }
      }
    },
    {
      "direction": "client_to_server",
      "message": {
        "jsonrpc": "2.0",
        "id": 7,
        "method": "tools/call",
        "params": {
          "name": "search_documentation",
          "arguments": {
            "query": "read",
            "version": "3.13",
            "k": 2
          }
        }
      }
    },
    {
      "direction": "server_to_client",
      "message": {
        "jsonrpc": "2.0",
        "id": 7,
        "result": {
          "content": [
            {
              "text": "{\n  \"corpus_id\": \"0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e\",\n  \"search_request_id\": \"6644a5007738d93bc51c8c2dc73d8e6d2aa86c6bfa01c1b87cd40d994ff93be0\",\n  \"query\": \"read\",\n  \"version\": \"3.13\",\n  \"k\": 2,\n  \"results\": [\n    {\n      \"corpus_id\": \"0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e\",\n      \"search_request_id\": \"6644a5007738d93bc51c8c2dc73d8e6d2aa86c6bfa01c1b87cd40d994ff93be0\",\n      \"passage_id\": \"bdaeff5ae3ab88b70b12b9b6d4a0a46de45ea14520b971a7756cb03bbd384f35\",\n      \"source_id\": \"path-read-3-13\",\n      \"version\": \"3.13\",\n      \"document_revision\": \"d68df3e7ea1e24af3f40366a61402fc80558fefe2ef5f3eda928de0e01820db9\",\n      \"source_sha256\": \"0dd5becb0c04458ad5f8bbf3fdef4f71034c584ef863bf748793bef7309b9f4f\",\n      \"start_line\": 1,\n      \"end_line\": 1,\n      \"text_sha256\": \"0dd5becb0c04458ad5f8bbf3fdef4f71034c584ef863bf748793bef7309b9f4f\",\n      \"byte_count\": 174,\n      \"native_score\": -1.0374479889042996e-6,\n      \"rank\": 1,\n      \"read_token\": \"d66070e4825f4678515afdebeaf88fc6ac76b52a18688121494689935d16bd67\"\n    }\n  ]\n}",
              "type": "text"
            }
          ],
          "isError": false,
          "structuredContent": {
            "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
            "search_request_id": "6644a5007738d93bc51c8c2dc73d8e6d2aa86c6bfa01c1b87cd40d994ff93be0",
            "query": "read",
            "version": "3.13",
            "k": 2,
            "results": [
              {
                "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
                "search_request_id": "6644a5007738d93bc51c8c2dc73d8e6d2aa86c6bfa01c1b87cd40d994ff93be0",
                "passage_id": "bdaeff5ae3ab88b70b12b9b6d4a0a46de45ea14520b971a7756cb03bbd384f35",
                "source_id": "path-read-3-13",
                "version": "3.13",
                "document_revision": "d68df3e7ea1e24af3f40366a61402fc80558fefe2ef5f3eda928de0e01820db9",
                "source_sha256": "0dd5becb0c04458ad5f8bbf3fdef4f71034c584ef863bf748793bef7309b9f4f",
                "start_line": 1,
                "end_line": 1,
                "text_sha256": "0dd5becb0c04458ad5f8bbf3fdef4f71034c584ef863bf748793bef7309b9f4f",
                "byte_count": 174,
                "native_score": -1.0374479889042996e-06,
                "rank": 1,
                "read_token": "d66070e4825f4678515afdebeaf88fc6ac76b52a18688121494689935d16bd67"
              }
            ]
          }
        }
      }
    },
    {
      "direction": "client_to_server",
      "message": {
        "jsonrpc": "2.0",
        "id": 8,
        "method": "tools/call",
        "params": {
          "name": "search_documentation",
          "arguments": {
            "query": "text",
            "version": "3.12",
            "k": true
          }
        }
      }
    },
    {
      "direction": "server_to_client",
      "message": {
        "jsonrpc": "2.0",
        "id": 8,
        "result": {
          "content": [
            {
              "text": "Error executing tool search_documentation: 1 validation error for search_documentationArguments\nk\n  Input should be a valid integer [type=int_type, input_value=True, input_type=bool]\n    For further information visit https://errors.pydantic.dev/2.14/v/int_type",
              "type": "text"
            }
          ],
          "isError": true
        }
      }
    },
    {
      "direction": "client_to_server",
      "message": {
        "jsonrpc": "2.0",
        "id": 9,
        "method": "tools/call",
        "params": {
          "name": "search_documentation",
          "arguments": {
            "query": "text",
            "version": "3.12",
            "unexpected": 1
          }
        }
      }
    },
    {
      "direction": "server_to_client",
      "message": {
        "jsonrpc": "2.0",
        "id": 9,
        "result": {
          "content": [
            {
              "text": "Error executing tool search_documentation: 1 validation error for search_documentationArguments\nunexpected\n  Extra inputs are not permitted [type=extra_forbidden, input_value=1, input_type=int]\n    For further information visit https://errors.pydantic.dev/2.14/v/extra_forbidden",
              "type": "text"
            }
          ],
          "isError": true
        }
      }
    },
    {
      "direction": "client_to_server",
      "message": {
        "jsonrpc": "2.0",
        "id": 10,
        "method": "tools/call",
        "params": {
          "name": "read_documentation",
          "arguments": {
            "handle": {
              "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
              "search_request_id": "0000000000000000000000000000000000000000000000000000000000000000",
              "passage_id": "c737db948e8111ae00e3442d8a22c80c876e43446dc1ee176ffe8ce142a41900",
              "source_id": "path-read",
              "version": "3.12",
              "document_revision": "b58385b9bf597a951c16c035653d639929924e53eae3e5ada255afd6ee1592f2",
              "source_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
              "start_line": 1,
              "end_line": 1,
              "text_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
              "byte_count": 154,
              "native_score": -1.4220532319391636e-06,
              "rank": 1,
              "read_token": "72abbf5e0022ef780447ed8c2322b711cac8b4971d817a440bc02dfa28b07124"
            }
          }
        }
      }
    },
    {
      "direction": "server_to_client",
      "message": {
        "jsonrpc": "2.0",
        "id": 10,
        "result": {
          "content": [
            {
              "text": "Error executing tool read_documentation: unissued_search_receipt",
              "type": "text"
            }
          ],
          "isError": true
        }
      }
    },
    {
      "direction": "client_to_server",
      "message": {
        "jsonrpc": "2.0",
        "id": 11,
        "method": "tools/call",
        "params": {
          "name": "read_documentation",
          "arguments": {
            "handle": {
              "corpus_id": "0000000000000000000000000000000000000000000000000000000000000000",
              "search_request_id": "3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f",
              "passage_id": "c737db948e8111ae00e3442d8a22c80c876e43446dc1ee176ffe8ce142a41900",
              "source_id": "path-read",
              "version": "3.12",
              "document_revision": "b58385b9bf597a951c16c035653d639929924e53eae3e5ada255afd6ee1592f2",
              "source_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
              "start_line": 1,
              "end_line": 1,
              "text_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
              "byte_count": 154,
              "native_score": -1.4220532319391636e-06,
              "rank": 1,
              "read_token": "72abbf5e0022ef780447ed8c2322b711cac8b4971d817a440bc02dfa28b07124"
            }
          }
        }
      }
    },
    {
      "direction": "server_to_client",
      "message": {
        "jsonrpc": "2.0",
        "id": 11,
        "result": {
          "content": [
            {
              "text": "Error executing tool read_documentation: stale_corpus",
              "type": "text"
            }
          ],
          "isError": true
        }
      }
    },
    {
      "direction": "client_to_server",
      "message": {
        "jsonrpc": "2.0",
        "id": 12,
        "method": "tools/call",
        "params": {
          "name": "read_documentation",
          "arguments": {
            "handle": {
              "corpus_id": "0615d22a3315e97c0a88c6c566c546877304f5a28a97e83f68dd36881d4bbd0e",
              "search_request_id": "3f33383e706e36449e22c380704d880d5e2b8a4b1f6b779b8aa54206e072ad5f",
              "passage_id": "c737db948e8111ae00e3442d8a22c80c876e43446dc1ee176ffe8ce142a41900",
              "source_id": "path-read",
              "version": "3.12",
              "document_revision": "b58385b9bf597a951c16c035653d639929924e53eae3e5ada255afd6ee1592f2",
              "source_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
              "start_line": 1,
              "end_line": 1,
              "text_sha256": "dc097ca63486ace45279f412ea266bf754fcd2f0b1153f5d763ce905dafbc2c0",
              "byte_count": 155,
              "native_score": -1.4220532319391636e-06,
              "rank": 1,
              "read_token": "72abbf5e0022ef780447ed8c2322b711cac8b4971d817a440bc02dfa28b07124"
            }
          }
        }
      }
    },
    {
      "direction": "server_to_client",
      "message": {
        "jsonrpc": "2.0",
        "id": 12,
        "result": {
          "content": [
            {
              "text": "Error executing tool read_documentation: invalid_read_handle",
              "type": "text"
            }
          ],
          "isError": true
        }
      }
    },
    {
      "direction": "client_to_server",
      "message": {
        "jsonrpc": "2.0",
        "id": 13,
        "method": "tools/call",
        "params": {
          "name": "unknown_documentation_tool",
          "arguments": {}
        }
      }
    },
    {
      "direction": "server_to_client",
      "message": {
        "jsonrpc": "2.0",
        "id": 13,
        "result": {
          "content": [
            {
              "text": "Unknown tool: unknown_documentation_tool",
              "type": "text"
            }
          ],
          "isError": true
        }
      }
    }
  ],
  "server_stderr": "INFO retrieval registry ready\nINFO Tool 'search_documentation' rejected arguments: ['k']\nINFO Tool 'search_documentation' rejected arguments: ['unexpected']\nINFO Tool 'read_documentation' failed: 'Error executing tool read_documentation: unissued_search_receipt'\nINFO Tool 'read_documentation' failed: 'Error executing tool read_documentation: stale_corpus'\nINFO Tool 'read_documentation' failed: 'Error executing tool read_documentation: invalid_read_handle'\nINFO Tool 'unknown_documentation_tool' failed: 'Unknown tool: unknown_documentation_tool'\nINFO retrieval registry closed\n",
  "fresh_process_stderr": "INFO retrieval registry ready\nINFO Tool 'read_documentation' failed: 'Error executing tool read_documentation: unissued_search_receipt'\nINFO retrieval registry closed\n",
  "limit": "Actual local SDK transport and source-binding checks only. ClientSession uses the SDK legacy-handshake compatibility path. No model agent, generation, HTTP authentication, cross-service authorization or production-security claim."
}

Compare a tool refusal with startup failure

Inspect the search call, its selected handle and the subsequent read. Trace the source identity, version and hash into the validated client result. Then compare an altered-handle tool error with the changed-corpus startup failure. Explain what had initialized in each case and why a fresh process cannot read an old handle until it issues the matching search itself.

A client passes an old search handle to a fresh stdio server process. What happens in this lab?

Choose one answer, then check your reasoning.

Read the explanation

Keep discovery, process-local source metadata and task outcomes separate.

What’s next

Continue with Authorize collection searches.

References

The official MCP server guide and Python SDK documentation, checked on 23 October 2026, describe server tools and stdio execution. The run records the installed SDK entry points and the negotiated protocol. The strict argument models, caller-binding checks and source-validation rules are this adapter’s own contracts, checked by its tests. Tool discovery does not show that a source is correct or that a caller is authorized.

Written by Arjun Prabhulal.

Module 10

Application integration