# Sony Camera MCP Server

A Model Context Protocol (MCP) server for controlling Sony Alpha cameras remotely. This server provides AI assistants with the ability to interact with Sony cameras using the Camera Remote API.

## Features

- **Exposure Control**: Adjust ISO, shutter speed, and exposure compensation
- **Photo Capture**: Take pictures and receive them as base64-encoded images
- **Zoom Control**: Control camera zoom in/out with different modes
- **Shoot Mode Management**: Switch between still and movie modes
- **Live View**: Start and stop live view streaming
- **Real-time Communication**: Direct integration with Sony Camera Remote API

## Quick Start

The easiest way to use this MCP server is with npx:

```bash
npx -y @neirth/sony-camera-mcp
```

## Requirements

- Sony Alpha camera with Wi-Fi capability and Camera Remote API support
- Camera connected via Wi-Fi Direct or to the same network as your computer
- Node.js 18+ (for development)

> **Note**: This server has been tested and verified to work with the Sony Alpha 6100. Other Sony Alpha cameras with Camera Remote API support should work as well.

## Supported Sony Cameras

This server works with Sony Alpha cameras that support the Camera Remote API, including:
- Sony α7 series
- Sony α6000 series  
- Sony FX series
- And other compatible Sony cameras with Wi-Fi

## Configuration

### Environment Variables

You can configure the server using environment variables:

```bash
CAMERA_IP=192.168.122.1      # Camera IP address (default: 192.168.122.1)
CAMERA_PORT=10000            # Camera port (default: 10000)
DD_XML_PORT=64321           # Device description XML port (default: 64321)
DEBUG=true                  # Enable debug logging (default: false)
```

### Camera Setup

1. Enable Wi-Fi on your Sony camera
2. Set the camera to "Control with Smartphone" mode or enable Wi-Fi Direct
3. Connect your camera to your Wi-Fi network or establish a Wi-Fi Direct connection
4. Note the camera's IP address (usually found in camera network settings)

> **Wi-Fi Direct**: If using Wi-Fi Direct, your camera will create its own network that you can connect to directly from your computer. This is often the easiest setup method.

## Available Tools

### `exposure_control`
Control camera exposure settings.

**Parameters:**
- `action`: "get" or "set"
- `parameter`: "iso", "shutter_speed", "ev", "white_balance" (for get/set operations)
- `value`: New value (for set operations)

**Examples:**
- Get current ISO: `{"action": "get", "parameter": "iso"}`
- Set ISO to 800: `{"action": "set", "parameter": "iso", "value": "800"}`
- Get all exposure settings: `{"action": "get"}`

### `shoot_control`
Capture photos.

**Parameters:**
- `action`: "capture"

**Example:**
- Take a picture: `{"action": "capture"}`

### `zoom_control`
Control camera zoom.

**Parameters:**
- `action`: "in" or "out"
- `type`: "1shot", "start", or "stop"

**Example:**
- Zoom in once: `{"action": "in", "type": "1shot"}`

### `shoot_mode`
Manage shooting mode.

**Parameters:**
- `action`: "get" or "set"
- `mode`: "still" or "movie" (for set operations)

**Examples:**
- Get current mode: `{"action": "get"}`
- Set to still mode: `{"action": "set", "mode": "still"}`

### `live_view`
Control live view streaming.

**Parameters:**
- `action`: "start" or "stop"

**Examples:**
- Start live view: `{"action": "start"}`
- Stop live view: `{"action": "stop"}`

## Development

### Installation

```bash
git clone <repository-url>
cd sony_camera_mcp
npm install
```

### Building

```bash
npm run build
```

### Testing

```bash
npm test
```

### Running in Development Mode

```bash
npm run dev
```

### Contributing with Conventional Commits

This project uses conventional commits for better changelog generation and automated versioning.

#### Making Commits

Use the interactive commit tool:

```bash
npm run commit
# or
./commit.sh
```

This will guide you through creating properly formatted commit messages.

#### Manual Commits

If you prefer to write commits manually, follow the conventional commit format:

```
<type>[optional scope]: <description>

[optional body]

[optional footer(s)]
```

**Types:**
- `feat`: New feature
- `fix`: Bug fix
- `docs`: Documentation changes
- `style`: Code style changes (formatting, etc.)
- `refactor`: Code refactoring
- `test`: Adding or updating tests
- `chore`: Maintenance tasks
- `perf`: Performance improvements
- `ci`: CI/CD changes
- `build`: Build system changes

#### Creating Releases

To create a new release:

```bash
npm run release
```

This will:
1. Analyze commits since the last release
2. Determine the next version number
3. Generate/update CHANGELOG.md
4. Create a git tag
5. Commit the changes

### CI/CD Pipeline

The project includes GitHub Actions workflows for:

- **CI/CD Pipeline** (`.github/workflows/ci-cd.yml`):
  - Runs tests on multiple Node.js versions
  - Builds the project
  - Publishes to NPM on releases
  - Validates conventional commits on PRs

- **Manual Release** (`.github/workflows/release.yml`):
  - Manually triggered releases
  - Choose release type (patch/minor/major)
  - Automated NPM publishing

#### Required Secrets

To enable NPM publishing, add the following secret to your GitHub repository:

- `NPM_TOKEN`: Your NPM authentication token

## Integration with AI Assistants

This MCP server is designed to work with AI assistants that support the Model Context Protocol. When integrated, AI assistants can:

- Automatically adjust camera settings based on scene analysis
- Capture photos and analyze them in real-time
- Provide cinematography advice and apply optimal settings
- Control multiple camera functions through natural language

## Troubleshooting

### Common Issues

1. **Camera not found**: Ensure the camera is connected to Wi-Fi or Wi-Fi Direct and the IP address is correct
2. **Connection timeout**: Check that both devices are on the same network or properly connected via Wi-Fi Direct
3. **Permission denied**: Make sure the camera is in "Control with Smartphone" mode or Wi-Fi Direct is enabled

### Debug Mode

Enable debug logging to see detailed API communication:

```bash
DEBUG=true npx -y @neirth/sony-camera-mcp
```

## License

MIT License

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.
