Create a new folder in "sillytavern\data\default-user\extensions\" called kobold_mcp_bridge. The name doesn't really matter.
In there create 2 files, index.js and manifest.json and copy the following contents into them:

index.js

(async function() {
    console.log("🚀 MCP Bridge: Script starting up...");
    const MCP_URL = 'http://localhost:5001/mcp';
    async function initializeMcpSession() {
        console.log("🔑 MCP Bridge: Attempting handshake...");
        const initResponse = await fetch(MCP_URL, {
            method: "POST",
            headers: { "Content-Type": "application/json" },
            body: JSON.stringify({
                jsonrpc: "2.0",
                id: 1,
                method: "initialize",
                params: {
                    protocolVersion: "2024-11-05",
                    clientInfo: { name: "ST-Auto-Bridge", version: "1.0.0" },
                    capabilities: {}
                }
            })
        });
        const sessionId = initResponse.headers.get("MCP-Session-Id");
        console.log("✅ MCP Bridge: Session established! ID:", sessionId);
        return sessionId;
    }
    async function executeKoboldTool(toolName, args, sessionId) {
        console.log(`🛠️ MCP Bridge: Calling tool ${toolName} with args:`, args);
        const response = await fetch(MCP_URL, {
            method: "POST",
            headers: {
                "Content-Type": "application/json",
                "MCP-Protocol-Version": "2024-11-05",
                "MCP-Session-Id": sessionId
            },
            body: JSON.stringify({
                jsonrpc: "2.0",
                id: Date.now(),
                method: "tools/call",
                params: { name: toolName, arguments: args }
            })
        });
        const data = await response.json();
        return data.result.content[0].text;
    }
    const { eventSource, event_types } = SillyTavern.getContext();

    eventSource.on(event_types.APP_READY, async () => {
        console.log("🌟 MCP Bridge: APP_READY event detected! Starting registration...");
        try {
            const { registerFunctionTool } = SillyTavern.getContext();
            const sessionId = await initializeMcpSession();
            const listResponse = await fetch(MCP_URL, {
                method: "POST",
                headers: {
                    "Content-Type": "application/json",
                    "MCP-Protocol-Version": "2024-11-05",
                    "MCP-Session-Id": sessionId
                },
                body: JSON.stringify({
                    jsonrpc: "2.0",
                    id: 2,
                    method: "tools/list",
                    params: {}
                })
            });
            const listData = await listResponse.json();
            const tools = listData.result.tools;
            console.log(`📦 MCP Bridge: Found ${tools.length} tools on server.`);
            tools.forEach(tool => {
                console.log(`📝 MCP Bridge: Registering ${tool.name}...`);
                registerFunctionTool({
                    name: tool.name,
                    displayName: tool.name,
                    description: tool.description,
                    parameters: tool.inputSchema,
                    action: async (args) => {
                        try {
                            return await executeKoboldTool(tool.name, args, sessionId);
                        } catch (e) {
                            return `error: ${e.message} 💀`;
                        }
                    },
                    stealth: false,
                });
            });
            console.log("✨ MCP Bridge: ALL TOOLS REGISTERED SUCCESSFULLY! ✨");
        } catch (e) {
            console.error("❌ MCP Bridge Critical Error:", e);
        }
    });
    console.log("⏳ MCP Bridge: Waiting for APP_READY...");
})();

manifest.json

1
2
3
4
5
6
7
{
    "display_name": "Kobold MCP Bridge",
    "js": "index.js",
    "author": "Anon_1B_1Q_K_XXXXXS.geeguf",
    "version": "1.0.0",
    "loading_order": 100
}

Now reload ST and check if the tools are registered either by looking in the browser console, asking the bot, or using this slash command: /tools-list

Edit

Pub: 17 Apr 2026 11:36 UTC

Views: 16