mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
🔀 fix: MCP Improvements, Auto-Save Drafts, Artifact Markup (#7040)
* feat: Update MCP tool creation to use lowercase provider name * refactor: handle MCP image output edge cases where tool outputs must contain string responses * feat: Drop 'anyOf' and 'oneOf' fields from JSON schema conversion * feat: Transform 'oneOf' and 'anyOf' fields to Zod union in JSON schema conversion * fix: artifactPlugin to replace textDirective with expected text, closes #7029 * fix: auto-save functionality to handle conversation transitions from pending drafts, closes #7027 * refactor: improve async handling during user disconnection process * fix: use correct user ID variable for MCP tool calling * fix: improve handling of pending drafts in auto-save functionality * fix: add support for additional model names in getValueKey function * fix: reset form values on agent deletion when no agents remain
This commit is contained in:
parent
150116eefe
commit
7f1d01c35a
12 changed files with 856 additions and 73 deletions
|
|
@ -19,7 +19,7 @@ const { logger, getMCPManager } = require('~/config');
|
|||
* @param {string} params.model - The model for the tool.
|
||||
* @returns { Promise<typeof tool | { _call: (toolInput: Object | string) => unknown}> } An object with `_call` method to execute the tool input.
|
||||
*/
|
||||
async function createMCPTool({ req, toolKey, provider }) {
|
||||
async function createMCPTool({ req, toolKey, provider: _provider }) {
|
||||
const toolDefinition = req.app.locals.availableTools[toolKey]?.function;
|
||||
if (!toolDefinition) {
|
||||
logger.error(`Tool ${toolKey} not found in available tools`);
|
||||
|
|
@ -27,9 +27,10 @@ async function createMCPTool({ req, toolKey, provider }) {
|
|||
}
|
||||
/** @type {LCTool} */
|
||||
const { description, parameters } = toolDefinition;
|
||||
const isGoogle = provider === Providers.VERTEXAI || provider === Providers.GOOGLE;
|
||||
const isGoogle = _provider === Providers.VERTEXAI || _provider === Providers.GOOGLE;
|
||||
let schema = convertJsonSchemaToZod(parameters, {
|
||||
allowEmptyObject: !isGoogle,
|
||||
transformOneOfAnyOf: true,
|
||||
});
|
||||
|
||||
if (!schema) {
|
||||
|
|
@ -49,7 +50,8 @@ async function createMCPTool({ req, toolKey, provider }) {
|
|||
const _call = async (toolArguments, config) => {
|
||||
try {
|
||||
const derivedSignal = config?.signal ? AbortSignal.any([config.signal]) : undefined;
|
||||
const mcpManager = getMCPManager(config?.userId);
|
||||
const mcpManager = getMCPManager(config?.configurable?.user_id);
|
||||
const provider = (config?.metadata?.provider || _provider)?.toLowerCase();
|
||||
const result = await mcpManager.callTool({
|
||||
serverName,
|
||||
toolName,
|
||||
|
|
@ -70,7 +72,7 @@ async function createMCPTool({ req, toolKey, provider }) {
|
|||
return result;
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
`[MCP][User: ${config?.userId}][${serverName}] Error calling "${toolName}" MCP tool:`,
|
||||
`[MCP][User: ${config?.configurable?.user_id}][${serverName}] Error calling "${toolName}" MCP tool:`,
|
||||
error,
|
||||
);
|
||||
throw new Error(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue