FASTMCP SF · GITHUB HQ · DEC 2
servers can send events to clients.
poll
push
webhook
🐔 upstream
something happens out in the world
MCP server
event log
every change, in order
client
wants to know
push
stays connected
webhook
gets a POST
🐔 upstream
something happens out in the world
MCP server
event log
every change, in order
anything new?
client
wants to know
push
stays connected
webhook
gets a POST
🐔 upstream
something happens out in the world
MCP server
event log
every change, in order
anything new?
client
wants to know
push
stays connected
webhook
gets a POST
client: anything new?
server: nope.
client: anything new?
server: nope.
client: anything new?
server: nope.
client: anything new?
server: yes, 3 things changed.
🐔 upstream
something happens out in the world
MCP server
event log
every change, in order
anything new?
client
wants to know
push
stays connected
webhook
gets a POST
client: anything new?
server: nope.
client: anything new?
server: nope.
client: anything new?
server: nope.
client: anything new?
server: yes, 3 things changed.
ask more often: more nopes. ask less often: you hear later.
🐔 upstream
something happens out in the world
MCP server
event log
every change, in order
client
wants to know
push
stays connected
webhook
gets a POST
🐔 upstream
something happens out in the world
MCP server
event log
every change, in order
poll
asks every few seconds
push
stays connected
webhook
gets a POST
🐔 upstream
something happens out in the world
MCP server
event log
every change, in order
poll
asks every few seconds
push
stays connected
webhook
gets a POST
🐔 upstream
something happens out in the world
MCP server
event log
every change, in order
poll
asks every few seconds
push
stays connected
webhook
gets a POST
…f65b-4
…f65b-4
…f65b-4
drop, come back, or switch modes: you pick up right where you left off.
@events.source
async def top_chicken(feed: EventFeed):
async for board in race(after=feed.position):
await events.emit(overtake, event_id=board.id)
await feed.save_position(board.ts)
@mcp.custom_route("/hooks/alerts", methods=["POST"])
async def alert_hook(request):
data = await request.json()
await events.emit(Alert(**data), event_id=data["id"])
@events.reader(EmailReceived)
def read_inbox(poll: EventPoll) -> EventBatch:
new = INBOX[int(poll.cursor):]
return EventBatch(events=..., cursor=str(len(INBOX)))
@mcp.tool
async def deploy(service: str) -> str:
run = await ci.trigger(service)
await events.emit(Deploying(service=service, run=run.id))
return run.id
poll, push and webhook read the same events, however they got in.
the event
@events.event("chicken.overtake")
class Overtake(BaseModel):
passer: str
passed: str
rank: int
def for_subscription(
self, top: int = 10
):
if self.rank <= top:
return self
the source
@events.source
async def top_chicken(feed: EventFeed):
async for board in race():
for change in diff(board):
await events.emit(change, event_id=change.id)
await feed.save_position(str(board.ts))
the server runs it once for everyone, restarts it if it fails, and resumes from feed.position.
fastmcp delivers events to clients by poll, push or webhook. you only write the event and the source.
🐔 top chicken
most-liked bluesky post of the day wins
board
server.py
@events.source
overtake · new leader · crowned
events
poll
asks every 10s · its own announcer
push
stream held open · its own announcer
webhook
signed POSTs · its own announcer
each announcer is a small model that only knows what its client received.
poll
every overtake, in batches, up to 10 seconds late.
push
each overtake as it happened, over a stream it kept open.
webhook
each overtake as it happened, POSTed to its URL by the server.
hang up
everything it missed, in order, all at once when it came back with its cursor.
push and webhook tie on speed. the difference is who pays for the delivery.
poll stops
picks up from its cursor
push drops
reconnects from its cursor
webhook URL is down
the server retries with the same event id
MCP server
restarts
with a shared store, subscriptions and positions are kept
an ordered log
every mode reads it from the client’s cursor. in memory on one replica; Redis to survive restarts and share across replicas.
a doorbell for open streams
when the log grows, open streams on every replica wake up. in-process on one replica; Redis pub/sub across replicas.
a sender that POSTs
one delivery line per webhook, with its own cursor, retrying with backoff. receivers drop duplicates by event id.
poll needs nothing past the log.
sources: your code that puts events on the log. fastmcp runs each one once.
EventsExtension(log=RedisEventLog("redis://…")) # fastmcp-events[redis]
SEP-3415 is final. events is an official MCP extension; its spec is published as beta.
fastmcp-events is experimental. poll, push, webhooks and sources are all in 4.2.7a3.
ChatGPT takes events by webhook, in Work chats. Claude and Cursor don’t support events yet.
uv add --prerelease=allow "fastmcp[events]==4.2.7a3"