@cnbcool/mcp-server 0.4.1 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,6 @@
1
- export default class CnbApiClient {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class CnbApiClient {
2
4
  static instance = null;
3
5
  _baseUrl;
4
6
  _token;
@@ -47,3 +49,4 @@ export default class CnbApiClient {
47
49
  return response.json();
48
50
  }
49
51
  }
52
+ exports.default = CnbApiClient;
package/dist/api/group.js CHANGED
@@ -1,6 +1,15 @@
1
- import CnbApiClient from './client.js';
2
- export async function listGroups(params) {
3
- const cnbInst = CnbApiClient.getInstance();
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.listGroups = listGroups;
7
+ exports.listSubGroups = listSubGroups;
8
+ exports.getGroup = getGroup;
9
+ exports.createGroup = createGroup;
10
+ const client_js_1 = __importDefault(require("./client.js"));
11
+ async function listGroups(params) {
12
+ const cnbInst = client_js_1.default.getInstance();
4
13
  const url = new URL('/user/groups', cnbInst.baseUrl);
5
14
  if (params) {
6
15
  for (const [key, value] of Object.entries(params)) {
@@ -11,8 +20,8 @@ export async function listGroups(params) {
11
20
  }
12
21
  return cnbInst.request('GET', `${url.pathname}${url.search}`);
13
22
  }
14
- export async function listSubGroups(group, params) {
15
- const cnbInst = CnbApiClient.getInstance();
23
+ async function listSubGroups(group, params) {
24
+ const cnbInst = client_js_1.default.getInstance();
16
25
  const url = new URL(`/user/groups/${group}`, cnbInst.baseUrl);
17
26
  if (params) {
18
27
  for (const [key, value] of Object.entries(params)) {
@@ -23,18 +32,18 @@ export async function listSubGroups(group, params) {
23
32
  }
24
33
  return cnbInst.request('GET', `${url.pathname}${url.search}`);
25
34
  }
26
- export async function getGroup(group) {
27
- const cnbInst = CnbApiClient.getInstance();
35
+ async function getGroup(group) {
36
+ const cnbInst = client_js_1.default.getInstance();
28
37
  return cnbInst.request('GET', `/${group}`);
29
38
  }
30
- export async function createGroup(params) {
39
+ async function createGroup(params) {
31
40
  const body = Object.entries(params).reduce((acc, [key, value]) => {
32
41
  if (value === undefined)
33
42
  return acc;
34
43
  Object.assign(acc, { [key]: value });
35
44
  return acc;
36
45
  }, {});
37
- const response = await CnbApiClient.getInstance().request('POST', '/groups', body, {
46
+ const response = await client_js_1.default.getInstance().request('POST', '/groups', body, {
38
47
  header: { 'Content-Type': 'application/json' }
39
48
  }, 'raw');
40
49
  if (response.status === 201) {
package/dist/api/issue.js CHANGED
@@ -1,6 +1,23 @@
1
- import CnbApiClient from './client.js';
2
- export async function listIssues(repo, params) {
3
- const cnbInst = CnbApiClient.getInstance();
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.listIssues = listIssues;
7
+ exports.getIssue = getIssue;
8
+ exports.createIssue = createIssue;
9
+ exports.updateIssue = updateIssue;
10
+ exports.listIssueComments = listIssueComments;
11
+ exports.createIssueComment = createIssueComment;
12
+ exports.updateIssueComment = updateIssueComment;
13
+ exports.listIssueLabels = listIssueLabels;
14
+ exports.addIssueLabels = addIssueLabels;
15
+ exports.setIssueLabels = setIssueLabels;
16
+ exports.deleteIssueLabels = deleteIssueLabels;
17
+ exports.deleteIssueLabel = deleteIssueLabel;
18
+ const client_js_1 = __importDefault(require("./client.js"));
19
+ async function listIssues(repo, params) {
20
+ const cnbInst = client_js_1.default.getInstance();
4
21
  const url = new URL(`/${repo}/-/issues`, cnbInst.baseUrl);
5
22
  if (params) {
6
23
  for (const [key, value] of Object.entries(params)) {
@@ -11,27 +28,27 @@ export async function listIssues(repo, params) {
11
28
  }
12
29
  return cnbInst.request('GET', `${url.pathname}${url.search}`);
13
30
  }
14
- export async function getIssue(repo, issueId) {
15
- return CnbApiClient.getInstance().request('GET', `/${repo}/-/issues/${issueId}`);
31
+ async function getIssue(repo, issueId) {
32
+ return client_js_1.default.getInstance().request('GET', `/${repo}/-/issues/${issueId}`);
16
33
  }
17
- export async function createIssue(repo, params) {
34
+ async function createIssue(repo, params) {
18
35
  const newParams = Object.entries(params).reduce((acc, [key, value]) => {
19
36
  if (value === undefined)
20
37
  return acc;
21
38
  Object.assign(acc, { [key]: value });
22
39
  return acc;
23
40
  }, {});
24
- return CnbApiClient.getInstance().request('POST', `/${repo}/-/issues`, newParams, {
41
+ return client_js_1.default.getInstance().request('POST', `/${repo}/-/issues`, newParams, {
25
42
  header: { 'Content-Type': 'application/json' }
26
43
  });
27
44
  }
28
- export async function updateIssue(repo, issueId, params) {
29
- return CnbApiClient.getInstance().request('PATCH', `/${repo}/-/issues/${issueId}`, params, {
45
+ async function updateIssue(repo, issueId, params) {
46
+ return client_js_1.default.getInstance().request('PATCH', `/${repo}/-/issues/${issueId}`, params, {
30
47
  header: { 'Content-Type': 'application/json' }
31
48
  });
32
49
  }
33
- export async function listIssueComments(repo, issueId, params) {
34
- const cnbInst = CnbApiClient.getInstance();
50
+ async function listIssueComments(repo, issueId, params) {
51
+ const cnbInst = client_js_1.default.getInstance();
35
52
  const url = new URL(`/${repo}/-/issues/${issueId}/comments`, cnbInst.baseUrl);
36
53
  if (params) {
37
54
  for (const [key, value] of Object.entries(params)) {
@@ -42,32 +59,32 @@ export async function listIssueComments(repo, issueId, params) {
42
59
  }
43
60
  return cnbInst.request('GET', `${url.pathname}${url.search}`);
44
61
  }
45
- export async function createIssueComment(repo, issueId, params) {
46
- return CnbApiClient.getInstance().request('POST', `/${repo}/-/issues/${issueId}/comments`, params, {
62
+ async function createIssueComment(repo, issueId, params) {
63
+ return client_js_1.default.getInstance().request('POST', `/${repo}/-/issues/${issueId}/comments`, params, {
47
64
  header: { 'Content-Type': 'application/json' }
48
65
  });
49
66
  }
50
- export async function updateIssueComment(repo, issueId, commentId, params) {
51
- return CnbApiClient.getInstance().request('PATCH', `/${repo}/-/issues/${issueId}/comments/${commentId}`, params, {
67
+ async function updateIssueComment(repo, issueId, commentId, params) {
68
+ return client_js_1.default.getInstance().request('PATCH', `/${repo}/-/issues/${issueId}/comments/${commentId}`, params, {
52
69
  header: { 'Content-Type': 'application/json' }
53
70
  });
54
71
  }
55
- export async function listIssueLabels(repo, issueId) {
56
- return CnbApiClient.getInstance().request('GET', `/${repo}/-/issues/${issueId}/labels`);
72
+ async function listIssueLabels(repo, issueId) {
73
+ return client_js_1.default.getInstance().request('GET', `/${repo}/-/issues/${issueId}/labels`);
57
74
  }
58
- export async function addIssueLabels(repo, issueId, labels) {
59
- return CnbApiClient.getInstance().request('POST', `/${repo}/-/issues/${issueId}/labels`, { labels }, {
75
+ async function addIssueLabels(repo, issueId, labels) {
76
+ return client_js_1.default.getInstance().request('POST', `/${repo}/-/issues/${issueId}/labels`, { labels }, {
60
77
  header: { 'Content-Type': 'application/json' }
61
78
  });
62
79
  }
63
- export async function setIssueLabels(repo, issueId, labels) {
64
- return CnbApiClient.getInstance().request('PUT', `/${repo}/-/issues/${issueId}/labels`, { labels }, {
80
+ async function setIssueLabels(repo, issueId, labels) {
81
+ return client_js_1.default.getInstance().request('PUT', `/${repo}/-/issues/${issueId}/labels`, { labels }, {
65
82
  header: { 'Content-Type': 'application/json' }
66
83
  });
67
84
  }
68
- export async function deleteIssueLabels(repo, issueId) {
69
- await CnbApiClient.getInstance().request('DELETE', `/${repo}/-/issues/${issueId}/labels`);
85
+ async function deleteIssueLabels(repo, issueId) {
86
+ await client_js_1.default.getInstance().request('DELETE', `/${repo}/-/issues/${issueId}/labels`);
70
87
  }
71
- export async function deleteIssueLabel(repo, issueId, labelName) {
72
- await CnbApiClient.getInstance().request('DELETE', `/${repo}/-/issues/${issueId}/labels/${encodeURIComponent(labelName)}`);
88
+ async function deleteIssueLabel(repo, issueId, labelName) {
89
+ await client_js_1.default.getInstance().request('DELETE', `/${repo}/-/issues/${issueId}/labels/${encodeURIComponent(labelName)}`);
73
90
  }
package/dist/api/pull.js CHANGED
@@ -1,6 +1,18 @@
1
- import CnbApiClient from './client.js';
2
- export async function listPulls(repo, params) {
3
- const cnbInst = CnbApiClient.getInstance();
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.listPulls = listPulls;
7
+ exports.getPull = getPull;
8
+ exports.createPull = createPull;
9
+ exports.updatePull = updatePull;
10
+ exports.mergePull = mergePull;
11
+ exports.listPullComments = listPullComments;
12
+ exports.createPullComment = createPullComment;
13
+ const client_js_1 = __importDefault(require("./client.js"));
14
+ async function listPulls(repo, params) {
15
+ const cnbInst = client_js_1.default.getInstance();
4
16
  const url = new URL(`/${repo}/-/pulls`, cnbInst.baseUrl);
5
17
  if (params) {
6
18
  for (const [key, value] of Object.entries(params)) {
@@ -11,26 +23,26 @@ export async function listPulls(repo, params) {
11
23
  }
12
24
  return cnbInst.request('GET', `${url.pathname}${url.search}`);
13
25
  }
14
- export async function getPull(repo, number) {
15
- return CnbApiClient.getInstance().request('GET', `/${repo}/-/pulls/${number}`);
26
+ async function getPull(repo, number) {
27
+ return client_js_1.default.getInstance().request('GET', `/${repo}/-/pulls/${number}`);
16
28
  }
17
- export async function createPull(repo, params) {
18
- return CnbApiClient.getInstance().request('POST', `/${repo}/-/pulls`, params, {
29
+ async function createPull(repo, params) {
30
+ return client_js_1.default.getInstance().request('POST', `/${repo}/-/pulls`, params, {
19
31
  header: { 'Content-Type': 'application/json' }
20
32
  });
21
33
  }
22
- export async function updatePull(repo, number, params) {
23
- return CnbApiClient.getInstance().request('PATCH', `/${repo}/-/pulls/${number}`, params, {
34
+ async function updatePull(repo, number, params) {
35
+ return client_js_1.default.getInstance().request('PATCH', `/${repo}/-/pulls/${number}`, params, {
24
36
  header: { 'Content-Type': 'application/json' }
25
37
  });
26
38
  }
27
- export async function mergePull(repo, number, params) {
28
- return CnbApiClient.getInstance().request('PUT', `/${repo}/-/pulls/${number}/merge`, params, {
39
+ async function mergePull(repo, number, params) {
40
+ return client_js_1.default.getInstance().request('PUT', `/${repo}/-/pulls/${number}/merge`, params, {
29
41
  header: { 'Content-Type': 'application/json' }
30
42
  });
31
43
  }
32
- export async function listPullComments(repo, number, params) {
33
- const cnbInst = CnbApiClient.getInstance();
44
+ async function listPullComments(repo, number, params) {
45
+ const cnbInst = client_js_1.default.getInstance();
34
46
  const url = new URL(`/${repo}/-/pulls/${number}/comments`, cnbInst.baseUrl);
35
47
  if (params) {
36
48
  for (const [key, value] of Object.entries(params)) {
@@ -41,8 +53,8 @@ export async function listPullComments(repo, number, params) {
41
53
  }
42
54
  return cnbInst.request('GET', `${url.pathname}${url.search}`);
43
55
  }
44
- export async function createPullComment(repo, number, params) {
45
- const response = await CnbApiClient.getInstance().request('POST', `/${repo}/-/pulls/${number}/comments`, params, {
56
+ async function createPullComment(repo, number, params) {
57
+ const response = await client_js_1.default.getInstance().request('POST', `/${repo}/-/pulls/${number}/comments`, params, {
46
58
  header: { 'Content-Type': 'application/json' }
47
59
  }, 'raw');
48
60
  if (response.status === 201) {
@@ -1,6 +1,15 @@
1
- import CnbApiClient from './client.js';
2
- export async function listRepositories(params) {
3
- const cnbInst = CnbApiClient.getInstance();
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.listRepositories = listRepositories;
7
+ exports.listGroupRepositories = listGroupRepositories;
8
+ exports.getRepository = getRepository;
9
+ exports.createRepository = createRepository;
10
+ const client_js_1 = __importDefault(require("./client.js"));
11
+ async function listRepositories(params) {
12
+ const cnbInst = client_js_1.default.getInstance();
4
13
  const url = new URL('/user/repos', cnbInst.baseUrl);
5
14
  if (params) {
6
15
  for (const [key, value] of Object.entries(params)) {
@@ -11,8 +20,8 @@ export async function listRepositories(params) {
11
20
  }
12
21
  return cnbInst.request('GET', `${url.pathname}${url.search}`);
13
22
  }
14
- export async function listGroupRepositories(group, params) {
15
- const cnbInst = CnbApiClient.getInstance();
23
+ async function listGroupRepositories(group, params) {
24
+ const cnbInst = client_js_1.default.getInstance();
16
25
  const url = new URL(`/${group}/-/repos`, cnbInst.baseUrl);
17
26
  if (params) {
18
27
  for (const [key, value] of Object.entries(params)) {
@@ -23,17 +32,17 @@ export async function listGroupRepositories(group, params) {
23
32
  }
24
33
  return cnbInst.request('GET', `${url.pathname}${url.search}`);
25
34
  }
26
- export async function getRepository(repo) {
27
- return CnbApiClient.getInstance().request('GET', `/${repo}`);
35
+ async function getRepository(repo) {
36
+ return client_js_1.default.getInstance().request('GET', `/${repo}`);
28
37
  }
29
- export async function createRepository(group, params) {
38
+ async function createRepository(group, params) {
30
39
  const body = Object.entries(params).reduce((acc, [key, value]) => {
31
40
  if (value === undefined)
32
41
  return acc;
33
42
  Object.assign(acc, { [key]: value });
34
43
  return acc;
35
44
  }, {});
36
- const response = await CnbApiClient.getInstance().request('POST', `/${group}/-/repos`, body, {
45
+ const response = await client_js_1.default.getInstance().request('POST', `/${group}/-/repos`, body, {
37
46
  header: { 'Content-Type': 'application/json' }
38
47
  }, 'raw');
39
48
  if (response.status === 201) {
package/dist/api/user.js CHANGED
@@ -1,5 +1,11 @@
1
- import CnbApiClient from './client.js';
2
- export async function getUser() {
3
- const cnbInst = CnbApiClient.getInstance();
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getUser = getUser;
7
+ const client_js_1 = __importDefault(require("./client.js"));
8
+ async function getUser() {
9
+ const cnbInst = client_js_1.default.getInstance();
4
10
  return cnbInst.request('GET', '/user');
5
11
  }
@@ -1,6 +1,13 @@
1
- import CnbApiClient from './client.js';
2
- export async function listWorkspace(params) {
3
- const cnbInst = CnbApiClient.getInstance();
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.listWorkspace = listWorkspace;
7
+ exports.deleteWorkspace = deleteWorkspace;
8
+ const client_js_1 = __importDefault(require("./client.js"));
9
+ async function listWorkspace(params) {
10
+ const cnbInst = client_js_1.default.getInstance();
4
11
  const url = new URL('/workspace/list', cnbInst.baseUrl);
5
12
  if (params) {
6
13
  for (const [key, value] of Object.entries(params)) {
@@ -11,8 +18,8 @@ export async function listWorkspace(params) {
11
18
  }
12
19
  return cnbInst.request('GET', `${url.pathname}${url.search}`);
13
20
  }
14
- export async function deleteWorkspace(params) {
15
- const cnbInst = CnbApiClient.getInstance();
21
+ async function deleteWorkspace(params) {
22
+ const cnbInst = client_js_1.default.getInstance();
16
23
  const url = new URL('/workspace/delete', cnbInst.baseUrl);
17
24
  return cnbInst.request('POST', `${url.pathname}`, params, {
18
25
  header: { 'Content-Type': 'application/json' }
@@ -1,13 +1,15 @@
1
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { registerTools } from '../tools/index.js';
3
- // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-3.html#import-attributes
4
- import packageJSON from '../../package.json' with { type: 'json' };
5
- export function createMcpServer(req) {
6
- const mcpServer = new McpServer({
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createMcpServer = createMcpServer;
4
+ const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
5
+ const index_js_1 = require("../tools/index.js");
6
+ const package_json_1 = require("../../package.json");
7
+ function createMcpServer(req) {
8
+ const mcpServer = new mcp_js_1.McpServer({
7
9
  name: 'cnb-mcp-server',
8
- version: packageJSON.version
10
+ version: package_json_1.version
9
11
  });
10
12
  const token = req?.headers['authorization']?.split(' ')[1];
11
- registerTools(mcpServer, token);
13
+ (0, index_js_1.registerTools)(mcpServer, token);
12
14
  return mcpServer;
13
15
  }
@@ -1,4 +1,8 @@
1
- export function formatTextToolResult(text, toolName) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatTextToolResult = formatTextToolResult;
4
+ exports.formatToolError = formatToolError;
5
+ function formatTextToolResult(text, toolName) {
2
6
  return {
3
7
  content: [
4
8
  {
@@ -8,7 +12,7 @@ export function formatTextToolResult(text, toolName) {
8
12
  ]
9
13
  };
10
14
  }
11
- export function formatToolError(error, toolName) {
15
+ function formatToolError(error, toolName) {
12
16
  return {
13
17
  content: [
14
18
  {
@@ -1,4 +1,7 @@
1
- export function stopWithWrongTransport(res) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stopWithWrongTransport = stopWithWrongTransport;
4
+ function stopWithWrongTransport(res) {
2
5
  res.status(400).json({
3
6
  jsonrpc: '2.0',
4
7
  error: {
package/dist/stdio.js CHANGED
@@ -1,12 +1,17 @@
1
1
  #!/usr/bin/env node
2
- import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
- import dotenv from 'dotenv';
4
- import { createMcpServer } from './helpers/createMcpServer.js';
5
- dotenv.config();
6
- const server = createMcpServer();
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
8
+ const dotenv_1 = __importDefault(require("dotenv"));
9
+ const createMcpServer_js_1 = require("./helpers/createMcpServer.js");
10
+ dotenv_1.default.config();
11
+ const server = (0, createMcpServer_js_1.createMcpServer)();
7
12
  async function main() {
8
13
  console.error('server starting...');
9
- const transport = new StdioServerTransport();
14
+ const transport = new stdio_js_1.StdioServerTransport();
10
15
  await server.connect(transport);
11
16
  console.error('server connected');
12
17
  }
@@ -1,38 +1,43 @@
1
1
  #!/usr/bin/env node
2
- import express from 'express';
3
- import { randomUUID } from 'node:crypto';
4
- import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
5
- import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
6
- import { isInitializeRequest } from '@modelcontextprotocol/sdk/types.js';
7
- import dotenv from 'dotenv';
8
- import { createMcpServer } from './helpers/createMcpServer.js';
9
- import { stopWithWrongTransport } from './helpers/sendResponse.js';
10
- dotenv.config();
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const express_1 = __importDefault(require("express"));
8
+ const node_crypto_1 = require("node:crypto");
9
+ const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
10
+ const sse_js_1 = require("@modelcontextprotocol/sdk/server/sse.js");
11
+ const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
12
+ const dotenv_1 = __importDefault(require("dotenv"));
13
+ const createMcpServer_js_1 = require("./helpers/createMcpServer.js");
14
+ const sendResponse_js_1 = require("./helpers/sendResponse.js");
15
+ dotenv_1.default.config();
11
16
  const DEFAULT_APP_PORT = 3000;
12
17
  // Store transports for each session type
13
18
  const transports = {
14
19
  streamable: {},
15
20
  sse: {}
16
21
  };
17
- const app = express();
18
- app.use(express.json());
22
+ const app = (0, express_1.default)();
23
+ app.use(express_1.default.json());
19
24
  app.post('/mcp', async (req, res) => {
20
25
  const sessionId = req.headers['mcp-session-id'];
21
26
  let transport;
22
27
  // Reuse existing transport
23
28
  if (sessionId && transports.streamable[sessionId]) {
24
29
  transport = transports.streamable[sessionId];
25
- if (!(transport instanceof StreamableHTTPServerTransport)) {
26
- stopWithWrongTransport(res);
30
+ if (!(transport instanceof streamableHttp_js_1.StreamableHTTPServerTransport)) {
31
+ (0, sendResponse_js_1.stopWithWrongTransport)(res);
27
32
  return;
28
33
  }
29
34
  await transport.handleRequest(req, res, req.body);
30
35
  return;
31
36
  }
32
37
  // New initialization request
33
- if (!sessionId && isInitializeRequest(req.body)) {
34
- transport = new StreamableHTTPServerTransport({
35
- sessionIdGenerator: () => randomUUID(),
38
+ if (!sessionId && (0, types_js_1.isInitializeRequest)(req.body)) {
39
+ transport = new streamableHttp_js_1.StreamableHTTPServerTransport({
40
+ sessionIdGenerator: () => (0, node_crypto_1.randomUUID)(),
36
41
  onsessioninitialized: (sessionId) => {
37
42
  transports.streamable[sessionId] = transport;
38
43
  }
@@ -43,7 +48,7 @@ app.post('/mcp', async (req, res) => {
43
48
  delete transports.streamable[transport.sessionId];
44
49
  }
45
50
  };
46
- const mcpServer = createMcpServer(req);
51
+ const mcpServer = (0, createMcpServer_js_1.createMcpServer)(req);
47
52
  await mcpServer.connect(transport);
48
53
  await transport.handleRequest(req, res, req.body);
49
54
  return;
@@ -70,12 +75,12 @@ const handleSessionRequest = async (req, res) => {
70
75
  app.get('/mcp', handleSessionRequest);
71
76
  app.delete('/mcp', handleSessionRequest);
72
77
  app.get('/sse', async (req, res) => {
73
- const transport = new SSEServerTransport('/messages', res);
78
+ const transport = new sse_js_1.SSEServerTransport('/messages', res);
74
79
  transports.sse[transport.sessionId] = transport;
75
80
  res.on('close', () => {
76
81
  delete transports.sse[transport.sessionId];
77
82
  });
78
- const mcpServer = createMcpServer(req);
83
+ const mcpServer = (0, createMcpServer_js_1.createMcpServer)(req);
79
84
  await mcpServer.connect(transport);
80
85
  });
81
86
  app.post('/messages', async (req, res) => {
@@ -85,8 +90,8 @@ app.post('/messages', async (req, res) => {
85
90
  res.status(400).send('No transport found for sessionId');
86
91
  return;
87
92
  }
88
- if (!(transport instanceof SSEServerTransport)) {
89
- stopWithWrongTransport(res);
93
+ if (!(transport instanceof sse_js_1.SSEServerTransport)) {
94
+ (0, sendResponse_js_1.stopWithWrongTransport)(res);
90
95
  return;
91
96
  }
92
97
  await transport.handlePostMessage(req, res, req.body);
@@ -1,62 +1,65 @@
1
- import { z } from 'zod';
2
- import { createGroup, getGroup, listGroups, listSubGroups } from '../api/group.js';
3
- import { formatTextToolResult, formatToolError } from '../helpers/formatToolResult.js';
4
- export default function registerGroupTools(server) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = registerGroupTools;
4
+ const zod_1 = require("zod");
5
+ const group_js_1 = require("../api/group.js");
6
+ const formatToolResult_js_1 = require("../helpers/formatToolResult.js");
7
+ function registerGroupTools(server) {
5
8
  server.tool('list-groups', '获取当前用户拥有权限的顶层组织列表', {
6
- page: z.number().default(1).describe('第几页,从1开始'),
7
- page_size: z.number().default(10).describe('每页多少条数据'),
8
- search: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('仓库关键字'),
9
- role: z
10
- .preprocess((val) => (val === null ? undefined : val), z.enum(['Guest', 'Reporter', 'Developer', 'Master', 'Owner']).optional())
9
+ page: zod_1.z.number().default(1).describe('第几页,从1开始'),
10
+ page_size: zod_1.z.number().default(10).describe('每页多少条数据'),
11
+ search: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('仓库关键字'),
12
+ role: zod_1.z
13
+ .preprocess((val) => (val === null ? undefined : val), zod_1.z.enum(['Guest', 'Reporter', 'Developer', 'Master', 'Owner']).optional())
11
14
  .describe('最小仓库权限')
12
15
  }, async ({ page, page_size, search, role }) => {
13
16
  try {
14
- const groups = await listGroups({ page, page_size, search, role });
15
- return formatTextToolResult(JSON.stringify(groups, null, 2), 'list-groups');
17
+ const groups = await (0, group_js_1.listGroups)({ page, page_size, search, role });
18
+ return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(groups, null, 2), 'list-groups');
16
19
  }
17
20
  catch (error) {
18
- return formatToolError(error, 'list-groups');
21
+ return (0, formatToolResult_js_1.formatToolError)(error, 'list-groups');
19
22
  }
20
23
  });
21
24
  server.tool('list-sub-groups', '查询当前用户在指定组织下拥有指定权限的子组织列表', {
22
- group: z.string().describe('组织名称'),
23
- page: z.number().default(1).describe('第几页,从1开始'),
24
- page_size: z.number().default(10).describe('每页多少条数据'),
25
- access: z.preprocess((val) => (val === null ? undefined : val), z.number().optional()).describe('权限等级')
25
+ group: zod_1.z.string().describe('组织名称'),
26
+ page: zod_1.z.number().default(1).describe('第几页,从1开始'),
27
+ page_size: zod_1.z.number().default(10).describe('每页多少条数据'),
28
+ access: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.number().optional()).describe('权限等级')
26
29
  }, async ({ group, page, page_size, access }) => {
27
30
  try {
28
- const subGroups = await listSubGroups(group, { page, page_size, access });
29
- return formatTextToolResult(JSON.stringify(subGroups, null, 2), 'list-sub-groups');
31
+ const subGroups = await (0, group_js_1.listSubGroups)(group, { page, page_size, access });
32
+ return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(subGroups, null, 2), 'list-sub-groups');
30
33
  }
31
34
  catch (error) {
32
- return formatToolError(error, 'list-sub-groups');
35
+ return (0, formatToolResult_js_1.formatToolError)(error, 'list-sub-groups');
33
36
  }
34
37
  });
35
38
  server.tool('get-group', '获取指定组织信息', {
36
- group: z.string().describe('组织路径')
39
+ group: zod_1.z.string().describe('组织路径')
37
40
  }, async ({ group }) => {
38
41
  try {
39
- const groupInfo = await getGroup(group);
40
- return formatTextToolResult(JSON.stringify(groupInfo, null, 2), 'get-group');
42
+ const groupInfo = await (0, group_js_1.getGroup)(group);
43
+ return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(groupInfo, null, 2), 'get-group');
41
44
  }
42
45
  catch (error) {
43
- return formatToolError(error, 'get-group');
46
+ return (0, formatToolResult_js_1.formatToolError)(error, 'get-group');
44
47
  }
45
48
  });
46
49
  server.tool('create-group', '创建新组织', {
47
- path: z.string().describe('组织路径'),
48
- description: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('组织描述'),
49
- remark: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('仓库备注'),
50
- bind_domain: z
51
- .preprocess((val) => (val === null ? undefined : val), z.string().optional())
50
+ path: zod_1.z.string().describe('组织路径'),
51
+ description: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('组织描述'),
52
+ remark: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('仓库备注'),
53
+ bind_domain: zod_1.z
54
+ .preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional())
52
55
  .describe('根组织绑定的域名')
53
56
  }, async ({ path, description, remark, bind_domain }) => {
54
57
  try {
55
- const data = await createGroup({ path, description, remark, bind_domain });
56
- return formatTextToolResult(JSON.stringify(data, null, 2), 'create-group');
58
+ const data = await (0, group_js_1.createGroup)({ path, description, remark, bind_domain });
59
+ return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(data, null, 2), 'create-group');
57
60
  }
58
61
  catch (error) {
59
- return formatToolError(error, 'create-group');
62
+ return (0, formatToolResult_js_1.formatToolError)(error, 'create-group');
60
63
  }
61
64
  });
62
65
  }