feat: add support for external plugins #721
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
β¨ Feature / Enhancement PR
π Epic / Issue
Link to the epic or parent issue:
Closes #
π Summary (1-2 sentences)
This PR adds support for external plugins to the Context Forge. External plugins are plugins that are backed by a service such as LLMGuard. External plugins communicate with these services through MCP, to do run services on the system.
The MCPGateway now has an ExternalPlugin object, that is configured as follows:
Where:
Note that the external plugin will pull the
PluginConfigfrom the MCP server and use it as a configuration. However, we can override any attribute EXCEPT theconfig:section of the plugin from the client side. The external plugin first downloads the plugin configuration from the server, merges with the configuration from the client and uses that in thePluginManagerto determine things like priority, hook points, etc.For example, we could set:
and this would use the configuration from the MCP server, but override priority and hooks using the client configurations.
The server side of the code currently resides here: https://github.com/araujof/mcp-context-forge-plugin/blob/feat/mcp_server_code/src/plugins/framework/mcp/server.py and has the following tools:
get_plugin_configs() - return all the plugin configurations from plugins installed in the MCP server.
get_plugin_config(name) - return the plugin config for a specific plugin given a name.
pre_prompt_fetch - pre prompt fetch hook
pos_prompt_fetch - post prompt fetch hook
We will support the other plugin hook points, and plugins will be installed into an MCP server as python packages. We will have a base MCP server image on which plugins can be installed.
π§ͺ Checks
make lintpassesmake testpasses