// ⚠️ Logging callbacks are not yet supported in the TypeScript library.
// Support is coming soon! If you need this feature now, please open an issue:
// https://github.com/mcp-use/mcp-use
// When supported, the API will look similar to:
/*
import { MCPClient, types } from 'mcp-use'
// A dedicated handler for log messages
async function handleLogs(logParams: types.LoggingMessageNotificationParams) {
console.log(`LOG [${logParams.level.toUpperCase()}]: ${logParams.message}`)
}
async function testLogging(primitiveServer: string) {
const config = { mcpServers: { PrimitiveServer: { url: `${primitiveServer}/mcp` } } }
// Pass the callback to the client
const client = new MCPClient(config, { loggingCallback: handleLogs })
try {
await client.createAllSessions()
const session = client.getSession('PrimitiveServer')
// This tool will trigger the loggingCallback
const result = await session.callTool('logging_tool', {})
console.assert(result.content[0].text === 'Logging tool completed')
} finally {
await client.closeAllSessions()
}
}
*/