Skip to content

[Agent Builder] Improve MCP tool call error message#248549

Merged
dennis-tismenko merged 3 commits intoelastic:mainfrom
dennis-tismenko:agent-builder/fix-mcp-client-logging
Jan 12, 2026
Merged

[Agent Builder] Improve MCP tool call error message#248549
dennis-tismenko merged 3 commits intoelastic:mainfrom
dennis-tismenko:agent-builder/fix-mcp-client-logging

Conversation

@dennis-tismenko
Copy link
Contributor

@dennis-tismenko dennis-tismenko commented Jan 9, 2026

Summary

Improves MCP tool call error messages by extracting and displaying the actual error content from the response. Per the MCP specification, tool execution errors are returned as text content parts, so the error message now properly surfaces this information instead of showing an undefined response.error property.

CleanShot 2026-01-09 at 17 16 03

Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

  • Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
  • Documentation was added for features that require explanation or tutorials
  • Unit or functional tests were updated or added to match the most common scenarios
  • If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the docker list
  • This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The release_note:breaking label should be applied in these situations.
  • Flaky Test Runner was used on any tests changed
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines
  • Review the backport guidelines and apply applicable backport:* labels.

@dennis-tismenko dennis-tismenko added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting v9.4.0 labels Jan 9, 2026
@dennis-tismenko dennis-tismenko changed the title [Agent Builder] Improve MCP tool call error logging [Agent Builder] Improve MCP tool call error message Jan 9, 2026
@dennis-tismenko dennis-tismenko force-pushed the agent-builder/fix-mcp-client-logging branch from a246f04 to 0fc9d9d Compare January 9, 2026 22:22
@dennis-tismenko dennis-tismenko marked this pull request as ready for review January 9, 2026 22:22
@dennis-tismenko dennis-tismenko requested a review from a team as a code owner January 9, 2026 22:22
@dennis-tismenko dennis-tismenko force-pushed the agent-builder/fix-mcp-client-logging branch from 09996b5 to b3a15c6 Compare January 9, 2026 23:55
@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #115 / Serverless Common UI - Management Index Management Index Details can view index details can add mappings

Metrics [docs]

✅ unchanged

History

@dennis-tismenko
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@mattnowzari mattnowzari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 🚀

@dennis-tismenko dennis-tismenko merged commit 8925713 into elastic:main Jan 12, 2026
13 checks passed
tsullivan pushed a commit that referenced this pull request Jan 12, 2026
## Summary

Improves MCP tool call error messages by extracting and displaying the
actual error content from the response. Per the [MCP
specification](https://modelcontextprotocol.io/specification/2025-11-25/server/tools#error-handling),
tool execution errors are returned as text content parts, so the error
message now properly surfaces this information instead of showing an
undefined response.error property.



<img width="1290" height="1241" alt="CleanShot 2026-01-09 at 17 16 03"
src="https://github.com/user-attachments/assets/94e0b0cb-7d4b-4bae-9266-38c65b334cfe"
/>

### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [x] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [x] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@dennis-tismenko
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
9.3

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

dennis-tismenko added a commit to dennis-tismenko/kibana that referenced this pull request Jan 14, 2026
## Summary

Improves MCP tool call error messages by extracting and displaying the
actual error content from the response. Per the [MCP
specification](https://modelcontextprotocol.io/specification/2025-11-25/server/tools#error-handling),
tool execution errors are returned as text content parts, so the error
message now properly surfaces this information instead of showing an
undefined response.error property.

<img width="1290" height="1241" alt="CleanShot 2026-01-09 at 17 16 03"
src="https://github.com/user-attachments/assets/94e0b0cb-7d4b-4bae-9266-38c65b334cfe"
/>

### Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [x] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [x] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
(cherry picked from commit 8925713)
dennis-tismenko added a commit that referenced this pull request Jan 14, 2026
…249069)

# Backport

This will backport the following commits from `main` to `9.3`:
- [[Agent Builder] Improve MCP tool call error message
(#248549)](#248549)

<!--- Backport version: 10.2.0 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Dennis
Tismenko","email":"dennis.tismenko@elastic.co"},"sourceCommit":{"committedDate":"2026-01-12T18:03:14Z","message":"[Agent
Builder] Improve MCP tool call error message (#248549)\n\n##
Summary\n\nImproves MCP tool call error messages by extracting and
displaying the\nactual error content from the response. Per the
[MCP\nspecification](https://modelcontextprotocol.io/specification/2025-11-25/server/tools#error-handling),\ntool
execution errors are returned as text content parts, so the
error\nmessage now properly surfaces this information instead of showing
an\nundefined response.error property.\n\n\n\n<img width=\"1290\"
height=\"1241\" alt=\"CleanShot 2026-01-09 at 17 16
03\"\nsrc=\"https://github.com/user-attachments/assets/94e0b0cb-7d4b-4bae-9266-38c65b334cfe\"\n/>\n\n###
Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers
should verify this PR satisfies this list as well.\n\n- [x] Any text
added follows [EUI's
writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\nsentence case text and includes
[i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n-
[x]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas
added for features that require explanation or tutorials\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] If a plugin
configuration key changed, check if it needs to be\nallowlisted in the
cloud and added to the
[docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n-
[x] This was checked for breaking HTTP API changes, and any
breaking\nchanges have been approved by the breaking-change committee.
The\n`release_note:breaking` label should be applied in these
situations.\n- [x] [Flaky
Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\nused on any tests changed\n- [x] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"89257138a7985b0a1020215e6c78b913de8b3a64","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:skip","v9.4.0"],"title":"[Agent
Builder] Improve MCP tool call error
message","number":248549,"url":"https://github.com/elastic/kibana/pull/248549","mergeCommit":{"message":"[Agent
Builder] Improve MCP tool call error message (#248549)\n\n##
Summary\n\nImproves MCP tool call error messages by extracting and
displaying the\nactual error content from the response. Per the
[MCP\nspecification](https://modelcontextprotocol.io/specification/2025-11-25/server/tools#error-handling),\ntool
execution errors are returned as text content parts, so the
error\nmessage now properly surfaces this information instead of showing
an\nundefined response.error property.\n\n\n\n<img width=\"1290\"
height=\"1241\" alt=\"CleanShot 2026-01-09 at 17 16
03\"\nsrc=\"https://github.com/user-attachments/assets/94e0b0cb-7d4b-4bae-9266-38c65b334cfe\"\n/>\n\n###
Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers
should verify this PR satisfies this list as well.\n\n- [x] Any text
added follows [EUI's
writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\nsentence case text and includes
[i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n-
[x]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas
added for features that require explanation or tutorials\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] If a plugin
configuration key changed, check if it needs to be\nallowlisted in the
cloud and added to the
[docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n-
[x] This was checked for breaking HTTP API changes, and any
breaking\nchanges have been approved by the breaking-change committee.
The\n`release_note:breaking` label should be applied in these
situations.\n- [x] [Flaky
Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\nused on any tests changed\n- [x] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"89257138a7985b0a1020215e6c78b913de8b3a64"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/248549","number":248549,"mergeCommit":{"message":"[Agent
Builder] Improve MCP tool call error message (#248549)\n\n##
Summary\n\nImproves MCP tool call error messages by extracting and
displaying the\nactual error content from the response. Per the
[MCP\nspecification](https://modelcontextprotocol.io/specification/2025-11-25/server/tools#error-handling),\ntool
execution errors are returned as text content parts, so the
error\nmessage now properly surfaces this information instead of showing
an\nundefined response.error property.\n\n\n\n<img width=\"1290\"
height=\"1241\" alt=\"CleanShot 2026-01-09 at 17 16
03\"\nsrc=\"https://github.com/user-attachments/assets/94e0b0cb-7d4b-4bae-9266-38c65b334cfe\"\n/>\n\n###
Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers
should verify this PR satisfies this list as well.\n\n- [x] Any text
added follows [EUI's
writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\nsentence case text and includes
[i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n-
[x]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas
added for features that require explanation or tutorials\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] If a plugin
configuration key changed, check if it needs to be\nallowlisted in the
cloud and added to the
[docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n-
[x] This was checked for breaking HTTP API changes, and any
breaking\nchanges have been approved by the breaking-change committee.
The\n`release_note:breaking` label should be applied in these
situations.\n- [x] [Flaky
Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\nused on any tests changed\n- [x] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"89257138a7985b0a1020215e6c78b913de8b3a64"}}]}]
BACKPORT-->

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes v9.3.0 v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants