npx markmv --help
TypeScript CLI for markdown file operations with intelligent link refactoring
markmv revolutionises how you manage markdown documentation by providing intelligent file operations that automatically maintain link integrity across your entire project. Whether you're reorganising documentation, splitting large files, or combining related content, markmv ensures your links never break.
# Use directly with npx (recommended)
npx markmv --help
# Install globally
npm install -g markmv
# Install as library
npm install markmv
Requirements: Node.js >= 18.0.0
# Move a file and update all references
npx markmv move old-doc.md new-location/renamed-doc.md
# Split a large file by headers
npx markmv split large-guide.md --strategy headers --header-level 2
# Join multiple files
npx markmv join intro.md setup.md usage.md --output complete-guide.md
# Generate documentation index
npx markmv index --type links --strategy directory
markmv provides multiple interfaces for different use cases:
npx markmv move old.md new.md --json # JSON output for scripting
npx --package=markmv markmv-api # Start HTTP server on port 3000
npx --package=markmv markmv-mcp # Model Context Protocol server
import { moveFile } from 'markmv';
const result = await moveFile('old.md', 'new.md');
The markmv MCP server enables AI agents (like Claude) to use markmv functionality directly. Here's how to set it up:
Add markmv to your Claude Desktop configuration:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"markmv": {
"command": "npx",
"args": [
"--package=markmv",
"markmv-mcp"
],
"env": {
"NODE_OPTIONS": "--no-warnings"
}
}
}
}
Once configured, Claude can use these markmv tools:
move_file
- Move/rename files with link updatesmove_files
- Move multiple files in batchvalidate_operation
- Check for broken linksNote: Additional tools (split, join, merge, convert, index) will be added in future releases.
After setup, you can ask Claude to:
"Use markmv to move
docs/old-guide.md
toguides/new-guide.md
and update all references"
"Move multiple files from the
drafts/
folder topublished/
and update all links"
"Validate my recent file moves to check for any broken links"
Restart Claude Desktop and look for the 🔧 MCP icon in the chat. If configured correctly, you'll see "markmv" listed in the connected MCP servers.
function convertCommand(patterns: string[], options: ConvertOptions): Promise<void>;
Defined in: commands/convert.ts:244
CLI command handler for convert operations.
Processes markdown files to convert link formats and path resolution according to specified options. Supports dry run mode, verbose output, and various conversion strategies.
# Convert all links to relative paths
markmv convert docs/star.md --path-resolution relative
# Convert to wikilink style with absolute paths
markmv convert starstar/star.md --link-style wikilink --path-resolution absolute
# Dry run with verbose output
markmv convert README.md --link-style claude --dry-run --verbose
function indexCommand(directory: undefined | string, cliOptions: IndexCliOptions): Promise<void>;
Defined in: commands/index.ts:131
CLI command handler for generating documentation indexes.
Creates organized documentation indexes from markdown files using various strategies. Supports multiple index types including links, imports, embeds, and hybrid modes.
# Generate a links-based index
markmv index --type links --strategy directory
# Generate with custom template
markmv index docs/ --type hybrid --template custom.md
# Dry run with verbose output
markmv index --dry-run --verbose
function createMarkMv(): FileOperations;
Defined in: index.ts:146
Main entry point for the markmv library
Creates a new FileOperations instance for performing markdown file operations. This is the recommended way to get started with the library.
A new FileOperations instance
import { createMarkMv } from 'markmv';
const markmv = createMarkMv();
const result = await markmv.moveFile('old.md', 'new.md');
```;
***
### moveFile()
```ts
function moveFile(
sourcePath: string,
destinationPath: string,
options: MoveOperationOptions): Promise<OperationResult>;
Defined in: index.ts:170
Convenience function for moving a single markdown file
string
The current file path
string
The target file path
MoveOperationOptions
= {}
Optional configuration
Promise
<OperationResult
>
Promise resolving to operation result
import { moveFile } from 'markmv';
const result = await moveFile('docs/old.md', 'docs/new.md', {
dryRun: true
});
```;
***
### moveFiles()
```ts
function moveFiles(moves: object[], options: MoveOperationOptions): Promise<OperationResult>;
Defined in: index.ts:199
Convenience function for moving multiple markdown files
object
[]
Array of source/destination pairs
MoveOperationOptions
= {}
Optional configuration
Promise
<OperationResult
>
Promise resolving to operation result
import { moveFiles } from 'markmv';
const result = await moveFiles([
{ source: 'old1.md', destination: 'new1.md' },
{ source: 'old2.md', destination: 'new2.md' }
]);
```;
***
### validateOperation()
```ts
function validateOperation(result: OperationResult): Promise<{
valid: boolean;
brokenLinks: number;
errors: string[];
}>;
Defined in: index.ts:228
Convenience function for validating markdown file operations
The operation result to validate
Promise
<{
valid
: boolean
;
brokenLinks
: number
;
errors
: string
[];
}>
Promise resolving to validation result
import { moveFile, validateOperation } from 'markmv';
const result = await moveFile('old.md', 'new.md');
const validation = await validateOperation(result);
if (!validation.valid) {
console.error(`Found ${validation.brokenLinks} broken links`);
}
git clone https://github.com/ExaDev/markmv.git
cd markmv
npm install
npm run build
npm test
Contributing Guide | Development Setup
CC BY-NC-SA 4.0 - see the LICENSE file for details.