# MD CLI

A comprehensive CLI tool for MD (project and task) management with interactive interface and MCP server integration.

## Features

- **Interactive CLI Interface**: Built with Ink and React for rich terminal UI
- **Project Management**: Create, manage, and track projects and tasks
- **Task Management**: Create parent tasks and subtasks with context-aware operations
- **Context-Driven Operations**: Smart context resolution for seamless task operations
- **MCP Server Integration**: Model Context Protocol server for AI agent integration
- **Authentication**: Secure user authentication and session management
- **Real-time Updates**: File watching and background services
- **Rich Terminal UI**: Interactive forms, tables, and navigation panels

## Installation

### Prerequisites

- Node.js >= 18.0.0
- npm or yarn

### Install

```bash
npm install -g @codehard-th/md-cli
```

Or run directly with npx:

```bash
npx @codehard-th/md-cli
```

## Quick Start

1. **Initialize the CLI**:
   ```bash
   md-cli init
   ```

2. **Login**:
   ```bash
   md-cli login
   ```

3. **Start the interactive interface**:
   ```bash
   md-cli
   ```

4. **Run as MCP server** (for AI agent integration):
   ```bash
   md-cli mcp-server
   ```

## Commands

| Command | Description |
|---------|-------------|
| `md-cli` | Start interactive mode |
| `md-cli init` | Initialize configuration |
| `md-cli login` | Authenticate with the MD system |
| `md-cli logout` | Sign out and clear credentials |
| `md-cli watch` | Start file watching service |
| `md-cli submit` | Submit work or tasks |
| `md-cli history` | View work history |
| `md-cli mcp` | Start MCP server for AI agents |
| `md-cli deinit` | Remove configuration and data |

## MCP Server Integration

The CLI includes a Model Context Protocol (MCP) server that enables AI agents to interact with your MD system:

### Available MCP Tools

- **Context Management**: `set-context`, `resolve-context`, `get-context-info`
- **Project Management**: `list-projects`, `onboarding`
- **Task Management**: `create-parent-task`, `create-subtask`, `list-parent-tasks`
- **Task Groups**: `list-task-groups`, `find-parent-tasks`
- **Work Tasks**: `list-work-tasks`

### MCP Server integration (with Claude Desktop, Claude Code, Gemini CLI, etc)

```bash
"mcpServers": {
    "md": {
      "command": "md-cli",
      "args": [
        "mcp"
      ],
    }
  }
```
