🪄 refactor: Simplify MCP Tool Content Formatting to Unified String Output (#12352)

* refactor: Simplify content formatting in MCP service and parser

- Consolidated content handling in `formatToolContent` to return a plain-text string instead of an array for all providers, enhancing clarity and consistency.
- Removed unnecessary checks for content array providers, streamlining the logic for handling text and image artifacts.
- Updated related tests to reflect changes in expected output format, ensuring comprehensive coverage for the new implementation.

* fix: Return empty string for image-only tool responses instead of '(No response)'

When artifacts exist (images/UI resources) but no text content is present,
return an empty string rather than the misleading '(No response)' fallback.
Adds missing test assertions for image-only content and standardizes
length checks to explicit `> 0` comparisons.
This commit is contained in:
Danny Avila 2026-03-21 13:01:59 -04:00
parent b5c097e5c7
commit 7829fa9eca
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
4 changed files with 95 additions and 154 deletions

View file

@ -15,13 +15,7 @@ const {
GenerationJobManager,
resolveJsonSchemaRefs,
} = require('@librechat/api');
const {
Time,
CacheKeys,
Constants,
ContentTypes,
isAssistantsEndpoint,
} = require('librechat-data-provider');
const { Time, CacheKeys, Constants, isAssistantsEndpoint } = require('librechat-data-provider');
const {
getOAuthReconnectionManager,
getMCPServersRegistry,
@ -605,9 +599,6 @@ function createToolInstance({
if (isAssistantsEndpoint(provider) && Array.isArray(result)) {
return result[0];
}
if (isGoogle && Array.isArray(result[0]) && result[0][0]?.type === ContentTypes.TEXT) {
return [result[0][0].text, result[1]];
}
return result;
} catch (error) {
logger.error(