MCPcopy Index your code
hub / github.com/docker/docker-agent / ReadFileForInline

Function ReadFileForInline

pkg/chat/chat.go:263–269  ·  view source on GitHub ↗

ReadFileForInline reads a text file and wraps it in an XML-like tag with the file path for context. Returns the formatted content and any error.

(filePath string)

Source from the content-addressed store, hash-verified

261// ReadFileForInline reads a text file and wraps it in an XML-like tag with
262// the file path for context. Returns the formatted content and any error.
263func ReadFileForInline(filePath string) (string, error) {
264 data, err := os.ReadFile(filePath)
265 if err != nil {
266 return "", fmt.Errorf("failed to read file: %w", err)
267 }
268 return fmt.Sprintf("<attached_file path=%q>\n%s\n</attached_file>", filePath, string(data)), nil
269}
270
271// isTextExtension returns true for file extensions known to be text-based.
272// This includes programming languages, config files, markup, and data formats.

Callers 5

processFileAttachmentMethod · 0.92
processFilePartFunction · 0.85
TestReadFileForInlineFunction · 0.85

Calls 1

ReadFileMethod · 0.80

Tested by 2

TestReadFileForInlineFunction · 0.68