Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,23 @@ Command-line interface for Firecrawl. Scrape, crawl, and extract data from any w
npm install -g firecrawl-cli
```

If you are using in any AI agent like Claude Code, you can install the skill with:
If you are using an AI coding agent like Claude Code, you can install the skill with:

```bash
firecrawl init skills
```

To install the Firecrawl MCP server into your editors (Cursor, Claude Code, VS Code, etc.):

```bash
firecrawl init mcp
```

Or directly via npx:

```bash
npx skills add firecrawl/cli
npx add-mcp "npx -y firecrawl-mcp" --name firecrawl
```

## Quick Start
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "firecrawl-cli",
"version": "1.4.1",
"version": "1.5.0",
"description": "Command-line interface for Firecrawl. Scrape, crawl, and extract data from any website directly from your terminal.",
"main": "dist/index.js",
"bin": {
Expand Down
98 changes: 98 additions & 0 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/**
* Init command implementation
* Installs firecrawl skill files and MCP server into AI coding agents
*/

import { execSync } from 'child_process';
import { getApiKey } from '../utils/config';

export type InitSubcommand = 'skills' | 'mcp';

export interface InitOptions {
global?: boolean;
agent?: string;
}

/**
* Main init command handler
*/
export async function handleInitCommand(
subcommand: InitSubcommand,
options: InitOptions = {}
): Promise<void> {
switch (subcommand) {
case 'skills':
await installSkills(options);
break;
case 'mcp':
await installMcp(options);
break;
default:
console.error(`Unknown init subcommand: ${subcommand}`);
console.log('\nAvailable subcommands:');
console.log(' skills Install firecrawl skill into AI coding agents');
console.log(
' mcp Install firecrawl MCP server into editors (Cursor, Claude Code, VS Code, etc.)'
);
process.exit(1);
}
}

async function installSkills(options: InitOptions): Promise<void> {
const args = ['npx', 'skills', 'add', 'firecrawl/cli'];

if (options.global) {
args.push('--global');
}

if (options.agent) {
args.push('--agent', options.agent);
}

const cmd = args.join(' ');
console.log(`Running: ${cmd}\n`);

try {
execSync(cmd, { stdio: 'inherit' });
} catch {
process.exit(1);
}
}

async function installMcp(options: InitOptions): Promise<void> {
const apiKey = getApiKey();
if (!apiKey) {
console.error(
'No API key found. Please run `firecrawl login` first, or set FIRECRAWL_API_KEY.'
);
process.exit(1);
}

const args = [
'npx',
'add-mcp',
`"npx -y firecrawl-mcp"`,
'--name',
'firecrawl',
];

if (options.global) {
args.push('--global');
}

if (options.agent) {
args.push('--agent', options.agent);
}

const cmd = args.join(' ');
console.log(`Running: ${cmd}\n`);

try {
execSync(cmd, {
stdio: 'inherit',
env: { ...process.env, FIRECRAWL_API_KEY: apiKey },
});
} catch {
process.exit(1);
}
}
11 changes: 11 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import { handleVersionCommand } from './commands/version';
import { handleLoginCommand } from './commands/login';
import { handleLogoutCommand } from './commands/logout';
import { handleInitCommand } from './commands/init';
import { handleStatusCommand } from './commands/status';
import { isUrl, normalizeUrl } from './utils/url';
import { parseScrapeOptions } from './utils/options';
Expand Down Expand Up @@ -944,6 +945,16 @@ program
await handleLogoutCommand();
});

program
.command('init')
.description('Initialize firecrawl integrations (skills, mcp)')
.argument('<subcommand>', 'What to initialize: "skills" or "mcp"')
.option('-g, --global', 'Install globally (user-level)')
.option('-a, --agent <agent>', 'Install to a specific agent')
.action(async (subcommand, options) => {
await handleInitCommand(subcommand, options);
});

program
.command('credit-usage')
.description('Get team credit usage information')
Expand Down