Skip to content

Fix/support to connect claude mcp filesystem #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Client struct {
protocol *protocol.Protocol
capabilities *ServerCapabilities
initialized bool
info ClientInfo
}

// NewClient creates a new MCP client with the specified transport
Expand All @@ -25,6 +26,20 @@ func NewClient(transport transport.Transport) *Client {
}
}

type ClientInfo struct {
Name string `json:"name"`
Version string `json:"version"`
}

// NewClientWithInfo create a new client with info. This is required by anthorpic mcp tools
func NewClientWithInfo(transport transport.Transport, info ClientInfo) *Client {
return &Client{
transport: transport,
protocol: protocol.NewProtocol(nil),
info: info,
}
}

// Initialize connects to the server and retrieves its capabilities
func (c *Client) Initialize(ctx context.Context) (*InitializeResponse, error) {
if c.initialized {
Expand All @@ -37,7 +52,11 @@ func (c *Client) Initialize(ctx context.Context) (*InitializeResponse, error) {
}

// Make initialize request to server
response, err := c.protocol.Request(ctx, "initialize", map[string]interface{}{}, nil)
response, err := c.protocol.Request(ctx, "initialize", map[string]interface{}{
"protocolVersion": "1.0",
"capabilities": map[string]interface{}{},
"clientInfo": c.info,
}, nil)
if err != nil {
return nil, errors.Wrap(err, "failed to initialize")
}
Expand Down