Internationalizes error messages and console logs.

This commit is contained in:
uxname committed 2025-06-02 23:13:46 +03:00
1 parent fa126651de
commit c7735cc6f9
4 files changed
+50 -57

No files matched your search

+11 -9
View File
@@ -24,10 +24,10 @@ export class McpToolsService {
version: '1.0.0',
});
await this.mcpClient.connect(this.transport);
console.log(`[MCP Service] Подключено к MCP серверу: ${this.serverUrl}`);
console.log(`[MCP Service] Connected to MCP server: ${this.serverUrl}`);
} catch (error) {
console.error(
`[MCP Service] Ошибка подключения к MCP серверу ${this.serverUrl}:`,
`[MCP Service] Error connecting to MCP server ${this.serverUrl}:`,
error,
);
throw error;
@@ -39,13 +39,15 @@ export class McpToolsService {
await this.mcpClient.close();
this.mcpClient = null;
this.transport = null;
console.log(`[MCP Service] Отключено от MCP сервера: ${this.serverUrl}`);
console.log(
`[MCP Service] Disconnected from MCP server: ${this.serverUrl}`,
);
}
}
async getLangchainTools(): Promise<DynamicStructuredTool[]> {
if (!this.mcpClient) {
throw new Error('MCP клиент не подключен. Сначала вызовите .connect()');
throw new Error('MCP client is not connected. Call .connect() first');
}
const mcpTools: McpTool[] = (await this.mcpClient.listTools()).tools;
@@ -89,7 +91,7 @@ export class McpToolsService {
schema: zodSchema,
func: async (args: Record<string, unknown>) => {
console.log(
`[MCP Tool Call] Вызов инструмента MCP: ${mcpTool.name} с аргументами:`,
`[MCP Tool Call] Calling MCP tool: ${mcpTool.name} with arguments:`,
args,
);
const result = await this.mcpClient!.callTool({
@@ -103,7 +105,7 @@ export class McpToolsService {
.map((c) => (c as TextContent).text || '')
.join('\n');
throw new Error(
`Ошибка выполнения инструмента ${mcpTool.name}: ${errorContent}`,
`Error executing tool ${mcpTool.name}: ${errorContent}`,
);
}
@@ -114,9 +116,9 @@ export class McpToolsService {
return (result.content as any[])
.map((c) => {
if (c.type === 'text') return (c as TextContent).text;
if (c.type === 'image') return `[Изображение: ${c.mimeType}]`;
if (c.type === 'audio') return `[Аудио: ${c.mimeType}]`;
if (c.type === 'resource') return `[Ресурс: ${c.uri}]`;
if (c.type === 'image') return `[Image: ${c.mimeType}]`;
if (c.type === 'audio') return `[Audio: ${c.mimeType}]`;
if (c.type === 'resource') return `[Resource: ${c.uri}]`;
return JSON.stringify(c);
})
.join('\n');