MCPcopy
hub / github.com/docker/docker-agent / AddAttachedFile

Method AddAttachedFile

pkg/session/session.go:724–738  ·  view source on GitHub ↗

AddAttachedFile records absPath as a file the user attached to this session. The path must be absolute; relative paths are silently dropped (with a debug log) since they would be ambiguous to sub-agents started in a fresh working directory. Empty paths and duplicates already present in AttachedFiles

(absPath string)

Source from the content-addressed store, hash-verified

722// so that delegated agents can read the same files without having to scan the
723// workspace or guess from a bare filename.
724func (s *Session) AddAttachedFile(absPath string) {
725 if absPath == "" {
726 return
727 }
728 if !filepath.IsAbs(absPath) {
729 slog.Debug("ignoring non-absolute attached file path", "session_id", s.ID, "path", absPath)
730 return
731 }
732 s.mu.Lock()
733 defer s.mu.Unlock()
734 if slices.Contains(s.AttachedFiles, absPath) {
735 return
736 }
737 s.AttachedFiles = append(s.AttachedFiles, absPath)
738}
739
740// AttachedFilesSnapshot returns a copy of the session's attached file paths.
741// Callers may freely mutate the returned slice without affecting the session.

Callers 6

RunFunction · 0.80
TestAddAttachedFileFunction · 0.80
WithAttachedFilesFunction · 0.80
SendFirstMessageMethod · 0.80
RunMethod · 0.80

Implementers 7

fakeSessionpkg/tools/lifecycle/supervisor_test.go
sessionClientpkg/tools/mcp/session_client.go
mockMCPClientpkg/tools/mcp/mcp_test.go
reconnectableMockClientpkg/tools/mcp/mcp_test.go
failingInitClientpkg/tools/mcp/reconnect_test.go
clientSessionpkg/tools/mcp/mcp.go
lspSessionpkg/tools/builtin/lsp/lsp_lifecycle.go

Calls 3

DebugMethod · 0.80
LockMethod · 0.45
UnlockMethod · 0.45

Tested by 2

TestAddAttachedFileFunction · 0.64