# `ExMCP.Server.Tools.Helpers`
[🔗](https://github.com/azmaveth/ex_mcp/blob/v1.0.0/lib/ex_mcp/server/tools/helpers.ex#L1)

Helper functions for building tool responses and working with schemas.

> #### Deprecated {: .warning}
>
> Part of the deprecated `ExMCP.Server.Tools` API. **Planned for removal in 2.0.0.**
> Prefer `ExMCP.Server.DSL.Result` (`ToolResult` inside DSL modules) or raw
> MCP content maps from handler callbacks.

This module provides utilities to simplify common patterns when implementing
MCP tools, including response builders, schema validators, and type converters.

# `array_schema`

Generates an array schema.

# `error_response`

Creates an error response with text content.

## Examples

    iex> error_response("Something went wrong")
    %{content: [%{type: "text", text: "Something went wrong"}], isError: true}

# `image_response`

Creates an image response.

## Examples

    iex> image_response("https://example.com/image.png", "An example image")
    [%{
      type: "image",
      data: "https://example.com/image.png",
      mimeType: "image/png",
      description: "An example image"
    }]

# `multi_content_response`

Creates a multi-content response with mixed content types.

## Examples

    iex> multi_content_response([
    ...>   {:text, "Here is some text"},
    ...>   {:image, "data:image/png;base64,abc123", "A diagram"},
    ...>   {:resource, "file:///doc.pdf", "application/pdf"}
    ...> ])

# `number_schema`

Generates a number schema with constraints.

# `object_schema`

Generates an object schema.

# `resource_response`

Creates a resource response.

## Examples

    iex> resource_response("file:///path/to/file.txt", "text/plain")
    [%{
      type: "resource",
      uri: "file:///path/to/file.txt",
      mimeType: "text/plain"
    }]

# `string_schema`

Generates a string schema with constraints.

# `structured_response`

Creates a response with both text and structured content.

## Examples

    iex> structured_response("Operation completed", %{status: "success", count: 42})
    %{
      content: [%{type: "text", text: "Operation completed"}],
      structuredContent: %{status: "success", count: 42}
    }

# `text_response`

Creates a simple text response.

## Examples

    iex> text_response("Hello, World!")
    [%{type: "text", text: "Hello, World!"}]

# `validate_arguments`

Validates arguments against a JSON schema.

Returns {:ok, validated_args} with defaults applied, or {:error, reason}.

## Examples

    iex> schema = %{
    ...>   type: "object",
    ...>   properties: %{
    ...>     name: %{type: "string"},
    ...>     age: %{type: "integer"}
    ...>   },
    ...>   required: ["name"]
    ...> }
    iex> validate_arguments(%{name: "Alice", age: 30}, schema)
    {:ok, %{name: "Alice", age: 30}}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
