Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(mcp): reject empty sessionId (min(1)) to prevent scope-check bypass

Yudhi Armyndharis1a2046df2895
diff --git a/src/core/agent-tools/tools/contact.tools.ts b/src/core/agent-tools/tools/contact.tools.ts
index 67e9fb70f..41b5f6911 100644
--- a/src/core/agent-tools/tools/contact.tools.ts
+++ b/src/core/agent-tools/tools/contact.tools.ts
@@ -3,7 +3,7 @@ import { ApiKeyRole } from '../../../modules/auth/entities/api-key.entity';
import type { ContactService } from '../../../modules/contact/contact.service';
import type { ToolDescriptor } from '../tool-descriptor';
-const sessionId = z.string().describe('Session UUID (the session id, not the name)');
+const sessionId = z.string().min(1).describe('Session UUID (the session id, not the name)');
export function contactTools(contact: ContactService): ToolDescriptor[] {
return [
diff --git a/src/core/agent-tools/tools/group.tools.ts b/src/core/agent-tools/tools/group.tools.ts
index c393b97cc..702171a69 100644
--- a/src/core/agent-tools/tools/group.tools.ts
+++ b/src/core/agent-tools/tools/group.tools.ts
@@ -3,7 +3,7 @@ import { ApiKeyRole } from '../../../modules/auth/entities/api-key.entity';
import type { GroupService } from '../../../modules/group/group.service';
import type { ToolDescriptor } from '../tool-descriptor';
-const sessionId = z.string().describe('Session UUID (the session id, not the name)');
+const sessionId = z.string().min(1).describe('Session UUID (the session id, not the name)');
export function groupTools(group: GroupService): ToolDescriptor[] {
return [
diff --git a/src/core/agent-tools/tools/message.tools.ts b/src/core/agent-tools/tools/message.tools.ts
index 96fef2039..92ec57f6d 100644
--- a/src/core/agent-tools/tools/message.tools.ts
+++ b/src/core/agent-tools/tools/message.tools.ts
@@ -3,7 +3,7 @@ import { ApiKeyRole } from '../../../modules/auth/entities/api-key.entity';
import type { MessageService } from '../../../modules/message/message.service';
import type { ToolDescriptor } from '../tool-descriptor';
-const sessionId = z.string().describe('Session UUID (the session id, not the name)');
+const sessionId = z.string().min(1).describe('Session UUID (the session id, not the name)');
export function messageTools(message: MessageService): ToolDescriptor[] {
return [
@@ -17,7 +17,7 @@ export function messageTools(message: MessageService): ToolDescriptor[] {
sessionId,
chatId: z.string().optional().describe('Filter to a specific chat JID'),
from: z.string().optional().describe('Filter by sender phone or JID'),
- limit: z.number().int().min(1).max(500).optional(),
+ limit: z.number().int().min(1).max(100).optional(),
offset: z.number().int().min(0).optional(),
}),
handler: (input: { sessionId: string; chatId?: string; from?: string; limit?: number; offset?: number }) =>
@@ -37,7 +37,13 @@ export function messageTools(message: MessageService): ToolDescriptor[] {
inputSchema: z.object({
sessionId,
chatId: z.string().describe('Chat JID (e.g. [email protected] or [email protected])'),
- limit: z.number().int().min(1).max(2000).optional(),
+ limit: z
+ .number()
+ .int()
+ .min(1)
+ .max(2000)
+ .optional()
+ .describe('Number of messages to fetch; without deep:true the engine caps at 100'),
includeMedia: z.boolean().optional().describe('Download media as base64 (slower)'),
deep: z.boolean().optional().describe('Raise limit ceiling to 2000 for reaching further back in history'),
}),