Pure Node.js package for Cursor editor integration file management. Manages OpenPets MCP entries in Cursor's mcp.json configuration files and optional project-local Cursor rules guidance. Provides safe, atomic file operations with validation, backup, and redaction capabilities.
- Global config:
<homeDir>/.cursor/mcp.json- user-wide MCP settings - Project config:
<projectDir>/.cursor/mcp.json- project-specific MCP settings - Rules path:
<projectDir>/.cursor/rules/openpets.mdc- project-local Cursor rules - All APIs accept explicit
configPathfor custom locations
- Strict JSON only (no JSONC comments)
- Maximum config size: 256 KiB (rules: 64 KiB)
- Reject symlinks at any path level (config file, parent directories, ancestors)
- Reject non-regular files (directories, sockets, etc.)
- Validate parent directories before creating
.cursorfolders - Atomic writes using temp files and atomic rename
- Automatic backup creation before modifications
- Private file permissions (0o600) where supported
missing: No config file or no OpenPets entry existsinstalled: Matching OpenPets entry present and up-to-dateneeds-update: Old version, different pet, or content driftconflict: Non-OpenPets entry blocking installationinvalid: Parse error, oversized, unsafe path, malformed schemaerror: Unexpected I/O failure
{
"type": "stdio",
"command": "npx",
"args": ["-y", "@open-pets/mcp@VERSION", "--pet", "PET_ID"]
}- Published mode:
npx -y @open-pets/mcp@SEMVER [--pet PET] - Local mode:
node <absolute-path> [--pet PET] - Validates semantic versioning and pet ID format
- Rejects unpinned versions (e.g.,
@latest)
Recursive, case-insensitive redaction of:
- Keys:
env,headers,auth,authorization,token,secret,password,credentials - URL query parameters matching sensitive patterns
- String values containing
token=,api_key=,secret=,password=,auth=
- Exact whole-file ownership requires recognized frontmatter
- Requires exactly one ordered
OPENPETS:CURSOR_RULES:START/ENDmarker pair - Rejects duplicate, reversed, or missing markers
- Rejects user content before/after managed block
- Desktop uses preview/copy only; CLI writes project-local rules
- Read existing config via
readCursorMcpConfig(path) - Classify status via
classifyCursorMcpStatus(result, path, expected) - Plan operation via
planCursorMcpInstall(path, options, allowReplace?) - Execute write via
executeCursorMcpWrite(plan) - Atomic write creates temp file, backs up existing, renames to target
- Read and classify existing config
- Verify status is
needs-update,conflict, orinstalled - Plan replace via
planCursorMcpReplace(path, options) - Execute preserves unrelated MCP servers and top-level fields
- Read and classify existing config
- Verify entry is managed by OpenPets (not conflict)
- Plan remove via
planCursorMcpRemove(path) - Execute removes only
mcpServers.openpets, preserves other servers - Empty
mcpServerskept as{}after removal
- Read existing rules via
readCursorOpenPetsRules(projectDir) - Classify status via
classifyCursorRulesStatus(result, path, expected?) - Plan via
planCursorRulesInstall(projectDir, allowReplace?) - Execute via
executeCursorRulesWrite(plan) - Managed content includes frontmatter + START/END markers
- Build preview via
buildOpenPetsOnlyPreview(options) - Redact sensitive config via
redactCursorConfig(config) - Safe for logging and UI display
src/index.ts: Public API exports (re-exports all modules)src/cursor-mcp.ts: MCP entry builders and path utilitiessrc/cursor-status.ts: Status classification and config read/write operationssrc/cursor-previews.ts: Config preview and redaction helperssrc/cursor-rules.ts: Project-local Cursor rules preview/status/write/remove helperssrc/check-cursor.ts: Contract validation tests (runs vianpm test)
From cursor-mcp.ts:
buildCursorMcpEntry(options): Build MCP entry objectformatCursorMcpConfig(options): Build full config with openpets entrygetCursorGlobalMcpPath(homeDir): Get global config pathgetCursorProjectMcpPath(projectDir): Get project config pathvalidateOpenPetsPetId(id): Validate and return pet IDisValidPetId(id): Check if pet ID is valid
From cursor-status.ts:
classifyCursorMcpStatus(result, path, expected): Classify config statusreadCursorMcpConfig(path): Read and validate config fileplanCursorMcpInstall(path, options, allowReplace?): Plan install operationplanCursorMcpReplace(path, options): Plan replace operationplanCursorMcpRemove(path): Plan remove operationexecuteCursorMcpWrite(plan): Execute planned write atomicallyisManagedOpenPetsMcpEntry(value): Check if entry is OpenPets-managedmaxCursorConfigBytes: 256 KiB limit constant
From cursor-previews.ts:
buildOpenPetsOnlyPreview(options): Build OpenPets-only previewredactCursorConfig(config): Redact sensitive fields from config
From cursor-rules.ts:
getCursorProjectRulesPath(projectDir): Get project rules pathbuildCursorOpenPetsRule(): Build managed Cursor rules contentbuildCursorRulesPreview(): Build copyable rules previewreadCursorOpenPetsRules(projectDir): Safely read managed rules fileclassifyCursorRulesStatus(result, path, expected?): Classify rules statusplanCursorRulesInstall(projectDir, allowReplace?): Plan project rules install/updateplanCursorRulesReplace(projectDir): Plan explicit replacementplanCursorRulesRemove(projectDir): Plan managed rules removalexecuteCursorRulesWrite(plan): Execute rules write/remove atomicallyisManagedCursorOpenPetsRule(content): Check managed marker/frontmatter shapemaxCursorRulesBytes: 64 KiB limit constant
npm test: Run contract validation tests (node dist/check-cursor.js)npm run check: Full typecheck + build + test pipelinenpm run typecheck: TypeScript type checking onlynpm run build: Compile TypeScript todist/
- Desktop app: Uses preview/redaction APIs for UI display
- CLI tools: Uses planning/execution APIs for install/remove operations
- Both use status classification to determine available actions
check-cursor.ts validates:
- Pet ID validation (valid/invalid patterns, length limits)
- MCP entry building (published/local modes, version validation)
- Config formatting and path helpers
- All status classifications (missing, empty, installed, needs-update, conflict, invalid)
- Parse errors, oversized files, symlink rejection
- Non-object schema rejection (top-level, mcpServers, entries)
- Backup creation and atomic write behavior
- Uninstall preserves unrelated entries and top-level fields
- No writes on invalid/error status
- No conflict write without explicit replace
- Explicit replace preserves unrelated servers/fields
- Recursive and case-insensitive redaction
- URL token parameter redaction
- Symlink parent/ancestor rejection
- Empty mcpServers preservation after remove
- Cursor project rules generation and path resolution
- Rules missing/installed/needs-update/conflict classification
- Rules duplicate/reversed/missing marker handling
- Rules frontmatter conflict detection
- Rules symlink parent/file, dangling symlink, non-regular, oversized rejection
- Rules backup, atomic write, replace, remove, and no-write invalid behavior