MCPcopy Index your code
hub / github.com/modelcontextprotocol/python-sdk / notify

Method notify

src/mcp/server/connection.py:278–287  ·  view source on GitHub ↗

Send a best-effort notification on the standalone stream. Never raises. If there's no standalone channel or the stream is broken, the notification is dropped and debug-logged.

(self, method: str, params: Mapping[str, Any] | None, opts: CallOptions | None = None)

Source from the content-addressed store, hash-verified

276 return cls.model_validate(raw, by_name=False)
277
278 async def notify(self, method: str, params: Mapping[str, Any] | None, opts: CallOptions | None = None) -> None:
279 """Send a best-effort notification on the standalone stream.
280
281 Never raises. If there's no standalone channel or the stream is broken,
282 the notification is dropped and debug-logged.
283 """
284 try:
285 await self.outbound.notify(method, params, opts)
286 except (anyio.BrokenResourceError, anyio.ClosedResourceError):
287 logger.debug("dropped %s: standalone stream closed", method)
288
289 async def ping(self, *, meta: Meta | None = None, opts: CallOptions | None = None) -> None:
290 """Send a `ping` request on the standalone stream.

Callers 7

logMethod · 0.95
send_resource_updatedMethod · 0.95
logMethod · 0.45
send_notificationMethod · 0.45

Calls 1

debugMethod · 0.80

Tested by

no test coverage detected