vibe-coding-mcp 2.3.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.
- package/README.md +179 -0
- package/dist/__tests__/collectCodeContext.test.d.ts +2 -0
- package/dist/__tests__/collectCodeContext.test.d.ts.map +1 -0
- package/dist/__tests__/collectCodeContext.test.js +139 -0
- package/dist/__tests__/collectCodeContext.test.js.map +1 -0
- package/dist/__tests__/createSessionLog.test.d.ts +2 -0
- package/dist/__tests__/createSessionLog.test.d.ts.map +1 -0
- package/dist/__tests__/createSessionLog.test.js +130 -0
- package/dist/__tests__/createSessionLog.test.js.map +1 -0
- package/dist/__tests__/generateDevDocument.test.d.ts +2 -0
- package/dist/__tests__/generateDevDocument.test.d.ts.map +1 -0
- package/dist/__tests__/generateDevDocument.test.js +174 -0
- package/dist/__tests__/generateDevDocument.test.js.map +1 -0
- package/dist/__tests__/normalizeForPlatform.test.d.ts +2 -0
- package/dist/__tests__/normalizeForPlatform.test.d.ts.map +1 -0
- package/dist/__tests__/normalizeForPlatform.test.js +171 -0
- package/dist/__tests__/normalizeForPlatform.test.js.map +1 -0
- package/dist/__tests__/publishDocument.test.d.ts +2 -0
- package/dist/__tests__/publishDocument.test.d.ts.map +1 -0
- package/dist/__tests__/publishDocument.test.js +93 -0
- package/dist/__tests__/publishDocument.test.js.map +1 -0
- package/dist/__tests__/summarizeDesignDecisions.test.d.ts +2 -0
- package/dist/__tests__/summarizeDesignDecisions.test.d.ts.map +1 -0
- package/dist/__tests__/summarizeDesignDecisions.test.js +158 -0
- package/dist/__tests__/summarizeDesignDecisions.test.js.map +1 -0
- package/dist/core/cache.d.ts +39 -0
- package/dist/core/cache.d.ts.map +1 -0
- package/dist/core/cache.js +112 -0
- package/dist/core/cache.js.map +1 -0
- package/dist/core/config.d.ts +30 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +90 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/errors.d.ts +52 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +99 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/logger.d.ts +57 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +114 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/schemas.d.ts +690 -0
- package/dist/core/schemas.d.ts.map +1 -0
- package/dist/core/schemas.js +136 -0
- package/dist/core/schemas.js.map +1 -0
- package/dist/core/security.d.ts +28 -0
- package/dist/core/security.d.ts.map +1 -0
- package/dist/core/security.js +103 -0
- package/dist/core/security.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +168 -0
- package/dist/index.js.map +1 -0
- package/dist/platforms/confluence.d.ts +13 -0
- package/dist/platforms/confluence.d.ts.map +1 -0
- package/dist/platforms/confluence.js +178 -0
- package/dist/platforms/confluence.js.map +1 -0
- package/dist/platforms/discord.d.ts +54 -0
- package/dist/platforms/discord.d.ts.map +1 -0
- package/dist/platforms/discord.js +176 -0
- package/dist/platforms/discord.js.map +1 -0
- package/dist/platforms/github-wiki.d.ts +3 -0
- package/dist/platforms/github-wiki.d.ts.map +1 -0
- package/dist/platforms/github-wiki.js +120 -0
- package/dist/platforms/github-wiki.js.map +1 -0
- package/dist/platforms/notion.d.ts +3 -0
- package/dist/platforms/notion.d.ts.map +1 -0
- package/dist/platforms/notion.js +205 -0
- package/dist/platforms/notion.js.map +1 -0
- package/dist/platforms/obsidian.d.ts +3 -0
- package/dist/platforms/obsidian.d.ts.map +1 -0
- package/dist/platforms/obsidian.js +43 -0
- package/dist/platforms/obsidian.js.map +1 -0
- package/dist/platforms/slack.d.ts +21 -0
- package/dist/platforms/slack.d.ts.map +1 -0
- package/dist/platforms/slack.js +217 -0
- package/dist/platforms/slack.js.map +1 -0
- package/dist/stdio.d.ts +6 -0
- package/dist/stdio.d.ts.map +1 -0
- package/dist/stdio.js +98 -0
- package/dist/stdio.js.map +1 -0
- package/dist/tools/analyzeCode.d.ts +65 -0
- package/dist/tools/analyzeCode.d.ts.map +1 -0
- package/dist/tools/analyzeCode.js +113 -0
- package/dist/tools/analyzeCode.js.map +1 -0
- package/dist/tools/collectCodeContext.d.ts +86 -0
- package/dist/tools/collectCodeContext.d.ts.map +1 -0
- package/dist/tools/collectCodeContext.js +275 -0
- package/dist/tools/collectCodeContext.js.map +1 -0
- package/dist/tools/createSessionLog.d.ts +79 -0
- package/dist/tools/createSessionLog.d.ts.map +1 -0
- package/dist/tools/createSessionLog.js +160 -0
- package/dist/tools/createSessionLog.js.map +1 -0
- package/dist/tools/generateDevDocument.d.ts +216 -0
- package/dist/tools/generateDevDocument.d.ts.map +1 -0
- package/dist/tools/generateDevDocument.js +659 -0
- package/dist/tools/generateDevDocument.js.map +1 -0
- package/dist/tools/normalizeForPlatform.d.ts +95 -0
- package/dist/tools/normalizeForPlatform.d.ts.map +1 -0
- package/dist/tools/normalizeForPlatform.js +340 -0
- package/dist/tools/normalizeForPlatform.js.map +1 -0
- package/dist/tools/publishDocument.d.ts +60 -0
- package/dist/tools/publishDocument.d.ts.map +1 -0
- package/dist/tools/publishDocument.js +117 -0
- package/dist/tools/publishDocument.js.map +1 -0
- package/dist/tools/summarizeDesignDecisions.d.ts +82 -0
- package/dist/tools/summarizeDesignDecisions.d.ts.map +1 -0
- package/dist/tools/summarizeDesignDecisions.js +361 -0
- package/dist/tools/summarizeDesignDecisions.js.map +1 -0
- package/dist/types/index.d.ts +63 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/astParser.d.ts +55 -0
- package/dist/utils/astParser.d.ts.map +1 -0
- package/dist/utils/astParser.js +333 -0
- package/dist/utils/astParser.js.map +1 -0
- package/dist/utils/i18n.d.ts +67 -0
- package/dist/utils/i18n.d.ts.map +1 -0
- package/dist/utils/i18n.js +193 -0
- package/dist/utils/i18n.js.map +1 -0
- package/dist/utils/markdown.d.ts +9 -0
- package/dist/utils/markdown.d.ts.map +1 -0
- package/dist/utils/markdown.js +99 -0
- package/dist/utils/markdown.js.map +1 -0
- package/dist/utils/mermaidGenerator.d.ts +69 -0
- package/dist/utils/mermaidGenerator.d.ts.map +1 -0
- package/dist/utils/mermaidGenerator.js +315 -0
- package/dist/utils/mermaidGenerator.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration validation and management
|
|
3
|
+
*/
|
|
4
|
+
export interface ConfigStatus {
|
|
5
|
+
platform: string;
|
|
6
|
+
configured: boolean;
|
|
7
|
+
missing: string[];
|
|
8
|
+
}
|
|
9
|
+
export interface ConfigValidationResult {
|
|
10
|
+
valid: boolean;
|
|
11
|
+
platforms: ConfigStatus[];
|
|
12
|
+
warnings: string[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Validates configuration for all platforms
|
|
16
|
+
*/
|
|
17
|
+
export declare function validateConfiguration(): ConfigValidationResult;
|
|
18
|
+
/**
|
|
19
|
+
* Logs configuration status on startup
|
|
20
|
+
*/
|
|
21
|
+
export declare function logConfigurationStatus(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Gets configuration status for a specific platform
|
|
24
|
+
*/
|
|
25
|
+
export declare function getPlatformConfig(platform: string): ConfigStatus | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if a platform is properly configured
|
|
28
|
+
*/
|
|
29
|
+
export declare function isPlatformConfigured(platform: string): boolean;
|
|
30
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAgCD;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,sBAAsB,CA6B9D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAe7C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAG5E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAG9D"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration validation and management
|
|
3
|
+
*/
|
|
4
|
+
import { logger } from './logger.js';
|
|
5
|
+
/**
|
|
6
|
+
* Platform configuration requirements
|
|
7
|
+
*/
|
|
8
|
+
const platformRequirements = {
|
|
9
|
+
notion: {
|
|
10
|
+
required: ['NOTION_API_KEY'],
|
|
11
|
+
optional: ['NOTION_DATABASE_ID']
|
|
12
|
+
},
|
|
13
|
+
'github-wiki': {
|
|
14
|
+
required: ['GITHUB_TOKEN', 'GITHUB_REPO'],
|
|
15
|
+
optional: []
|
|
16
|
+
},
|
|
17
|
+
obsidian: {
|
|
18
|
+
required: [],
|
|
19
|
+
optional: ['OBSIDIAN_VAULT_PATH']
|
|
20
|
+
},
|
|
21
|
+
confluence: {
|
|
22
|
+
required: ['CONFLUENCE_BASE_URL', 'CONFLUENCE_USERNAME', 'CONFLUENCE_API_TOKEN', 'CONFLUENCE_SPACE_KEY'],
|
|
23
|
+
optional: []
|
|
24
|
+
},
|
|
25
|
+
slack: {
|
|
26
|
+
required: [],
|
|
27
|
+
optional: ['SLACK_WEBHOOK_URL']
|
|
28
|
+
},
|
|
29
|
+
discord: {
|
|
30
|
+
required: [],
|
|
31
|
+
optional: ['DISCORD_WEBHOOK_URL']
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Validates configuration for all platforms
|
|
36
|
+
*/
|
|
37
|
+
export function validateConfiguration() {
|
|
38
|
+
const platforms = [];
|
|
39
|
+
const warnings = [];
|
|
40
|
+
for (const [platform, requirements] of Object.entries(platformRequirements)) {
|
|
41
|
+
const missing = [];
|
|
42
|
+
for (const envVar of requirements.required) {
|
|
43
|
+
if (!process.env[envVar]) {
|
|
44
|
+
missing.push(envVar);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const configured = missing.length === 0;
|
|
48
|
+
platforms.push({
|
|
49
|
+
platform,
|
|
50
|
+
configured,
|
|
51
|
+
missing
|
|
52
|
+
});
|
|
53
|
+
if (!configured && requirements.required.length > 0) {
|
|
54
|
+
warnings.push(`${platform}: Missing required env vars: ${missing.join(', ')}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const valid = platforms.some(p => p.configured);
|
|
58
|
+
return { valid, platforms, warnings };
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Logs configuration status on startup
|
|
62
|
+
*/
|
|
63
|
+
export function logConfigurationStatus() {
|
|
64
|
+
const result = validateConfiguration();
|
|
65
|
+
logger.info('Configuration validation complete', {
|
|
66
|
+
valid: result.valid,
|
|
67
|
+
configuredPlatforms: result.platforms.filter(p => p.configured).map(p => p.platform)
|
|
68
|
+
});
|
|
69
|
+
for (const warning of result.warnings) {
|
|
70
|
+
logger.warn(warning);
|
|
71
|
+
}
|
|
72
|
+
if (!result.valid) {
|
|
73
|
+
logger.warn('No platforms are fully configured. Some features may not work.');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Gets configuration status for a specific platform
|
|
78
|
+
*/
|
|
79
|
+
export function getPlatformConfig(platform) {
|
|
80
|
+
const result = validateConfiguration();
|
|
81
|
+
return result.platforms.find(p => p.platform === platform);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Checks if a platform is properly configured
|
|
85
|
+
*/
|
|
86
|
+
export function isPlatformConfigured(platform) {
|
|
87
|
+
const config = getPlatformConfig(platform);
|
|
88
|
+
return config?.configured ?? false;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAcrC;;GAEG;AACH,MAAM,oBAAoB,GAA+D;IACvF,MAAM,EAAE;QACN,QAAQ,EAAE,CAAC,gBAAgB,CAAC;QAC5B,QAAQ,EAAE,CAAC,oBAAoB,CAAC;KACjC;IACD,aAAa,EAAE;QACb,QAAQ,EAAE,CAAC,cAAc,EAAE,aAAa,CAAC;QACzC,QAAQ,EAAE,EAAE;KACb;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,CAAC,qBAAqB,CAAC;KAClC;IACD,UAAU,EAAE;QACV,QAAQ,EAAE,CAAC,qBAAqB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,sBAAsB,CAAC;QACxG,QAAQ,EAAE,EAAE;KACb;IACD,KAAK,EAAE;QACL,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,CAAC,mBAAmB,CAAC;KAChC;IACD,OAAO,EAAE;QACP,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,CAAC,qBAAqB,CAAC;KAClC;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACnC,MAAM,SAAS,GAAmB,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,KAAK,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,CAAC;QAC5E,MAAM,OAAO,GAAa,EAAE,CAAC;QAE7B,KAAK,MAAM,MAAM,IAAI,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AAM,CAAC,IAAI,CAAC,gEAAgE,CAAC,CAAC;IAChF,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAgB;IAChD,MAAM,MAAM,GAAG,qBAAqB,EAAE,CAAC;IACvC,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;AAC7D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACnD,MAAM,MAAM,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC3C,OAAO,MAAM,EAAE,UAAU,IAAI,KAAK,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error classes for structured error handling
|
|
3
|
+
*/
|
|
4
|
+
export type ErrorCode = 'VALIDATION_ERROR' | 'PLATFORM_ERROR' | 'NETWORK_ERROR' | 'AUTH_ERROR' | 'NOT_FOUND' | 'RATE_LIMIT' | 'INTERNAL_ERROR' | 'PARSE_ERROR' | 'TIMEOUT';
|
|
5
|
+
export interface ErrorContext {
|
|
6
|
+
tool?: string;
|
|
7
|
+
platform?: string;
|
|
8
|
+
input?: Record<string, unknown>;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
export declare class ToolError extends Error {
|
|
12
|
+
readonly code: ErrorCode;
|
|
13
|
+
readonly context?: ErrorContext;
|
|
14
|
+
readonly cause?: Error;
|
|
15
|
+
readonly timestamp: string;
|
|
16
|
+
constructor(message: string, code: ErrorCode, context?: ErrorContext, cause?: Error);
|
|
17
|
+
toJSON(): Record<string, unknown>;
|
|
18
|
+
static fromError(error: unknown, code?: ErrorCode, context?: ErrorContext): ToolError;
|
|
19
|
+
}
|
|
20
|
+
export declare class ValidationError extends ToolError {
|
|
21
|
+
readonly field?: string;
|
|
22
|
+
readonly expected?: string;
|
|
23
|
+
readonly received?: string;
|
|
24
|
+
constructor(message: string, field?: string, expected?: string, received?: string, context?: ErrorContext);
|
|
25
|
+
}
|
|
26
|
+
export declare class PlatformError extends ToolError {
|
|
27
|
+
readonly platform: string;
|
|
28
|
+
readonly statusCode?: number;
|
|
29
|
+
constructor(message: string, platform: string, statusCode?: number, context?: ErrorContext, cause?: Error);
|
|
30
|
+
}
|
|
31
|
+
export declare class AuthError extends ToolError {
|
|
32
|
+
constructor(message: string, context?: ErrorContext, cause?: Error);
|
|
33
|
+
}
|
|
34
|
+
export declare class RateLimitError extends ToolError {
|
|
35
|
+
readonly retryAfter?: number;
|
|
36
|
+
constructor(message: string, retryAfter?: number, context?: ErrorContext);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Wraps async function with error handling
|
|
40
|
+
*/
|
|
41
|
+
export declare function withErrorHandling<T extends (...args: unknown[]) => Promise<unknown>>(fn: T, toolName: string): T;
|
|
42
|
+
/**
|
|
43
|
+
* Creates a standardized error response for MCP
|
|
44
|
+
*/
|
|
45
|
+
export declare function createErrorResponse(error: unknown): {
|
|
46
|
+
content: Array<{
|
|
47
|
+
type: 'text';
|
|
48
|
+
text: string;
|
|
49
|
+
}>;
|
|
50
|
+
isError: true;
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,SAAS,GACjB,kBAAkB,GAClB,gBAAgB,GAChB,eAAe,GACf,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,gBAAgB,GAChB,aAAa,GACb,SAAS,CAAC;AAEd,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAA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CAAC,EAAE,KAAK;CAInE;AAED,qBAAa,cAAe,SAAQ,SAAS;IAC3C,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;gBAExB,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAKzE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,EAClF,EAAE,EAAE,CAAC,EACL,QAAQ,EAAE,MAAM,GACf,CAAC,CAQH;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG;IACnD,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,OAAO,EAAE,IAAI,CAAC;CACf,CASA"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error classes for structured error handling
|
|
3
|
+
*/
|
|
4
|
+
export class ToolError extends Error {
|
|
5
|
+
code;
|
|
6
|
+
context;
|
|
7
|
+
cause;
|
|
8
|
+
timestamp;
|
|
9
|
+
constructor(message, code, context, cause) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = 'ToolError';
|
|
12
|
+
this.code = code;
|
|
13
|
+
this.context = context;
|
|
14
|
+
this.cause = cause;
|
|
15
|
+
this.timestamp = new Date().toISOString();
|
|
16
|
+
// Maintains proper stack trace for where error was thrown
|
|
17
|
+
Error.captureStackTrace?.(this, ToolError);
|
|
18
|
+
}
|
|
19
|
+
toJSON() {
|
|
20
|
+
return {
|
|
21
|
+
name: this.name,
|
|
22
|
+
message: this.message,
|
|
23
|
+
code: this.code,
|
|
24
|
+
context: this.context,
|
|
25
|
+
timestamp: this.timestamp,
|
|
26
|
+
cause: this.cause?.message
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
static fromError(error, code = 'INTERNAL_ERROR', context) {
|
|
30
|
+
if (error instanceof ToolError) {
|
|
31
|
+
return error;
|
|
32
|
+
}
|
|
33
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
34
|
+
const cause = error instanceof Error ? error : undefined;
|
|
35
|
+
return new ToolError(message, code, context, cause);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export class ValidationError extends ToolError {
|
|
39
|
+
field;
|
|
40
|
+
expected;
|
|
41
|
+
received;
|
|
42
|
+
constructor(message, field, expected, received, context) {
|
|
43
|
+
super(message, 'VALIDATION_ERROR', { ...context, field, expected, received });
|
|
44
|
+
this.name = 'ValidationError';
|
|
45
|
+
this.field = field;
|
|
46
|
+
this.expected = expected;
|
|
47
|
+
this.received = received;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export class PlatformError extends ToolError {
|
|
51
|
+
platform;
|
|
52
|
+
statusCode;
|
|
53
|
+
constructor(message, platform, statusCode, context, cause) {
|
|
54
|
+
super(message, 'PLATFORM_ERROR', { ...context, platform, statusCode }, cause);
|
|
55
|
+
this.name = 'PlatformError';
|
|
56
|
+
this.platform = platform;
|
|
57
|
+
this.statusCode = statusCode;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export class AuthError extends ToolError {
|
|
61
|
+
constructor(message, context, cause) {
|
|
62
|
+
super(message, 'AUTH_ERROR', context, cause);
|
|
63
|
+
this.name = 'AuthError';
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export class RateLimitError extends ToolError {
|
|
67
|
+
retryAfter;
|
|
68
|
+
constructor(message, retryAfter, context) {
|
|
69
|
+
super(message, 'RATE_LIMIT', { ...context, retryAfter });
|
|
70
|
+
this.name = 'RateLimitError';
|
|
71
|
+
this.retryAfter = retryAfter;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Wraps async function with error handling
|
|
76
|
+
*/
|
|
77
|
+
export function withErrorHandling(fn, toolName) {
|
|
78
|
+
return (async (...args) => {
|
|
79
|
+
try {
|
|
80
|
+
return await fn(...args);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
throw ToolError.fromError(error, 'INTERNAL_ERROR', { tool: toolName });
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Creates a standardized error response for MCP
|
|
89
|
+
*/
|
|
90
|
+
export function createErrorResponse(error) {
|
|
91
|
+
const toolError = error instanceof ToolError
|
|
92
|
+
? error
|
|
93
|
+
: ToolError.fromError(error);
|
|
94
|
+
return {
|
|
95
|
+
content: [{ type: 'text', text: JSON.stringify(toolError.toJSON(), null, 2) }],
|
|
96
|
+
isError: true
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAoBH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAClB,IAAI,CAAY;IAChB,OAAO,CAAgB;IACvB,KAAK,CAAS;IACd,SAAS,CAAS;IAElC,YACE,OAAe,EACf,IAAe,EACf,OAAsB,EACtB,KAAa;QAEb,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAE1C,0DAA0D;QAC1D,KAAK,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;Y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;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAIhD,MAAM,SAAS,GAAG,KAAK,YAAY,SAAS;QAC1C,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAE/B,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;QAC9E,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured logging utility for MCP server
|
|
3
|
+
*/
|
|
4
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
5
|
+
export interface LogContext {
|
|
6
|
+
tool?: string;
|
|
7
|
+
platform?: string;
|
|
8
|
+
sessionId?: string;
|
|
9
|
+
requestId?: string;
|
|
10
|
+
duration?: number;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
}
|
|
13
|
+
export interface LogEntry {
|
|
14
|
+
timestamp: string;
|
|
15
|
+
level: LogLevel;
|
|
16
|
+
message: string;
|
|
17
|
+
context?: LogContext;
|
|
18
|
+
error?: {
|
|
19
|
+
name: string;
|
|
20
|
+
message: string;
|
|
21
|
+
stack?: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
declare class Logger {
|
|
25
|
+
private minLevel;
|
|
26
|
+
private static levelPriority;
|
|
27
|
+
setLevel(level: LogLevel): void;
|
|
28
|
+
private shouldLog;
|
|
29
|
+
private formatEntry;
|
|
30
|
+
private log;
|
|
31
|
+
debug(message: string, context?: LogContext): void;
|
|
32
|
+
info(message: string, context?: LogContext): void;
|
|
33
|
+
warn(message: string, context?: LogContext): void;
|
|
34
|
+
error(message: string, error?: Error, context?: LogContext): void;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a child logger with preset context
|
|
37
|
+
*/
|
|
38
|
+
child(defaultContext: LogContext): ChildLogger;
|
|
39
|
+
/**
|
|
40
|
+
* Measures and logs execution time
|
|
41
|
+
*/
|
|
42
|
+
time<T>(label: string, fn: () => Promise<T>, context?: LogContext): Promise<T>;
|
|
43
|
+
}
|
|
44
|
+
declare class ChildLogger {
|
|
45
|
+
private parent;
|
|
46
|
+
private defaultContext;
|
|
47
|
+
constructor(parent: Logger, defaultContext: LogContext);
|
|
48
|
+
private mergeContext;
|
|
49
|
+
debug(message: string, context?: LogContext): void;
|
|
50
|
+
info(message: string, context?: LogContext): void;
|
|
51
|
+
warn(message: string, context?: LogContext): void;
|
|
52
|
+
error(message: string, error?: Error, context?: LogContext): void;
|
|
53
|
+
}
|
|
54
|
+
export declare const logger: Logger;
|
|
55
|
+
export declare function createToolLogger(toolName: string): ChildLogger;
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3D,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,QAAQ,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,KAAK,CAAC,EA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EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI;IAIjD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI;CAGlE;AAGD,eAAO,MAAM,MAAM,QAAe,CAAC;AAGnC,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,CAE9D"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured logging utility for MCP server
|
|
3
|
+
*/
|
|
4
|
+
class Logger {
|
|
5
|
+
minLevel = 'info';
|
|
6
|
+
static levelPriority = {
|
|
7
|
+
debug: 0,
|
|
8
|
+
info: 1,
|
|
9
|
+
warn: 2,
|
|
10
|
+
error: 3
|
|
11
|
+
};
|
|
12
|
+
setLevel(level) {
|
|
13
|
+
this.minLevel = level;
|
|
14
|
+
}
|
|
15
|
+
shouldLog(level) {
|
|
16
|
+
return Logger.levelPriority[level] >= Logger.levelPriority[this.minLevel];
|
|
17
|
+
}
|
|
18
|
+
formatEntry(entry) {
|
|
19
|
+
return JSON.stringify(entry);
|
|
20
|
+
}
|
|
21
|
+
log(level, message, context, error) {
|
|
22
|
+
if (!this.shouldLog(level))
|
|
23
|
+
return;
|
|
24
|
+
const entry = {
|
|
25
|
+
timestamp: new Date().toISOString(),
|
|
26
|
+
level,
|
|
27
|
+
message,
|
|
28
|
+
context
|
|
29
|
+
};
|
|
30
|
+
if (error) {
|
|
31
|
+
entry.error = {
|
|
32
|
+
name: error.name,
|
|
33
|
+
message: error.message,
|
|
34
|
+
stack: error.stack
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const formatted = this.formatEntry(entry);
|
|
38
|
+
switch (level) {
|
|
39
|
+
case 'error':
|
|
40
|
+
console.error(formatted);
|
|
41
|
+
break;
|
|
42
|
+
case 'warn':
|
|
43
|
+
console.warn(formatted);
|
|
44
|
+
break;
|
|
45
|
+
default:
|
|
46
|
+
console.log(formatted);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
debug(message, context) {
|
|
50
|
+
this.log('debug', message, context);
|
|
51
|
+
}
|
|
52
|
+
info(message, context) {
|
|
53
|
+
this.log('info', message, context);
|
|
54
|
+
}
|
|
55
|
+
warn(message, context) {
|
|
56
|
+
this.log('warn', message, context);
|
|
57
|
+
}
|
|
58
|
+
error(message, error, context) {
|
|
59
|
+
this.log('error', message, context, error);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Creates a child logger with preset context
|
|
63
|
+
*/
|
|
64
|
+
child(defaultContext) {
|
|
65
|
+
return new ChildLogger(this, defaultContext);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Measures and logs execution time
|
|
69
|
+
*/
|
|
70
|
+
async time(label, fn, context) {
|
|
71
|
+
const start = Date.now();
|
|
72
|
+
try {
|
|
73
|
+
const result = await fn();
|
|
74
|
+
const duration = Date.now() - start;
|
|
75
|
+
this.info(`${label} completed`, { ...context, duration });
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
const duration = Date.now() - start;
|
|
80
|
+
this.error(`${label} failed`, error, { ...context, duration });
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
class ChildLogger {
|
|
86
|
+
parent;
|
|
87
|
+
defaultContext;
|
|
88
|
+
constructor(parent, defaultContext) {
|
|
89
|
+
this.parent = parent;
|
|
90
|
+
this.defaultContext = defaultContext;
|
|
91
|
+
}
|
|
92
|
+
mergeContext(context) {
|
|
93
|
+
return { ...this.defaultContext, ...context };
|
|
94
|
+
}
|
|
95
|
+
debug(message, context) {
|
|
96
|
+
this.parent.debug(message, this.mergeContext(context));
|
|
97
|
+
}
|
|
98
|
+
info(message, context) {
|
|
99
|
+
this.parent.info(message, this.mergeContext(context));
|
|
100
|
+
}
|
|
101
|
+
warn(message, context) {
|
|
102
|
+
this.parent.warn(message, this.mergeContext(context));
|
|
103
|
+
}
|
|
104
|
+
error(message, error, context) {
|
|
105
|
+
this.parent.error(message, error, this.mergeContext(context));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Singleton instance
|
|
109
|
+
export const logger = new Logger();
|
|
110
|
+
// Convenience function to create tool-specific logger
|
|
111
|
+
export function createToolLogger(toolName) {
|
|
112
|
+
return logger.child({ tool: toolName });
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAyBH,MAAM,MAAM;IACF,QAAQ,GAAa,MAAM,CAAC;IAC5B,MAAM,CAAC,aAAa,GAA6B;QACvD,KAAK,EAAE,CAAC;QACR,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,CAAC;KACT,CAAC;IAEF,QAAQ,CAAC,KAAe;QACtB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;IACxB,CAAC;IAEO,SAAS,CAAC,KAAe;QAC/B,OAAO,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5E,CAAC;IAEO,WAAW,CAAC,KAAe;QACjC,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAEO,GAAG,CAAC,KAAe,EAAE,OAAe,EAAE,OAAoB,EAAE,KAAa;QAC/E,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;YAAE,OAAO;QAEnC,MAAM,KAAK,GAAa;YACtB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,KAAK;YACL,OAAO;YACP,OAAO;SACR,CAAC;QAEF,IAAI,KAAK,EAAE,CAAC;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