fix(mcp-actions-backend): return structured content and remove markdown formatting in tool responses

This change aligns the MCP tool execution responses with the specification by returning plain text in the 'content' array and providing the raw JSON in a new 'structuredContent' field. It also removes the unnecessary Markdown code block formatting that was previously added to tool results.

Fixes #34052

Signed-off-by: Love Kumar Chauhan <lovechauhan6564@gmail.com>

Co-authored-by: benjdlambert <3645856+benjdlambert@users.noreply.github.com>
Signed-off-by: benjdlambert <ben@blam.sh>
This commit is contained in:
Love Kumar Chauhan
2026-04-25 23:52:49 +05:30
committed by benjdlambert
parent 381cf2ae10
commit ca8951ae87
5 changed files with 14 additions and 21 deletions
+4
View File
@@ -135,6 +135,10 @@ When errors are thrown from MCP actions, the backend will handle and surface err
See [Backstage Errors](https://backstage.io/docs/reference/errors/) for a full list of supported errors.
### Response Format
Tool execution results are returned in a format compliant with the MCP specification, including both a plain-text representation in the `content` array and the raw JSON result in the `structuredContent` field. This ensures that AI clients can process the data either as text or as structured data for more precise tool use.
When writing MCP tools, use the appropriate error from `@backstage/errors` when applicable:
```ts