Separate McpServer definition from implementation

Abierto
#10,826 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
25/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
typescript
Área
api

Línea de trabajo

Start by reading the McpServer and McpClient modules and the Rpc definition/implementation split they are built on, then read the linked comment in #8912. The request is for McpServer.make(...) to describe the server shape while McpClient.make(MyMcpServer) infers tools, resources and prompts. Done means an agreed API direction and a refactor separating definition from handlers; no files or tests are named, so this is design work first.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

enhancement
What is the problem this feature would solve?

This came up when looking at sharing the McpSchema types across the McpServer and McpClient and I was thinking how nice of a DX it would be to have a similar experience as HttpApi and Rpc where the server definition could be used to already infer the client shape. I did a bit of digging and this is certainly a bit of work to refactor how the server handers are currently structured, but it shouldnt be too hard to allow the McpServer to be shared in a monorepo?

export class MyMcpServer extends McpServer.make(
  Tool.make("tick", {
    parameters: Schema.Struct({
      arg: Schema.String,
    }),
    success: Schema.String,
    failure: Schema.String
  }),
) {}

//       ┏━ Effect.Effect<{...}, McpClient.McpClientError, McpClient>
const workflow = Effect.gen(function*() {
  const client = yield* McpClient.make(MyMcpServer)
  //      ┏━ Tool.Tool<string, string>
  const tick = yield* client.tools.tick({arg:"hello"})

  //    ┏━ string
  const r = yield* tick;
  yield* tick;
  yield* tick;

})

This isn't something I've seen possible with other SDKs but would open up a "fullstack MCP architecture" and improve the DX for application workflows not reliant on LLMs and json schema.

Originally posted by @lloydrichards in #8912

What is the feature you are proposing to solve the problem?

As it says in the original comment, the idea would be to have McpServer / McpClient to follow the same pattern of shape definition followed by implementation details so the server can be shared with the client to get typesafe completion and access to tools, resources and prompts.

Since McpServer is already built on Rpc this shouldnt be too difficult but would be good to have some discussion on this direction and what would feel right for the API.

What alternatives have you considered?

Right now, the McpClient needs a lot of manual mapping and calling to find what it needs which is fine if you're looking at both implementation but maybe for larger projects it doesn't feel like a very integrated experience like many of the other higher level Effect APIs feel (HttpAPI, RPC)

Lenguaje dominante
TypeScript
Estrellas
16.7k
Forks
808
Merge medio
21 h 22 min
PR fusionados (30 d)
486

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Effect-TS/effect

Todos los issues de Effect-TS/effect

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.