Enables external tool registration and execution through WebSocket-based communication, providing a unified interface for real-time tool management within SillyTavern.
This extension adds WebSocket-based tool execution support to SillyTavern, allowing external tools to be registered and executed through a standardized interface.
See INSTRUCTIONS.md for step-by-step instructions on installing through SillyTavern's web interface.
Clone this repository into your SillyTavern plugins directory:
cd /path/to/SillyTavern/plugins git clone https://github.com/CG-Labs/SillyTavern-MCP-Extension.git mcp-extension
Install dependencies:
cd mcp-extension npm install
Restart SillyTavern
The extension can be configured through the SillyTavern UI under Settings > Extensions > MCP Extension.
To register a tool, send a WebSocket message with the following format:
{ "type": "register_tool", "data": { "name": "example_tool", "schema": { "type": "object", "properties": { "param1": { "type": "string", "description": "First parameter" }, "param2": { "type": "number", "description": "Second parameter" } }, "required": ["param1"] } } }
To execute a registered tool, send a WebSocket message with the following format:
{ "type": "execute_tool", "data": { "executionId": "unique_execution_id", "name": "example_tool", "args": { "param1": "value1", "param2": 42 } } }
The extension broadcasts execution status updates to all connected clients:
{ "type": "tool_execution_started", "data": { "executionId": "unique_execution_id", "name": "example_tool", "args": { "param1": "value1", "param2": 42 } } }
{ "type": "tool_execution_completed", "data": { "executionId": "unique_execution_id", "result": { // Tool-specific result data } } }
{ "type": "tool_execution_failed", "data": { "executionId": "unique_execution_id", "error": { "code": "ERROR_CODE", "message": "Error message" } } }
INVALID_NAME
: Invalid tool nameINVALID_SCHEMA
: Invalid tool schemaINVALID_URI
: Invalid resource URIINVALID_HANDLER
: Invalid handler implementationINVALID_ARGUMENTS
: Invalid tool argumentsTOOL_EXISTS
: Tool already registeredTOOL_NOT_FOUND
: Tool not foundTOOL_EXECUTION_FAILED
: Tool execution failedSERVER_ERROR
: Internal server errormcp-extension/
├── index.js # Main plugin entry point
├── manifest.json # Plugin manifest
├── package.json # Dependencies and scripts
├── public/ # Public assets
│ ├── script.js # Client-side JavaScript
│ ├── style.css # Client-side styles
│ └── templates/ # HTML templates
├── utils/ # Utility modules
│ ├── errors.js # Error handling
│ ├── logger.js # Logging utility
│ └── validation.js # Input validation
└── README.md # This documentation
To add a new tool:
Example tool implementation:
const ws = new WebSocket('ws://localhost:5005'); ws.onopen = () => { // Register tool ws.send(JSON.stringify({ type: 'register_tool', data: { name: 'example_tool', schema: { type: 'object', properties: { input: { type: 'string' } }, required: ['input'] } } })); }; ws.onmessage = (event) => { const message = JSON.parse(event.data); if (message.type === 'execute_tool' && message.data.name === 'example_tool') { // Handle execution const result = doSomething(message.data.args.input); // Send result ws.send(JSON.stringify({ type: 'tool_execution_completed', data: { executionId: message.data.executionId, result } })); } };
If you encounter any issues or have questions:
MIT License - see LICENSE file for details
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!