Repository navigation
How to handle notifications from MCP server? What are best practices? #1192
Replies: 6 comments 20 replies
|
Hi @Gelembjuk it can be helpful to check out this reference server for examples of how different types of MCP notifications can be implemented: https://github.com/modelcontextprotocol/servers/tree/main/src/everything And if you want to see how a client could listen for these in a Typescript implementation, check out the Inspector code for where |
|
Since this discussion started i have done some investigating. Maybe it will be interesting to someone here. |
|
@olaservo The idea of this request is to have a way to get events/notifications from the mcp server to the mcp client (and on this way to the agent/llm). A mail mcp server (or anything related to notifications/ action triggers) could be named as a typical use case. Is there any way to propose something to the standard? Is this somehow a known feature request or is there any ongoing discussion related to this? |
|
Please note, there is another problem related to notifications from a tools server back to AI agent - there is no way to tell LLM that "this request is from a tool inited by a tool". When we send a request to LLM we use roles - "user" or "assistant" or "system". And there is no a role or some option to mark a tool inited request. So, it is not only about the transport. LLMs world also must adopt this |
It sounds like you are talking about a "resources/updated" notification. Here is what they are supposed to look like: {
"jsonrpc": "2.0",
"method": "notifications/resources/updated",
"params": {
"uri": "file:///project/src/main.rs"
}
}So the method would be as above. And you would need a resource URI to identify the window, or whatever. In my understanding, one thing missing here is the optional |
|
We've limited Discussions in this repository to meeting notes and are closing this thread. To continue the conversation, pick a channel from Contributor Communication. Thanks for posting. |
Uh oh!
There was an error while loading. Please reload this page.
Pre-submission Checklist
Question Category
Your Question
I have tried to implement support of notifications from MCP servers in my AI assistant.
As an example i use the "MCP server for smart home" . Ii simulates some actions related to a smart home. Like open/close windows/doors
It has tools to manage a "smart home" by LLM.
And i want to add a support of notifications when a status of a window/door is changed "by 3-rd party".
So, i use the notifications feature of MCP (with SSE transport). I can send a notification from the server and my AI assistant can receive it.
But i still can not find what should be the right contents of a notification.
This is what i have for now:
I made my assistant to parse this fine. But it is not universal solution . Other MCP server can have this different.
What is presumed to be in the "params"?
What is the method? should it be just name of one of my tools or resources? what are params and where should be some content of the notification?
Possible the notification is just a command "call this tool back with given params?"
Also, finally, how to provide the content of a notification to LLM?
Thank you.
All reactions