Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions pkg/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ func (e *Engine) Start(ctx Context, input string) (ret *Return, err error) {
}
select {
case <-ctx.userCancel:
if ret == nil {
ret = new(Return)
}
if ret.Result == nil {
ret.Result = new(string)
}
Expand Down
26 changes: 26 additions & 0 deletions pkg/mcp/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,32 @@ func (l *Local) LoadTools(ctx context.Context, server ServerConfig, toolName str
return l.sessionToTools(ctx, session, toolName, allowedTools)
}

func (l *Local) ShutdownServer(server ServerConfig) error {
if l == nil {
return nil
}

id := hash.Digest(server)

l.lock.Lock()

if l.sessionCtx == nil {
l.lock.Unlock()
return nil
}

session := l.sessions[id]
delete(l.sessions, id)

l.lock.Unlock()

if session == nil {
return nil
}

return session.Client.Close()
}

func (l *Local) Close() error {
if l == nil {
return nil
Expand Down