MCP Server Plugin (#335)

This commit is contained in:
Gregory Schier
2025-12-31 08:41:57 -08:00
committed by GitHub
parent 58eff84f43
commit 6b9b207e1c
44 changed files with 2144 additions and 191 deletions

View File

@@ -0,0 +1,25 @@
import type { Context, PluginDefinition } from '@yaakapp/api';
import { createMcpServer } from './server.js';
const serverPort = 64343;
let mcpServer: Awaited<ReturnType<typeof createMcpServer>> | null = null;
export const plugin: PluginDefinition = {
async init(ctx: Context) {
// Start the server after waiting, so there's an active window open to do things
// like show the startup toast.
setTimeout(() => {
mcpServer = createMcpServer({ yaak: ctx }, serverPort);
}, 5000);
},
async dispose() {
console.log('Disposing MCP Server plugin');
if (mcpServer) {
await mcpServer.close();
mcpServer = null;
}
},
};