Skip to content

Commit 0494b4a

Browse files
authored
enhance: allow passing of MCP client options when creating clients (#984)
Signed-off-by: Donnie Adams <[email protected]>
1 parent a1f3754 commit 0494b4a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pkg/mcp/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
nmcp "github.com/nanobot-ai/nanobot/pkg/mcp"
55
)
66

7-
func (l *Local) Client(server ServerConfig) (*Client, error) {
8-
session, err := l.loadSession(server, "default")
7+
func (l *Local) Client(server ServerConfig, clientOpts ...nmcp.ClientOption) (*Client, error) {
8+
session, err := l.loadSession(server, "default", clientOpts...)
99
if err != nil {
1010
return nil, err
1111
}

pkg/mcp/loader.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ func (l *Local) sessionToTools(ctx context.Context, session *Session, toolName s
276276
return toolDefs, nil
277277
}
278278

279-
func (l *Local) loadSession(server ServerConfig, serverName string) (*Session, error) {
279+
func (l *Local) loadSession(server ServerConfig, serverName string, clientOpts ...nmcp.ClientOption) (*Session, error) {
280280
id := hash.Digest(server)
281281
l.lock.Lock()
282282
existing, ok := l.sessions[id]
@@ -296,7 +296,7 @@ func (l *Local) loadSession(server ServerConfig, serverName string) (*Session, e
296296
Args: server.Args,
297297
BaseURL: server.GetBaseURL(),
298298
Headers: splitIntoMap(server.Headers),
299-
})
299+
}, clientOpts...)
300300
if err != nil {
301301
return nil, fmt.Errorf("failed to create MCP stdio client: %w", err)
302302
}

0 commit comments

Comments
 (0)