Agent middleware covering what MCP tools need around every call.
The tools themselves come out of langchain.mcp unmodified. Everything this
app wants on top — an argument quirk, and translating a dead-token failure into
something a model and a user can act on — sits here instead, so the adapter
stays the plain conversion it is and this behavior applies to any MCP tool the
agent is given.
Drop empty-string values for optional MCP tool params.
Some MCP servers (e.g. Slack's slack_search_public_and_private) validate
optional ID-typed params with value is not a channel ID when the model
fills them in with "" instead of omitting them. JSON-Schema-derived
models happily accept "" for an optional string, so the request reaches
the server and comes back as a generic failure.
Treat "" for a non-required string field as "omitted", so the server sees
the payload it would have for a field the model genuinely skipped. Required
fields pass through unchanged, so the server's own missing-field error still
runs. Only "" is normalized; None is left to the server.
Build the middleware wrapping every MCP tool call.