Skip to content

Commit 03968bf

Browse files
authored
feat: handle missing .md extension in article filenames (#33)
Add a check to append the `.md` extension if it is missing in article file requests to ensure proper file loading.
1 parent 2d25125 commit 03968bf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/resources/docs.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,12 @@ func (r *Docs) FetchDocsResources(_ context.Context, article string) ([]mcp.Reso
117117

118118
default:
119119

120-
// For other articles, read the file directly from the filesystem
120+
// Sometimes LLMs forget to add the .md extension, so we check for that
121+
if !strings.HasSuffix(article, ".md") {
122+
article += ".md"
123+
}
124+
125+
// Read the file directly from the filesystem
121126
fileData, err := r.docsFS.ReadFile(article)
122127
if err != nil {
123128
return nil, fmt.Errorf("failed to read file %s: %w", article, err)

0 commit comments

Comments
 (0)