Allow controlling Tool return format
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3582933. -->
Reported by: [b_sharpe](https://www.drupal.org/user/2512258)
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Currently the return of a tool is textual which is fine for AI to analyze, but sometimes in MCP or other methods like <a href="https://www.drupal.org/project/agui">AG-UI</a> that want the raw result. </p>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<p>Call a tool and observe the result, it will be something like:</p>
<pre>Tool Plugin executed successfully: View 'my_view' executed successfully.\nOutput for results: { actual tool result }</pre><h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>I see a few ways forward here</p>
<ol>
<li>Change to just spit out the raw result directly</li>
<li>Separate the result from the text so they are two different array values in the return. This could get messy if both the return and the tool output are JSON</li>
<li>Tool config? Usage of a tool allows choosing its output format</li>
<li>Other? ToolOutputFormatInterface?</li>
</ol>
issue