agents icon indicating copy to clipboard operation
agents copied to clipboard

Default values for clientInfo in MCP client API?

Open irvinebroque opened this issue 9 months ago • 6 comments

refs https://github.com/cloudflare/agents/pull/125

Today you write this:

    await this.mcp.connectToServer(new URL("http://localhost:5174/sse"), {
      name: "mcp-server-1",
      version: "1.0.0",
    });

In accordance with the spec, since the MCP client must share its own name and version.

But:

  1. It's a bit awkward to have an API where in the call to connect to something else, you set options about the identity/details of the caller
  2. The name and version of the client will be the same when connecting to multiple MCP servers, but you have to declare this multiple times
  3. There are likely defaults we can set — the name from the name of the Agent class, and protocol version is something that we should be able to know

Seems like these properties could be set on the MCPClientManager class? So that you don't have to set them here?

irvinebroque avatar Apr 01 '25 14:04 irvinebroque

Yeah I like that idea

threepointone avatar Apr 01 '25 14:04 threepointone

@cmsparks @geelen @dinasaur404 @jmorrell-cloudflare curious what you think (just thinking about shape that this API ultimately takes and if there's path for it to feel super simple)

irvinebroque avatar Apr 01 '25 14:04 irvinebroque

In same vein — curious why the input type is URL rather than a string that then gets validated?

Wonder if there's a way to get it down to this:

await this.mcp.connect("http://localhost:5174/sse");

Or this:

await this.mcp.connect(["http://localhost:5174/sse"]);

...thinking towards a world where there's a registry, an agent connects to many MCP servers, etc.

irvinebroque avatar Apr 01 '25 15:04 irvinebroque

Yeah, I sorta mirrored the Client API for the URL/client info portion just for the initial API here (that's why we're explicitly passing it in and using a URL rather than a string). I think I like this though. I think there's inherently going to be complexity though, because the user will eventually need to provide per server transport/client/capability options upon connecting.

cmsparks avatar Apr 01 '25 16:04 cmsparks

can we close this now @cmsparks ?

threepointone avatar Apr 15 '25 09:04 threepointone

Oh missed this, but yeah we can close this!

cmsparks avatar May 13 '25 01:05 cmsparks