Skip to content

Conversation

@evereq
Copy link
Member

@evereq evereq commented Dec 19, 2025

PR

Please note: we will close your PR without comment if you do not check the boxes above and provide ALL requested information.



Summary by cubic

Decoupled mcp-server from @gauzy/auth and simplified type usage to stop TypeScript OOMs, speed up builds, and stabilize Docker builds. Added local auth, security, and error utilities, plus lightweight input schemas and a tool registration helper.

  • Refactors

    • Replaced @gauzy/auth imports with local modules (auth-types, security-logger, error-utils); updated middleware and transports.
    • Introduced input-schemas (simple enums) and tool-helper; updated all tools to use them and reduce Zod inference; added targeted ts-nocheck where needed.
    • Updated server bootstrap to the new MCP SDK init pattern and adjusted capability setup.
    • Added inline type stubs for csrf and session to avoid import resolution issues.
    • Pointed package main/types to dist; enabled skipLibCheck and excluded heavy schema from tsconfig; increased build memory via NODE_OPTIONS; set apps/mcp implicit dependency on mcp-server.
  • Bug Fixes

    • Switched postinstall.manual to use node instead of ts-node, fixing Docker build failures.
    • Unified error/log sanitization via local utilities in API client and auth manager.

Written for commit 9da1d7a. Summary will update automatically on new commits.

The postinstall.js script is plain JavaScript and doesn't require ts-node. This fixes the Docker build error where ts-node was not available to the node user.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 19, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch develop

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@evereq evereq merged commit c1ae5c2 into stage Dec 19, 2025
24 of 25 checks passed
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 19, 2025

Greptile Summary

This PR refactors the MCP server to resolve TypeScript compilation memory issues by removing the @gauzy/auth dependency and duplicating its utilities locally, and introducing a tool registration helper to bypass complex Zod type inference.

Key Changes

  • Removed @gauzy/auth dependency - Created local copies of auth types, error utilities, and security logging to avoid the complex dependency chain that caused TypeScript compilation performance issues
  • New tool-helper.ts - Introduced helper functions registerTool() and registerNoArgsTool() to bypass TypeScript's complex Zod type inference for 324+ tools by using type casting
  • Simplified input schemas - Replaced detailed Zod schemas with generic z.record(z.string(), z.any()) types to reduce compilation overhead
  • Added @ts-nocheck - Applied to 28 tool files to suppress type errors introduced by the refactoring
  • Increased Node memory - Build scripts now allocate 12GB (--max-old-space-size=12288) to handle compilation
  • Fixed postinstall script - Changed from ts-node to node for better compatibility

Critical Issues Found

  • tool-helper.ts uses wrong method name - Calls server.registerTool() instead of server.tool(), which will cause runtime failures when any tool is invoked
  • auth.ts incorrect function signature - The cleanup_sessions tool uses registerTool with empty schema instead of registerNoArgsTool
  • Widespread type suppression - Using @ts-nocheck on 28 files masks legitimate type errors that should be fixed

Impact

While this PR aims to solve TypeScript compilation issues, the critical bug in tool-helper.ts will break the entire MCP server at runtime. All 324+ tools will fail to register correctly.

Confidence Score: 0/5

  • This PR contains critical runtime bugs that will break the entire MCP server
  • Score reflects multiple critical issues: tool-helper.ts calls non-existent method server.registerTool() instead of server.tool(), which breaks all 324+ tool registrations; auth.ts has incorrect function call syntax; 28 files use @ts-nocheck masking type errors. While the architectural goal is sound (removing problematic dependency), the implementation has fundamental bugs that prevent the server from functioning.
  • Critical attention needed on packages/mcp-server/src/lib/tools/tool-helper.ts (wrong method name will break all tools) and packages/mcp-server/src/lib/tools/auth.ts (incorrect function signature)

Important Files Changed

Filename Overview
packages/mcp-server/src/lib/tools/tool-helper.ts new helper for tool registration with critical method name bug - uses server.registerTool() instead of server.tool()
packages/mcp-server/src/lib/tools/auth.ts refactored to use tool-helper with incorrect function call syntax on cleanup_sessions tool
packages/mcp-server/src/lib/common/auth-types.ts new file with local auth types to avoid @gauzy/auth dependency, includes OAuth validators and response builders
packages/mcp-server/src/lib/common/error-utils.ts new sanitization utilities for error messages and logging, properly redacts sensitive data
packages/mcp-server/src/lib/input-schemas.ts new simplified schemas using generic record types to avoid TypeScript type inference overhead
packages/mcp-server/src/lib/tools/tasks.ts refactored to use tool-helper and simplified schemas, uses @ts-nocheck to suppress type errors
packages/mcp-server/package.json removed @gauzy/auth dependency, increased Node memory allocation to 12GB for builds
packages/mcp-server/tsconfig.lib.json added skipLibCheck: true and excluded schema.ts file to improve compilation performance

Sequence Diagram

sequenceDiagram
    participant Client as MCP Client
    participant Server as MCP Server
    participant Helper as tool-helper.ts
    participant Auth as auth-types.ts
    participant ErrorUtil as error-utils.ts
    participant Security as security-logger.ts
    participant API as Gauzy API

    Note over Server,Helper: Refactored Architecture

    Client->>Server: Initialize MCP Server
    Server->>Server: createMcpServer()
    Note over Server: Changed constructor params<br/>to match SDK signature
    
    Server->>Helper: registerTool(name, desc, schema, callback)
    Note over Helper: CRITICAL ISSUE<br/>Uses incorrect method name<br/>server.registerTool vs server.tool
    Helper->>Server: Attempt tool registration
    
    Client->>Server: Invoke tool (e.g., login)
    Note over Server: May fail at runtime<br/>due to incorrect registration
    
    Server->>Auth: Extract and validate bearer
    Auth->>ErrorUtil: sanitizeErrorMessage()
    ErrorUtil-->>Auth: Cleaned error text
    
    Server->>Security: logSecurityEvent()
    Security->>Security: Store event in memory
    
    Server->>API: Make authenticated request
    API-->>Server: Response or error
    
    Server->>ErrorUtil: sanitizeForLogging()
    ErrorUtil-->>Server: Safe log data
    
    Server-->>Client: Tool execution result

    Note over Server,Helper: Removed external auth dependency<br/>Duplicated utilities locally<br/>Added type suppressions to files
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Comments (1)

  1. packages/mcp-server/src/lib/tools/auth.ts, line 487 (link)

    syntax: closing brace doesn't match function signature

47 files reviewed, 6 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +449 to +451
registerTool(
server,
'cleanup_sessions', 'Cleanup expired sessions and get session statistics', {}, async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: incorrect function call - should use registerNoArgsTool for tools with no parameters

registerTool expects 5 parameters (server, name, description, schema, callback) but here all arguments are being passed on one line. Since the schema is empty {}, this should use registerNoArgsTool instead:

Suggested change
registerTool(
server,
'cleanup_sessions', 'Cleanup expired sessions and get session statistics', {}, async () => {
registerNoArgsTool(
server,
'cleanup_sessions',
'Cleanup expired sessions and get session statistics',
async () => {

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/mcp-server/src/lib/tools/auth.ts
Line: 449:451

Comment:
**syntax:** incorrect function call - should use `registerNoArgsTool` for tools with no parameters

`registerTool` expects 5 parameters `(server, name, description, schema, callback)` but here all arguments are being passed on one line. Since the schema is empty `{}`, this should use `registerNoArgsTool` instead:

```suggestion
	registerNoArgsTool(
		server,
		'cleanup_sessions', 
		'Cleanup expired sessions and get session statistics', 
		async () => {
```

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +69 to +76
(server.registerTool as any)(
name,
{
description,
inputSchema: z.object(schema)
},
callback
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: using server.registerTool instead of server.tool

the MCP SDK method is server.tool(), not server.registerTool(). This will cause runtime errors.

Suggested change
(server.registerTool as any)(
name,
{
description,
inputSchema: z.object(schema)
},
callback
);
(server.tool as any)(
name,
{
description,
inputSchema: z.object(schema)
},
callback
);
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/mcp-server/src/lib/tools/tool-helper.ts
Line: 69:76

Comment:
**logic:** using `server.registerTool` instead of `server.tool`

the MCP SDK method is `server.tool()`, not `server.registerTool()`. This will cause runtime errors.

```suggestion
	(server.tool as any)(
		name,
		{
			description,
			inputSchema: z.object(schema)
		},
		callback
	);
```

How can I resolve this? If you propose a fix, please make it concise.

description: string,
callback: () => Promise<ToolResult>
): void {
(server.registerTool as any)(name, { description }, callback);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: using server.registerTool instead of server.tool

the MCP SDK method is server.tool(), not server.registerTool(). This will cause runtime errors.

Suggested change
(server.registerTool as any)(name, { description }, callback);
(server.tool as any)(name, { description }, callback);
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/mcp-server/src/lib/tools/tool-helper.ts
Line: 93:93

Comment:
**logic:** using `server.registerTool` instead of `server.tool`

the MCP SDK method is `server.tool()`, not `server.registerTool()`. This will cause runtime errors.

```suggestion
	(server.tool as any)(name, { description }, callback);
```

How can I resolve this? If you propose a fix, please make it concise.

"strictBindCallApply": false,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": false
"noFallthroughCasesInSwitch": false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: using skipLibCheck: true hides type errors

while this helps with compilation performance, it masks type errors in node_modules and declaration files which could lead to runtime issues

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/mcp-server/tsconfig.lib.json
Line: 19:19

Comment:
**style:** using `skipLibCheck: true` hides type errors

while this helps with compilation performance, it masks type errors in node_modules and declaration files which could lead to runtime issues

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

@@ -1,15 +1,11 @@
// @ts-nocheck
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: @ts-nocheck disables all type checking for this entire file

this suppresses legitimate type errors throughout the file. Better to fix type issues individually or add targeted @ts-expect-error comments

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/mcp-server/src/lib/tools/tasks.ts
Line: 1:1

Comment:
**style:** `@ts-nocheck` disables all type checking for this entire file

this suppresses legitimate type errors throughout the file. Better to fix type issues individually or add targeted `@ts-expect-error` comments

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

13 issues found across 47 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/mcp-server/src/lib/tools/incomes.ts">

<violation number="1" location="packages/mcp-server/src/lib/tools/incomes.ts:273">
P2: Using `z.record(z.string(), z.any())` provides no meaningful validation - it accepts any arbitrary object. This weakens data validation and could allow unexpected/malicious fields to pass through to the API. Consider defining a proper schema with expected fields.</violation>
</file>

<file name="packages/mcp-server/src/lib/tools/goals.ts">

<violation number="1" location="packages/mcp-server/src/lib/tools/goals.ts:171">
P2: Inconsistent validation: `level` field uses `z.string()` instead of `GoalLevelEnum` which is used elsewhere in this file. This allows invalid level values to pass client-side validation, leading to confusing server-side errors.</violation>
</file>

<file name="packages/mcp-server/src/lib/tools/payments.ts">

<violation number="1" location="packages/mcp-server/src/lib/tools/payments.ts:1">
P1: Adding `// @ts-nocheck` disables TypeScript checking for the entire file, hiding potential type errors and bugs. This defeats the purpose of using TypeScript and can lead to runtime errors that would otherwise be caught at compile time. Consider fixing the underlying type issues instead of suppressing all checks.</violation>
</file>

<file name="packages/mcp-server/src/lib/tools/key-results.ts">

<violation number="1" location="packages/mcp-server/src/lib/tools/key-results.ts:163">
P2: `goalId` should use `.uuid()` validation for consistency with other tool definitions in this file (e.g., `get_key_results_by_goal` uses `z.string().uuid()`).</violation>
</file>

<file name="packages/mcp-server/src/lib/tools/comments.ts">

<violation number="1" location="packages/mcp-server/src/lib/tools/comments.ts:152">
P2: Missing `.uuid()` validation on `entityId`. Other tools in this file consistently validate `entityId` as UUID (e.g., `get_comments_by_entity`, `reply_to_comment`). This inconsistency could allow invalid entity IDs.</violation>
</file>

<file name="packages/mcp-server/src/lib/tools/invoices.ts">

<violation number="1" location="packages/mcp-server/src/lib/tools/invoices.ts:219">
P2: `z.record(z.string(), z.any())` provides no validation - it accepts any keys and values. Consider defining expected update fields with proper types, or at minimum use a more restrictive schema like `z.record(z.string(), z.unknown())` and validate on the server side.</violation>
</file>

<file name="packages/mcp-server/package.json">

<violation number="1" location="packages/mcp-server/package.json:20">
P2: The `main` and `types` paths use fragile relative paths (`../../../dist/...`) that traverse outside the package directory. This is inconsistent with other packages in the monorepo (e.g., `packages/common`, `packages/core`) which use `./src/index.js`. Consider keeping the same pattern or ensuring the build outputs to a local `dist/` folder within the package.</violation>
</file>

<file name="packages/mcp-server/src/lib/tools/daily-plan.ts">

<violation number="1" location="packages/mcp-server/src/lib/tools/daily-plan.ts:326">
P2: The `status` field should use `DailyPlanStatusEnum` instead of `z.string()` for proper validation. The enum is already imported and used elsewhere in this file for filtering.</violation>

<violation number="2" location="packages/mcp-server/src/lib/tools/daily-plan.ts:723">
P2: The `id` field should use `z.string().uuid()` for UUID validation to be consistent with other ID fields in this file and ensure valid UUIDs are passed.</violation>
</file>

<file name="packages/mcp-server/src/lib/tools/candidates.ts">

<violation number="1" location="packages/mcp-server/src/lib/tools/candidates.ts:171">
P1: Schema validation significantly weakened. Using `.passthrough()` allows any additional properties without validation. The userId field also lost its UUID validation. Consider maintaining proper schema validation to prevent invalid/malicious data from being submitted.</violation>

<violation number="2" location="packages/mcp-server/src/lib/tools/candidates.ts:208">
P1: Using `z.record(z.string(), z.any())` removes all meaningful validation for update data. Any key-value pairs will be accepted without type checking. This is a security concern and could allow invalid or malicious data to be passed to the API.</violation>
</file>

<file name="packages/mcp-server/src/lib/tools/products.ts">

<violation number="1" location="packages/mcp-server/src/lib/tools/products.ts:384">
P1: `z.record(z.string(), z.any())` provides no validation on the product data structure. This is extremely permissive and removes type safety for product updates. Consider using a proper schema (like `ProductInputSchema.partial()`) to validate the update payload.</violation>
</file>

<file name="packages/mcp-server/src/lib/tools/equipment.ts">

<violation number="1" location="packages/mcp-server/src/lib/tools/equipment.ts:1">
P1: Adding `// @ts-nocheck` disables TypeScript checking for the entire file. This hides potential type errors and reduces code quality. Consider fixing the underlying type issues instead of suppressing all type checking.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

{
id: z.string().uuid().describe('The income ID'),
income_data: IncomeSchemaFull.partial().describe('The data for updating the income')
income_data: z.record(z.string(), z.any()).describe('The data for updating the income')
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Using z.record(z.string(), z.any()) provides no meaningful validation - it accepts any arbitrary object. This weakens data validation and could allow unexpected/malicious fields to pass through to the API. Consider defining a proper schema with expected fields.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/mcp-server/src/lib/tools/incomes.ts, line 273:

<comment>Using `z.record(z.string(), z.any())` provides no meaningful validation - it accepts any arbitrary object. This weakens data validation and could allow unexpected/malicious fields to pass through to the API. Consider defining a proper schema with expected fields.</comment>

<file context>
@@ -255,12 +264,13 @@ export const registerIncomeTools = (server: McpServer) =&gt; {
 		{
 			id: z.string().uuid().describe(&#39;The income ID&#39;),
-			income_data: IncomeSchemaFull.partial().describe(&#39;The data for updating the income&#39;)
+			income_data: z.record(z.string(), z.any()).describe(&#39;The data for updating the income&#39;)
 		},
 		async ({ id, income_data }) =&gt; {
</file context>
Fix with Cubic

.object({
name: z.string().describe('The goal name (required)'),
deadline: z.string().describe('The deadline (required)'),
level: z.string().describe('The level (required)')
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Inconsistent validation: level field uses z.string() instead of GoalLevelEnum which is used elsewhere in this file. This allows invalid level values to pass client-side validation, leading to confusing server-side errors.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/mcp-server/src/lib/tools/goals.ts, line 171:

<comment>Inconsistent validation: `level` field uses `z.string()` instead of `GoalLevelEnum` which is used elsewhere in this file. This allows invalid level values to pass client-side validation, leading to confusing server-side errors.</comment>

<file context>
@@ -154,16 +159,18 @@ export const registerGoalTools = (server: McpServer) =&gt; {
+				.object({
+					name: z.string().describe(&#39;The goal name (required)&#39;),
+					deadline: z.string().describe(&#39;The deadline (required)&#39;),
+					level: z.string().describe(&#39;The level (required)&#39;)
 				})
+				.passthrough()
</file context>
Suggested change
level: z.string().describe('The level (required)')
level: GoalLevelEnum.describe('The level (required)')
Fix with Cubic

@@ -1,11 +1,13 @@
// @ts-nocheck
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Adding // @ts-nocheck disables TypeScript checking for the entire file, hiding potential type errors and bugs. This defeats the purpose of using TypeScript and can lead to runtime errors that would otherwise be caught at compile time. Consider fixing the underlying type issues instead of suppressing all checks.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/mcp-server/src/lib/tools/payments.ts, line 1:

<comment>Adding `// @ts-nocheck` disables TypeScript checking for the entire file, hiding potential type errors and bugs. This defeats the purpose of using TypeScript and can lead to runtime errors that would otherwise be caught at compile time. Consider fixing the underlying type issues instead of suppressing all checks.</comment>

<file context>
@@ -1,11 +1,13 @@
+// @ts-nocheck
 import { McpServer } from &#39;@modelcontextprotocol/sdk/server/mcp.js&#39;;
 import { Logger } from &#39;@nestjs/common&#39;;
</file context>
Fix with Cubic

key_result_data: z
.object({
name: z.string().describe('The key result name (required)'),
goalId: z.string().describe('The goal ID (required)'),
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: goalId should use .uuid() validation for consistency with other tool definitions in this file (e.g., get_key_results_by_goal uses z.string().uuid()).

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/mcp-server/src/lib/tools/key-results.ts, line 163:

<comment>`goalId` should use `.uuid()` validation for consistency with other tool definitions in this file (e.g., `get_key_results_by_goal` uses `z.string().uuid()`).</comment>

<file context>
@@ -147,16 +152,18 @@ export const registerKeyResultTools = (server: McpServer) =&gt; {
+			key_result_data: z
+				.object({
+					name: z.string().describe(&#39;The key result name (required)&#39;),
+					goalId: z.string().describe(&#39;The goal ID (required)&#39;),
+					deadline: z.string().describe(&#39;The deadline (required)&#39;)
 				})
</file context>
Suggested change
goalId: z.string().describe('The goal ID (required)'),
goalId: z.string().uuid().describe('The goal ID (required)'),
Fix with Cubic

.object({
comment: z.string().describe('The comment text (required)'),
entity: z.string().describe('The entity type (required)'),
entityId: z.string().describe('The entity ID (required)')
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Missing .uuid() validation on entityId. Other tools in this file consistently validate entityId as UUID (e.g., get_comments_by_entity, reply_to_comment). This inconsistency could allow invalid entity IDs.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/mcp-server/src/lib/tools/comments.ts, line 152:

<comment>Missing `.uuid()` validation on `entityId`. Other tools in this file consistently validate `entityId` as UUID (e.g., `get_comments_by_entity`, `reply_to_comment`). This inconsistency could allow invalid entity IDs.</comment>

<file context>
@@ -135,16 +140,18 @@ export const registerCommentTools = (server: McpServer) =&gt; {
+				.object({
+					comment: z.string().describe(&#39;The comment text (required)&#39;),
+					entity: z.string().describe(&#39;The entity type (required)&#39;),
+					entityId: z.string().describe(&#39;The entity ID (required)&#39;)
 				})
+				.passthrough()
</file context>
Suggested change
entityId: z.string().describe('The entity ID (required)')
entityId: z.string().uuid().describe('The entity ID (required)')
Fix with Cubic

.object({
date: z.string().describe('The date (required)'),
workTimePlanned: z.number().describe('Work time planned (required)'),
status: z.string().describe('The status (required)')
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The status field should use DailyPlanStatusEnum instead of z.string() for proper validation. The enum is already imported and used elsewhere in this file for filtering.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/mcp-server/src/lib/tools/daily-plan.ts, line 326:

<comment>The `status` field should use `DailyPlanStatusEnum` instead of `z.string()` for proper validation. The enum is already imported and used elsewhere in this file for filtering.</comment>

<file context>
@@ -306,16 +314,18 @@ export const registerDailyPlanTools = (server: McpServer) =&gt; {
+				.object({
+					date: z.string().describe(&#39;The date (required)&#39;),
+					workTimePlanned: z.number().describe(&#39;Work time planned (required)&#39;),
+					status: z.string().describe(&#39;The status (required)&#39;)
 				})
+				.passthrough()
</file context>
Suggested change
status: z.string().describe('The status (required)')
status: DailyPlanStatusEnum.describe('The status (required)')
Fix with Cubic

{
id: z.string().uuid().describe('The candidate ID'),
candidate_data: CandidateSchema.partial().describe('The data for updating the candidate')
candidate_data: z.record(z.string(), z.any()).describe('The data for updating the candidate')
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Using z.record(z.string(), z.any()) removes all meaningful validation for update data. Any key-value pairs will be accepted without type checking. This is a security concern and could allow invalid or malicious data to be passed to the API.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/mcp-server/src/lib/tools/candidates.ts, line 208:

<comment>Using `z.record(z.string(), z.any())` removes all meaningful validation for update data. Any key-value pairs will be accepted without type checking. This is a security concern and could allow invalid or malicious data to be passed to the API.</comment>

<file context>
@@ -196,12 +199,13 @@ export const registerCandidateTools = (server: McpServer) =&gt; {
 		{
 			id: z.string().uuid().describe(&#39;The candidate ID&#39;),
-			candidate_data: CandidateSchema.partial().describe(&#39;The data for updating the candidate&#39;)
+			candidate_data: z.record(z.string(), z.any()).describe(&#39;The data for updating the candidate&#39;)
 		},
 		async ({ id, candidate_data }) =&gt; {
</file context>
Fix with Cubic

.required({
userId: true
})
candidate_data: z.object({ userId: z.string().describe('The userId (required)') }).passthrough()
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Schema validation significantly weakened. Using .passthrough() allows any additional properties without validation. The userId field also lost its UUID validation. Consider maintaining proper schema validation to prevent invalid/malicious data from being submitted.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/mcp-server/src/lib/tools/candidates.ts, line 171:

<comment>Schema validation significantly weakened. Using `.passthrough()` allows any additional properties without validation. The userId field also lost its UUID validation. Consider maintaining proper schema validation to prevent invalid/malicious data from being submitted.</comment>

<file context>
@@ -158,14 +163,12 @@ export const registerCandidateTools = (server: McpServer) =&gt; {
-				.required({
-					userId: true
-				})
+			candidate_data: z.object({ userId: z.string().describe(&#39;The userId (required)&#39;) }).passthrough()
 				.describe(&#39;The data for creating the candidate&#39;)
 		},
</file context>
Fix with Cubic

{
id: z.string().uuid().describe('The product ID'),
product_data: ProductSchema.partial().describe('The data for updating the product')
product_data: z.record(z.string(), z.any()).describe('The data for updating the product')
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: z.record(z.string(), z.any()) provides no validation on the product data structure. This is extremely permissive and removes type safety for product updates. Consider using a proper schema (like ProductInputSchema.partial()) to validate the update payload.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/mcp-server/src/lib/tools/products.ts, line 384:

<comment>`z.record(z.string(), z.any())` provides no validation on the product data structure. This is extremely permissive and removes type safety for product updates. Consider using a proper schema (like `ProductInputSchema.partial()`) to validate the update payload.</comment>

<file context>
@@ -365,17 +375,18 @@ export const registerProductTools = (server: McpServer) =&gt; {
 		{
 			id: z.string().uuid().describe(&#39;The product ID&#39;),
-			product_data: ProductSchema.partial().describe(&#39;The data for updating the product&#39;)
+			product_data: z.record(z.string(), z.any()).describe(&#39;The data for updating the product&#39;)
 		},
 		async ({ id, product_data }) =&gt; {
</file context>
Suggested change
product_data: z.record(z.string(), z.any()).describe('The data for updating the product')
product_data: ProductInputSchema.partial().describe('The data for updating the product')
Fix with Cubic

@@ -1,11 +1,13 @@
// @ts-nocheck
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Adding // @ts-nocheck disables TypeScript checking for the entire file. This hides potential type errors and reduces code quality. Consider fixing the underlying type issues instead of suppressing all type checking.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/mcp-server/src/lib/tools/equipment.ts, line 1:

<comment>Adding `// @ts-nocheck` disables TypeScript checking for the entire file. This hides potential type errors and reduces code quality. Consider fixing the underlying type issues instead of suppressing all type checking.</comment>

<file context>
@@ -1,11 +1,13 @@
+// @ts-nocheck
 import { McpServer } from &#39;@modelcontextprotocol/sdk/server/mcp.js&#39;;
 import { Logger } from &#39;@nestjs/common&#39;;
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants