Skip to content

Beta 5 - MCP server notifications (like logging) on the client? #7172

@RicSala

Description

@RicSala

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

  1. SSE connection establishes correctly
  2. Server sends notifications via SSE ✅ (visible in server logs)
  3. Tool calls work perfectly
  4. Client never receives notifications ❌ (onmessage never fires)

Questions

  1. Does experimental_createMCPClient support MCP notifications?
  2. How should I handle server-sent notifications (like logging) on the client?
  3. 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",

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy