/
gkat
/
gitverse-codex-plugin
Обзор
Документация
Войти
/
gkat
/
gitverse-codex-plugin
Код
Запросы
0
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
scripts/local-mcp.mjs
64 строки
2 KB
gkat
Register repository listing as standalone MCP server
29 июл 2026, 15:31
29 июл 2026, 15:31
8aee95b
Код
Авторство
О чём код?
#!/usr/bin/env node import readline from "node:readline"; import { resolveToken } from "./auth.mjs"; import { callLocalTool, listMyRepositoriesTool } from "./local-tools.mjs"; const { token } = resolveToken(); function emit(message) { process.stdout.write(`${JSON.stringify(message)}\n`); } async function handle(message) { if (message.method === "initialize") { emit({ jsonrpc: "2.0", id: message.id, result: { protocolVersion: message.params?.protocolVersion || "2024-11-05", capabilities: { tools: {} }, serverInfo: { name: "GitVerse Codex Local Tools", version: "0.4.0" }, }, }); return; } if (message.method === "tools/list") { emit({ jsonrpc: "2.0", id: message.id, result: { tools: [listMyRepositoriesTool] }, }); return; } const localReply = await callLocalTool(message, { token }); if (localReply) { emit(localReply); return; } if (message.id !== undefined && !message.method?.startsWith("notifications/")) { emit({ jsonrpc: "2.0", id: message.id, error: { code: -32601, message: `Method not found: ${message.method}` }, }); } } const input = readline.createInterface({ input: process.stdin }); let chain = Promise.resolve(); input.on("line", (line) => { if (!line.trim()) return; chain = chain.then(async () => { try { await handle(JSON.parse(line)); } catch (error) { process.stderr.write(`GitVerse local MCP: ${error.message}\n`); } }); });