-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Labels
Description
Description
I'm trying to implement MCP logging notifications using experimental_createMCPClient
but can't receive server notifications on the client side. The server sends log notifications via SSE, but I can't see how to receive those in the client.
Current Setup
Server (MCP):
// Server sends log notifications
const logNotification = {
jsonrpc: '2.0',
method: 'notifications/message',
params: {
level: 'info',
logger: 'tool-executor',
data: { message: 'Tool execution started', toolName: 'get_time' },
},
};
Client (AI SDK):
import { experimental_createMCPClient } from 'ai';
import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
const transport = new SSEClientTransport(new URL('/api/mcp-server/sse'));
// This never gets called for notifications
transport.onmessage = (message) => {
console.log('Message received:', message);
if (message.method === 'notifications/message') {
console.log('Log notification:', message.params);
}
};
const client = await experimental_createMCPClient({ transport });
What I've Observed
- SSE connection establishes correctly ✅
- Server sends notifications via SSE ✅ (visible in server logs)
- Tool calls work perfectly ✅
- Client never receives notifications ❌ (
onmessage
never fires)
Questions
- Does
experimental_createMCPClient
support MCP notifications? - How should I handle server-sent notifications (like logging) on the client?
- Is there a different approach for bidirectional MCP communication?
Expected Behavior
According to the MCP logging spec, servers should be able to send log notifications to clients, and clients should be able to receive them.
Any guidance on the correct approach would be greatly appreciated!
AI SDK Version
"ai": "5.0.0-beta.7",
"@ai-sdk/openai": "2.0.0-beta.5",
"@ai-sdk/react": "2.0.0-beta.7",
ooaeoaii