@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
49 lines (48 loc) • 1.65 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.listGroups = listGroups;
exports.listSubGroups = listSubGroups;
exports.getGroup = getGroup;
exports.createGroup = createGroup;
async function listGroups(client, params) {
const url = new URL('/user/groups', client.baseUrl);
if (params) {
for (const [key, value] of Object.entries(params)) {
if (value === undefined)
continue;
url.searchParams.set(key, value.toString());
}
}
return client.request('GET', `${url.pathname}${url.search}`);
}
async function listSubGroups(client, group, params) {
const url = new URL(`/user/groups/${group}`, client.baseUrl);
if (params) {
for (const [key, value] of Object.entries(params)) {
if (value === undefined)
continue;
url.searchParams.set(key, value.toString());
}
}
return client.request('GET', `${url.pathname}${url.search}`);
}
async function getGroup(client, group) {
return client.request('GET', `/${group}`);
}
async function createGroup(client, params) {
const body = Object.entries(params).reduce((acc, [key, value]) => {
if (value === undefined)
return acc;
Object.assign(acc, { [key]: value });
return acc;
}, {});
const response = await client.request('POST', '/groups', body, {
header: { 'Content-Type': 'application/json' }
}, 'raw');
if (response.status === 201) {
return { message: 'Created' };
}
else {
return { status: response.status, message: response.statusText };
}
}