modelcontextprotocol / modelcontextprotocol/java-sdk

McpServerSession lifecycle doesn't support distributed services

Aberta
#274 17 comentários 12 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

area/server enhancement feature/session-storage
Linguagem predominante
Java
Estrelas
3.7k
Forks
1.1k
Merge médio
1d 15h
PRs com merge (30d)
9

Descrição

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.

  1. A new client application initiates a session by sending an initialize message, followed by a notifications/initialized notifications.
  2. Let's say that the Load Balancer routed both messages to replica A
  3. As a result, replica A generated a new session which Id is communicated back to the client
  4. Replica A now has an McpServerSession instance properly initialized with all the necessary client information

Problem:

  1. Next the client sends a tools/list message with the obtain sessionId, but this time the load balancer routes the message to replica B
  2. Even though I believe it should be the server's responsibility to share the session id across replicas, the McpServerSession instance that lives in replica B has never received (and will never receive) the initialize message and notifications
  3. Although it's possible to distribute all that state and simulate that handshake in replica B (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.

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece lendo esta issue junto com a issue relacionada #273 e, em seguida, acompanhe o ciclo de vida da sessão StreamableHttp desde initialize e notifications/initialized até tools/list. Inspecione os pontos de entrada do gerenciamento de sessões e de SessionFactory mencionados na issue. Considera-se concluído quando uma sessão inicializada na réplica A puder ser usada na réplica B sem simular manualmente o handshake.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
java
Domínio
backend, distributed-systems
Tipo de issue
Funcionalidade
Dificuldade
5/5
Tempo estimado
Mais de uma semana
Status de atividade
Pouca atividade
Clareza
Razoavelmente clara
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.