# normalize_mcp_arguments

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/mcp_middleware/normalize_mcp_arguments)

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.

## Signature

```python
normalize_mcp_arguments(
    arguments: dict[str, Any],
    input_schema: Any,
) -> dict[str, Any]
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `arguments` | `dict[str, Any]` | Yes | Arguments the model produced for this call. |
| `input_schema` | `Any` | Yes | The MCP tool's input schema (raw JSON Schema dict). |

## Returns

`dict[str, Any]`

A new argument dict, or `arguments` unchanged when nothing was dropped.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/4bfa52000ef65ac623d8ada0cb67f67cbdd663ea/libs/code/deepagents_code/mcp_middleware.py#L39)