Default values for clientInfo in MCP client API?
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:
- 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
- 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
- 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?
Yeah I like that idea
@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)
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.
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.
can we close this now @cmsparks ?
Oh missed this, but yeah we can close this!