Skip to content

fix: use plugin_dirs config to resolve external plugins (#2935)#2959

Open
omorros wants to merge 6 commits intoIBM:mainfrom
omorros:fix/plugin-dirs-sys-path
Open

fix: use plugin_dirs config to resolve external plugins (#2935)#2959
omorros wants to merge 6 commits intoIBM:mainfrom
omorros:fix/plugin-dirs-sys-path

Conversation

@omorros
Copy link
Contributor

@omorros omorros commented Feb 15, 2026

🔗 Related Issue
Closes #2935


📝 Summary

The plugin_dirs config field in plugins/config.yaml was never used by the plugin
manager. External plugins in custom directories failed to load because their paths were
not added to sys.path before importlib.import_module() was called.

This PR adds the configured plugin_dirs to sys.path during PluginManager.initialize()
and cleans them up on shutdown() and reset().


🏷️ Type of Change

  • Bug fix

🧪 Verification

Command: pytest tests/unit/mcpgateway/plugins/framework/test_manager.py -v
Status: 13/13 passed


✅ Checklist

  • Code formatted (make black isort pre-commit)
  • Tests added/updated for changes
  • Documentation updated (if applicable)
  • No secrets or credentials committed

📓 Notes (optional)

  • Only mcpgateway/plugins/framework/manager.py was changed (production code)
  • Directories are only added if they exist on disk (os.path.isdir check)
  • sys.path is cleaned up in both shutdown() and reset() to avoid leaking paths across
    tests or restarts

Signed-off-by: Oriol Morros Vilaseca <OM368@student.aru.ac.uk>
Signed-off-by: Oriol Morros Vilaseca <OM368@student.aru.ac.uk>
Signed-off-by: Oriol Morros Vilaseca <OM368@student.aru.ac.uk>
Signed-off-by: Oriol Morros Vilaseca <OM368@student.aru.ac.uk>
Signed-off-by: Oriol Morros Vilaseca <OM368@student.aru.ac.uk>
Signed-off-by: Oriol Morros Vilaseca <OM368@student.aru.ac.uk>
@omorros omorros force-pushed the fix/plugin-dirs-sys-path branch from 6ba484a to 77163c0 Compare February 15, 2026 22:59
@omorros
Copy link
Contributor Author

omorros commented Feb 16, 2026

All Python tests and coverage checks pass on both py3.11 and py3.12. The only failing check is linting-full, which seems to be a Helm unittest plugin installation issue unrelated to this PR. Let me know if anything needs to be changed! ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Plugin manager not using plugins_dir config

1 participant