• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mongodb-js / mongodb-mcp-server / 17835624766

18 Sep 2025 04:48PM UTC coverage: 81.919%. First build
17835624766

Pull #571

github

web-flow
Merge 7e2a6b7d5 into dd36b1a75
Pull Request #571: fix: Use JSON for stdio, similiar to the HTTP Transport and use EJSON deserialize when necessary MCP-207

1019 of 1352 branches covered (75.37%)

Branch coverage included in aggregate %.

23 of 26 new or added lines in 8 files covered. (88.46%)

4993 of 5987 relevant lines covered (83.4%)

55.62 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.25
/src/tools/args.ts
1
import { z, type ZodString } from "zod";
2✔
2
import { EJSON } from "bson";
2✔
3

4
const NO_UNICODE_REGEX = /^[\x20-\x7E]*$/;
2✔
5
export const NO_UNICODE_ERROR = "String cannot contain special characters or Unicode symbols";
2✔
6

7
const ALLOWED_USERNAME_CHARACTERS_REGEX = /^[a-zA-Z0-9._-]+$/;
2✔
8
export const ALLOWED_USERNAME_CHARACTERS_ERROR =
2✔
9
    "Username can only contain letters, numbers, dots, hyphens, and underscores";
2✔
10

11
const ALLOWED_REGION_CHARACTERS_REGEX = /^[a-zA-Z0-9_-]+$/;
2✔
12
export const ALLOWED_REGION_CHARACTERS_ERROR = "Region can only contain letters, numbers, hyphens, and underscores";
2✔
13

14
const ALLOWED_CLUSTER_NAME_CHARACTERS_REGEX = /^[a-zA-Z0-9_-]+$/;
2✔
15
export const ALLOWED_CLUSTER_NAME_CHARACTERS_ERROR =
2✔
16
    "Cluster names can only contain ASCII letters, numbers, and hyphens.";
2✔
17

18
const ALLOWED_PROJECT_NAME_CHARACTERS_REGEX = /^[a-zA-Z0-9\s()@&+:._',-]+$/;
2✔
19
export const ALLOWED_PROJECT_NAME_CHARACTERS_ERROR =
2✔
20
    "Project names can't be longer than 64 characters and can only contain letters, numbers, spaces, and the following symbols: ( ) @ & + : . _ - ' ,";
2✔
21
export const CommonArgs = {
2✔
22
    string: (): ZodString => z.string().regex(NO_UNICODE_REGEX, NO_UNICODE_ERROR),
2✔
23

24
    objectId: (fieldName: string): z.ZodString =>
2✔
25
        z
515✔
26
            .string()
515✔
27
            .min(1, `${fieldName} is required`)
515✔
28
            .length(24, `${fieldName} must be exactly 24 characters`)
515✔
29
            .regex(/^[0-9a-fA-F]+$/, `${fieldName} must contain only hexadecimal characters`),
515✔
30
};
2✔
31

32
export const AtlasArgs = {
2✔
33
    projectId: (): z.ZodString => CommonArgs.objectId("projectId"),
2✔
34

35
    organizationId: (): z.ZodString => CommonArgs.objectId("organizationId"),
2✔
36

37
    clusterName: (): z.ZodString =>
2✔
38
        z
206✔
39
            .string()
206✔
40
            .min(1, "Cluster name is required")
206✔
41
            .max(64, "Cluster name must be 64 characters or less")
206✔
42
            .regex(ALLOWED_CLUSTER_NAME_CHARACTERS_REGEX, ALLOWED_CLUSTER_NAME_CHARACTERS_ERROR),
206✔
43

44
    projectName: (): z.ZodString =>
2✔
45
        z
47✔
46
            .string()
47✔
47
            .min(1, "Project name is required")
47✔
48
            .max(64, "Project name must be 64 characters or less")
47✔
49
            .regex(ALLOWED_PROJECT_NAME_CHARACTERS_REGEX, ALLOWED_PROJECT_NAME_CHARACTERS_ERROR),
47✔
50

51
    username: (): z.ZodString =>
2✔
52
        z
52✔
53
            .string()
52✔
54
            .min(1, "Username is required")
52✔
55
            .max(100, "Username must be 100 characters or less")
52✔
56
            .regex(ALLOWED_USERNAME_CHARACTERS_REGEX, ALLOWED_USERNAME_CHARACTERS_ERROR),
52✔
57

58
    ipAddress: (): z.ZodString => z.string().ip({ version: "v4" }),
2✔
59

60
    cidrBlock: (): z.ZodString => z.string().cidr(),
2✔
61

62
    region: (): z.ZodString =>
2✔
63
        z
69✔
64
            .string()
69✔
65
            .min(1, "Region is required")
69✔
66
            .max(50, "Region must be 50 characters or less")
69✔
67
            .regex(ALLOWED_REGION_CHARACTERS_REGEX, ALLOWED_REGION_CHARACTERS_ERROR),
69✔
68

69
    password: (): z.ZodString =>
2✔
70
        z.string().min(1, "Password is required").max(100, "Password must be 100 characters or less"),
46✔
71
};
2✔
72

73
function toEJSON<T extends object | undefined>(value: T): T {
109✔
74
    if (!value) {
109!
NEW
75
        return value;
×
NEW
76
    }
×
77

78
    return EJSON.deserialize(value, { relaxed: false }) as T;
109✔
79
}
109✔
80

81
export function zEJSON(): z.AnyZodObject {
2✔
82
    return z.object({}).passthrough().transform(toEJSON) as unknown as z.AnyZodObject;
396✔
83
}
396✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc