You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Plugins now support resources pre/post hooks (#719)
* Plugins now support resources pre/post
Signed-off-by: Mihai Criveti <[email protected]>
* Plugins now support resources pre/post
Signed-off-by: Mihai Criveti <[email protected]>
* Plugins now support resources pre/post
Signed-off-by: Mihai Criveti <[email protected]>
* Plugins now support resources pre/post
Signed-off-by: Mihai Criveti <[email protected]>
* Plugins now support resources pre/post
Signed-off-by: Mihai Criveti <[email protected]>
* Plugins now support resources pre/post
Signed-off-by: Mihai Criveti <[email protected]>
---------
Signed-off-by: Mihai Criveti <[email protected]>
Copy file name to clipboardExpand all lines: docs/docs/using/plugins/index.md
+81-4Lines changed: 81 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# Plugin Framework
2
2
3
3
!!! warning "Experimental Feature"
4
-
The plugin framework is currently in **MVP stage** and marked as experimental. Only prompt hooks (`prompt_pre_fetch`and `prompt_post_fetch`) are implemented. Additional hooks for tools, resources, authentication, and server registration are planned for future releases.
4
+
The plugin framework is currently in **MVP stage** and marked as experimental. Prompt, tool, and resource hooks are implemented. Additional hooks for authentication and server registration are planned for future releases.
5
5
6
6
## Overview
7
7
@@ -94,7 +94,7 @@ are defined as follows:
94
94
| **description** | The description of the plugin configuration. | A plugin for replacing bad words. |
95
95
| **version** | The version of the plugin configuration. | 0.1 |
96
96
| **author** | The team that wrote the plugin. | MCP Context Forge |
97
-
| **hooks** | A list of hooks for which the plugin will be executed. Supported hooks: "prompt_pre_fetch", "prompt_post_fetch", "tool_pre_invoke", "tool_post_invoke"| ["prompt_pre_fetch", "prompt_post_fetch", "tool_pre_invoke", "tool_post_invoke"] |
97
+
| **hooks** | A list of hooks for which the plugin will be executed. Supported hooks: "prompt_pre_fetch", "prompt_post_fetch", "tool_pre_invoke", "tool_post_invoke", "resource_pre_fetch", "resource_post_fetch" | ["prompt_pre_fetch", "prompt_post_fetch", "tool_pre_invoke", "tool_post_invoke", "resource_pre_fetch", "resource_post_fetch"] |
98
98
| **tags** | Descriptive keywords that make the configuration searchable. | ["security", "filter"] |
99
99
| **mode** | Mode of operation of the plugin. - enforce (stops during a violation), permissive (audits a violation but doesn't stop), disabled (disabled) | permissive |
100
100
| **priority** | The priority in which the plugin will run - 0 is higher priority | 100 |
@@ -152,6 +152,7 @@ Users may only want plugins to be invoked on specific servers, tools, and prompt
152
152
| **server_ids** | The list of MCP servers on which the plugin will trigger |
153
153
| **tools** | The list of tools on which the plugin will be applied. |
154
154
| **prompts** | The list of prompts on which the plugin will be applied. |
155
+
| **resources** | The list of resource URIs on which the plugin will be applied. |
155
156
| **user_patterns** | The list of users on which the plugin will be applied. |
156
157
| **content_types** | The list of content types on which the plugin will trigger. |
The resource hooks enable plugins to intercept and modify resource fetching:
189
+
190
+
- **`resource_pre_fetch`**: Receives the resource URI and metadata before fetching. Can modify the URI, add metadata, or block the fetch entirely.
191
+
- **`resource_post_fetch`**: Receives the resource content after fetching. Can modify the content, redact sensitive information, or block it from being returned.
logger.error(f"Could not retrieve prompt {name}: {ex}")
1762
-
ifisinstance(ex, (ValueError, PromptError)):
1763
-
result=JSONResponse(content={"message": "Prompt execution arguments contains HTML tags that may cause security issues"}, status_code=422)
1764
-
elifisinstance(ex, PluginViolationError):
1765
-
result=JSONResponse(content={"message": "Prompt execution arguments contains HTML tags that may cause security issues", "details": ex.message}, status_code=422)
0 commit comments