mcpField
B
blink-realtime

blink-realtime

github.com/blink-newDevelopment438 installsUpdated 2w ago
Repository

About blink-realtime

blink-realtime is a skill for publishing and subscribing to Blink realtime channels through the CLI and SDK. It helps developers build chat, collaboration, notification, gaming, and live dashboard features, with message and presence support.

Key features

  1. 01Publish events to channels
  2. 02Subscribe to channel messages
  3. 03Track channel presence
  4. 04Use CLI and SDK APIs

Use cases

  1. 01Build chat with messages and presence
  2. 02Send alerts to connected clients
  3. 03Sync collaborative edits or game state

MCP support

It provides the `blink_realtime_publish` tool for publishing an event to a channel through MCP.

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/blink-new/blink-plugin --skill blink-realtime

After installing, type/blink-realtimein Claude Code to confirm it loaded.

Details

From the project README

Requires auth: initialize with auth: { mode: 'managed' } for realtime to work.

Getting Started

# Publish a message to a channel
blink realtime publish chat-room --type message --data '{"text":"Hello everyone!"}'

# Publish with user context
blink realtime publish notifications --type alert --data '{"level":"info","text":"Deploy complete"}'

MCP Tools

ToolDescription
blink_realtime_publishPublish event to a channel

SDK Methods

// Simple subscribe/publish
const unsubscribe = await blink.realtime.subscribe('chat-room', (message) => {
  console.log(message.data)
})

await blink.realtime.publish('chat-room', 'message', { text: 'Hello!' })
unsubscribe()

Channel API (Advanced)

const channel = blink.realtime.channel('game-lobby')

await channel.subscribe({
  userId: user.id,
  metadata: { displayName: user.name, status: 'online' }
})

channel.onMessage((msg) => {
  if (msg.type === 'chat') addMessage(msg.data)
})

channel.onPresence((users) => {
  setOnlineUsers(users)
})

await channel.publish('chat', { text: 'Hello!' }, { userId: user.id })

const history = await channel.getMessages({ limit: 50 })
const users = await channel.getPresence()

await channel.unsubscribe()

Message Format

{
  id: '1640995200000-0',
  type: 'chat',
  data: { text: 'Hello!' },
  timestamp: 1640995200000,
  userId: 'user123',
  metadata: { displayName: 'John' }
}

Presence Format

{
  userId: 'user123',
  metadata: { displayName: 'John', status: 'online' },
  joinedAt: 1640995200000,
  lastSeen: 1640995230000
}

React Cleanup (Critical)

useEffect(() => {
  if (!user?.id) return

  let channel: any = null

  const init = async () => {
    channel = blink.realtime.channel('room')
    await channel.subscribe({ userId: user.id })
    channel.onMessage((msg: any) => setMessages(prev => [...prev, msg]))
  }

  init().catch(console.error)

  return () => { channel?.unsubscribe() }
}, [user?.id])

Never return cleanup from inside an async function — it gets lost. Store channel reference outside and clean up synchronously.

Use Cases

  • Chat apps — messages + presence + history
  • Live collaboration — cursor positions, document edits
  • Notifications — real-time alerts pushed to connected clients
  • Gaming — game state sync, lobby management
  • Dashboards — live data updates

Comments

Markdown supported