UNPKG

@cnbcool/mcp-server

Version:

CNB MCP Server. A comprehensive MCP server that provides seamless integration to the CNB's API(https://cnb.cool), offering a wide range of tools for repository management, pipelines operations and collaboration features

67 lines (66 loc) 2.63 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.listPulls = listPulls; exports.getPull = getPull; exports.createPull = createPull; exports.updatePull = updatePull; exports.mergePull = mergePull; exports.listPullComments = listPullComments; exports.createPullComment = createPullComment; const client_js_1 = __importDefault(require("./client.js")); async function listPulls(repo, params) { const cnbInst = client_js_1.default.getInstance(); const url = new URL(`/${repo}/-/pulls`, cnbInst.baseUrl); if (params) { for (const [key, value] of Object.entries(params)) { if (value === undefined) continue; url.searchParams.set(key, value.toString()); } } return cnbInst.request('GET', `${url.pathname}${url.search}`); } async function getPull(repo, number) { return client_js_1.default.getInstance().request('GET', `/${repo}/-/pulls/${number}`); } async function createPull(repo, params) { return client_js_1.default.getInstance().request('POST', `/${repo}/-/pulls`, params, { header: { 'Content-Type': 'application/json' } }); } async function updatePull(repo, number, params) { return client_js_1.default.getInstance().request('PATCH', `/${repo}/-/pulls/${number}`, params, { header: { 'Content-Type': 'application/json' } }); } async function mergePull(repo, number, params) { return client_js_1.default.getInstance().request('PUT', `/${repo}/-/pulls/${number}/merge`, params, { header: { 'Content-Type': 'application/json' } }); } async function listPullComments(repo, number, params) { const cnbInst = client_js_1.default.getInstance(); const url = new URL(`/${repo}/-/pulls/${number}/comments`, cnbInst.baseUrl); if (params) { for (const [key, value] of Object.entries(params)) { if (value === undefined) continue; url.searchParams.set(key, value.toString()); } } return cnbInst.request('GET', `${url.pathname}${url.search}`); } async function createPullComment(repo, number, params) { const response = await client_js_1.default.getInstance().request('POST', `/${repo}/-/pulls/${number}/comments`, params, { header: { 'Content-Type': 'application/json' } }, 'raw'); if (response.status === 201) { return { message: 'Created' }; } else { return { status: response.status, message: response.statusText }; } }