npm package: @iforgot/install-mcp
Description: A CLI tool and programmatic API to install iForgot MCP server.
Author: iForgot Team
Latest version: 0.0.3

# @iforgot/install-mcp

A CLI tool and programmatic API to install iForgot MCP server with simple configuration.

## Features

- 🔧 **CLI Tool**: Command-line interface for easy iForgot MCP server installation
- 📚 **Programmatic API**: Node.js API for integration in applications (especially Electron apps)
- 🤖 **Non-interactive Mode**: Perfect for automation and CI/CD
- 🔄 **Multiple Clients**: Support for Claude, Cursor, Cline, and more
- 📖 **Configuration Reading**: Read and manage existing configurations
- 🏗️ **Simple Setup**: Just provide your API key and target client

## Installation

```bash
npm install @iforgot/install-mcp
```

## CLI Usage

### Basic Installation
```bash
# Install iForgot MCP server for Cursor
npx @iforgot/install-mcp --client cursor --apiKey iforgot-de0c1d40816947a6a40313d21a23785eb8806ee9fa11d80ec2fd0761670cfb9d

# Install for Claude Desktop
npx @iforgot/install-mcp --client claude --apiKey your-iforgot-api-key

# Non-interactive mode (perfect for scripts)
npx @iforgot/install-mcp --client cursor --apiKey your-iforgot-api-key --yes
```

### Advanced Options
```bash
# Install locally (to current directory)
npx @iforgot/install-mcp --client cursor --apiKey your-iforgot-api-key --local

# Completely non-interactive 
npx @iforgot/install-mcp --client claude --apiKey your-iforgot-api-key --non-interactive
```

## Generated Configuration

The tool will generate a configuration like this:

```json
{
  "mcpServers": {
    "iforgot": {
      "command": "npx",
      "args": [
        "-y",
        "@iforgot/memory-mcp@latest"
      ],
      "env": {
        "IFORGOT_API_KEY": "your-iforgot-api-key"
      }
    }
  }
}
```

## Programmatic API

### Basic Usage

```typescript
import { MCPInstaller } from '@iforgot/install-mcp'

// Install iForgot MCP server
const success = await MCPInstaller.installiForgot({
  client: 'cursor',
  apiKey: 'iforgot-de0c1d40816947a6a40313d21a23785eb8806ee9fa11d80ec2fd0761670cfb9d'
})

// Read MCP configurations (returns unified structure)
const config = MCPInstaller.readMCPConfig({ client: 'cursor' })
console.log(config)
// Output:
// {
//   "iforgot": {
//     "command": "npx",
//     "args": ["-y", "@iforgot/memory-mcp@latest"],
//     "env": {
//       "IFORGOT_API_KEY": "iforgot-de0c1d40816947a6a40313d21a23785eb8806ee9fa11d80ec2fd0761670cfb9d"
//     }
//   }
// }

// Remove iForgot server
const removed = await MCPInstaller.removeiForgot({ client: 'cursor' })

// Check if iForgot is installed
const isInstalled = MCPInstaller.isiForgotInstalled({ client: 'cursor' })
```

### Advanced API Usage

```typescript
import { MCPInstaller, type UnifiedMCPConfig } from '@iforgot/install-mcp'

// Check supported clients
const clients = MCPInstaller.getSupportedClients()
console.log(clients) // ['claude', 'cursor', 'cline', ...]

// Check if config file exists
const exists = MCPInstaller.configExists('cursor')

// Get config file path
const configPath = MCPInstaller.getConfigPath('cursor')

// Install to local directory
await MCPInstaller.installiForgot({
  client: 'cursor',
  apiKey: 'your-iforgot-api-key',
  local: true
})
```

### Integration in Electron Apps

Perfect for Electron applications that need to manage iForgot MCP configurations:

```typescript
// In your Electron main process or renderer
import { MCPInstaller } from '@iforgot/install-mcp'

class iForgotManager {
  async addiForgotServer(apiKey: string, client: string = 'cursor') {
    const success = await MCPInstaller.installiForgot({
      client,
      apiKey
    })
    
    return success
  }
  
  async removeiForgotServer(client: string = 'cursor') {
    return await MCPInstaller.removeiForgot({ client })
  }
  
  isiForgotConfigured(client: string = 'cursor') {
    return MCPInstaller.isiForgotInstalled({ client })
  }
  
  getAllServers(client: string = 'cursor'): UnifiedMCPConfig {
    return MCPInstaller.readMCPConfig({ client })
  }
}
```

## Configuration Structure

The API returns a unified configuration structure:

```typescript
interface iForgotInstallOptions {
  apiKey: string
  client: string
  local?: boolean
}

interface UnifiedMCPConfig {
  [serverName: string]: {
    command: string
    args: string[]
    env?: Record<string, string>
  }
}
```

This means regardless of the underlying client configuration format, you always get a consistent structure containing the MCP server configurations.

## Supported Clients

- **claude**: Claude Desktop
- **cursor**: Cursor IDE  
- **cline**: Cline extension
- **roo-cline**: Roo Cline extension
- **windsurf**: Windsurf IDE
- **witsy**: Witsy
- **enconvo**: Enconvo
- **amazonq**: Amazon Q

## API Key Format

Your iForgot API key should start with `iforgot-` followed by your unique identifier. For example:
```
iforgot-de0c1d40816947a6a40313d21a23785eb8806ee9fa11d80ec2fd0761670cfb9d
```

## Testing

Run the test suite to verify functionality:

```bash
pnpm test
# or for one-time run:
npx vitest run
```

## License

MIT