Skip to content

Commit 8acc5ab

Browse files
committed
feat: enhance plugin system with new lifecycle hooks and utilities
- Introduced a new `plugin-types.ts` file to define plugin interfaces and context types. - Added utility functions in `plugin-utils.ts` for plugin management, including validation and loading. - Refactored existing plugins to use the new plugin system, including `config-plugin.ts`, `visibility-plugin.ts`, and `logging-plugin.ts`. - Updated the `ComposableMCPServer` class to support new plugin lifecycle hooks such as `configureServer`, `transformTool`, and `composeEnd`. - Improved the `loadPlugin` function to handle query parameters for dynamic plugin configuration. - Enhanced the `large-result` and `search-tool` plugins to utilize the new plugin structure and lifecycle methods. - Updated the `set-up-mcp-compose.ts` to reflect changes in plugin loading and configuration.
1 parent f0a9b2c commit 8acc5ab

16 files changed

+455
-264
lines changed

packages/core/deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mcpc/core",
3-
"version": "0.1.2",
3+
"version": "0.1.3-beta.plugin-params",
44
"tasks": {
55
"server:compile": "echo \"no need to compile\"",
66
"test": "deno test --allow-env --allow-read tests/",

packages/core/examples/11-large-result-plugin-demo.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
99
import { mcpc } from "../src/set-up-mcp-compose.ts";
10-
import { createLargeResultPlugin } from "../plugins.ts";
10+
// import { createLargeResultPlugin } from "../plugins.ts";
1111
import { jsonSchema } from "ai";
1212

1313
const server = await mcpc(
@@ -17,7 +17,11 @@ const server = await mcpc(
1717
name: "large-output-handler",
1818
description:
1919
"Agent that demonstrates automatic large output handling and file storage",
20-
plugins: [createLargeResultPlugin()],
20+
plugins: [
21+
"./plugins/large-result.ts?maxSize=8000&previewSize=4000",
22+
// create a large result plugin instance
23+
// createLargeResultPlugin(),
24+
],
2125
},
2226
],
2327
(server) => {
@@ -39,9 +43,9 @@ const server = await mcpc(
3943
}
4044
return { content: [{ type: "text", text }] };
4145
},
42-
{ internal: true },
46+
{ internal: true }
4347
);
44-
},
48+
}
4549
);
4650

4751
const transport = new StdioServerTransport();

packages/core/plugins.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* import largeResultPlugin from "@mcpc/core/plugins/large-result";
2929
*
3030
* const server = await mcpc([...], [...]);
31-
*
31+
*
3232
* // Use plugins with default settings
3333
* await server.addPlugin(searchPlugin);
3434
* await server.addPlugin(largeResultPlugin);
@@ -46,5 +46,4 @@ export { default as defaultSearchPlugin } from "./src/plugins/search-tool.ts";
4646
export { default as defaultLargeResultPlugin } from "./src/plugins/large-result.ts";
4747

4848
// Export plugin types for advanced users
49-
export type { ToolPlugin } from "./src/compose.ts";
5049
export type { SearchOptions } from "./src/plugins/search-tool.ts";

0 commit comments

Comments
 (0)