Skip to content

Expose server capabilities as client #166

@spachava753

Description

@spachava753

Is your feature request related to a problem? Please describe.
Currently, it looks like there is no way for a ClientSession to return the server's capabilities, leading to users of the ClientSession guessing whether a certain capability is supported by the server. For example, the DeepWiki MCP server only supports the tools capability, and trying to use the List Prompts method returns an error.

Describe the solution you'd like
Instead, I think a method on ClientSession to expose the server's capabilities will allow users to check if method is supported before calling it, potentially saving the network call in cases of connecting to HTTP servers. We already store the server's capabilities in the initialize result:

go-sdk/mcp/client.go

Lines 158 to 164 in 8dd9a81

type ClientSession struct {
conn *jsonrpc2.Connection
client *Client
initializeResult *InitializeResult
keepaliveCancel context.CancelFunc
mcpConn Connection
}

go-sdk/mcp/protocol.go

Lines 304 to 322 in 8dd9a81

// After receiving an initialize request from the client, the server sends this
// response.
type InitializeResult struct {
// This property is reserved by the protocol to allow clients and servers to
// attach additional metadata to their responses.
Meta `json:"_meta,omitempty"`
Capabilities *serverCapabilities `json:"capabilities"`
// Instructions describing how to use the server and its features.
//
// This can be used by clients to improve the LLM's understanding of available
// tools, resources, etc. It can be thought of like a "hint" to the model. For
// example, this information may be added to the system prompt.
Instructions string `json:"instructions,omitempty"`
// The version of the Model Context Protocol that the server wants to use. This
// may not match the version that the client requested. If the client cannot
// support this version, it must disconnect.
ProtocolVersion string `json:"protocolVersion"`
ServerInfo *Implementation `json:"serverInfo"`
}

Describe alternatives you've considered
A possible alternative is simply returning an exposed sentinel error, that the user can check with error.Is or error.As. This alternative can also be implemented with the solution described above, offering both ways to understand a server's capabilities as a client.

Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking changebugSomething isn't workingrelease blockerThis issue blocks the release milestone with which it is associated.

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions