@edicarlos.lds/businessmap-mcp 2.3.0 โ†’ 3.1.0

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.
Files changed (144) hide show
  1. package/CONTRIBUTING.md +73 -0
  2. package/README.md +24 -4
  3. package/SECURITY.md +36 -0
  4. package/dist/client/businessmap-client.d.ts +17 -100
  5. package/dist/client/businessmap-client.d.ts.map +1 -1
  6. package/dist/client/businessmap-client.js +63 -283
  7. package/dist/client/businessmap-client.js.map +1 -1
  8. package/dist/client/businessmap-error.d.ts +16 -0
  9. package/dist/client/businessmap-error.d.ts.map +1 -0
  10. package/dist/client/businessmap-error.js +43 -0
  11. package/dist/client/businessmap-error.js.map +1 -0
  12. package/dist/client/modules/board-client.d.ts.map +1 -1
  13. package/dist/client/modules/board-client.js +16 -2
  14. package/dist/client/modules/board-client.js.map +1 -1
  15. package/dist/client/modules/card-client.d.ts +19 -5
  16. package/dist/client/modules/card-client.d.ts.map +1 -1
  17. package/dist/client/modules/card-client.js +61 -13
  18. package/dist/client/modules/card-client.js.map +1 -1
  19. package/dist/client/modules/custom-field-client.js +1 -1
  20. package/dist/client/modules/custom-field-client.js.map +1 -1
  21. package/dist/client/modules/doc-client.d.ts +44 -0
  22. package/dist/client/modules/doc-client.d.ts.map +1 -0
  23. package/dist/client/modules/doc-client.js +73 -0
  24. package/dist/client/modules/doc-client.js.map +1 -0
  25. package/dist/client/modules/index.d.ts +1 -0
  26. package/dist/client/modules/index.d.ts.map +1 -1
  27. package/dist/client/modules/index.js +1 -0
  28. package/dist/client/modules/index.js.map +1 -1
  29. package/dist/config/environment.d.ts +3 -0
  30. package/dist/config/environment.d.ts.map +1 -1
  31. package/dist/config/environment.js +60 -1
  32. package/dist/config/environment.js.map +1 -1
  33. package/dist/index.d.ts +1 -1
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +19 -9
  36. package/dist/index.js.map +1 -1
  37. package/dist/schemas/card-schemas.d.ts +111 -85
  38. package/dist/schemas/card-schemas.d.ts.map +1 -1
  39. package/dist/schemas/card-schemas.js +39 -162
  40. package/dist/schemas/card-schemas.js.map +1 -1
  41. package/dist/schemas/common-schemas.d.ts +10 -4
  42. package/dist/schemas/common-schemas.d.ts.map +1 -1
  43. package/dist/schemas/common-schemas.js +25 -0
  44. package/dist/schemas/common-schemas.js.map +1 -1
  45. package/dist/schemas/doc-schemas.d.ts +176 -0
  46. package/dist/schemas/doc-schemas.d.ts.map +1 -0
  47. package/dist/schemas/doc-schemas.js +141 -0
  48. package/dist/schemas/doc-schemas.js.map +1 -0
  49. package/dist/schemas/index.d.ts +1 -0
  50. package/dist/schemas/index.d.ts.map +1 -1
  51. package/dist/schemas/index.js +1 -0
  52. package/dist/schemas/index.js.map +1 -1
  53. package/dist/schemas/setup-schemas.d.ts +418 -0
  54. package/dist/schemas/setup-schemas.d.ts.map +1 -1
  55. package/dist/schemas/setup-schemas.js +30 -7
  56. package/dist/schemas/setup-schemas.js.map +1 -1
  57. package/dist/schemas/workspace-schemas.d.ts +3 -0
  58. package/dist/schemas/workspace-schemas.d.ts.map +1 -1
  59. package/dist/schemas/workspace-schemas.js +6 -0
  60. package/dist/schemas/workspace-schemas.js.map +1 -1
  61. package/dist/server/http.d.ts +7 -1
  62. package/dist/server/http.d.ts.map +1 -1
  63. package/dist/server/http.js +140 -31
  64. package/dist/server/http.js.map +1 -1
  65. package/dist/server/mcp-server.d.ts.map +1 -1
  66. package/dist/server/mcp-server.js +2 -1
  67. package/dist/server/mcp-server.js.map +1 -1
  68. package/dist/server/resources/board-resources.js +2 -2
  69. package/dist/server/resources/board-resources.js.map +1 -1
  70. package/dist/server/resources/card-resources.d.ts.map +1 -1
  71. package/dist/server/resources/card-resources.js +26 -2
  72. package/dist/server/resources/card-resources.js.map +1 -1
  73. package/dist/server/resources/workspace-resources.js +1 -1
  74. package/dist/server/resources/workspace-resources.js.map +1 -1
  75. package/dist/server/tools/base-tool.d.ts +39 -0
  76. package/dist/server/tools/base-tool.d.ts.map +1 -1
  77. package/dist/server/tools/base-tool.js +130 -0
  78. package/dist/server/tools/base-tool.js.map +1 -1
  79. package/dist/server/tools/board-tools.d.ts +0 -13
  80. package/dist/server/tools/board-tools.d.ts.map +1 -1
  81. package/dist/server/tools/board-tools.js +168 -257
  82. package/dist/server/tools/board-tools.js.map +1 -1
  83. package/dist/server/tools/card-tools.d.ts +6 -42
  84. package/dist/server/tools/card-tools.d.ts.map +1 -1
  85. package/dist/server/tools/card-tools.js +506 -702
  86. package/dist/server/tools/card-tools.js.map +1 -1
  87. package/dist/server/tools/custom-field-tools.d.ts +1 -2
  88. package/dist/server/tools/custom-field-tools.d.ts.map +1 -1
  89. package/dist/server/tools/custom-field-tools.js +8 -16
  90. package/dist/server/tools/custom-field-tools.js.map +1 -1
  91. package/dist/server/tools/doc-tools.d.ts +15 -0
  92. package/dist/server/tools/doc-tools.d.ts.map +1 -0
  93. package/dist/server/tools/doc-tools.js +307 -0
  94. package/dist/server/tools/doc-tools.js.map +1 -0
  95. package/dist/server/tools/index.d.ts +1 -0
  96. package/dist/server/tools/index.d.ts.map +1 -1
  97. package/dist/server/tools/index.js +1 -0
  98. package/dist/server/tools/index.js.map +1 -1
  99. package/dist/server/tools/setup-tools.d.ts +13 -2
  100. package/dist/server/tools/setup-tools.d.ts.map +1 -1
  101. package/dist/server/tools/setup-tools.js +145 -96
  102. package/dist/server/tools/setup-tools.js.map +1 -1
  103. package/dist/server/tools/user-tools.d.ts +0 -4
  104. package/dist/server/tools/user-tools.d.ts.map +1 -1
  105. package/dist/server/tools/user-tools.js +36 -65
  106. package/dist/server/tools/user-tools.js.map +1 -1
  107. package/dist/server/tools/utility-tools.d.ts +0 -2
  108. package/dist/server/tools/utility-tools.d.ts.map +1 -1
  109. package/dist/server/tools/utility-tools.js +15 -28
  110. package/dist/server/tools/utility-tools.js.map +1 -1
  111. package/dist/server/tools/workflow-tools.d.ts +0 -8
  112. package/dist/server/tools/workflow-tools.d.ts.map +1 -1
  113. package/dist/server/tools/workflow-tools.js +84 -139
  114. package/dist/server/tools/workflow-tools.js.map +1 -1
  115. package/dist/server/tools/workspace-tools.d.ts +0 -4
  116. package/dist/server/tools/workspace-tools.d.ts.map +1 -1
  117. package/dist/server/tools/workspace-tools.js +35 -65
  118. package/dist/server/tools/workspace-tools.js.map +1 -1
  119. package/dist/types/base.d.ts +1 -0
  120. package/dist/types/base.d.ts.map +1 -1
  121. package/dist/types/card.d.ts +21 -5
  122. package/dist/types/card.d.ts.map +1 -1
  123. package/dist/types/doc.d.ts +96 -0
  124. package/dist/types/doc.d.ts.map +1 -0
  125. package/dist/types/doc.js +3 -0
  126. package/dist/types/doc.js.map +1 -0
  127. package/dist/types/index.d.ts +1 -0
  128. package/dist/types/index.d.ts.map +1 -1
  129. package/dist/types/index.js +1 -0
  130. package/dist/types/index.js.map +1 -1
  131. package/dist/types/workspace.d.ts +1 -0
  132. package/dist/types/workspace.d.ts.map +1 -1
  133. package/dist/utils/logger.d.ts +7 -12
  134. package/dist/utils/logger.d.ts.map +1 -1
  135. package/dist/utils/logger.js +73 -10
  136. package/dist/utils/logger.js.map +1 -1
  137. package/dist/utils/request-context.d.ts +7 -0
  138. package/dist/utils/request-context.d.ts.map +1 -0
  139. package/dist/utils/request-context.js +9 -0
  140. package/dist/utils/request-context.js.map +1 -0
  141. package/docs/LOGGING.md +15 -0
  142. package/docs/MIDDLEWARE.md +26 -4
  143. package/docs/TOOLS.md +43 -8
  144. package/package.json +4 -1
@@ -0,0 +1,96 @@
1
+ export interface DocListItem {
2
+ doc_id: number;
3
+ parent_doc_id: number | null;
4
+ title: string;
5
+ is_archived: number;
6
+ is_important: number;
7
+ position: number;
8
+ show_in_main_doc_list: number;
9
+ updated_at: string;
10
+ author_id: number;
11
+ size: number;
12
+ }
13
+ export interface Doc extends DocListItem {
14
+ content: string;
15
+ everyone_can_edit: number;
16
+ everyone_can_comment: number;
17
+ everyone_can_view: number;
18
+ created_at: string;
19
+ }
20
+ export interface DocsListData {
21
+ result: DocListItem[];
22
+ fully_hidden_docs?: number[];
23
+ docs_without_owners?: number[];
24
+ }
25
+ export interface DocsListResponse {
26
+ data: DocsListData;
27
+ }
28
+ export interface DocResponse {
29
+ data: Doc;
30
+ }
31
+ export interface PersonalDocListItem {
32
+ doc_id: number;
33
+ title: string;
34
+ position: number;
35
+ updated_at?: string;
36
+ size?: number;
37
+ }
38
+ export interface PersonalDoc extends PersonalDocListItem {
39
+ content: string;
40
+ created_at?: string;
41
+ }
42
+ export interface PersonalDocsListResponse {
43
+ data: PersonalDocListItem[];
44
+ }
45
+ export interface PersonalDocResponse {
46
+ data: PersonalDoc;
47
+ }
48
+ export interface BoardDocItem {
49
+ doc_id: number;
50
+ title: string;
51
+ is_important: number;
52
+ is_archived: number;
53
+ position: number;
54
+ }
55
+ export interface BoardDocsResponse {
56
+ data: BoardDocItem[];
57
+ }
58
+ export interface DocFilters {
59
+ doc_ids?: number[];
60
+ title?: string;
61
+ is_archived?: number;
62
+ show_in_main_doc_list?: number;
63
+ is_important?: number;
64
+ for_welcome?: number;
65
+ parent_doc_ids?: number[];
66
+ }
67
+ export interface CreateDocParams {
68
+ title: string;
69
+ content?: string;
70
+ is_important?: number;
71
+ for_welcome?: number;
72
+ is_archived?: number;
73
+ parent_doc_id?: number;
74
+ position?: number;
75
+ show_in_main_doc_list?: number;
76
+ }
77
+ export interface UpdateDocParams {
78
+ title?: string;
79
+ content?: string;
80
+ is_important?: number;
81
+ for_welcome?: number;
82
+ is_archived?: number;
83
+ parent_doc_id?: number;
84
+ position?: number;
85
+ }
86
+ export interface CreatePersonalDocParams {
87
+ title: string;
88
+ content?: string;
89
+ position?: number;
90
+ }
91
+ export interface UpdatePersonalDocParams {
92
+ title?: string;
93
+ content?: string;
94
+ position?: number;
95
+ }
96
+ //# sourceMappingURL=doc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doc.d.ts","sourceRoot":"","sources":["../../src/types/doc.ts"],"names":[],"mappings":"AA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AO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,3 @@
1
+ // Doc (documents) Types for BusinessMap API
2
+ export {};
3
+ //# sourceMappingURL=doc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doc.js","sourceRoot":"","sources":["../../src/types/doc.ts"],"names":[],"mappings":"AAAA,4CAA4C"}
@@ -2,6 +2,7 @@ export * from './base';
2
2
  export * from './board';
3
3
  export * from './card';
4
4
  export * from './custom-field';
5
+ export * from './doc';
5
6
  export * from './lane';
6
7
  export * from './user';
7
8
  export * from './workflow';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
@@ -3,6 +3,7 @@ export * from './base';
3
3
  export * from './board';
4
4
  export * from './card';
5
5
  export * from './custom-field';
6
+ export * from './doc';
6
7
  export * from './lane';
7
8
  export * from './user';
8
9
  export * from './workflow';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
@@ -7,5 +7,6 @@ export interface Workspace {
7
7
  export interface CreateWorkspaceParams {
8
8
  name: string;
9
9
  description?: string;
10
+ type?: number;
10
11
  }
11
12
  //# sourceMappingURL=workspace.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/types/workspace.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,SAAS;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB"}
1
+ {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/types/workspace.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,SAAS;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
@@ -1,12 +1,3 @@
1
- /**
2
- * Logger utility for MCP servers
3
- *
4
- * MCP servers MUST use STDERR for all logging to avoid corrupting
5
- * the JSON-RPC protocol which uses STDOUT exclusively.
6
- *
7
- * This logger provides different log levels while ensuring all output
8
- * goes to STDERR (process.stderr.write or console.error).
9
- */
10
1
  export declare enum LogLevel {
11
2
  DEBUG = 0,
12
3
  INFO = 1,
@@ -14,10 +5,15 @@ export declare enum LogLevel {
14
5
  ERROR = 3,
15
6
  NONE = 4
16
7
  }
17
- declare class Logger {
8
+ export type LogFormat = 'text' | 'json';
9
+ export declare function parseLogLevel(value: string | undefined): LogLevel;
10
+ export declare function parseLogFormat(value: string | undefined): LogFormat;
11
+ export declare class Logger {
18
12
  private currentLevel;
19
- constructor(level?: LogLevel);
13
+ private format;
14
+ constructor(level?: LogLevel, format?: LogFormat);
20
15
  setLevel(level: LogLevel): void;
16
+ setFormat(format: LogFormat): void;
21
17
  /**
22
18
  * Debug messages for development and troubleshooting
23
19
  */
@@ -41,5 +37,4 @@ declare class Logger {
41
37
  private log;
42
38
  }
43
39
  export declare const logger: Logger;
44
- export {};
45
40
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,oBAAY,QAAQ;IAClB,KAAK,IAAI;IACT,IAAI,IAAI;IACR,IAAI,IAAI;IACR,KAAK,IAAI;IACT,IAAI,IAAI;CACT;AAED,cAAM,MAAM;IACV,OAAO,CAAC,YAAY,CAAW;gBAEnB,KAAK,GAA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AG,IAAI;IAIlC;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAMhD;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAM/C;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAM/C;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAMhD;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAMlD,OAAO,CAAC,GAAG;CA8BZ;AAGD,eAAO,MAAM,MAAM,QAGlB,CAAC"}
@@ -7,6 +7,7 @@
7
7
  * This logger provides different log levels while ensuring all output
8
8
  * goes to STDERR (process.stderr.write or console.error).
9
9
  */
10
+ import { getRequestContext } from './request-context.js';
10
11
  export var LogLevel;
11
12
  (function (LogLevel) {
12
13
  LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
@@ -15,20 +16,67 @@ export var LogLevel;
15
16
  LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
16
17
  LogLevel[LogLevel["NONE"] = 4] = "NONE";
17
18
  })(LogLevel || (LogLevel = {}));
18
- class Logger {
19
+ const LEVEL_NAMES = {
20
+ debug: '๐Ÿ” DEBUG',
21
+ info: 'โ„น๏ธ INFO',
22
+ warn: 'โš ๏ธ WARN',
23
+ error: 'โŒ ERROR',
24
+ success: 'โœ… SUCCESS',
25
+ };
26
+ export function parseLogLevel(value) {
27
+ if (value === undefined || value === '') {
28
+ return LogLevel.INFO;
29
+ }
30
+ const parsed = Number(value);
31
+ if (!Number.isInteger(parsed) || parsed < LogLevel.DEBUG || parsed > LogLevel.NONE) {
32
+ throw new TypeError('LOG_LEVEL must be an integer between 0 and 4');
33
+ }
34
+ return parsed;
35
+ }
36
+ export function parseLogFormat(value) {
37
+ const format = (value || 'text').toLowerCase();
38
+ if (format === 'text' || format === 'json') {
39
+ return format;
40
+ }
41
+ throw new TypeError('LOG_FORMAT must be either "text" or "json"');
42
+ }
43
+ function stringifyJson(value) {
44
+ const seen = new WeakSet();
45
+ return JSON.stringify(value, (_key, item) => {
46
+ if (item instanceof Error) {
47
+ return { name: item.name, message: item.message, stack: item.stack };
48
+ }
49
+ if (typeof item === 'bigint') {
50
+ return item.toString();
51
+ }
52
+ if (item !== null && typeof item === 'object') {
53
+ if (seen.has(item)) {
54
+ return '[Circular]';
55
+ }
56
+ seen.add(item);
57
+ }
58
+ return item;
59
+ });
60
+ }
61
+ export class Logger {
19
62
  currentLevel;
20
- constructor(level = LogLevel.INFO) {
63
+ format;
64
+ constructor(level = LogLevel.INFO, format = 'text') {
21
65
  this.currentLevel = level;
66
+ this.format = format;
22
67
  }
23
68
  setLevel(level) {
24
69
  this.currentLevel = level;
25
70
  }
71
+ setFormat(format) {
72
+ this.format = format;
73
+ }
26
74
  /**
27
75
  * Debug messages for development and troubleshooting
28
76
  */
29
77
  debug(message, ...args) {
30
78
  if (this.currentLevel <= LogLevel.DEBUG) {
31
- this.log('๐Ÿ” DEBUG', message, ...args);
79
+ this.log('debug', message, ...args);
32
80
  }
33
81
  }
34
82
  /**
@@ -36,7 +84,7 @@ class Logger {
36
84
  */
37
85
  info(message, ...args) {
38
86
  if (this.currentLevel <= LogLevel.INFO) {
39
- this.log('โ„น๏ธ INFO', message, ...args);
87
+ this.log('info', message, ...args);
40
88
  }
41
89
  }
42
90
  /**
@@ -44,7 +92,7 @@ class Logger {
44
92
  */
45
93
  warn(message, ...args) {
46
94
  if (this.currentLevel <= LogLevel.WARN) {
47
- this.log('โš ๏ธ WARN', message, ...args);
95
+ this.log('warn', message, ...args);
48
96
  }
49
97
  }
50
98
  /**
@@ -52,7 +100,7 @@ class Logger {
52
100
  */
53
101
  error(message, ...args) {
54
102
  if (this.currentLevel <= LogLevel.ERROR) {
55
- this.log('โŒ ERROR', message, ...args);
103
+ this.log('error', message, ...args);
56
104
  }
57
105
  }
58
106
  /**
@@ -60,14 +108,29 @@ class Logger {
60
108
  */
61
109
  success(message, ...args) {
62
110
  if (this.currentLevel <= LogLevel.INFO) {
63
- this.log('โœ… SUCCESS', message, ...args);
111
+ this.log('success', message, ...args);
64
112
  }
65
113
  }
66
- log(prefix, message, ...args) {
114
+ log(level, message, ...args) {
67
115
  // CRITICAL: Always use STDERR for MCP servers
68
116
  // STDOUT is reserved for JSON-RPC protocol only
69
117
  const timestamp = new Date().toISOString();
70
- const formattedMessage = `[${timestamp}] ${prefix}: ${message}`;
118
+ const context = getRequestContext();
119
+ if (this.format === 'json') {
120
+ console.error(stringifyJson({
121
+ timestamp,
122
+ level,
123
+ message,
124
+ ...(context && {
125
+ correlationId: context.correlationId,
126
+ ...(context.sessionId && { sessionId: context.sessionId }),
127
+ }),
128
+ ...(args.length > 0 && { details: args }),
129
+ }));
130
+ return;
131
+ }
132
+ const contextSuffix = context ? ` [request: ${context.correlationId}]` : '';
133
+ const formattedMessage = `[${timestamp}] ${LEVEL_NAMES[level]}: ${message}${contextSuffix}`;
71
134
  if (args.length > 0) {
72
135
  console.error(formattedMessage, ...args);
73
136
  }
@@ -77,5 +140,5 @@ class Logger {
77
140
  }
78
141
  }
79
142
  // Export singleton instance
80
- export const logger = new Logger(process.env.LOG_LEVEL ? Number.parseInt(process.env.LOG_LEVEL) : LogLevel.INFO);
143
+ export const logger = new Logger(parseLogLevel(process.env.LOG_LEVEL), parseLogFormat(process.env.LOG_FORMAT));
81
144
  //# sourceMappingURL=logger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,CAAN,IAAY,QAMX;AAND,WAAY,QAAQ;IAClB,yCA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,CAAC,CACH,CAAC;YACF,OAAO;QACT,CAAC;QAED,MAAM,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC,cAAc,OAAO,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5E,MAAM,gBAAgB,GAAG,IAAI,SAAS,KAAK,WAAW,CAAC,KAAK,CAAC,KAAK,OAAO,GAAG,aAAa,EAAE,CAAC;QAC5F,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,GAAG,IAAI,CAAC,CAAC;QAC3C,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;CACF;AAED,4BAA4B;AAC5B,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,MAAM,CAC9B,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EACpC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CACvC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export interface RequestContext {
2
+ correlationId: string;
3
+ sessionId?: string;
4
+ }
5
+ export declare function runWithRequestContext<T>(context: RequestContext, callback: () => T): T;
6
+ export declare function getRequestContext(): RequestContext | undefined;
7
+ //# sourceMappingURL=request-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-context.d.ts","sourceRoot":"","sources":["../../src/utils/request-context.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,MAAM,CAAC,GAChB,CAAC,CAEH;AAED,wBAAgB,iBAAiB,IAAI,cAAc,GAAG,SAAS,CAE9D"}
@@ -0,0 +1,9 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ const storage = new AsyncLocalStorage();
3
+ export function runWithRequestContext(context, callback) {
4
+ return storage.run(context, callback);
5
+ }
6
+ export function getRequestContext() {
7
+ return storage.getStore();
8
+ }
9
+ //# sourceMappingURL=request-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-context.js","sourceRoot":"","sources":["../../src/utils/request-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAOrD,MAAM,OAAO,GAAG,IAAI,iBAAiB,EAAkB,CAAC;AAExD,MAAM,UAAU,qBAAqB,CACnC,OAAuB,EACvB,QAAiB;IAEjB,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC;AAC5B,CAAC"}
package/docs/LOGGING.md CHANGED
@@ -64,6 +64,18 @@ All log messages include timestamps and clear prefixes:
64
64
  [2025-11-15T10:30:47.345Z] โŒ ERROR: Failed to connect to API
65
65
  ```
66
66
 
67
+ Set `LOG_FORMAT=json` for machine-readable logs:
68
+
69
+ ```json
70
+ {"timestamp":"2026-07-09T18:00:00.000Z","level":"info","message":"MCP mutation tool completed","correlationId":"request-123","details":[{"event":"mcp_tool_mutation","tool":"update_card","outcome":"success","durationMs":42,"identifiers":{"card_id":123}}]}
71
+ ```
72
+
73
+ HTTP requests accept an optional `x-request-id` header and echo it in the
74
+ response. Invalid or missing IDs are replaced with a UUID. The same correlation
75
+ ID is propagated to BusinessMap API calls and included in logs. Mutation audit
76
+ events contain tool names and numeric identifiers only; free-form card content,
77
+ comments, descriptions, email addresses, and credentials are not logged.
78
+
67
79
  ## Configuration
68
80
 
69
81
  Set the `LOG_LEVEL` environment variable to control verbosity:
@@ -85,6 +97,9 @@ LOG_LEVEL=3 npx @edicarlos.lds/businessmap-mcp
85
97
  LOG_LEVEL=4 npx @edicarlos.lds/businessmap-mcp
86
98
  ```
87
99
 
100
+ Use `LOG_FORMAT=text` (default) for human-readable output or
101
+ `LOG_FORMAT=json` for log aggregation systems.
102
+
88
103
  ### In Claude Desktop Config
89
104
 
90
105
  ```json
@@ -18,7 +18,10 @@ You can import `startHttpServer` and launch the MCP server in HTTP mode programm
18
18
  import { startHttpServer } from '@edicarlos.lds/businessmap-mcp';
19
19
 
20
20
  // Start HTTP server with default options
21
- await startHttpServer();
21
+ const server = await startHttpServer();
22
+
23
+ // Close the listener and all MCP sessions during application shutdown
24
+ await server.shutdown();
22
25
  ```
23
26
 
24
27
  ---
@@ -38,8 +41,8 @@ const API_KEY = process.env.MCP_SERVER_KEY || 'your-secret-api-key';
38
41
  await startHttpServer({
39
42
  middlewares: [
40
43
  (req, res, next) => {
41
- // Allow health check to remain public
42
- if (req.path === '/health') {
44
+ // Allow orchestrator probes to remain public
45
+ if (req.path === '/health' || req.path === '/ready') {
43
46
  return next();
44
47
  }
45
48
 
@@ -67,7 +70,7 @@ const JWT_SECRET = process.env.JWT_SECRET!;
67
70
  await startHttpServer({
68
71
  middlewares: [
69
72
  (req, res, next) => {
70
- if (req.path === '/health') return next();
73
+ if (req.path === '/health' || req.path === '/ready') return next();
71
74
 
72
75
  const authHeader = req.headers['authorization'];
73
76
  if (!authHeader?.startsWith('Bearer ')) {
@@ -128,6 +131,25 @@ Middlewares are executed sequentially in the order they are passed in the `middl
128
131
 
129
132
  ---
130
133
 
134
+ ## HTTP Resource Limits
135
+
136
+ The standalone server supports `HTTP_BODY_LIMIT` (default `1mb`),
137
+ `HTTP_MAX_SESSIONS` (default `100`), and `HTTP_SESSION_TIMEOUT_MS` (default 30
138
+ minutes). Embedded applications can override them directly:
139
+
140
+ ```typescript
141
+ const server = await startHttpServer({
142
+ bodyLimit: '512kb',
143
+ maxSessions: 50,
144
+ sessionTimeoutMs: 15 * 60 * 1000,
145
+ });
146
+ ```
147
+
148
+ `GET /health` is a liveness probe. `GET /ready` returns `503` while the server
149
+ is shutting down or cannot accept another session.
150
+
151
+ ---
152
+
131
153
  ## ๐Ÿงช Testing Your Middleware
132
154
 
133
155
  You can test HTTP requests using `curl` or any API client (like Postman):
package/docs/TOOLS.md CHANGED
@@ -6,10 +6,15 @@ Complete reference for all tools, resources, and prompts provided by the Busines
6
6
 
7
7
  | Category | Count |
8
8
  | --------- | :---: |
9
- | Tools | 76 |
10
- | Resources | 5 |
9
+ | Tools | 92 |
10
+ | Resources | 6 |
11
11
  | Prompts | 4 |
12
12
 
13
+ The counts above describe the default `full` profile. Set
14
+ `BUSINESSMAP_TOOL_PROFILE=essential` to register a smaller catalog of common
15
+ workspace, board, card, docs, user, and health operations. Read-only mode is
16
+ applied independently and removes mutation tools from either profile.
17
+
13
18
  ---
14
19
 
15
20
  ## Tools
@@ -45,7 +50,7 @@ Complete reference for all tools, resources, and prompts provided by the Busines
45
50
 
46
51
  ---
47
52
 
48
- ### Card Management (42 tools)
53
+ ### Card Management (44 tools)
49
54
 
50
55
  #### Basic Operations
51
56
 
@@ -73,6 +78,12 @@ Complete reference for all tools, resources, and prompts provided by the Busines
73
78
  }
74
79
  ```
75
80
 
81
+ By default, `list_cards` keeps its legacy array response. Set
82
+ `include_pagination: true` to receive `{ data, pagination }`; use `page` and
83
+ `per_page` to select the requested page. Set `compact: true` on `list_cards` or
84
+ `search_cards` to return only identifiers, placement, ownership, status, and
85
+ planning fields.
86
+
76
87
  #### Comments
77
88
 
78
89
  | Tool | Description | Read-Only Safe |
@@ -98,6 +109,7 @@ Complete reference for all tools, resources, and prompts provided by the Busines
98
109
  | `get_card_flow_history` | Get the card's movement (transitions) across workflows/columns with timing | โœ… |
99
110
  | `get_card_blocked_times` | Get the full blocking history of a card | โœ… |
100
111
  | `get_card_logged_time` | Get time logged on a card and its subtasks, with individual entries | โœ… |
112
+ | `get_card_revisions` | Get the chronological change history (revisions) of a card; pass a revision number for the full card state at that point | โœ… |
101
113
 
102
114
  #### Relationships
103
115
 
@@ -123,6 +135,7 @@ Complete reference for all tools, resources, and prompts provided by the Busines
123
135
  | `get_card_parent` | Check if a card is a parent of a given card | โœ… |
124
136
  | `get_card_parent_graph` | Get parent cards including their parents (full graph) | โœ… |
125
137
  | `get_card_children` | Get a list of child cards of a specified parent card | โœ… |
138
+ | `get_card_child_graph` | Get the hierarchical graph of a card's children (children of children too) | โœ… |
126
139
  | `add_card_parent` | Make a card a parent of a given card | โŒ |
127
140
  | `remove_card_parent` | Remove the link between a child card and a parent card | โŒ |
128
141
 
@@ -180,15 +193,36 @@ Complete reference for all tools, resources, and prompts provided by the Busines
180
193
 
181
194
  ---
182
195
 
183
- ### Quick Setup โ€” Batch (2 tools)
196
+ ### Quick Setup โ€” Batch (3 tools)
184
197
 
185
- | Tool | Description | Read-Only Safe |
186
- | :--------------------------- | :------------------------------------------------------------------------------------------------------ | :------------: |
187
- | `create_boards_in_workspace` | Create up to 3 boards with their full structure (workflows, renamed default columns, columns, lanes) in one call | โŒ |
198
+ | Tool | Description | Read-Only Safe |
199
+ | :----------------------------- | :------------------------------------------------------------------------------------------------------ | :------------: |
200
+ | `create_workspaces_and_boards` | Create up to 3 workspaces together with their boards and full board structure in one call | โŒ |
201
+ | `create_boards_in_workspace` | Create up to 3 boards with their full structure (workflows, renamed default columns, columns, lanes) in one call | โŒ |
188
202
  | `configure_board_structure` | Configure an existing board's structure in one call: create/rename workflows, rename built-in columns, add columns and lanes | โŒ |
189
203
 
190
204
  ---
191
205
 
206
+ ### Docs (13 tools)
207
+
208
+ | Tool | Description | Read-Only Safe |
209
+ | :-------------------------- | :------------------------------------------------------------------------------------------------------- | :------------: |
210
+ | `search_docs` | Search docs by title (case-insensitive substring), optionally including archived and personal docs | โœ… |
211
+ | `get_docs_text_title_search`| Search docs by title AND content, returning matches with content snippets | โœ… |
212
+ | `get_doc_hierarchy` | Get the hierarchical parent/child tree of docs, optionally rooted at a specific doc | โœ… |
213
+ | `list_docs` | Get a list of docs (metadata only) with filters (ids, title, archived, important, parent) | โœ… |
214
+ | `list_personal_docs` | Get a list of your personal docs (metadata only) | โœ… |
215
+ | `get_doc_content_batch` | Get the full details (including content) of up to 20 docs in one call (shared or personal) | โœ… |
216
+ | `get_docs_for_boards_batch` | Get the docs pinned to each of up to 10 boards in one call | โœ… |
217
+ | `create_doc` | Create a new doc, optionally as a child of another doc | โŒ |
218
+ | `update_doc` | Update the title, content, position, or parent of an existing doc | โŒ |
219
+ | `archive_doc` | Archive a doc | โŒ |
220
+ | `unarchive_doc` | Restore an archived doc | โŒ |
221
+ | `create_personal_doc` | Create a new personal doc (visible only to you) | โŒ |
222
+ | `update_personal_doc` | Update the title, content, or position of an existing personal doc | โŒ |
223
+
224
+ ---
225
+
192
226
  ### User Management (4 tools)
193
227
 
194
228
  | Tool | Description | Read-Only Safe |
@@ -219,6 +253,7 @@ MCP resources provide structured data access via URI. Clients can read resources
219
253
  | `businessmap://boards` | `boards` | List all boards | โœ… |
220
254
  | `businessmap://boards/{board_id}` | `board` | Get details of a specific board | โŒ |
221
255
  | `businessmap://boards/{board_id}/cards` | `cards` | List all cards for a specific board | โœ… |
256
+ | `businessmap://boards/{board_id}/cards/pages/{page}/size/{per_page}` | `card-page` | Read a bounded card page (maximum 100) | โŒ |
222
257
  | `businessmap://cards/{card_id}` | `card` | Get details of a specific card | โŒ |
223
258
 
224
259
  ---
@@ -313,4 +348,4 @@ When `BUSINESSMAP_READ_ONLY_MODE=true`, only tools marked โœ… in the "Read-Only
313
348
  - Granting read-only access to AI assistants
314
349
  - Auditing and reporting use cases
315
350
 
316
- > Note: All 5 resources and all 4 prompts are available regardless of read-only mode setting.
351
+ > Note: All 6 resources and all 4 prompts are available regardless of read-only mode setting.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edicarlos.lds/businessmap-mcp",
3
- "version": "2.3.0",
3
+ "version": "3.1.0",
4
4
  "description": "Model Context Protocol server for BusinessMap (Kanbanize) integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -11,6 +11,8 @@
11
11
  "dist",
12
12
  "docs",
13
13
  "README.md",
14
+ "CONTRIBUTING.md",
15
+ "SECURITY.md",
14
16
  "LICENSE"
15
17
  ],
16
18
  "scripts": {
@@ -20,6 +22,7 @@
20
22
  "dev": "tsx src/index.ts",
21
23
  "watch": "tsx --watch src/index.ts",
22
24
  "test": "jest",
25
+ "test:coverage": "jest --coverage --runInBand",
23
26
  "test:npx": "bash scripts/test-npx.sh",
24
27
  "publish:npm": "bash scripts/publish-npm.sh",
25
28
  "publish:github": "bash scripts/publish-github.sh",