Improve MCP loading process by verifying directory existence before file operations
- Added a check to confirm the existence of the 'mcps' directory prior to loading MCP files, enhancing error handling and preventing unnecessary attempts to load from a non-existent directory. - Updated error handling to ensure that any issues encountered during the loading process are logged appropriately.
This commit is contained in:
parent
36e3334058
commit
125c32a0b5
1 changed files with 21 additions and 16 deletions
|
|
@ -19,9 +19,13 @@ import (
|
||||||
func Load(cfg config.Config) error {
|
func Load(cfg config.Config) error {
|
||||||
messages := []string{}
|
messages := []string{}
|
||||||
|
|
||||||
// Load filesystem MCP clients
|
// Check if mcps directory exists
|
||||||
|
exists, err := application.App.Exists("mcps")
|
||||||
|
|
||||||
|
// Load filesystem MCP clients if directory exists
|
||||||
|
if err == nil && exists {
|
||||||
exts := []string{"*.mcp.yao", "*.mcp.json", "*.mcp.jsonc"}
|
exts := []string{"*.mcp.yao", "*.mcp.json", "*.mcp.jsonc"}
|
||||||
err := application.App.Walk("mcps", func(root, file string, isdir bool) error {
|
err = application.App.Walk("mcps", func(root, file string, isdir bool) error {
|
||||||
if isdir {
|
if isdir {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -38,6 +42,7 @@ func Load(cfg config.Config) error {
|
||||||
}
|
}
|
||||||
return fmt.Errorf("%s", strings.Join(messages, ";\n"))
|
return fmt.Errorf("%s", strings.Join(messages, ";\n"))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Load database MCP clients (ignore error)
|
// Load database MCP clients (ignore error)
|
||||||
errs := loadDatabaseMCPs()
|
errs := loadDatabaseMCPs()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue