API: Generalize notifications for SDK server classes
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 28/100
- Issue-Typ
- Feature
- Klarheit
- Muss geklärt werden
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- java
- Bereich
- backend-api-design
Rechercherichtung
Beginne bei McpAsyncServer, insbesondere bei notifyToolsListChanged() um Zeile 510, und verfolge, wie addTool und removeTool Benachrichtigungen auslösen. Vergleiche dies mit den Benachrichtigungs-Handlern von McpAsyncClient und prüfe Issue #793. Die fertige Lösung sollte Server-Erweiterungen eine unterstützte Möglichkeit bieten, benutzerdefinierte Themen mit Daten zu senden und die bestehenden automatischen Tool-Benachrichtigungen zu steuern, wobei Raum für Ressourcen und Prompts bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
I'm building an extension that uses the Java sdk that uses notifications to send 'tool add/delete/update' data to clients (e.g. when new tools are added to an MCP server at runtime).
For this extension to work, it's necessary to provide a new topic string and non-null data to the following transport-level call:
Line 510 in current McpAsyncServer
public Mono<Void> notifyToolsListChanged() {
return this.mcpTransportProvider.notifyClients(McpSchema.METHOD_NOTIFICATION_TOOLS_LIST_CHANGED, null);
}
There is currently no way for the extension to add a custom param to this notification, nor to define a new value for the topic...both of which are required for the extension...e.g.:
public/protected Mono<Void> notifyToolsListChanged(String topic, Object param) {
return this.mcpTransportProvider.notifyClients(topic, param);
}
Where my extension wishes to call via something like:
server.notifyToolsListChanged("myorg/update", myData);
In a issue #793 I suggested allowing inheritance of the McpAsyncServer class, so that the notifyToolsListChanged() could be overridden by subclasses (via public or protected constructors, constructor args, and member variables) and call the transport directly with desired arguments.
Although I still believe inheritance of core classes is sometimes reasonable for an SDK, it seems that composition is currently favored for this case. There is no way that can see for this to be done through composition currently.
This extension also needs to have some way to prevent the existing notification notifyToolsListChanged() from being sent by addTool and remove/Tool (asynchronously)...meaning that addTool/removeTool need to be customized as well.
Note that I'm interested in generalizing this update extension to other primitives...e.g. resources and prompts...plus others...so the same extension access for server-side dynamic updates. Ultimately it's not just for tools but I'm starting with tools.
On the McpAsyncClient, conversely, there are notification handlers that can be passed into the client on construction, allowing it to receive custom topics with params.
Clearly there are multiple ways to fix this in the SDK. One suggestion: Consider defining a public AbstractAsyncServer superclass, and moving protected members, constructors, and generalized methods into that super class. This is the one way with inheritance that I'm aware of that allows generalization and will not break binary compatibility for the current McpAsyncServer API consumers (e.g. by renaming public methods).
With that said, I'm open to composition rather than inheritance as a solution (as long as it supports what this update extension needs), but afaict will likely require larger refactoring and perhaps API changes at this point.
- Vorherrschende Sprache
- Java
- Sterne
- 3.7k
- Forks
- 1.1k
- Ø Merge
- 1 T. 15 Std.
- Gemergte PRs (30 T.)
- 9
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus modelcontextprotocol/java-sdk
-
area/transport bug P2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
modelcontextprotocol/java-sdk#1136 ·
-
area/client bug P2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
modelcontextprotocol/java-sdk#1124 · 1 Kommentar ·
-
ServerCapabilities.logging is added unconditionally, overriding the caller's explicit capabilities Offenbug P2 ready for work
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
modelcontextprotocol/java-sdk#1086 · 1 Kommentar ·
-
enhancement good first issue P3
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
modelcontextprotocol/java-sdk#1067 ·
-
bug P2 ready for work
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
modelcontextprotocol/java-sdk#898 · 1 Kommentar ·
Alle Issues in modelcontextprotocol/java-sdk
Ähnliche Issues
-
awaiting triage bug Causes friction Hop Gui P1 P2 Transforms
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
apache/flink-agents#1152 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
jenkinsci/blueocean-plugin#5417 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
objectionary/eo-graphs#75 ·