This is the documentation for the v2 beta — looking for the v1 documentation?
Skip to content

MCP TypeScript SDK (V2) / @modelcontextprotocol/codemod / utils/packageJsonUpdater

utils/packageJsonUpdater

Interfaces

ManifestInfo

Defined in: utils/packageJsonUpdater.ts:73

Properties

dir

dir: string

Defined in: utils/packageJsonUpdater.ts:75

Directory containing the manifest.

path

path: string

Defined in: utils/packageJsonUpdater.ts:77

Absolute path of the package.json.

Functions

discoverManifests()

discoverManifests(targetDir): ManifestInfo[]

Defined in: utils/packageJsonUpdater.ts:144

The manifests a migration run may need to update: the nearest package.json walking up from the target directory, plus every workspace-member manifest it declares (npm/yarn/bun workspaces and pnpm-workspace.yaml), so monorepo members do not keep a stale v1 dependency the root swap never sees.

Parameters

targetDir

string

Returns

ManifestInfo[]


normalizeToRoot()

normalizeToRoot(pkg): string

Defined in: utils/packageJsonUpdater.ts:80

Parameters

pkg

string

Returns

string


ownerManifest()

ownerManifest(filePath, manifests): ManifestInfo | undefined

Defined in: utils/packageJsonUpdater.ts:177

Longest-prefix owner of a file among the discovered manifest directories.

Parameters

filePath

string

manifests

readonly ManifestInfo[]

Returns

ManifestInfo | undefined


updatePackageJson()

updatePackageJson(manifests, usedByManifest, dryRun, zodInjectedByManifest?): PackageJsonChange[]

Defined in: utils/packageJsonUpdater.ts:262

Parameters

manifests

readonly ManifestInfo[]

usedByManifest

ReadonlyMap<string, ReadonlySet<string>>

dryRun

boolean

zodInjectedByManifest?

ReadonlyMap<string, readonly string[]> = ...

Returns

PackageJsonChange[]