Separate McpServer definition from implementation

未关闭
#10,826 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript
领域
api

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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)

主要语言
TypeScript
星标
16.7k
派生
808
平均合并
21 小时 22 分钟
30 天内合并 PR
486

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Effect-TS/effect 的其他 Issue

查看 Effect-TS/effect 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。