Plugin Development
Overview
Plugin Interface
Basic Plugin Structure
import { VConPlugin, RequestContext } from '@vcon/mcp-server/hooks';
import { VCon } from '@vcon/mcp-server/types';
import { Tool } from '@modelcontextprotocol/sdk/types';
export default class MyPlugin implements VConPlugin {
name = 'my-plugin';
version = '1.0.0';
async initialize(config: any): Promise<void> {
console.error('โ
My Plugin initialized');
}
async shutdown(): Promise<void> {
console.error('๐ My Plugin shutting down');
}
// Implement hooks as needed...
}Available Hooks
Lifecycle Hooks
initialize(config)
initialize(config)shutdown()
shutdown()Data Operation Hooks
beforeCreate(vcon, context)
beforeCreate(vcon, context)afterCreate(vcon, context)
afterCreate(vcon, context)beforeRead(uuid, context)
beforeRead(uuid, context)afterRead(vcon, context)
afterRead(vcon, context)beforeUpdate(uuid, updates, context)
beforeUpdate(uuid, updates, context)afterUpdate(vcon, context)
afterUpdate(vcon, context)beforeDelete(uuid, context)
beforeDelete(uuid, context)afterDelete(uuid, context)
afterDelete(uuid, context)beforeSearch(criteria, context)
beforeSearch(criteria, context)afterSearch(results, context)
afterSearch(results, context)Tool Registration
registerTools()
registerTools()registerResources()
registerResources()Request Context
Loading Plugins
Via Environment Variable
Plugin Configuration
Example: Simple Logging Plugin
Example: Access Control Plugin
Testing Your Plugin
Best Practices
Publishing Your Plugin
As npm Package
As Local Module
Plugin Ideas
Support
License
Last updated