lightroom-mcp 0.1.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. lightroom_mcp-0.1.3/LICENSE +21 -0
  2. lightroom_mcp-0.1.3/PKG-INFO +169 -0
  3. lightroom_mcp-0.1.3/README.md +138 -0
  4. lightroom_mcp-0.1.3/pyproject.toml +80 -0
  5. lightroom_mcp-0.1.3/pyproject.toml.orig +72 -0
  6. lightroom_mcp-0.1.3/src/lightroom_mcp/__init__.py +1 -0
  7. lightroom_mcp-0.1.3/src/lightroom_mcp/bridge.py +175 -0
  8. lightroom_mcp-0.1.3/src/lightroom_mcp/catalog.py +307 -0
  9. lightroom_mcp-0.1.3/src/lightroom_mcp/cli.py +457 -0
  10. lightroom_mcp-0.1.3/src/lightroom_mcp/config.py +58 -0
  11. lightroom_mcp-0.1.3/src/lightroom_mcp/core/__init__.py +28 -0
  12. lightroom_mcp-0.1.3/src/lightroom_mcp/core/app.py +72 -0
  13. lightroom_mcp-0.1.3/src/lightroom_mcp/core/develop.py +72 -0
  14. lightroom_mcp-0.1.3/src/lightroom_mcp/core/export.py +48 -0
  15. lightroom_mcp-0.1.3/src/lightroom_mcp/core/organize.py +84 -0
  16. lightroom_mcp-0.1.3/src/lightroom_mcp/core/plugins.py +259 -0
  17. lightroom_mcp-0.1.3/src/lightroom_mcp/core/search.py +42 -0
  18. lightroom_mcp-0.1.3/src/lightroom_mcp/lrplugin/LightroomBridge.lrplugin/CmdApp.lua +28 -0
  19. lightroom_mcp-0.1.3/src/lightroom_mcp/lrplugin/LightroomBridge.lrplugin/CmdDevelop.lua +134 -0
  20. lightroom_mcp-0.1.3/src/lightroom_mcp/lrplugin/LightroomBridge.lrplugin/CmdExport.lua +64 -0
  21. lightroom_mcp-0.1.3/src/lightroom_mcp/lrplugin/LightroomBridge.lrplugin/CmdOrganize.lua +146 -0
  22. lightroom_mcp-0.1.3/src/lightroom_mcp/lrplugin/LightroomBridge.lrplugin/CmdPhotos.lua +24 -0
  23. lightroom_mcp-0.1.3/src/lightroom_mcp/lrplugin/LightroomBridge.lrplugin/Dispatch.lua +75 -0
  24. lightroom_mcp-0.1.3/src/lightroom_mcp/lrplugin/LightroomBridge.lrplugin/Info.lua +21 -0
  25. lightroom_mcp-0.1.3/src/lightroom_mcp/lrplugin/LightroomBridge.lrplugin/Init.lua +59 -0
  26. lightroom_mcp-0.1.3/src/lightroom_mcp/lrplugin/LightroomBridge.lrplugin/JSON.lua +189 -0
  27. lightroom_mcp-0.1.3/src/lightroom_mcp/lrplugin/LightroomBridge.lrplugin/Server.lua +156 -0
  28. lightroom_mcp-0.1.3/src/lightroom_mcp/lrplugin/LightroomBridge.lrplugin/Shutdown.lua +5 -0
  29. lightroom_mcp-0.1.3/src/lightroom_mcp/lrplugin/LightroomBridge.lrplugin/ShutdownApp.lua +10 -0
  30. lightroom_mcp-0.1.3/src/lightroom_mcp/lrplugin/LightroomBridge.lrplugin/StatusMenu.lua +10 -0
  31. lightroom_mcp-0.1.3/src/lightroom_mcp/lrplugin/LightroomBridge.lrplugin/Util.lua +103 -0
  32. lightroom_mcp-0.1.3/src/lightroom_mcp/luatable.py +124 -0
  33. lightroom_mcp-0.1.3/src/lightroom_mcp/mcp_server.py +290 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 0xB0Bdev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,169 @@
1
+ Metadata-Version: 2.4
2
+ Name: lightroom-mcp
3
+ Version: 0.1.3
4
+ Summary: CLI and MCP server for Adobe Lightroom Classic
5
+ Keywords: lightroom,lightroom-classic,adobe,mcp,model-context-protocol,photography,cli
6
+ Author: 0xB0Bdev
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Environment :: Console
11
+ Classifier: Environment :: MacOS X
12
+ Classifier: Intended Audience :: End Users/Desktop
13
+ Classifier: Operating System :: MacOS
14
+ Classifier: Programming Language :: Lua
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Topic :: Multimedia :: Graphics
22
+ Requires-Dist: fastmcp>=4.2.2
23
+ Requires-Dist: pydantic>=2.14.3
24
+ Requires-Dist: typer>=0.29.2
25
+ Requires-Python: >=3.11
26
+ Project-URL: Homepage, https://github.com/0xB0Bdev/lightroom-mcp
27
+ Project-URL: Source, https://github.com/0xB0Bdev/lightroom-mcp
28
+ Project-URL: Issues, https://github.com/0xB0Bdev/lightroom-mcp/issues
29
+ Project-URL: Changelog, https://github.com/0xB0Bdev/lightroom-mcp/blob/main/CHANGELOG.md
30
+ Description-Content-Type: text/markdown
31
+
32
+ # lightroom-mcp
33
+
34
+ Control Adobe Lightroom Classic from the command line, and expose the same operations to AI agents through an MCP server.
35
+
36
+ - **Search and inspect** photos, collections and keywords (reads the catalog directly; Lightroom can be closed)
37
+ - **Organize**: ratings, flags, color labels, keywords, text metadata, collections
38
+ - **Develop**: read and apply settings, presets, copy settings, virtual copies
39
+ - **Export** through Lightroom's own renderer
40
+ - **Plugins**: list, install, uninstall, reload; restart Lightroom
41
+
42
+ macOS only. Built against Lightroom Classic 11 (SDK 11).
43
+
44
+ ## How it works
45
+
46
+ ```
47
+ lightroom-mcp (Typer) ─┐
48
+ ├─> core functions ─┬─> catalog.py read-only SQLite on the .lrcat
49
+ lightroom-mcp mcp ─────┘ ├─> bridge.py JSON lines over a localhost socket, replies as files
50
+ (FastMCP, stdio) └─> plugins/app files in Modules/, osascript to quit
51
+ │
52
+ LightroomBridge.lrplugin (Lua, runs inside Lightroom)
53
+ ```
54
+
55
+ Reads go straight to the catalog file, opened read-only. Anything that changes Lightroom goes through a small Lua plugin that runs inside Lightroom and uses the official SDK, so every change is a normal undoable Lightroom action. The catalog file is never written to directly.
56
+
57
+ ## Setup
58
+
59
+ Install the `lightroom-mcp` command:
60
+
61
+ ```bash
62
+ uv tool install lightroom-mcp
63
+ ```
64
+
65
+ (or `pipx install lightroom-mcp`). Then install the bridge plugin:
66
+
67
+ ```bash
68
+ lightroom-mcp plugins bridge-install --restart
69
+ ```
70
+
71
+ This copies the plugin into `~/Library/Application Support/Adobe/Lightroom/Modules/` and restarts Lightroom so it loads. Check it with:
72
+
73
+ ```bash
74
+ lightroom-mcp status
75
+ ```
76
+
77
+ After upgrading lightroom-mcp, run `bridge-install` again so the plugin matches.
78
+
79
+ ## Usage
80
+
81
+ Photos are addressed by catalog id (the `id` column from `photos search`) or with `--selected` for the current Lightroom selection. Add `--json` before the command for machine-readable output.
82
+
83
+ ```bash
84
+ lightroom-mcp photos search --rating ">=3" --camera "EOS" --after 2026-01-01
85
+ lightroom-mcp photos show 153 --develop
86
+ lightroom-mcp photos selected
87
+
88
+ lightroom-mcp organize rate 4 153 194
89
+ lightroom-mcp organize flag picked --selected
90
+ lightroom-mcp organize label red 153
91
+ lightroom-mcp organize set-metadata 153 -f title="Studio test" -f caption="First roll"
92
+ lightroom-mcp keywords add "film,studio" 153 194
93
+ lightroom-mcp collections create "Best Of"
94
+ lightroom-mcp collections add "Best Of" 153 194
95
+
96
+ lightroom-mcp develop get 153 --keys Exposure2012,Temperature,Tint
97
+ lightroom-mcp develop set Exposure2012=0.5 Contrast2012=10 --id 153
98
+ lightroom-mcp develop copy 153 194 229 --keys Temperature,Tint
99
+ lightroom-mcp develop presets
100
+ lightroom-mcp develop apply-preset "My Preset" --selected
101
+ lightroom-mcp develop virtual-copy 153
102
+
103
+ lightroom-mcp export 153 194 --to ~/Desktop/out --format jpeg --quality 85 --long-edge 2048
104
+
105
+ lightroom-mcp plugins list
106
+ lightroom-mcp plugins install ~/dev/MyPlugin.lrplugin --link --restart
107
+ lightroom-mcp plugins uninstall MyPlugin --restart
108
+ lightroom-mcp plugins reload
109
+ lightroom-mcp plugins extras
110
+ lightroom-mcp app restart
111
+ ```
112
+
113
+ ## MCP server
114
+
115
+ `lightroom-mcp mcp` runs a FastMCP server over stdio. To add it to Claude Code:
116
+
117
+ ```bash
118
+ claude mcp add lightroom -- uvx lightroom-mcp mcp
119
+ ```
120
+
121
+ Or in a JSON MCP config (Claude Desktop and others):
122
+
123
+ ```json
124
+ {
125
+ "mcpServers": {
126
+ "lightroom": {
127
+ "command": "uvx",
128
+ "args": ["lightroom-mcp", "mcp"]
129
+ }
130
+ }
131
+ }
132
+ ```
133
+
134
+ Tools mirror the CLI: `search_photos`, `get_photo`, `selected_photos`, `set_rating`, `set_flag`, `set_color_label`, `add_keywords`, `set_metadata`, `create_collection`, `add_to_collection`, `get_develop_settings`, `apply_develop_settings`, `apply_develop_preset`, `copy_develop_settings`, `create_virtual_copies`, `export_photos`, `list_plugins`, `install_plugin`, `uninstall_plugin`, `reload_plugin`, `restart_lightroom` and more. Read-only tools are annotated as such; tools that overwrite edits, delete plugins or restart Lightroom are marked destructive.
135
+
136
+ ## Plugin management limits
137
+
138
+ The Lightroom SDK has no API for installing, removing or reloading plugins, or for one plugin to run another's menu commands. So:
139
+
140
+ - `install` / `uninstall` copy into or delete from Lightroom's user `Modules` folder and take effect on restart. Plugins added through Plug-in Manager are listed but must be removed there.
141
+ - `reload` restarts the bridge plugin in place (its server and command handlers) without restarting Lightroom. Any other plugin is reloaded by restarting Lightroom (`--restart`).
142
+ - `plugins extras` lists every plugin's Plug-in Extras commands; `run-extra` can only run the bridge's own.
143
+ - `osascript` is used only to ask Lightroom to quit. No UI scripting, no Accessibility permission.
144
+
145
+ ## Configuration
146
+
147
+ | Variable | Purpose |
148
+ |---|---|
149
+ | `LIGHTROOM_CATALOG` | Path to the `.lrcat` to read. Default: `~/Pictures/Lightroom/Lightroom Catalog.lrcat` |
150
+ | `LIGHTROOM_BRIDGE_PORT` | Port the bridge plugin listens on. Default: 58763 |
151
+
152
+ ## Security
153
+
154
+ The bridge listens on localhost only and has no authentication: any local process can send it commands while Lightroom is open. Don't install it on a shared machine.
155
+
156
+ ## Development
157
+
158
+ ```bash
159
+ git clone https://github.com/0xB0Bdev/lightroom-mcp.git
160
+ cd lightroom-mcp
161
+ uv sync
162
+ uv run pytest
163
+ ```
164
+
165
+ Run the CLI from the checkout with `uv run lightroom-mcp …`. Install the bridge with `--link` to work on the Lua handlers in place; `lightroom-mcp plugins reload` picks up edits to any of the plugin's Lua files without restarting Lightroom.
166
+
167
+ ## License
168
+
169
+ [MIT](https://github.com/0xB0Bdev/lightroom-mcp/blob/main/LICENSE)
@@ -0,0 +1,138 @@
1
+ # lightroom-mcp
2
+
3
+ Control Adobe Lightroom Classic from the command line, and expose the same operations to AI agents through an MCP server.
4
+
5
+ - **Search and inspect** photos, collections and keywords (reads the catalog directly; Lightroom can be closed)
6
+ - **Organize**: ratings, flags, color labels, keywords, text metadata, collections
7
+ - **Develop**: read and apply settings, presets, copy settings, virtual copies
8
+ - **Export** through Lightroom's own renderer
9
+ - **Plugins**: list, install, uninstall, reload; restart Lightroom
10
+
11
+ macOS only. Built against Lightroom Classic 11 (SDK 11).
12
+
13
+ ## How it works
14
+
15
+ ```
16
+ lightroom-mcp (Typer) ─┐
17
+ ├─> core functions ─┬─> catalog.py read-only SQLite on the .lrcat
18
+ lightroom-mcp mcp ─────┘ ├─> bridge.py JSON lines over a localhost socket, replies as files
19
+ (FastMCP, stdio) └─> plugins/app files in Modules/, osascript to quit
20
+ │
21
+ LightroomBridge.lrplugin (Lua, runs inside Lightroom)
22
+ ```
23
+
24
+ Reads go straight to the catalog file, opened read-only. Anything that changes Lightroom goes through a small Lua plugin that runs inside Lightroom and uses the official SDK, so every change is a normal undoable Lightroom action. The catalog file is never written to directly.
25
+
26
+ ## Setup
27
+
28
+ Install the `lightroom-mcp` command:
29
+
30
+ ```bash
31
+ uv tool install lightroom-mcp
32
+ ```
33
+
34
+ (or `pipx install lightroom-mcp`). Then install the bridge plugin:
35
+
36
+ ```bash
37
+ lightroom-mcp plugins bridge-install --restart
38
+ ```
39
+
40
+ This copies the plugin into `~/Library/Application Support/Adobe/Lightroom/Modules/` and restarts Lightroom so it loads. Check it with:
41
+
42
+ ```bash
43
+ lightroom-mcp status
44
+ ```
45
+
46
+ After upgrading lightroom-mcp, run `bridge-install` again so the plugin matches.
47
+
48
+ ## Usage
49
+
50
+ Photos are addressed by catalog id (the `id` column from `photos search`) or with `--selected` for the current Lightroom selection. Add `--json` before the command for machine-readable output.
51
+
52
+ ```bash
53
+ lightroom-mcp photos search --rating ">=3" --camera "EOS" --after 2026-01-01
54
+ lightroom-mcp photos show 153 --develop
55
+ lightroom-mcp photos selected
56
+
57
+ lightroom-mcp organize rate 4 153 194
58
+ lightroom-mcp organize flag picked --selected
59
+ lightroom-mcp organize label red 153
60
+ lightroom-mcp organize set-metadata 153 -f title="Studio test" -f caption="First roll"
61
+ lightroom-mcp keywords add "film,studio" 153 194
62
+ lightroom-mcp collections create "Best Of"
63
+ lightroom-mcp collections add "Best Of" 153 194
64
+
65
+ lightroom-mcp develop get 153 --keys Exposure2012,Temperature,Tint
66
+ lightroom-mcp develop set Exposure2012=0.5 Contrast2012=10 --id 153
67
+ lightroom-mcp develop copy 153 194 229 --keys Temperature,Tint
68
+ lightroom-mcp develop presets
69
+ lightroom-mcp develop apply-preset "My Preset" --selected
70
+ lightroom-mcp develop virtual-copy 153
71
+
72
+ lightroom-mcp export 153 194 --to ~/Desktop/out --format jpeg --quality 85 --long-edge 2048
73
+
74
+ lightroom-mcp plugins list
75
+ lightroom-mcp plugins install ~/dev/MyPlugin.lrplugin --link --restart
76
+ lightroom-mcp plugins uninstall MyPlugin --restart
77
+ lightroom-mcp plugins reload
78
+ lightroom-mcp plugins extras
79
+ lightroom-mcp app restart
80
+ ```
81
+
82
+ ## MCP server
83
+
84
+ `lightroom-mcp mcp` runs a FastMCP server over stdio. To add it to Claude Code:
85
+
86
+ ```bash
87
+ claude mcp add lightroom -- uvx lightroom-mcp mcp
88
+ ```
89
+
90
+ Or in a JSON MCP config (Claude Desktop and others):
91
+
92
+ ```json
93
+ {
94
+ "mcpServers": {
95
+ "lightroom": {
96
+ "command": "uvx",
97
+ "args": ["lightroom-mcp", "mcp"]
98
+ }
99
+ }
100
+ }
101
+ ```
102
+
103
+ Tools mirror the CLI: `search_photos`, `get_photo`, `selected_photos`, `set_rating`, `set_flag`, `set_color_label`, `add_keywords`, `set_metadata`, `create_collection`, `add_to_collection`, `get_develop_settings`, `apply_develop_settings`, `apply_develop_preset`, `copy_develop_settings`, `create_virtual_copies`, `export_photos`, `list_plugins`, `install_plugin`, `uninstall_plugin`, `reload_plugin`, `restart_lightroom` and more. Read-only tools are annotated as such; tools that overwrite edits, delete plugins or restart Lightroom are marked destructive.
104
+
105
+ ## Plugin management limits
106
+
107
+ The Lightroom SDK has no API for installing, removing or reloading plugins, or for one plugin to run another's menu commands. So:
108
+
109
+ - `install` / `uninstall` copy into or delete from Lightroom's user `Modules` folder and take effect on restart. Plugins added through Plug-in Manager are listed but must be removed there.
110
+ - `reload` restarts the bridge plugin in place (its server and command handlers) without restarting Lightroom. Any other plugin is reloaded by restarting Lightroom (`--restart`).
111
+ - `plugins extras` lists every plugin's Plug-in Extras commands; `run-extra` can only run the bridge's own.
112
+ - `osascript` is used only to ask Lightroom to quit. No UI scripting, no Accessibility permission.
113
+
114
+ ## Configuration
115
+
116
+ | Variable | Purpose |
117
+ |---|---|
118
+ | `LIGHTROOM_CATALOG` | Path to the `.lrcat` to read. Default: `~/Pictures/Lightroom/Lightroom Catalog.lrcat` |
119
+ | `LIGHTROOM_BRIDGE_PORT` | Port the bridge plugin listens on. Default: 58763 |
120
+
121
+ ## Security
122
+
123
+ The bridge listens on localhost only and has no authentication: any local process can send it commands while Lightroom is open. Don't install it on a shared machine.
124
+
125
+ ## Development
126
+
127
+ ```bash
128
+ git clone https://github.com/0xB0Bdev/lightroom-mcp.git
129
+ cd lightroom-mcp
130
+ uv sync
131
+ uv run pytest
132
+ ```
133
+
134
+ Run the CLI from the checkout with `uv run lightroom-mcp …`. Install the bridge with `--link` to work on the Lua handlers in place; `lightroom-mcp plugins reload` picks up edits to any of the plugin's Lua files without restarting Lightroom.
135
+
136
+ ## License
137
+
138
+ [MIT](https://github.com/0xB0Bdev/lightroom-mcp/blob/main/LICENSE)
@@ -0,0 +1,80 @@
1
+ [project]
2
+ name = "lightroom-mcp"
3
+ version = "0.1.3"
4
+ description = "CLI and MCP server for Adobe Lightroom Classic"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ keywords = [
10
+ "lightroom",
11
+ "lightroom-classic",
12
+ "adobe",
13
+ "mcp",
14
+ "model-context-protocol",
15
+ "photography",
16
+ "cli",
17
+ ]
18
+ classifiers = [
19
+ "Development Status :: 3 - Alpha",
20
+ "Environment :: Console",
21
+ "Environment :: MacOS X",
22
+ "Intended Audience :: End Users/Desktop",
23
+ "Operating System :: MacOS",
24
+ "Programming Language :: Lua",
25
+ "Programming Language :: Python :: 3",
26
+ "Programming Language :: Python :: 3 :: Only",
27
+ "Programming Language :: Python :: 3.11",
28
+ "Programming Language :: Python :: 3.12",
29
+ "Programming Language :: Python :: 3.13",
30
+ "Programming Language :: Python :: 3.14",
31
+ "Topic :: Multimedia :: Graphics",
32
+ ]
33
+ dependencies = [
34
+ "fastmcp>=4.2.2",
35
+ "pydantic>=2.14.3",
36
+ "typer>=0.29.2",
37
+ ]
38
+
39
+ [[project.authors]]
40
+ name = "0xB0Bdev"
41
+
42
+ [project.urls]
43
+ Homepage = "https://github.com/0xB0Bdev/lightroom-mcp"
44
+ Source = "https://github.com/0xB0Bdev/lightroom-mcp"
45
+ Issues = "https://github.com/0xB0Bdev/lightroom-mcp/issues"
46
+ Changelog = "https://github.com/0xB0Bdev/lightroom-mcp/blob/main/CHANGELOG.md"
47
+
48
+ [project.scripts]
49
+ lightroom-mcp = "lightroom_mcp.cli:main"
50
+
51
+ [build-system]
52
+ requires = ["uv_build>=0.13.7,<0.14.0"]
53
+ build-backend = "uv_build"
54
+
55
+ [dependency-groups]
56
+ dev = ["pytest>=9.2.0"]
57
+
58
+ [tool.semantic_release]
59
+ version_toml = ["pyproject.toml:project.version"]
60
+ tag_format = "v{version}"
61
+ commit_message = "chore(release): {version} [skip ci]"
62
+ allow_zero_version = true
63
+ major_on_zero = false
64
+ build_command = """
65
+ uv lock --upgrade-package lightroom-mcp
66
+ uv run --no-project python scripts/sync_plugin_version.py
67
+ git add uv.lock src/lightroom_mcp/lrplugin/LightroomBridge.lrplugin/Info.lua
68
+ uv build
69
+ """
70
+
71
+ [tool.semantic_release.branches.main]
72
+ match = "main"
73
+ prerelease = false
74
+
75
+ [tool.semantic_release.changelog.default_templates]
76
+ changelog_file = "CHANGELOG.md"
77
+
78
+ [tool.semantic_release.publish]
79
+ dist_glob_patterns = ["dist/*"]
80
+ upload_to_vcs_release = true
@@ -0,0 +1,72 @@
1
+ [project]
2
+ name = "lightroom-mcp"
3
+ version = "0.1.3"
4
+ description = "CLI and MCP server for Adobe Lightroom Classic"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ authors = [{ name = "0xB0Bdev" }]
10
+ keywords = ["lightroom", "lightroom-classic", "adobe", "mcp", "model-context-protocol", "photography", "cli"]
11
+ classifiers = [
12
+ "Development Status :: 3 - Alpha",
13
+ "Environment :: Console",
14
+ "Environment :: MacOS X",
15
+ "Intended Audience :: End Users/Desktop",
16
+ "Operating System :: MacOS",
17
+ "Programming Language :: Lua",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3 :: Only",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Programming Language :: Python :: 3.14",
24
+ "Topic :: Multimedia :: Graphics",
25
+ ]
26
+ dependencies = [
27
+ "fastmcp>=4.2.2",
28
+ "pydantic>=2.14.3",
29
+ "typer>=0.29.2",
30
+ ]
31
+
32
+ [project.urls]
33
+ Homepage = "https://github.com/0xB0Bdev/lightroom-mcp"
34
+ Source = "https://github.com/0xB0Bdev/lightroom-mcp"
35
+ Issues = "https://github.com/0xB0Bdev/lightroom-mcp/issues"
36
+ Changelog = "https://github.com/0xB0Bdev/lightroom-mcp/blob/main/CHANGELOG.md"
37
+
38
+ [project.scripts]
39
+ lightroom-mcp = "lightroom_mcp.cli:main"
40
+
41
+ [build-system]
42
+ requires = ["uv_build>=0.13.7,<0.14.0"]
43
+ build-backend = "uv_build"
44
+
45
+ [dependency-groups]
46
+ dev = [
47
+ "pytest>=9.2.0",
48
+ ]
49
+
50
+ [tool.semantic_release]
51
+ version_toml = ["pyproject.toml:project.version"]
52
+ tag_format = "v{version}"
53
+ commit_message = "chore(release): {version} [skip ci]"
54
+ allow_zero_version = true
55
+ major_on_zero = false
56
+ build_command = """
57
+ uv lock --upgrade-package lightroom-mcp
58
+ uv run --no-project python scripts/sync_plugin_version.py
59
+ git add uv.lock src/lightroom_mcp/lrplugin/LightroomBridge.lrplugin/Info.lua
60
+ uv build
61
+ """
62
+
63
+ [tool.semantic_release.branches.main]
64
+ match = "main"
65
+ prerelease = false
66
+
67
+ [tool.semantic_release.changelog.default_templates]
68
+ changelog_file = "CHANGELOG.md"
69
+
70
+ [tool.semantic_release.publish]
71
+ dist_glob_patterns = ["dist/*"]
72
+ upload_to_vcs_release = true
@@ -0,0 +1 @@
1
+ """Command-line and MCP control of Adobe Lightroom Classic."""
@@ -0,0 +1,175 @@
1
+ """Client for the LightroomBridge plugin.
2
+
3
+ Requests are newline-delimited JSON written to the plugin's localhost socket. Each
4
+ request names a reply token, and the plugin answers by writing <token>.json into a
5
+ shared responses folder. (Lightroom's sockets are one-directional, and its sending
6
+ mode can't cope with clients coming and going, so replies don't use a socket.)
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import itertools
12
+ import json
13
+ import re
14
+ import select
15
+ import socket
16
+ import threading
17
+ import time
18
+ import uuid
19
+ from pathlib import Path
20
+ from typing import Any
21
+
22
+ from . import config
23
+
24
+
25
+ class BridgeError(RuntimeError):
26
+ """The plugin reported an error for a command."""
27
+
28
+
29
+ class BridgeUnavailable(BridgeError):
30
+ """Could not reach the plugin at all."""
31
+
32
+
33
+ _UNAVAILABLE = (
34
+ "Can't reach the Lightroom bridge. Make sure Lightroom Classic is running and the bridge "
35
+ "plugin is installed (`lightroom-mcp plugins bridge-install --restart`)."
36
+ )
37
+
38
+
39
+ class Bridge:
40
+ def __init__(self, host: str = "127.0.0.1", port: int | None = None, response_dir: Path | None = None):
41
+ self.host = host
42
+ self.port = port or config.bridge_port()
43
+ self.response_dir = Path(response_dir or config.RESPONSE_DIR)
44
+ self._sock: socket.socket | None = None
45
+ self._session = uuid.uuid4().hex
46
+ self._ids = itertools.count(1)
47
+ self._lock = threading.Lock()
48
+
49
+ def connect(self, wait: float = 3.0) -> None:
50
+ """Connect, retrying briefly (the plugin stops listening for a moment after each disconnect)."""
51
+ deadline = time.monotonic() + wait
52
+ while True:
53
+ try:
54
+ self._sock = socket.create_connection((self.host, self.port), timeout=1)
55
+ return
56
+ except OSError as exc:
57
+ self._sock = None
58
+ if time.monotonic() >= deadline:
59
+ raise BridgeUnavailable(f"{_UNAVAILABLE} ({exc})") from exc
60
+ time.sleep(0.1)
61
+
62
+ def close(self) -> None:
63
+ if self._sock is not None:
64
+ try:
65
+ self._sock.close()
66
+ except OSError:
67
+ pass
68
+ self._sock = None
69
+
70
+ def _drain(self, wait: float = 0.0) -> bytes | None:
71
+ """Read whatever the plugin wrote back; None if it hung up."""
72
+ if self._sock is None:
73
+ return None
74
+ data = b""
75
+ try:
76
+ while select.select([self._sock], [], [], wait)[0]:
77
+ chunk = self._sock.recv(4096)
78
+ if not chunk:
79
+ return None
80
+ data += chunk
81
+ wait = 0.0
82
+ except (OSError, ValueError):
83
+ return None
84
+ return data
85
+
86
+ def _send(self, payload: bytes) -> None:
87
+ """Connect and write the request. A failed write leaves no socket; the caller retries."""
88
+ self.connect()
89
+ assert self._sock is not None
90
+ try:
91
+ self._sock.sendall(payload)
92
+ except OSError:
93
+ self.close()
94
+
95
+ def call(self, command: str, params: dict[str, Any] | None = None, timeout: float = 30.0) -> Any:
96
+ """Send one command and wait for its result.
97
+
98
+ The plugin serves one connection at a time, so the connection is opened for the call
99
+ and closed straight after. A long-running process (the MCP server) that kept it open
100
+ would lock every other client out.
101
+
102
+ Lightroom acknowledges each line it reads with "ok". Right after another client
103
+ disconnects, a new connection can be accepted and then dropped unread while Lightroom
104
+ re-listens; if the connection dies before the acknowledgement, the request is sent
105
+ again. The plugin ignores a reply token it has already seen, so a resend can't run a
106
+ command twice.
107
+ """
108
+ with self._lock:
109
+ request_id = next(self._ids)
110
+ reply = f"{self._session}-{request_id}"
111
+ reply_file = self.response_dir / f"{reply}.json"
112
+ payload = json.dumps(
113
+ {"id": request_id, "command": command, "params": params or {}, "reply": reply}
114
+ ).encode() + b"\n"
115
+ deadline = time.monotonic() + timeout
116
+ acknowledged = False
117
+ try:
118
+ self._send(payload)
119
+ while True:
120
+ try:
121
+ text = reply_file.read_text()
122
+ except FileNotFoundError:
123
+ text = ""
124
+ # An empty file has been created but not yet written; keep waiting.
125
+ if text:
126
+ reply_file.unlink(missing_ok=True)
127
+ try:
128
+ message = json.loads(text)
129
+ except json.JSONDecodeError as error:
130
+ raise BridgeError(
131
+ f"Lightroom sent an unreadable reply to '{command}': {error}"
132
+ ) from error
133
+ break
134
+ if time.monotonic() >= deadline:
135
+ raise BridgeError(
136
+ f"Lightroom did not answer '{command}' within {timeout:g}s. It may be busy, "
137
+ "showing a dialog, or serving another client."
138
+ )
139
+ received = self._drain(wait=0.02)
140
+ if received:
141
+ acknowledged = True
142
+ elif received is None:
143
+ self.close()
144
+ if acknowledged:
145
+ # Delivered; the command is running. Only confirm Lightroom is still there.
146
+ self.connect()
147
+ else:
148
+ time.sleep(0.02)
149
+ self._send(payload)
150
+ finally:
151
+ self.close()
152
+ if not message.get("ok"):
153
+ error = str(message.get("error") or "unknown bridge error")
154
+ # Lua prefixes errors with their source position, e.g. [string "Util.lua"]:46:
155
+ raise BridgeError(re.sub(r'^\[string "[^"]*"\]:\d+: ', "", error))
156
+ return message.get("result")
157
+
158
+
159
+ _shared: Bridge | None = None
160
+
161
+
162
+ def call(command: str, params: dict[str, Any] | None = None, timeout: float = 30.0) -> Any:
163
+ """Call the bridge over a process-wide connection."""
164
+ global _shared
165
+ if _shared is None:
166
+ _shared = Bridge()
167
+ return _shared.call(command, params, timeout)
168
+
169
+
170
+ def is_available() -> bool:
171
+ try:
172
+ call("ping", timeout=3)
173
+ return True
174
+ except BridgeError:
175
+ return False