Skip to content

πŸš€ The fast, Pythonic way to build MCP servers and clients.

transforms: add experimental JevSearchTransform (#5170)

nate nowack5a876c4cbece
diff --git a/docs/servers/transforms/tool-search.mdx b/docs/servers/transforms/tool-search.mdx
index 5c50e9e61..f5fc64ad7 100644
--- a/docs/servers/transforms/tool-search.mdx
+++ b/docs/servers/transforms/tool-search.mdx
@@ -26,7 +26,7 @@ Search results are returned in the same JSON format as `list_tools`, including t
## Search Strategies
-FastMCP provides two search transforms. They share the same interface β€” two synthetic tools, same configuration options β€” but differ in how they match queries to tools.
+FastMCP provides two search transforms, plus an experimental third. They share the same interface β€” two synthetic tools, same configuration options β€” but differ in how they match queries to tools.
### Regex Search
@@ -92,15 +92,69 @@ result = await client.call_tool("search_tools", {
BM25 builds an in-memory index from the searchable text of all tools. The index is created lazily on the first search and automatically rebuilt whenever the tool catalog changes β€” for example, when tools are added, removed, or have their descriptions updated. The staleness check is based on a hash of all searchable text, so description changes are detected even when tool names stay the same.
+### Jev Search (Experimental)
+
+<Warning>
+`JevSearchTransform` is experimental. It lives in `fastmcp.experimental.transforms` and its ranking parameters may change as we learn what works on real catalogs.
+</Warning>
+
+`JevSearchTransform` ranks tools with [TypeSafe's Jev](https://docs.typesafe.ai), a model that returns calibrated probabilities over options you define instead of generated text. It reads the query and the tool descriptions for meaning, so `"archive last week's invoices"` finds `archive_invoices` without sharing a token with it, and a request that no tool serves comes back empty instead of returning the least-wrong match.
+
+<Tip>
+Jev search requires the `jev` extra and a TypeSafe API key in `TYPESAFE_API_KEY`. Install it with `pip install "fastmcp[jev]"`. A missing key is an error when the transform is constructed.
+</Tip>
+
+```python
+from fastmcp import FastMCP
+from fastmcp.experimental.transforms.jev_search import JevSearchTransform
+
+mcp = FastMCP("My Server", transforms=[JevSearchTransform()])
+
+# ... define tools ...
+```
+
+The LLM's `search_tools` call takes a natural-language `query`, the same as BM25:
+
+```python
+result = await client.call_tool("search_tools", {
+ "query": "show me the flow runs that failed in the last hour"
+})
+# Returns the best-fitting tool definitions first, or nothing when none fits
+```
+
+A search is a few Jev requests. On a 187-tool catalog generated from the Prefect OpenAPI spec, each of five queries completed in 0.6 to 1.1 seconds end to end:
+
+1. **Wide pass.** One request per chunk of the catalog. The query is the state, each tool name is an option, and its one-line summary is the option's description. Each chunk's top `shortlist` goes forward. If more than `3 * shortlist` candidates survive, they are ranked again in chunks until the close read fits.
+2. **Close read.** One request over the candidates with each tool's full description and parameters. A Choice question decides which candidate fits best and sets the order. One yes/no question per candidate asks whether that tool does what the query asks; candidates below `fit_threshold` are dropped, which is how an off-topic query returns nothing.
+
+A catalog no larger than `3 * shortlist` skips the wide pass.
+
+| Option | Default | Meaning |
+| --- | --- | --- |
+| `model` | `jev-latest` | TypeSafe model. Pin a versioned id once `fit_threshold` is tuned. |
+| `api_key` | `TYPESAFE_API_KEY` | TypeSafe API key. |
+| `client` | none | A ready `AsyncTypeSafeClient` to use instead of building one. |
+| `shortlist` | 8 | Candidates each wide-pass request carries forward; the close read sees at most three times this. |
+| `fit_threshold` | 0.3 | Minimum "does this tool do it" probability for a tool to be returned. |
+| `chunk_size` | 150 | Tools per wide-pass request, at most 255. |
+| `close_read` | `True` | Re-read the shortlist with full descriptions in a second request. `False` asks the fit question of every tool in the wide pass instead: one round trip, summaries only. On the 187-tool Prefect catalog it was 0.06s faster and six points worse at returning the right tool first. |
+| `timeout` | 10 | Seconds per API attempt. |
+| `summary_chars` | 160 | Description characters per tool in the wide pass. |
+| `detail_chars` | 1200 | Rendered characters per tool in the close read. |
+
+`fit_threshold` comes from TypeSafe's skill-suggestion cookbook; the other defaults were chosen for this transform and none were tuned on your catalog. Log what `search_tools` returns for real queries before relying on the threshold. Tool descriptions are model input: a description written to argue for its own selection can move the ranking, so treat catalogs from third-party servers accordingly.
+
### Which to Choose
Use **regex** when your LLM is good at constructing targeted patterns and you want deterministic, predictable results. Regex is also simpler to debug β€” you can see exactly what pattern was sent.
Use **BM25** when your LLM tends to describe what it needs in natural language, or when your tool catalog has nuanced descriptions where relevance ranking adds value. BM25 handles partial matches and synonyms better because it scores on individual terms rather than requiring a single pattern to match.
+Use **Jev** when queries and tool descriptions rarely share vocabulary, when the catalog has lookalike tools that only a full read separates, or when returning nothing for an unserved request matters. It costs a network call per search and needs an API key.
+
## Configuration
-Both search transforms accept the same configuration options.
+All search transforms accept the same configuration options.
### Limiting Results
diff --git a/fastmcp_slim/fastmcp/experimental/transforms/jev_search.py b/fastmcp_slim/fastmcp/experimental/transforms/jev_search.py
new file mode 100644
index 000000000..c8d34a54b
--- /dev/null
+++ b/fastmcp_slim/fastmcp/experimental/transforms/jev_search.py
@@ -0,0 +1,405 @@
+"""Tool search ranked by TypeSafe's Jev.
+
+Jev is a System One model: it does not generate text. A request carries a
+``state`` and a map of typed questions, every question is judged against the
+same state in parallel, and each answer is a probability distribution over
+options the caller defined. That makes it a natural ranker for a tool
+catalog: the query is the state, the tool names are the options, and the
+probabilities are the ranking.
+
+The transform follows the shape of TypeSafe's skill-suggestion cookbook
+(https://docs.typesafe.ai/cookbooks/skill_suggestion): a cheap wide pass over
+the whole catalog on one-line summaries, then a close read of a shortlist
+with each tool's full description and parameters. The close read asks two
+kinds of question. A Choice decides *which* candidate fits best and orders
+the results. One Noul per candidate decides *whether* it does what the query
+asks at all, so a query nothing serves comes back empty instead of returning
+the least-wrong tool.
+"""
+
+from __future__ import annotations
+
+import asyncio
+import hashlib
+import json
+import os
+from collections.abc import Mapping, Sequence
+from typing import Annotated, Any, Protocol
+
+from fastmcp.server.context import Context
+from fastmcp.server.transforms.search.base import (
+ BaseSearchTransform,
+ SearchResultSerializer,
+ serialize_tools_for_output_markdown,
+)
+from fastmcp.tools.base import Tool
+
+WIDE_INSTRUCTIONS = (
+ "Which of these tools is the right one to call to carry out the user's "
+ "request in `request`? Each option is a tool name; its description "
+ "summarizes what the tool does."
+)
+RERANK_INSTRUCTIONS = (
+ "Exactly one of these tools is the right one to call for the user's request "
+ "in `request`. Which one? Read what each tool actually does and what "
+ "parameters it takes, not just its name."
+)
+
+# A Choice question accepts at most this many options
+# (https://docs.typesafe.ai/primitives/choice).
+MAX_CHOICE_OPTIONS = 255
+API_KEY_ENV = "TYPESAFE_API_KEY"
+
+
+class SystemOneClient(Protocol):
+ """The slice of ``typesafe_sdk.AsyncTypeSafeClient`` the transform uses."""
+
+ async def system_one(self, state: Any, questions: Any) -> Any: ...
+
+
+def _summary(tool: Tool, limit: int) -> str:
+ """The first paragraph of a tool's description, or its name when it has none."""
+ text = (tool.description or "").strip()
+ first = text.split("\n\n", 1)[0].strip() or tool.name.replace("_", " ")
+ return first if len(first) <= limit else first[: limit - 1].rstrip() + "…"
+
+
+def _detail(tool: Tool, limit: int) -> str:
+ """A tool's full description and parameter list, rendered as markdown."""
+ text = serialize_tools_for_output_markdown([tool])
+ return text if len(text) <= limit else text[: limit - 1].rstrip() + "…"
+
+
+def _fingerprint(tool: Tool) -> str:
+ """Identity of everything the model is shown about a tool."""
+ payload = json.dumps(
+ [tool.name, tool.description or "", tool.parameters, tool.output_schema],
+ sort_keys=True,
+ default=str,
+ )
+ return hashlib.sha256(payload.encode()).hexdigest()
+
+
+def _fit_id(name: str) -> str:
+ return f"fits::{name}"
+
+
+class JevSearchTransform(BaseSearchTransform):
+ """Search transform that ranks tools with TypeSafe's Jev.
+
+ Experimental: the ranking parameters may change. Requires the ``jev``
+ extra (``pip install "fastmcp[jev]"``) and a TypeSafe API key, read from
+ ``TYPESAFE_API_KEY`` unless ``api_key`` or ``client`` is given. A missing
+ key is an error at construction, not at the first search.
+
+ Tool descriptions are model input. A description written to argue for
+ its own selection can move the ranking; the transform only ranks tools
+ the caller could already list, so that exposure is bounded by what the
+ catalog holds.
+
+ Args:
+ model: The TypeSafe model name. ``jev-latest`` follows releases;
+ pin a versioned id once you have tuned ``fit_threshold``.
+ api_key: TypeSafe API key. Defaults to ``TYPESAFE_API_KEY``.
+ client: A ready ``AsyncTypeSafeClient`` (or anything with an async
+ ``system_one``) to use instead of building one.
+ timeout: Seconds per API attempt when the transform builds its own
+ client. A search is one to a few requests.
+ shortlist: How many candidates each wide-pass request carries
+ forward. The close read sees at most ``3 * shortlist``
+ candidates; a larger catalog is narrowed with further wide
+ passes first.
+ fit_threshold: A candidate whose "does this tool do what the request
+ asks" probability falls below this is dropped from the results.
+ Tune it against queries from your own users.
+ close_read: Whether to re-read the shortlist with full descriptions
+ and parameters in a second request. ``False`` asks the fit
+ question of every tool in the wide pass instead, on summaries
+ only, so a search is a single round trip.
+ chunk_size: Tools per wide-pass request. Catalogs above this size
+ are ranked in concurrent chunks. At most 255, the Choice limit.
+ summary_chars: Characters of description per tool in the wide pass.
+ detail_chars: Characters of rendered description and parameters per
+ tool in the close read.
+ max_results, always_visible, search_tool_name, call_tool_name,
+ search_result_serializer: As on every search transform.
+ """
+
+ def __init__(
+ self,
+ *,
+ model: str = "jev-latest",
+ api_key: str | None = None,
+ client: SystemOneClient | None = None,
+ timeout: float = 10.0,
+ shortlist: int = 8,
+ fit_threshold: float = 0.3,
+ close_read: bool = True,
+ chunk_size: int = 150,
+ summary_chars: int = 160,
+ detail_chars: int = 1200,
+ max_results: int = 5,
+ always_visible: list[str] | None = None,
+ search_tool_name: str = "search_tools",
+ call_tool_name: str = "call_tool",
+ search_result_serializer: SearchResultSerializer | None = None,
+ ) -> None:
+ super().__init__(
+ max_results=max_results,
+ always_visible=always_visible,
+ search_tool_name=search_tool_name,
+ call_tool_name=call_tool_name,
+ search_result_serializer=search_result_serializer,
+ )
+ if shortlist < 1:
+ raise ValueError("shortlist must be at least 1")
+ if not 1 <= chunk_size <= MAX_CHOICE_OPTIONS:
+ raise ValueError(f"chunk_size must be between 1 and {MAX_CHOICE_OPTIONS}")
+ if not 0 <= fit_threshold <= 1:
+ raise ValueError("fit_threshold must be between 0 and 1")
+ if summary_chars < 8 or detail_chars < 8:
+ raise ValueError("summary_chars and detail_chars must be at least 8")
+ if client is None:
+ api_key = api_key or os.environ.get(API_KEY_ENV)
+ if not api_key:
+ raise ValueError(
+ f"JevSearchTransform needs a TypeSafe API key: pass api_key= "
+ f"or set {API_KEY_ENV}"
+ )
+ self._model = model
+ self._api_key = api_key
+ self._timeout = timeout
+ self._client = client
+ self._client_lock: asyncio.Lock | None = None
+ self._shortlist = shortlist
+ self._max_candidates = 3 * shortlist
+ self._fit_threshold = fit_threshold
+ self._close_read = close_read
+ self._chunk_size = chunk_size
+ self._summary_chars = summary_chars
+ self._detail_chars = detail_chars
+ # rendered text per tool fingerprint; shared across searches but only
+ # ever added to, so a concurrent search with a different catalog
+ # cannot remove an entry another search is about to read
+ self._texts: dict[str, tuple[str, str]] = {}
+
+ # ------------------------------------------------------------------
+ # Client
+ # ------------------------------------------------------------------
+
+ async def _get_client(self) -> SystemOneClient:
+ if self._client is not None:
+ return self._client
+ if self._client_lock is None:
+ self._client_lock = asyncio.Lock()
+ async with self._client_lock:
+ if self._client is None:
+ try:
+ from typesafe_sdk import AsyncTypeSafeClient
+ except ImportError as e:
+ raise ImportError(
+ "JevSearchTransform needs the typesafe-sdk package: "
+ 'install the jev extra with `pip install "fastmcp[jev]"`'
+ ) from e
+ self._client = AsyncTypeSafeClient(
+ api_key=self._api_key, model=self._model, timeout=self._timeout
+ )
+ return self._client
+
+ # ------------------------------------------------------------------
+ # Synthetic search tool
+ # ------------------------------------------------------------------
+
+ def _make_search_tool(self) -> Tool:
+ transform = self
+
+ async def search_tools(
+ query: Annotated[
+ str, "What you need to do, in natural language; not keywords"
+ ],
+ ctx: Context = None, # type: ignore[assignment] # ty:ignore[invalid-parameter-default]
+ ) -> str | list[dict[str, Any]]:
+ """Find the tools that carry out a request.
+
+ Returns the best-fitting tool definitions, best first, in the
+ same format as list_tools. Returns nothing when no tool fits.
+ """
+ hidden = await transform._get_visible_tools(ctx)
+ results = await transform._search(hidden, query)
+ return await transform._render_results(results)
+
+ return Tool.from_function(fn=search_tools, name=self._search_tool_name)
+
+ # ------------------------------------------------------------------
+ # Ranking
+ # ------------------------------------------------------------------
+
+ def _render(self, tools: Sequence[Tool]) -> tuple[dict[str, str], dict[str, str]]:
+ """Summary and detail text for this search's catalog, as locals."""
+ summaries: dict[str, str] = {}
+ details: dict[str, str] = {}
+ for tool in tools:
+ key = _fingerprint(tool)
+ if key not in self._texts:
+ self._texts[key] = (
+ _summary(tool, self._summary_chars),
+ _detail(tool, self._detail_chars),
+ )
+ summaries[tool.name], details[tool.name] = self._texts[key]
+ return summaries, details
+
+ @staticmethod
+ def _fit_question(name: str) -> dict[str, str]:
+ return {
+ "type": "noul",
+ "instructions": (
+ f"Does the tool described at `tools.{name}` do the specific "
+ "thing the user's request in `request` asks for?"
+ ),
+ }
+
+ async def _rank_chunk(
+ self, query: str, names: Sequence[str], summaries: Mapping[str, str]
+ ) -> list[str]:
+ """One wide request: rank every tool in a chunk by summary."""
+ client = await self._get_client()
+ response = await client.system_one(
+ state={"request": query},
+ questions={
+ "which": {
+ "type": "choice",
+ "instructions": WIDE_INSTRUCTIONS,
+ "criteria": {name: summaries[name] for name in names},
+ }
+ },
+ )
+ probabilities: Mapping[str, float] = response.answers["which"].probabilities
+ ranked = sorted(names, key=lambda name: -probabilities.get(name, 0.0))
+ return ranked[: self._shortlist]
+
+ async def _rank_and_fit_chunk(
+ self, query: str, names: Sequence[str], summaries: Mapping[str, str]
+ ) -> list[tuple[str, float]]:
+ """One request that both ranks a chunk and asks the fit question of
+ every tool in it, on summaries. Returns the fitting names with their
+ Choice probability."""
+ questions: dict[str, Any] = {
+ "which": {
+ "type": "choice",
+ "instructions": WIDE_INSTRUCTIONS,
+ "criteria": {name: summaries[name] for name in names},
+ }
+ }
+ for name in names:
+ questions[_fit_id(name)] = self._fit_question(name)
+ client = await self._get_client()
+ response = await client.system_one(
+ state={
+ "request": query,
+ "tools": {name: summaries[name] for name in names},
+ },
+ questions=questions,
+ )
+ answers = response.answers
+ probabilities: Mapping[str, float] = answers["which"].probabilities
+ return [
+ (name, probabilities.get(name, 0.0))
+ for name in names
+ if answers[_fit_id(name)].noul >= self._fit_threshold
+ ]
+
+ async def _single_pass(
+ self, query: str, names: list[str], summaries: Mapping[str, str]
+ ) -> list[str]:
+ """Rank and filter in one round trip. Chunks run concurrently; their
+ probabilities are not comparable, so the merged order is a heuristic."""
+ chunks = [
+ names[i : i + self._chunk_size]
+ for i in range(0, len(names), self._chunk_size)
+ ]
+ tasks = [
+ asyncio.ensure_future(self._rank_and_fit_chunk(query, chunk, summaries))
+ for chunk in chunks
+ ]
+ try:
+ results = await asyncio.gather(*tasks)
+ except BaseException:
+ for task in tasks:
+ task.cancel()
+ raise
+ fitting = [pair for result in results for pair in result]
+ return [name for name, _ in sorted(fitting, key=lambda pair: -pair[1])]
+
+ async def _narrow(
+ self, query: str, names: list[str], summaries: Mapping[str, str]
+ ) -> list[str]:
+ """Wide passes until the candidate set fits the close read.
+
+ Probabilities from different chunks are not comparable, so each
+ chunk's shortlist goes forward whole rather than through a merged
+ cut. When the union is still too large for one close read, it is
+ ranked again in chunks, which converges because every round keeps
+ at most ``shortlist`` names per ``chunk_size``.
+ """
+ while len(names) > self._max_candidates:
+ chunks = [
+ names[i : i + self._chunk_size]
+ for i in range(0, len(names), self._chunk_size)
+ ]
+ tasks = [
+ asyncio.ensure_future(self._rank_chunk(query, chunk, summaries))
+ for chunk in chunks
+ ]
+ try:
+ ranked_chunks = await asyncio.gather(*tasks)
+ except BaseException:
+ for task in tasks:
+ task.cancel()
+ raise
+ names = [name for ranked in ranked_chunks for name in ranked]
+ return names
+
+ async def _rerank(
+ self,
+ query: str,
+ names: Sequence[str],
+ summaries: Mapping[str, str],
+ details: Mapping[str, str],
+ ) -> list[str]:
+ """One close-read request over the shortlist: which fits best, and
+ whether each fits at all. Returns the names that fit, best first."""
+ questions: dict[str, Any] = {
+ "which": {
+ "type": "choice",
+ "instructions": RERANK_INSTRUCTIONS,
+ "criteria": {name: details[name] for name in names},
+ }
+ }
+ for name in names:
+ questions[_fit_id(name)] = self._fit_question(name)
+ client = await self._get_client()
+ response = await client.system_one(
+ state={
+ "request": query,
+ "tools": {name: summaries[name] for name in names},
+ },
+ questions=questions,
+ )
+ answers = response.answers
+ probabilities: Mapping[str, float] = answers["which"].probabilities
+ fitting = [
+ name for name in names if answers[_fit_id(name)].noul >= self._fit_threshold
+ ]
+ return sorted(fitting, key=lambda name: -probabilities.get(name, 0.0))
+
+ async def _search(self, tools: Sequence[Tool], query: str) -> Sequence[Tool]:
+ if not tools or not query.strip():
+ return []
+ summaries, details = self._render(tools)
+ by_name = {t.name: t for t in tools}
+ if self._close_read:
+ candidates = await self._narrow(query, list(by_name), summaries)
+ fitting = await self._rerank(query, candidates, summaries, details)
+ else:
+ fitting = await self._single_pass(query, list(by_name), summaries)
+ return [by_name[name] for name in fitting[: self._max_results]]
diff --git a/fastmcp_slim/pyproject.toml b/fastmcp_slim/pyproject.toml
index 83ebc8498..8c6ec6a45 100644
--- a/fastmcp_slim/pyproject.toml
+++ b/fastmcp_slim/pyproject.toml
@@ -75,6 +75,7 @@ client = [
"py-key-value-aio[filetree,keyring,memory]>=0.4.4,<0.5.0",
]
code-mode = ["pydantic-monty==0.0.21"]
+jev = ["typesafe-sdk>=0.5.7"]
gemini = ["google-genai>=1.18.0", "jsonref>=1.1.0"]
mcp = [
"exceptiongroup>=1.2.2",
diff --git a/pyproject.toml b/pyproject.toml
index 28d82b358..158c9fce6 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -56,6 +56,7 @@ anthropic = ["fastmcp-slim[anthropic]=={{ version }}"]
apps = ["fastmcp-slim[apps]=={{ version }}"]
azure = ["fastmcp-slim[azure]=={{ version }}"]
code-mode = ["fastmcp-slim[code-mode]=={{ version }}"]
+jev = ["fastmcp-slim[jev]=={{ version }}"]
gemini = ["fastmcp-slim[gemini]=={{ version }}"]
openai = ["fastmcp-slim[openai]=={{ version }}"]
tasks = ["fastmcp-tasks=={{ version }}"]
@@ -82,7 +83,7 @@ exclude-newer-package = { fastmcp = false, fastmcp-slim = false, fastmcp-remote
[dependency-groups]
dev = [
"dirty-equals>=0.9.0",
- "fastmcp[anthropic,apps,azure,code-mode,gemini,openai,tasks]",
+ "fastmcp[anthropic,apps,azure,code-mode,gemini,jev,openai,tasks]",
"fastapi>=0.115.12",
"fastmcp-remote",
"opentelemetry-sdk>=1.20.0",
diff --git a/tests/experimental/transforms/test_jev_search.py b/tests/experimental/transforms/test_jev_search.py
new file mode 100644
index 000000000..944587942
--- /dev/null
+++ b/tests/experimental/transforms/test_jev_search.py
@@ -0,0 +1,408 @@
+"""JevSearchTransform: request shape, two-pass ranking, thresholds, chunking.
+
+Jev is driven through a fake client so the suite needs neither the SDK nor
+a key. The fake records every request and answers from a table of
+probabilities keyed by tool name.
+"""
+
+from __future__ import annotations
+
+import asyncio
+import sys
+from collections.abc import Mapping
+from dataclasses import dataclass, field
+from typing import Any
+
+import pytest
+
+from fastmcp import Client, FastMCP
+from fastmcp.experimental.transforms.jev_search import (
+ RERANK_INSTRUCTIONS,
+ WIDE_INSTRUCTIONS,
+ JevSearchTransform,
+)
+from fastmcp.tools.base import Tool
+
+
+@dataclass
+class _Answer:
+ choice: str = ""
+ probabilities: dict[str, float] = field(default_factory=dict)
+ confidence: float = 0.0
+ noul: float = 0.0
+
+
+@dataclass
+class _Response:
+ answers: dict[str, _Answer]
+
+
+@dataclass
+class FakeJev:
+ """Answers Choice questions from ``weights`` and Nouls from ``fits``.
+
+ Options missing from ``weights`` get a small equal share; Nouls missing
+ from ``fits`` are answered as a confident yes. ``delay`` yields to the
+ event loop inside each request so concurrent searches interleave.
+ """
+
+ weights: Mapping[str, float] = field(default_factory=dict)
+ fits: Mapping[str, float] = field(default_factory=dict)
+ delay: float = 0.0
+ requests: list[dict[str, Any]] = field(default_factory=list)
+
+ async def system_one(self, state: Any, questions: Any) -> _Response:
+ self.requests.append({"state": state, "questions": dict(questions)})
+ if self.delay:
+ await asyncio.sleep(self.delay)
+ answers: dict[str, _Answer] = {}
+ for qid, question in questions.items():
+ if question["type"] == "choice":
+ raw = {
+ name: self.weights.get(name, 0.01) for name in question["criteria"]
+ }
+ total = sum(raw.values())
+ probabilities = {name: value / total for name, value in raw.items()}
+ best = max(probabilities, key=probabilities.__getitem__)
+ answers[qid] = _Answer(
+ choice=best,
+ probabilities=probabilities,
+ confidence=probabilities[best],
+ )
+ else:
+ name = qid.removeprefix("fits::")
+ answers[qid] = _Answer(noul=self.fits.get(name, 0.9))
+ return _Response(answers=answers)
+
+
+def _tool(name: str, doc: str | None = None, params: tuple[str, ...] = ("query",)):
+ def fn(query: str = "") -> str:
+ return f"{name}:{query}"
+
+ fn.__name__ = name
+ fn.__doc__ = (
+ doc
+ if doc is not None
+ else f"The {name.replace('_', ' ')} tool.\n\nMore detail about {name}."
+ )
+ parameters = {
+ "type": "object",
+ "properties": {p: {"type": "string"} for p in params},
+ "required": list(params),
+ }
+ return Tool.from_function(fn=fn, name=name, description=fn.__doc__).model_copy(
+ update={"parameters": parameters}
+ )
+
+
+def _server(*names: str) -> FastMCP:
+ mcp = FastMCP("test")
+ for name in names:
+
+ def make(name: str):
+ def tool(query: str) -> str:
+ return f"{name}:{query}"
+
+ tool.__name__ = name
+ tool.__doc__ = (
+ f"The {name.replace('_', ' ')} tool.\n\nMore detail about {name}."
+ )
+ return tool
+
+ mcp.tool(make(name))
+ return mcp
+
+
+async def _search(mcp: FastMCP, query: str) -> list[str]:
+ async with Client(mcp) as client:
+ result = await client.call_tool("search_tools", {"query": query})
+ assert result.structured_content is not None
+ return [tool["name"] for tool in result.structured_content["result"]]
+
+
+class TestListing:
+ async def test_list_tools_shows_only_synthetic_tools(self):
+ mcp = _server("send_email", "delete_record")
+ mcp.add_transform(JevSearchTransform(client=FakeJev()))
+ names = {t.name for t in await mcp.list_tools()}
+ assert names == {"search_tools", "call_tool"}
+
+ async def test_search_tool_takes_a_query(self):
+ mcp = _server("send_email")
+ mcp.add_transform(JevSearchTransform(client=FakeJev()))
+ search = await mcp.get_tool("search_tools")
+ assert search is not None
+ assert "query" in search.parameters["properties"]
+
+
+class TestSmallCatalog:
+ """A catalog that fits the close read goes there directly."""
+
+ async def test_single_request_orders_by_choice_probability(self):
+ jev = FakeJev(weights={"delete_record": 5, "send_email": 3, "add": 1})
+ mcp = _server("add", "send_email", "delete_record")
+ mcp.add_transform(JevSearchTransform(client=jev, shortlist=8))
+
+ assert await _search(mcp, "remove a row") == [
+ "delete_record",
+ "send_email",
+ "add",
+ ]
+ assert len(jev.requests) == 1
+
+ async def test_close_read_puts_summaries_in_state_and_detail_in_criteria(self):
+ jev = FakeJev()
+ mcp = _server("send_email", "delete_record")
+ mcp.add_transform(JevSearchTransform(client=jev))
+ await _search(mcp, "email someone")
+
+ [request] = jev.requests
+ state = request["state"]
+ assert state["request"] == "email someone"
+ # the description a noul refers to lives in state, not in the question
+ assert state["tools"] == {
+ "send_email": "The send email tool.",
+ "delete_record": "The delete record tool.",
+ }
+ which = request["questions"]["which"]
+ assert which["instructions"] == RERANK_INSTRUCTIONS
+ assert set(which["criteria"]) == {"send_email", "delete_record"}
+ # the close read sees the rendered tool, not just the first line
+ assert "More detail about send_email" in which["criteria"]["send_email"]
+ assert "`query`" in which["criteria"]["send_email"]
+ for name in ("send_email", "delete_record"):
+ noul = request["questions"][f"fits::{name}"]
+ assert noul["type"] == "noul"
+ assert f"`tools.{name}`" in noul["instructions"]
+ assert "The " not in noul["instructions"]
+
+ async def test_tools_below_fit_threshold_are_dropped(self):
+ jev = FakeJev(
+ weights={"send_email": 5, "delete_record": 4},
+ fits={"send_email": 0.8, "delete_record": 0.1},
+ )
+ mcp = _server("send_email", "delete_record")
+ mcp.add_transform(JevSearchTransform(client=jev, fit_threshold=0.3))
+ assert await _search(mcp, "email someone") == ["send_email"]
+
+ async def test_nothing_fits_returns_empty(self):
+ jev = FakeJev(fits={"send_email": 0.05, "delete_record": 0.02})
+ mcp = _server("send_email", "delete_record")
+ mcp.add_transform(JevSearchTransform(client=jev))
+ assert await _search(mcp, "book a flight") == []
+
+ async def test_max_results_caps_the_fitting_tools(self):
+ jev = FakeJev(weights={"a": 3, "b": 2, "c": 1})
+ mcp = _server("a", "b", "c")
+ mcp.add_transform(JevSearchTransform(client=jev, max_results=2))
+ assert await _search(mcp, "anything") == ["a", "b"]
+
+
+class TestLargeCatalog:
+ """Above the close-read size, wide passes per chunk narrow the field."""
+
+ async def test_wide_pass_is_chunked_and_shortlisted(self):
+ names = [f"tool_{i:02d}" for i in range(7)]
+ jev = FakeJev(
+ weights={
+ "tool_06": 9,
+ "tool_01": 5,
+ "tool_02": 3,
+ "tool_04": 2,
+ "tool_05": 1.5,
+ }
+ )
+ mcp = _server(*names)
+ # close read holds 3 * shortlist = 6; seven tools need a wide pass
+ mcp.add_transform(
+ JevSearchTransform(client=jev, shortlist=2, chunk_size=3, max_results=3)
+ )
+
+ assert await _search(mcp, "the sixth thing") == [
+ "tool_06",
+ "tool_01",
+ "tool_02",
+ ]
+
+ wide = jev.requests[:-1]
+ close = jev.requests[-1]
+ assert [sorted(r["questions"]["which"]["criteria"]) for r in wide] == [
+ ["tool_00", "tool_01", "tool_02"],
+ ["tool_03", "tool_04", "tool_05"],
+ ["tool_06"],
+ ]
+ assert all(
+ r["questions"]["which"]["instructions"] == WIDE_INSTRUCTIONS for r in wide
+ )
+ assert all(len(r["questions"]) == 1 for r in wide)
+ assert all(r["state"] == {"request": "the sixth thing"} for r in wide)
+ # two per chunk survive the wide pass; the third chunk only has one
+ assert sorted(close["questions"]["which"]["criteria"]) == [
+ "tool_01",
+ "tool_02",
+ "tool_04",
+ "tool_05",
+ "tool_06",
+ ]
+
+ async def test_wide_pass_repeats_until_the_close_read_fits(self):
+ names = [f"t{i:02d}" for i in range(30)]
+ jev = FakeJev(weights={"t29": 9})
+ mcp = _server(*names)
+ mcp.add_transform(JevSearchTransform(client=jev, shortlist=2, chunk_size=5))
+
+ assert (await _search(mcp, "the last one"))[0] == "t29"
+ # round one: 6 chunks of 5 keep 12; round two: 3 chunks of 5 keep 6;
+ # six fits the close read (3 * shortlist), so one more request
+ assert len(jev.requests) == 6 + 3 + 1
+ close = jev.requests[-1]
+ assert len(close["questions"]["which"]["criteria"]) == 6
+
+ async def test_wide_pass_uses_first_paragraph_only(self):
+ jev = FakeJev()
+ mcp = _server(*(f"t{i}" for i in range(4)))
+ mcp.add_transform(JevSearchTransform(client=jev, shortlist=1))
+ await _search(mcp, "x")
+ summary = jev.requests[0]["questions"]["which"]["criteria"]["t0"]
+ assert summary == "The t0 tool."
+
+
+class TestSinglePass:
+ """``close_read=False`` ranks and filters in one request per chunk."""
+
+ async def test_one_request_with_a_fit_question_per_tool(self):
+ jev = FakeJev(
+ weights={"delete_record": 5, "send_email": 3},
+ fits={"add": 0.1},
+ )
+ mcp = _server("add", "send_email", "delete_record")
+ mcp.add_transform(JevSearchTransform(client=jev, close_read=False))
+
+ assert await _search(mcp, "remove a row") == ["delete_record", "send_email"]
+ [request] = jev.requests
+ assert request["questions"]["which"]["instructions"] == WIDE_INSTRUCTIONS
+ assert set(request["questions"]) == {
+ "which",
+ "fits::add",
+ "fits::send_email",
+ "fits::delete_record",
+ }
+ # summaries only: the rendered parameter list never goes out
+ assert "`query`" not in request["questions"]["which"]["criteria"]["add"]
+ assert set(request["state"]["tools"]) == {"add", "send_email", "delete_record"}
+
+ async def test_large_catalog_is_still_one_round_trip(self):
+ names = [f"t{i:02d}" for i in range(30)]
+ jev = FakeJev(weights={"t29": 9})
+ mcp = _server(*names)
+ mcp.add_transform(
+ JevSearchTransform(client=jev, close_read=False, chunk_size=10)
+ )
+ assert (await _search(mcp, "the last one"))[0] == "t29"
+ assert len(jev.requests) == 3
+ assert all(len(r["questions"]) == 11 for r in jev.requests)
+
+
+class TestRenderedText:
+ def test_summary_and_detail_are_truncated(self):
+ transform = JevSearchTransform(
+ client=FakeJev(), summary_chars=12, detail_chars=40
+ )
+ tool = _tool("send_email", "Send an email to the given recipient.")
+ summaries, details = transform._render([tool])
+ assert summaries["send_email"] == "Send an ema…"
+ assert len(summaries["send_email"]) == 12
+ assert len(details["send_email"]) == 40
+ assert details["send_email"].endswith("…")
+
+ def test_parameter_change_rerenders_the_detail(self):
+ transform = JevSearchTransform(client=FakeJev())
+ before = _tool("send_email", "Send mail.", params=("to",))
+ after = _tool("send_email", "Send mail.", params=("to", "subject"))
+ _, first = transform._render([before])
+ _, second = transform._render([after])
+ assert "`subject`" not in first["send_email"]
+ assert "`subject`" in second["send_email"]
+
+
+class TestConcurrency:
+ async def test_searches_with_different_catalogs_do_not_interfere(self):
+ """Two sessions can see different tools and search at the same time;
+ neither may lose the text it needs mid-search."""
+ jev = FakeJev(weights={"tool_11": 9, "tool_03": 5}, delay=0.01)
+ transform = JevSearchTransform(client=jev, shortlist=2, chunk_size=4)
+ tools = [_tool(f"tool_{i:02d}") for i in range(12)]
+
+ full, partial = await asyncio.gather(
+ transform._search(tools, "the eleventh"),
+ transform._search(tools[:6], "the third"),
+ )
+ assert [t.name for t in full][0] == "tool_11"
+ assert [t.name for t in partial][0] == "tool_03"
+
+
+class TestCatalogChanges:
+ async def test_texts_refresh_when_a_tool_is_added(self):
+ jev = FakeJev()
+ mcp = _server("send_email")
+ mcp.add_transform(JevSearchTransform(client=jev))
+ await _search(mcp, "x")
+
+ @mcp.tool
+ def delete_record(record_id: str) -> str:
+ """Delete a record."""
+ return record_id
+
+ await _search(mcp, "x")
+ assert set(jev.requests[-1]["questions"]["which"]["criteria"]) == {
+ "send_email",
+ "delete_record",
+ }
+
+
+class TestCallThrough:
+ async def test_discovered_tool_runs_through_the_proxy(self):
+ jev = FakeJev(weights={"send_email": 9})
+ mcp = _server("send_email", "delete_record")
+ mcp.add_transform(JevSearchTransform(client=jev))
+ async with Client(mcp) as client:
+ found = await client.call_tool("search_tools", {"query": "email"})
+ assert found.structured_content is not None
+ name = found.structured_content["result"][0]["name"]
+ result = await client.call_tool(
+ "call_tool", {"name": name, "arguments": {"query": "hi"}}
+ )
+ assert result.data == "send_email:hi"
+
+
+class TestConfiguration:
+ def test_rejects_bad_settings(self):
+ with pytest.raises(ValueError):
+ JevSearchTransform(client=FakeJev(), fit_threshold=1.5)
+ with pytest.raises(ValueError):
+ JevSearchTransform(client=FakeJev(), shortlist=0)
+ with pytest.raises(ValueError, match="255"):
+ JevSearchTransform(client=FakeJev(), chunk_size=300)
+ with pytest.raises(ValueError):
+ JevSearchTransform(client=FakeJev(), summary_chars=0)
+
+ def test_missing_api_key_fails_at_construction(self, monkeypatch):
+ monkeypatch.delenv("TYPESAFE_API_KEY", raising=False)
+ with pytest.raises(ValueError, match="TYPESAFE_API_KEY"):
+ JevSearchTransform()
+
+ def test_api_key_from_environment_is_accepted(self, monkeypatch):
+ monkeypatch.setenv("TYPESAFE_API_KEY", "key-from-env")
+ assert JevSearchTransform()._api_key == "key-from-env"
+
+ async def test_missing_sdk_is_a_clear_error(self, monkeypatch):
+ monkeypatch.setitem(sys.modules, "typesafe_sdk", None)
+ with pytest.raises(ImportError, match="typesafe-sdk"):
+ await JevSearchTransform(api_key="k")._get_client()
+
+ async def test_empty_query_makes_no_request(self):
+ jev = FakeJev()
+ mcp = _server("send_email")
+ mcp.add_transform(JevSearchTransform(client=jev))
+ assert await _search(mcp, " ") == []
+ assert jev.requests == []
diff --git a/uv.lock b/uv.lock
index 858a61b7d..04851259c 100644
--- a/uv.lock
+++ b/uv.lock
@@ -13,7 +13,7 @@ resolution-markers = [
]
[options]
-exclude-newer = "2026-08-15T18:52:05.050937Z"
+exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for backwards compatibility when using relative exclude-newer values.
exclude-newer-span = "P1W"
[options.exclude-newer-package]
@@ -875,6 +875,9 @@ code-mode = [
gemini = [
{ name = "fastmcp-slim", extra = ["gemini"] },
]
+jev = [
+ { name = "fastmcp-slim", extra = ["jev"] },
+]
openai = [
{ name = "fastmcp-slim", extra = ["openai"] },
]
@@ -886,7 +889,7 @@ tasks = [
dev = [
{ name = "dirty-equals" },
{ name = "fastapi" },
- { name = "fastmcp", extra = ["anthropic", "apps", "azure", "code-mode", "gemini", "openai", "tasks"] },
+ { name = "fastmcp", extra = ["anthropic", "apps", "azure", "code-mode", "gemini", "jev", "openai", "tasks"] },
{ name = "fastmcp-remote" },
{ name = "inline-snapshot", extra = ["dirty-equals"] },
{ name = "ipython", version = "8.39.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },
@@ -921,16 +924,17 @@ requires-dist = [
{ name = "fastmcp-slim", extras = ["client", "server"], editable = "fastmcp_slim" },
{ name = "fastmcp-slim", extras = ["code-mode"], marker = "extra == 'code-mode'", editable = "fastmcp_slim" },
{ name = "fastmcp-slim", extras = ["gemini"], marker = "extra == 'gemini'", editable = "fastmcp_slim" },
+ { name = "fastmcp-slim", extras = ["jev"], marker = "extra == 'jev'", editable = "fastmcp_slim" },
{ name = "fastmcp-slim", extras = ["openai"], marker = "extra == 'openai'", editable = "fastmcp_slim" },
{ name = "fastmcp-tasks", marker = "extra == 'tasks'", editable = "fastmcp_tasks" },
]
-provides-extras = ["anthropic", "apps", "azure", "code-mode", "gemini", "openai", "tasks"]
+provides-extras = ["anthropic", "apps", "azure", "code-mode", "gemini", "jev", "openai", "tasks"]
[package.metadata.requires-dev]
dev = [
{ name = "dirty-equals", specifier = ">=0.9.0" },
{ name = "fastapi", specifier = ">=0.115.12" },
- { name = "fastmcp", extras = ["anthropic", "apps", "azure", "code-mode", "gemini", "openai", "tasks"], editable = "." },
+ { name = "fastmcp", extras = ["anthropic", "apps", "azure", "code-mode", "gemini", "jev", "openai", "tasks"], editable = "." },
{ name = "fastmcp-remote", editable = "fastmcp_remote" },
{ name = "inline-snapshot", extras = ["dirty-equals"], specifier = ">=0.27.2" },
{ name = "ipython", specifier = ">=8.12.3" },
@@ -1006,6 +1010,9 @@ gemini = [
{ name = "google-genai" },
{ name = "jsonref" },
]
+jev = [
+ { name = "typesafe-sdk" },
+]
mcp = [
{ name = "exceptiongroup" },
{ name = "httpx2" },
@@ -1085,13 +1092,14 @@ requires-dist = [
{ name = "starlette", marker = "extra == 'client'", specifier = ">=1.0.1" },
{ name = "starlette", marker = "extra == 'mcp'", specifier = ">=1.0.1" },
{ name = "starlette", marker = "extra == 'server'", specifier = ">=1.0.1" },
+ { name = "typesafe-sdk", marker = "extra == 'jev'", specifier = ">=0.5.7" },
{ name = "typing-extensions", specifier = ">=4.0.0" },
{ name = "uncalled-for", marker = "extra == 'server'", specifier = ">=0.4.0" },
{ name = "uvicorn", marker = "extra == 'server'", specifier = ">=0.35" },
{ name = "watchfiles", marker = "extra == 'server'", specifier = ">=1.0.0" },
{ name = "websockets", marker = "extra == 'server'", specifier = ">=15.0.1" },
]
-provides-extras = ["anthropic", "apps", "azure", "client", "code-mode", "gemini", "mcp", "openai", "server"]
+provides-extras = ["anthropic", "apps", "azure", "client", "code-mode", "gemini", "jev", "mcp", "openai", "server"]
[[package]]
name = "fastmcp-tasks"
@@ -1776,6 +1784,62 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/5e/75/bd9b7bb966668920f06b200e84454c8f3566b102183bc55c5473d96cb2b9/msal_extensions-1.3.1-py3-none-any.whl", hash = "sha256:96d3de4d034504e969ac5e85bae8106c8373b5c6568e4c8fa7af2eca9dbe6bca", size = 20583, upload-time = "2025-03-14T23:51:03.016Z" },
]
+[[package]]
+name = "msgspec"
+version = "0.21.1"
+source = { registry = "https://pypi.org/simple" }
+sdist = { url = "https://files.pythonhosted.org/packages/e3/60/f79b9b013a16fa3a58350c9295ddc6789f2e335f36ea61ed10a21b215364/msgspec-0.21.1.tar.gz", hash = "sha256:2313508e394b0d208f8f56892ca9b2799e2561329de9763b19619595a6c0f72c", size = 319193, upload-time = "2026-04-12T21:44:50.394Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/96/38/d591d9f66d43d897ecbd249f2833665823d19c8b043f16619bc8343e23df/msgspec-0.21.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:72d9cd03241b8b2edb2e12dcc66c500fa480d8cbd71a8bac105809d468882064", size = 195172, upload-time = "2026-04-12T21:43:45.062Z" },
+ { url = "https://files.pythonhosted.org/packages/69/1a/6899188b5982ec1324e0c629b7801eed2db987f6634fab58abd9fc82d317/msgspec-0.21.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ed2ab278200e743a1d2610a4e0c8fc74f6cecb8548544cdec43f927bd9265238", size = 188316, upload-time = "2026-04-12T21:43:46.641Z" },
+ { url = "https://files.pythonhosted.org/packages/9e/95/7e591b4fa11fdbbf9891164473c23420a8c781ef553295abe416bf335f42/msgspec-0.21.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:dd677e3001fdfed9186de72eab434da2976303cd5eb9550921d3d0c3e3e168ce", size = 216565, upload-time = "2026-04-12T21:43:48.081Z" },
+ { url = "https://files.pythonhosted.org/packages/19/86/714feeaf3b84cf2027235681725593840153dedd2868578f9f2715e296bb/msgspec-0.21.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:f667b90b37fad734a91671abd68e0d7f4d066862771b87e91c53996dcb7a9027", size = 222689, upload-time = "2026-04-12T21:43:49.385Z" },
+ { url = "https://files.pythonhosted.org/packages/7d/b9/4384243e814f2579e5205e17d170b9c1a30121afd1393298d904817a7fa7/msgspec-0.21.1-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:49880fd20fdbcfe1b793f07dd83f12572bab679c9800352c8b2240289aa46a06", size = 222343, upload-time = "2026-04-12T21:43:50.612Z" },
+ { url = "https://files.pythonhosted.org/packages/04/01/4b227d9c4057346271043632bad41979cf8c3dca372e41bb1f7d546395b2/msgspec-0.21.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:ae0162e22849a5e91eaad907766525107523b0daea3df267a9fcb5ba4e0936ae", size = 225607, upload-time = "2026-04-12T21:43:52.129Z" },
+ { url = "https://files.pythonhosted.org/packages/c1/ce/27021d1c3e5da837743092a7b7a5e8818397e1f4c05ee8b068bd7d1fd78a/msgspec-0.21.1-cp310-cp310-win_amd64.whl", hash = "sha256:f041a2279f31e3a53319005e4d60ba77c085cfcbe394cdc7ce803c2d01fe9449", size = 188392, upload-time = "2026-04-12T21:43:53.384Z" },
+ { url = "https://files.pythonhosted.org/packages/80/2b/daf7a8d6d7cf00e0dcd0439178b284ade701234abdcadf3385601da04fbd/msgspec-0.21.1-cp310-cp310-win_arm64.whl", hash = "sha256:1bf17cbd7b28a5dffc7e764c654eed8ccde5e0f1de7970628608304640d4ce4e", size = 174191, upload-time = "2026-04-12T21:43:54.6Z" },
+ { url = "https://files.pythonhosted.org/packages/ba/7f/bbc4e74cd33d316b75541149e4d35b163b63bce066530ae185a2ec3b5bfc/msgspec-0.21.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b504b6e7f7a22a24b27232b73034421692147865162daaec9f3bf62439007c87", size = 193131, upload-time = "2026-04-12T21:43:56.094Z" },
+ { url = "https://files.pythonhosted.org/packages/c1/60/504886af1aaf854112663b842d5eea9a15d9588f9bf7d0d2df736424b84d/msgspec-0.21.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:4692b7c1609155708c4418f88e92f63c13fdf08aa095c84bae82bad75b53389b", size = 186597, upload-time = "2026-04-12T21:43:57.242Z" },
+ { url = "https://files.pythonhosted.org/packages/fa/54/d24ddeaa65b5278c9e67f48ce3c17a9831e8f3722f3c8322ee120aca22ef/msgspec-0.21.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d3124010b3815451494c85ff345e693cb9fe5889cfcbbef39ed8622e0e72319c", size = 215158, upload-time = "2026-04-12T21:43:58.442Z" },
+ { url = "https://files.pythonhosted.org/packages/9f/75/bb79c8b89a93ae23cd33c0d802373f16feaf9633f05d8af77091350dda0a/msgspec-0.21.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6badc03b9725352219cca017bfe71c61f2fbd0fb5982b410ac17c97c213deb30", size = 219856, upload-time = "2026-04-12T21:44:00.015Z" },
+ { url = "https://files.pythonhosted.org/packages/b4/9c/c5ca26b46f0ebbd3a6683695ef89396712cb9e4199fd1f0bc1dd968216b1/msgspec-0.21.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:5d2d4116ebe3035a78d9ec76e99a9d64e5fa6d44fe61a9c5de7fd1acf54bcc69", size = 220314, upload-time = "2026-04-12T21:44:01.548Z" },
+ { url = "https://files.pythonhosted.org/packages/c8/31/645a351c4285dce40ed6755c3dcc0aa648e26dacb20a98018fe2cce5e87b/msgspec-0.21.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:0d1009f6715f5bff3b54d4ff5c7428ad96197e0534e1645b8e9b955890c84664", size = 223215, upload-time = "2026-04-12T21:44:02.884Z" },
+ { url = "https://files.pythonhosted.org/packages/09/af/8bf15736a6dd3cb4f90c5467f6dc39197d2daaf10754490cdc0aa17b7312/msgspec-0.21.1-cp311-cp311-win_amd64.whl", hash = "sha256:c6faffe5bb644ec884052679af4dfd776d4b5ca90e4a7ec7e7e319e4e6b93a6e", size = 188554, upload-time = "2026-04-12T21:44:04.151Z" },
+ { url = "https://files.pythonhosted.org/packages/ef/29/cc7db3a165b62d16e64a83f82eccb79655055cb5bc1f60459a6f9d7c82f2/msgspec-0.21.1-cp311-cp311-win_arm64.whl", hash = "sha256:ee9e3f11fa94603f7d673bf795cfa31b549c4a2c723bc39b45beb1e7f5a3fb99", size = 174517, upload-time = "2026-04-12T21:44:05.66Z" },
+ { url = "https://files.pythonhosted.org/packages/6e/cf/317224852c00248c620a9bcf4b26e2e4ab8afd752f18d2a6ef73ebd423b6/msgspec-0.21.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:d4248cf0b6129b7d230eacd493c17cc2d4f3989f3bb7f633a928a85b7dcfa251", size = 196188, upload-time = "2026-04-12T21:44:07.181Z" },
+ { url = "https://files.pythonhosted.org/packages/6d/81/074612945c0666078f7366f40000013de9f6ba687491d450df699bceebc9/msgspec-0.21.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:5102c7e9b3acff82178449b85006d96310e690291bb1ea0142f1b24bcb8aabcb", size = 188473, upload-time = "2026-04-12T21:44:08.736Z" },
+ { url = "https://files.pythonhosted.org/packages/8a/37/655101799590bcc5fddb2bd3fe0e6194e816c2d1da7c361725f5eb89a910/msgspec-0.21.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:846758412e9518252b2ac9bffd6f0e54d9ff614f5f9488df7749f81ff5c80920", size = 218871, upload-time = "2026-04-12T21:44:09.917Z" },
+ { url = "https://files.pythonhosted.org/packages/b5/d1/d4cd9fe89c7d400d7a18f86ccc94daa3f0927f53558846fcb60791dce5d6/msgspec-0.21.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:21995e74b5c598c2e004110ad66ec7f1b8c20bf2bcf3b2de8fd9a3094422d3ff", size = 225025, upload-time = "2026-04-12T21:44:11.191Z" },
+ { url = "https://files.pythonhosted.org/packages/24/bf/e20549e602b9edccadeeff98760345a416f9cce846a657e8b18e3396b212/msgspec-0.21.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:6129f0cca52992e898fd5344187f7c8127b63d810b2fd73e36fca73b4c6475ee", size = 222672, upload-time = "2026-04-12T21:44:12.481Z" },
+ { url = "https://files.pythonhosted.org/packages/b4/68/04d7a8f0f786545cf9b8c280c57aa6befb5977af6e884b8b54191cbe44b3/msgspec-0.21.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:ef3ec2296248d1f8b9231acb051b6d471dfde8f21819e86c9adaaa9f42918521", size = 227303, upload-time = "2026-04-12T21:44:13.709Z" },
+ { url = "https://files.pythonhosted.org/packages/cc/4d/619866af2840875be408047bf9e70ceafbae6ab50660de7134ed1b25eb86/msgspec-0.21.1-cp312-cp312-win_amd64.whl", hash = "sha256:d4ab834a054c6f0cbeef6df9e7e1b33d5f1bc7b86dea1d2fd7cad003873e783d", size = 190017, upload-time = "2026-04-12T21:44:14.977Z" },
+ { url = "https://files.pythonhosted.org/packages/5e/2e/a8f9eca8fd00e097d7a9e99ba8a4685db994494448e3d4f0b7f6e9a3c0f7/msgspec-0.21.1-cp312-cp312-win_arm64.whl", hash = "sha256:628aaa35c74950a8c59da330d7e98917e1c7188f983745782027748ee4ca573e", size = 175345, upload-time = "2026-04-12T21:44:16.431Z" },
+ { url = "https://files.pythonhosted.org/packages/7e/74/f11ede02839b19ff459f88e3145df5d711626ca84da4e23520cebf819367/msgspec-0.21.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:764173717a01743f007e9f74520ed281f24672c604514f7d76c1c3a10e8edb66", size = 196176, upload-time = "2026-04-12T21:44:17.613Z" },
+ { url = "https://files.pythonhosted.org/packages/bb/40/4476c1bd341418a046c4955aff632ec769315d1e3cb94e6acf86d461f9ed/msgspec-0.21.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:344c7cd0eaed1fb81d7959f99100ef71ec9b536881a376f11b9a6c4803365697", size = 188524, upload-time = "2026-04-12T21:44:18.815Z" },
+ { url = "https://files.pythonhosted.org/packages/ca/d9/9e9d7d7e5061b47540d03d640fab9b3965ba7ae49c1b2154861c8f007518/msgspec-0.21.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:48943e278b3854c2f89f955ddc6f9f430d3f0784b16e47d10604ee0463cd21f5", size = 218880, upload-time = "2026-04-12T21:44:20.028Z" },
+ { url = "https://files.pythonhosted.org/packages/74/66/2bb344f34abb4b57e60c7c9c761994e0417b9718ec1460bf00c296f2a7ea/msgspec-0.21.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a9aa659ebb0101b1cbc31461212b87e341d961f0ab0772aaf068a99e001ec4aa", size = 225050, upload-time = "2026-04-12T21:44:21.577Z" },
+ { url = "https://files.pythonhosted.org/packages/1a/84/7c1e412f76092277bf760cef12b7979d03314d259ab5b5cafde5d0c1722d/msgspec-0.21.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:f7b27d1a8ead2b6f5b0c4f2d07b8be1ccfcc041c8a0e704781edebe3ae13c484", size = 222713, upload-time = "2026-04-12T21:44:22.83Z" },
+ { url = "https://files.pythonhosted.org/packages/4e/27/0bba04b2b4ef05f3d068429410bc71d2cea925f1596a8f41152cccd5edb8/msgspec-0.21.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:38fe93e86b61328fe544cb7fd871fad5a27c8734bfda90f65e5dbe288ae50f61", size = 227259, upload-time = "2026-04-12T21:44:24.11Z" },
+ { url = "https://files.pythonhosted.org/packages/b0/2d/09574b0eea02fed2c2c1383dbaae2c7f79dc16dcd6487a886000afb5d7c4/msgspec-0.21.1-cp313-cp313-win_amd64.whl", hash = "sha256:8bc666331c35fcce05a7cd2d6221adbe0f6058f8e750711413d22793c080ac6a", size = 189857, upload-time = "2026-04-12T21:44:25.359Z" },
+ { url = "https://files.pythonhosted.org/packages/46/34/105b1576ad182879914f0c821f17ee1d13abb165cb060448f96fe2aff078/msgspec-0.21.1-cp313-cp313-win_arm64.whl", hash = "sha256:42bb1241e0750c1a4346f2aa84db26c5ffd99a4eb3a954927d9f149ff2f42898", size = 175403, upload-time = "2026-04-12T21:44:26.608Z" },
+ { url = "https://files.pythonhosted.org/packages/5a/ad/86954e987d1d6a5c579e2c2e7832b65e0fff194179fdac4f581536086024/msgspec-0.21.1-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:fab48eb45fdbfbdb2c0edfec00ffc53b6b6085beefc6b50b61e01659f9f8757f", size = 196261, upload-time = "2026-04-12T21:44:27.807Z" },
+ { url = "https://files.pythonhosted.org/packages/d1/a1/c5e46c3e42b866199365e35d11dddfd1fbd8bba4fdb3c52f965b1607ce94/msgspec-0.21.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:3cb779ea0c35bc807ff941d415875c1f69ca0be91a2e907ab99a171811d86a9a", size = 188729, upload-time = "2026-04-12T21:44:28.99Z" },
+ { url = "https://files.pythonhosted.org/packages/85/7d/1e29a319d678d6cb962ae5bdf32a6858ebdf38f73bc654c0e9c742a0c2c8/msgspec-0.21.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:68604db36b3b4dd9bf160e436e12798a4738848144cea1aca1cb984011eb160f", size = 219866, upload-time = "2026-04-12T21:44:31.104Z" },
+ { url = "https://files.pythonhosted.org/packages/25/1f/cca084ca2572810fff12ea9dbdcbe39eac048f40daf4a9077b49fcbe8cee/msgspec-0.21.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:3d6b9dc50948eaf65df54d2fd0ff66e6d8c32f116037209ee861810eb9b676cb", size = 224993, upload-time = "2026-04-12T21:44:32.649Z" },
+ { url = "https://files.pythonhosted.org/packages/71/94/d2120fc9d419a89a3a7c13e5b7078798c4b392a96a02a6e2b3ce43a8766c/msgspec-0.21.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:52c5e21930942302394429c5a582ce7e6b62c7f983b3760834c2ce107e0dd6df", size = 223535, upload-time = "2026-04-12T21:44:33.839Z" },
+ { url = "https://files.pythonhosted.org/packages/75/17/42418b66a3ad972a89bab73dd78b79cc6282bb488a25e73c853cee7443b9/msgspec-0.21.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:abbb39d65681fa24ed394e01af3d59d869068324f900c61d06062b7fb9980f2f", size = 227222, upload-time = "2026-04-12T21:44:35.093Z" },
+ { url = "https://files.pythonhosted.org/packages/c4/33/265c894268cca88ff67b144ca2b4c522fc8b9a6f1966a3640c70516e78e1/msgspec-0.21.1-cp314-cp314-win_amd64.whl", hash = "sha256:5666b1b560b97b6ec2eb3fca8a502298ebac56e13bbca1f88523538ce83d01ea", size = 193810, upload-time = "2026-04-12T21:44:36.612Z" },
+ { url = "https://files.pythonhosted.org/packages/3b/8f/a6d35f25bf1fc63c492fdd88fdce01ba0875ead48c2b91f90f33653b4131/msgspec-0.21.1-cp314-cp314-win_arm64.whl", hash = "sha256:d8b8578e4c83b14ceea4cef0d0b747e31d9330fe4b03b2b2ad4063866a178f93", size = 179125, upload-time = "2026-04-12T21:44:38.198Z" },
+ { url = "https://files.pythonhosted.org/packages/c6/39/74839641e64b99d87da55af0fc472854d42b46e2183b9e2a67fe1bb2a512/msgspec-0.21.1-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:15f523d51c00ebad412213bfe9f06f0a50ec2b93e0c19e824a2d267cabb48ea2", size = 200171, upload-time = "2026-04-12T21:44:39.414Z" },
+ { url = "https://files.pythonhosted.org/packages/70/9b/ce0cca6d2d87fcd4b6ff97600790494e64f26a2c55d61507cd2755c16193/msgspec-0.21.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:4e47390360583ba3d5c6cb44cf0a9f61b0a06a899d3c2c00627cedebb2e2884b", size = 192879, upload-time = "2026-04-12T21:44:40.882Z" },
+ { url = "https://files.pythonhosted.org/packages/a7/08/673a7bb05e5702dc787ddd3011195b509f9867927970da59052211929987/msgspec-0.21.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f60800e6299b798142dc40b0644da77ceac5ea0568be58228417eae14135c847", size = 226281, upload-time = "2026-04-12T21:44:42.181Z" },
+ { url = "https://files.pythonhosted.org/packages/7d/45/86508cf57283e9070b3c447e3ab25b792a7a0855a3ea4e0c6d111ac34c97/msgspec-0.21.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5f8e9dfcd98419cf7568808470c4317a3fb30bef0e3715b568730a2b272a20d7", size = 229863, upload-time = "2026-04-12T21:44:43.442Z" },
+ { url = "https://files.pythonhosted.org/packages/2c/62/e7c9367cd08d590559faacd711edbae36840342843e669440363f33c7d36/msgspec-0.21.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:92d89dfad13bd1ea640dc3e37e724ed380da1030b272bdf5ecafb983c3ad7c75", size = 230445, upload-time = "2026-04-12T21:44:44.806Z" },
+ { url = "https://files.pythonhosted.org/packages/42/b4/c0f54632103846b658a10930025f4de41c8724b5e4805a5f3b395586cb7e/msgspec-0.21.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:0d03867786e5d7ba25d666df4b11320c27170f4aeafcb8e3a8b0a50a4fb742ca", size = 231822, upload-time = "2026-04-12T21:44:46.343Z" },
+ { url = "https://files.pythonhosted.org/packages/ea/1d/0d85cc79d0ccf5508e9c846cc66552a6a16bf92abd1dbd8362617f7b35cd/msgspec-0.21.1-cp314-cp314t-win_amd64.whl", hash = "sha256:740fbf1c9d59992ca3537d6fbe9ebbf9eaf726a65fbf31448e0ecbc710697a63", size = 206650, upload-time = "2026-04-12T21:44:47.601Z" },
+ { url = "https://files.pythonhosted.org/packages/90/91/56c5d560f20e6c20e9e4f55bd0e458f7f162aa689ee350346c04c48eac0b/msgspec-0.21.1-cp314-cp314t-win_arm64.whl", hash = "sha256:0d2cc73df6058d811a126ac3a8ad63a4dfa210c82f9cf5a004802eaf4712de90", size = 183149, upload-time = "2026-04-12T21:44:48.833Z" },
+]
+
[[package]]
name = "mypy-extensions"
version = "1.1.0"
@@ -3455,6 +3519,21 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/40/03/26a383c9e58c213199d1aad1c3d353cfc22d4444ec6d2c0bf8ad02523843/typer-0.27.0-py3-none-any.whl", hash = "sha256:6f4b27631e47f077871b7dc30e933ec0131c1390fbe0e387ea5574b5bac9ccf1", size = 122716, upload-time = "2026-07-15T19:21:05.553Z" },
]
+[[package]]
+name = "typesafe-sdk"
+version = "0.5.7"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "httpx2" },
+ { name = "msgspec" },
+ { name = "tenacity" },
+ { name = "typing-extensions" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/a8/bb/595551be8c0786d830b4d115367cefc7ae16542ef4f45de2239abc8a1d92/typesafe_sdk-0.5.7.tar.gz", hash = "sha256:4293adef6ac1cbfa7dec22e487a303b3862cfd46324a085fcaa3e6978b460c4d", size = 19144, upload-time = "2026-09-11T23:05:51.893Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/2a/91/0f924e2a447e60e73438dd23a5c619c10bc943176353ab0f7f07c847432d/typesafe_sdk-0.5.7-py3-none-any.whl", hash = "sha256:739c8fbd69a372dcf9810154a08fcf77622d9f617cafda57c9825f228a92af03", size = 31613, upload-time = "2026-09-11T23:05:50.184Z" },
+]
+
[[package]]
name = "typing-extensions"
version = "4.16.0"