# @atlashub/smartstack-mcp

MCP server for SmartStack/AtlasHub platform development.

## Quick Start

```bash
npm install -g @atlashub/smartstack-mcp
claude mcp add -s user smartstack -- smartstack-mcp
```

## Installation

### Claude Code CLI

```bash
claude mcp add -s user smartstack -- npx -y @atlashub/smartstack-mcp
```

### VS Code

Create `.mcp.json` at project root:

```json
{
  "mcpServers": {
    "smartstack": {
      "command": "npx",
      "args": ["-y", "@atlashub/smartstack-mcp"]
    }
  }
}
```

### Claude Desktop

Config file location:
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`

```json
{
  "mcpServers": {
    "smartstack": {
      "command": "npx",
      "args": ["-y", "@atlashub/smartstack-mcp"]
    }
  }
}
```

## Context7 (Optional)

```bash
claude mcp add context7 -s user -- npx -y @upstash/context7-mcp
```

## Update & Restart

### Update to Latest Version

```bash
# Global installation
npm update -g @atlashub/smartstack-mcp

# Verify version
npm list -g @atlashub/smartstack-mcp
```

### Restart the MCP Server

After updating, you must restart the MCP server for changes to take effect:

| Environment | How to Restart |
|-------------|----------------|
| **VS Code** | Close and reopen VS Code, or run `Developer: Reload Window` (Ctrl+Shift+P) |
| **Claude Code CLI** | Exit and restart Claude Code (`/exit` then `claude`) |
| **Claude Desktop** | Quit and reopen Claude Desktop application |

> **Note**: The MCP server loads tools at startup. New or updated tools won't appear until restart.

## Configuration

| Variable | Description | Required |
|----------|-------------|----------|
| `SMARTSTACK_PROJECT_PATH` | Path to your SmartStack.app project | Yes (auto-detects if not set) |
| `SMARTSTACK_API_URL` | SmartStack API URL | No |
| `LOG_LEVEL` | Logging level (debug, info, warn, error) | No |

### Auto-Detection

The server automatically detects:
- **Project path**: Uses current working directory if `SMARTSTACK_PROJECT_PATH` not set
- **Namespaces**: Extracts from `.csproj` file names (e.g., `Aurora.Domain.csproj` → `Aurora`)
- **Web folder**: Searches `web/*/`, `web/`, `client/`, `frontend/`, `ui/`, `src/web/`

## Features

### Tools (13 total)

#### Core Tools
| Tool | Description |
|------|-------------|
| `validate_conventions` | Validate AtlasHub/SmartStack conventions (tables, migrations, services, namespaces) |
| `check_migrations` | Analyze EF Core migrations for conflicts and ordering issues |
| `scaffold_extension` | Generate code: feature, entity, service, controller, component, dto, validator, repository |
| `api_docs` | Get API documentation from Swagger/OpenAPI or controller files |
| `suggest_migration` | Suggest migration name following SmartStack conventions |

#### Frontend Tools
| Tool | Description |
|------|-------------|
| `scaffold_routes` | Generate frontend routes from backend NavRoute attributes |
| `validate_frontend_routes` | Validate frontend routes match backend NavRoutes |
| `scaffold_api_client` | Generate TypeScript API client with React Query hooks |

#### Test Tools
| Tool | Description |
|------|-------------|
| `scaffold_tests` | Generate test files for entities, services, controllers |
| `analyze_test_coverage` | Analyze test coverage and identify missing tests |
| `validate_test_conventions` | Validate test naming and structure conventions |
| `suggest_test_scenarios` | Suggest test scenarios based on code analysis |

### Resources

| Resource URI | Description |
|--------------|-------------|
| `smartstack://conventions` | Naming conventions |
| `smartstack://project` | Project information |
| `smartstack://api/{endpoint}` | API documentation |
| `smartstack://schema/{table}` | Database schema |

## License

MIT - AtlasHub
