Skip to main content
Glama
fs.go1.4 kB
package fs import ( "os" "os/exec" "path/filepath" "strings" ) type FileFilter struct { workspaceRoot string supportedExts map[string]bool } func NewFileFilter(workspaceRoot string, supportedExts []string) *FileFilter { extMap := make(map[string]bool, len(supportedExts)) for _, ext := range supportedExts { extMap[ext] = true } return &FileFilter{ workspaceRoot: workspaceRoot, supportedExts: extMap, } } func (f *FileFilter) ShouldIgnore(path string) bool { if f.isGitIgnored(path) { return true } ext := strings.ToLower(filepath.Ext(path)) if ext == "" { return false } return !f.supportedExts[ext] } func (f *FileFilter) isGitIgnored(path string) bool { name := filepath.Base(path) if name == ".git" { return true } cmd := exec.Command("git", "check-ignore", path) cmd.Dir = f.workspaceRoot return cmd.Run() == nil } func WalkSourceFiles(workspaceRoot string, supportedExts []string, callback func(filePath string) error) error { filter := NewFileFilter(workspaceRoot, supportedExts) return filepath.Walk(workspaceRoot, func(path string, info os.FileInfo, err error) error { if err != nil { return err } if filter.ShouldIgnore(path) { if info.IsDir() { return filepath.SkipDir } return nil } relPath, err := filepath.Rel(workspaceRoot, path) if err != nil { relPath = path } return callback(relPath) }) }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/st3v3nmw/sourcerer-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server