codex-review-mcp 2.2.0 → 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.
@@ -22,7 +22,8 @@ server.registerTool('get_version', {
22
22
  type: 'text',
23
23
  text: `codex-review-mcp version ${VERSION}`,
24
24
  mimeType: 'text/plain'
25
- }]
25
+ }],
26
+ _meta: { version: VERSION }
26
27
  };
27
28
  });
28
29
  server.registerTool('perform_code_review', {
@@ -93,28 +94,55 @@ server.registerTool('perform_code_review', {
93
94
  }, extra?.requestId ? { relatedRequestId: extra.requestId } : undefined);
94
95
  };
95
96
  const markdown = await performCodeReview(reviewInput, onProgress);
96
- return { content: [{ type: 'text', text: markdown, mimeType: 'text/markdown' }] };
97
+ return {
98
+ content: [{ type: 'text', text: markdown, mimeType: 'text/markdown' }],
99
+ _meta: { version: VERSION }
100
+ };
97
101
  }
98
102
  catch (error) {
99
103
  const errorMessage = error?.message || String(error);
104
+ const errorStack = error?.stack || '';
105
+ // Log detailed error to stderr for MCP logs
106
+ console.error(`[codex-review-mcp v${VERSION}] Tool error:`, errorMessage);
107
+ if (errorStack) {
108
+ console.error('[codex-review-mcp] Stack trace:', errorStack);
109
+ }
100
110
  return {
101
111
  content: [{
102
112
  type: 'text',
103
- text: `❌ Code Review Failed\n\n${errorMessage}`,
113
+ text: `❌ Code Review Failed\n\n**Error:** ${errorMessage}\n\n**Version:** ${VERSION}\n\nCheck MCP server logs for details.`,
104
114
  mimeType: 'text/markdown'
105
115
  }],
106
- isError: true
116
+ isError: true,
117
+ _meta: { version: VERSION, error: errorMessage }
107
118
  };
108
119
  }
109
120
  });
110
- // Global error handlers to prevent server crashes
121
+ // Global error handlers to prevent server crashes and inform users
111
122
  process.on('unhandledRejection', (reason, promise) => {
112
- console.error('[codex-review-mcp] Unhandled Rejection at:', promise, 'reason:', reason);
123
+ const errorMsg = reason instanceof Error ? reason.message : String(reason);
124
+ const errorStack = reason instanceof Error ? reason.stack : '';
125
+ console.error(`[codex-review-mcp v${VERSION}] ⚠️ UNHANDLED REJECTION`);
126
+ console.error(`[codex-review-mcp] Reason:`, errorMsg);
127
+ if (errorStack) {
128
+ console.error(`[codex-review-mcp] Stack:`, errorStack);
129
+ }
130
+ console.error(`[codex-review-mcp] Promise:`, promise);
131
+ console.error(`[codex-review-mcp] Server will continue running, but this indicates a bug that should be fixed.`);
113
132
  // Don't exit - let the server continue running
114
133
  });
115
134
  process.on('uncaughtException', (error) => {
116
- console.error('[codex-review-mcp] Uncaught Exception:', error);
135
+ console.error(`[codex-review-mcp v${VERSION}] ⚠️ UNCAUGHT EXCEPTION`);
136
+ console.error(`[codex-review-mcp] Error:`, error.message);
137
+ console.error(`[codex-review-mcp] Stack:`, error.stack);
138
+ console.error(`[codex-review-mcp] Server will continue running, but this indicates a serious bug.`);
117
139
  // Don't exit - let the server continue running
118
140
  });
141
+ // Log startup information
142
+ console.error(`[codex-review-mcp v${VERSION}] Starting server...`);
143
+ console.error(`[codex-review-mcp] Node version: ${process.version}`);
144
+ console.error(`[codex-review-mcp] Platform: ${process.platform}`);
119
145
  const transport = new StdioServerTransport();
120
146
  await server.connect(transport);
147
+ console.error(`[codex-review-mcp v${VERSION}] ✅ Server started successfully`);
148
+ console.error(`[codex-review-mcp] Ready to accept tool requests`);
@@ -5,44 +5,26 @@ export function buildPrompt({ diffText, context, focus, version, isStaticReview
5
5
  return [
6
6
  versionLine,
7
7
  '',
8
- 'You are an expert AI code reviewer. Be concise, specific, and actionable.',
9
- 'Prefer minimal diffs and direct fixes.',
8
+ 'You are an expert React and GraphQL code reviewer. Be concise, specific, and actionable.',
10
9
  '',
11
- 'ENVIRONMENT ASSUMPTION: The runtime and tooling are POSIX (macOS/Linux). Do NOT suggest Windows/PowerShell/cmd-specific commands or paths.',
10
+ 'PRIORITY HIERARCHY:',
11
+ '1. Project documentation (.cursor/rules/*, CODE_REVIEW.md, CONTRIBUTING.md)',
12
+ '2. Config files (tsconfig.json, .eslintrc, prettier)',
13
+ '3. Existing patterns in the same directory/module',
14
+ '4. General best practices (only when not conflicting above)',
12
15
  '',
13
- '🚨 CRITICAL REPO-SPECIFIC GUIDANCE HIERARCHY:',
14
- '1. HIGHEST PRIORITY: Project documentation (.cursor/rules/*, CODE_REVIEW.md, CONTRIBUTING.md, etc.)',
15
- '2. Configuration files (tsconfig.json, .eslintrc, prettier config, etc.)',
16
- '3. Existing patterns in similar files within the same directory',
17
- '4. General best practices (ONLY when not conflicting with above)',
18
- '',
19
- 'MANDATORY REVIEW REQUIREMENTS:',
20
- '- 🔍 EXAMINE existing code patterns in the same directory/module before suggesting changes',
21
- '- 📚 CHECK for existing utility functions, abstractions, and helpers before creating new ones',
22
- '- 🎯 FOLLOW the exact naming conventions, file structure, and import patterns used in this repo',
23
- '- 🧪 MATCH existing test patterns and testing approaches when reviewing test files',
24
- '- ⚙️ VALIDATE against linting and formatting rules defined in the project config',
25
- '- 🚫 NEVER suggest patterns that are inconsistent with the existing codebase',
26
- '- 🚫 NEVER introduce external libraries/patterns not already in use',
27
- '- ✅ PREFER reusing existing abstractions over creating new ones',
28
- '',
29
- 'SPECIFIC TECHNICAL GUIDELINES:',
30
- '- Follow ALL guidelines, conventions, and architectural patterns defined in the project documentation below',
31
- '- Maintain consistency with the existing codebase styling, naming conventions, and structural themes',
32
- '- Base your recommendations on the internal documentation, .cursor/rules files, and configuration files provided',
33
- '- Do NOT suggest changes that deviate from the project\'s established patterns or introduce external patterns',
34
- '- When project guidelines conflict with general best practices, prioritize the project guidelines',
35
- '- For accessibility audits: apply axe-core best practices and WCAG 2.1 Level AA guidelines',
36
- '- When reviewing accessibility audit results or configs: VERIFY the audit tool is configured for WCAG 2.1 Level AA only. FLAG if audits are misconfigured (using WCAG 2.2, Level AAA, or only Level A tags) as these will report violations that don\'t match the Axe browser extension defaults or project compliance requirements. Correct axe-core tags should be: ["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"].',
37
- '- CRITICAL Z-INDEX WARNING: Be extremely cautious with z-index changes on modals, overlays, or components. Analyze the entire z-index hierarchy before suggesting changes. Flag any z-index modifications as HIGH RISK and verify they won\'t break stacking context upstream or downstream. Always check for existing z-index patterns in the codebase first.',
38
- '- MATERIAL-UI/MUI SPACING: Use theme.spacing() for all margin, padding, and gap values instead of hardcoded px/rem/em values to avoid magic numbers (e.g., gap: theme.spacing(3) for 24px). Flag any hardcoded spacing values.',
16
+ 'CORE PRINCIPLES:',
17
+ '- Match existing patterns, naming, structure, and imports in this codebase',
18
+ '- Reuse existing utilities and abstractions; never introduce new ones unnecessarily',
19
+ '- Never suggest external libraries or patterns not already in use',
20
+ '- Validate against project linting and formatting rules',
21
+ '- When project guidelines conflict with best practices, follow the project',
39
22
  focusLine,
40
23
  '',
41
- 'BEFORE making ANY suggestion, ask yourself:',
42
- '1. Does this pattern already exist in the codebase? (Check similar files)',
43
- '2. Is there an existing utility/helper that could be reused?',
44
- '3. Does this follow the exact conventions shown in the project documentation?',
45
- '4. Would this change maintain consistency with the surrounding code?',
24
+ 'TECHNICAL REQUIREMENTS:',
25
+ '- Accessibility: WCAG 2.1 Level AA with tags ["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"]. Flag misconfigured audits using WCAG 2.2, AAA, or only Level A.',
26
+ '- Z-index: Flag as HIGH RISK. Check entire stacking context before suggesting changes.',
27
+ '- MUI spacing: Use theme.spacing() for margins/padding/gaps. Flag hardcoded px/rem/em values.',
46
28
  '',
47
29
  `\n---\n${reviewType}${isStaticReview ? ' - Code Files' : ' (unified=0)'}:\n`,
48
30
  diffText,
@@ -61,10 +61,10 @@ describe('buildPrompt', () => {
61
61
  diffText: mockDiff,
62
62
  });
63
63
  // Verify key sections are present
64
- expect(prompt).toContain('You are an expert AI code reviewer');
65
- expect(prompt).toContain('CRITICAL REPO-SPECIFIC GUIDANCE HIERARCHY');
66
- expect(prompt).toContain('MANDATORY REVIEW REQUIREMENTS');
67
- expect(prompt).toContain('SPECIFIC TECHNICAL GUIDELINES');
64
+ expect(prompt).toContain('You are an expert React and GraphQL code reviewer');
65
+ expect(prompt).toContain('PRIORITY HIERARCHY');
66
+ expect(prompt).toContain('CORE PRINCIPLES');
67
+ expect(prompt).toContain('TECHNICAL REQUIREMENTS');
68
68
  expect(prompt).toContain('Output strictly as Markdown with the following sections');
69
69
  });
70
70
  it('should include the diff text', () => {
@@ -87,27 +87,20 @@ describe('buildPrompt', () => {
87
87
  expect(prompt).toContain('TypeScript best practices');
88
88
  expect(prompt).toContain(mockDiff);
89
89
  });
90
- it('should include POSIX environment assumption', () => {
91
- const prompt = buildPrompt({
92
- diffText: mockDiff,
93
- });
94
- expect(prompt).toContain('ENVIRONMENT ASSUMPTION: The runtime and tooling are POSIX (macOS/Linux)');
95
- expect(prompt).toContain('Do NOT suggest Windows/PowerShell/cmd-specific commands');
96
- });
97
90
  it('should include z-index warning', () => {
98
91
  const prompt = buildPrompt({
99
92
  diffText: mockDiff,
100
93
  });
101
- expect(prompt).toContain('CRITICAL Z-INDEX WARNING');
102
- expect(prompt).toContain('z-index changes on modals, overlays, or components');
94
+ expect(prompt).toContain('Z-index: Flag as HIGH RISK');
95
+ expect(prompt).toContain('Check entire stacking context');
103
96
  });
104
97
  it('should include guidance hierarchy with proper priorities', () => {
105
98
  const prompt = buildPrompt({
106
99
  diffText: mockDiff,
107
100
  });
108
- expect(prompt).toContain('1. HIGHEST PRIORITY: Project documentation');
109
- expect(prompt).toContain('2. Configuration files');
110
- expect(prompt).toContain('3. Existing patterns in similar files');
101
+ expect(prompt).toContain('1. Project documentation');
102
+ expect(prompt).toContain('2. Config files');
103
+ expect(prompt).toContain('3. Existing patterns in the same directory/module');
111
104
  expect(prompt).toContain('4. General best practices');
112
105
  });
113
106
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-review-mcp",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "build": "tsc",