Skip to content

[Feature]: add support for external plugins #773

@araujof

Description

@araujof

🚀 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:

plugins:
  - name: "DenyListPlugin"
    kind: "external"
    mcp:
      proto: STREAMABLEHTTP
      url: http://127.0.0.1:3000/mcp

Where:

  1. name represents the External plugin residing on the MCP server.
  2. kind is "external"
  3. map signifies the type of transport protocol (StreamableHTTP, Stdio, SSE) and url or script (if stdio) of the external plugin.

Note that the external plugin will pull the PluginConfig from the MCP server and use it as a configuration. However, we can override any attribute EXCEPT the config: 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 the PluginManager to determine things like priority, hook points, etc.

For example, we could set:

plugins:
  - name: "DenyListPlugin"
    kind: "external"
   priority: 100
   hooks: ["pre_prompt_fetch", "post_prompt_fetch"]
    mcp:
      proto: STREAMABLEHTTP
      url: http://127.0.0.1:3000/mcp

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 lint passes
  • make test passes
  • CHANGELOG updated (if user-facing)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions