modelcontextprotocol / modelcontextprotocol/java-sdk
McpServerSession lifecycle doesn't support distributed services
Personne n'a encore pris cette issue.
- Langage dominant
- Java
- Étoiles
- 3.7k
- Forks
- 1.1k
- Merge moyen
- 1 j 15 h
- PR mergées (30 j)
- 9
Description
This issue is closely related to #273 and could be considered as a follow up to that, but I decided to split it for convenience and readability.
Consider an MCP server written with this SDK and using the StreamableHttp transport. We deploy two replicas (A and B) of this server, with a load balancer in front.
- A new client application initiates a session by sending an
initializemessage, followed by anotifications/initializednotifications. - Let's say that the Load Balancer routed both messages to replica
A - As a result, replica
Agenerated a new session which Id is communicated back to the client - Replica
Anow has anMcpServerSessioninstance properly initialized with all the necessary client information
Problem:
- Next the client sends a
tools/listmessage with the obtain sessionId, but this time the load balancer routes the message to replicaB - Even though I believe it should be the server's responsibility to share the session id across replicas, the
McpServerSessioninstance that lives in replicaBhas never received (and will never receive) the initialize message and notifications - Although it's possible to distribute all that state and
simulatethat handshake in replicaB(I actually did it), I think this SDK should have an OOTB support for that, or at the very least, SessionFactory methods that make it easier to generate "ready to use" Sessions based on previous initializations.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par lire cette issue avec l’issue associée #273, puis suivez le cycle de vie de la session StreamableHttp, de initialize et notifications/initialized jusqu’à tools/list. Inspectez les points d’entrée de la gestion des sessions et de SessionFactory mentionnés dans l’issue. Le travail est terminé lorsqu’une session initialisée sur la replica A peut être utilisée sur la replica B sans simuler manuellement le handshake.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- java
- Domaine
- backend, distributed-systems
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- Calme
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100