--- title: "Run the camera MCP server without Studio" description: "Serve Darkgrade's camera MCP tools without Studio: one command, npx darkgrade mcp, or your own Node.js server written with Slate." url: https://darkgrade.com/docs/ai/server last_updated: 2026-12-04 docs_index: https://darkgrade.com/docs/llms.txt --- # Run the camera MCP server without Studio > Serve Darkgrade's camera MCP tools without Studio: one command, npx darkgrade mcp, or your own Node.js server written with Slate. > ## Documentation Index > Fetch the complete documentation index at: https://darkgrade.com/docs/llms.txt > Use this file to discover all available pages before exploring further. Serve Darkgrade's camera MCP tools without Studio: on a headless machine, on Linux, beside your own app, or in a rig with several cameras. There are two ways, one command or a short script. | You want | Use | | - | - | | Claude running your camera, with Studio open | [Studio](https://darkgrade.com/docs/ai.md). No code. | | The same without Studio, for one camera | [One command](#run-it-with-one-command): `npx darkgrade mcp` | | Several cameras, HTTP, or your own rules | [Your own server](#write-the-server), written with [Slate](https://darkgrade.com/docs/slate/getting_started/quickstart.md) | ## Run it with one command The CLI serves the tools itself. Add it to Claude Code: ```bash claude mcp add darkgrade -- npx -y darkgrade mcp ``` In any other app that starts MCP servers as a command, the command is `npx` with the arguments `-y darkgrade mcp`. The server holds the one attached camera, opens it on first use, and saves photos and downloads in `Pictures/Darkgrade`. [Serve your camera to an AI app](https://darkgrade.com/docs/cli/mcp.md) has the flags and each app's configuration. ## Write the server #### 1. Install Slate and the MCP SDK [Install Slate](https://darkgrade.com/docs/slate/getting_started/installation.md) in a project, then add the MCP SDK and zod. Slate lists both as optional peer dependencies at these exact versions. ```bash npm install @modelcontextprotocol/server@2.3.0 zod@4.6.6 ``` #### 2. Create the script Save this as `camera-mcp.mts`. It opens the camera, then serves the tools over stdio, the transport where your AI app starts the script and talks to it directly. ```typescript camera-mcp.mts import { Camera } from '@darkgrade/slate' import { CameraRuntime } from '@darkgrade/slate/runtime' import { createCameraMcpServer, } from '@darkgrade/slate/runtime/mcp' import { serveStdio, } from '@modelcontextprotocol/server/stdio' const camera = new Camera() await camera.connect() const runtime = new CameraRuntime({ discover: () => Camera.discover(), camera: () => camera, assertAllowed: () => {}, // allow every operation }) await serveStdio(() => createCameraMcpServer(runtime)) ``` [`CameraRuntime`](https://darkgrade.com/docs/slate/guides/runtime.md) runs each tool call through [`Camera`](https://darkgrade.com/docs/slate/getting_started/camera.md) and makes calls take turns, so Claude and your own code can share one camera. It calls `assertAllowed` before every operation: throw from it to [refuse one](https://darkgrade.com/docs/slate/guides/runtime.md#a-busy-camera). #### 3. Add it to your AI app Use the script's full path. Node.js 22.18 or later runs the TypeScript file as it is. ```bash Claude Code claude mcp add darkgrade -- node /full/path/to/camera-mcp.mts ``` ```json Claude Desktop { "mcpServers": { "darkgrade": { "command": "node", "args": ["/full/path/to/camera-mcp.mts"] } } } ``` ```json Cursor { "mcpServers": { "darkgrade": { "command": "node", "args": ["/full/path/to/camera-mcp.mts"] } } } ``` The app starts the script when it needs the tools, so plug the camera in and switch it on first. [Connect your AI app](https://darkgrade.com/docs/ai/clients.md) says where each app keeps its config. #### 4. Ask > What camera is connected? Claude calls [`camera_get_info`](https://darkgrade.com/docs/functionality/connection.md#camera-info) with `camera: "main"`, or any other name: this script holds one camera and answers for every name. > [!NOTE] > > On macOS, `connect()` fails with an access or busy error until you stop the system's own camera service. [Prepare your computer](https://darkgrade.com/docs/slate/getting_started/installation.md#prepare-your-computer) shows how. Studio does this for you. ## What differs from Studio Your server offers every tool in the [tool reference](https://darkgrade.com/docs/ai/tools.md). Compared with Studio's server and with [`darkgrade mcp`](#run-it-with-one-command): | | Studio | `darkgrade mcp` | Your own process | | - | - | - | - | | Connection tools | Not offered: Studio connects for you | `camera_discover` and `camera_recover`: the server connects and disconnects for you | `camera_discover`, `camera_connect`, `camera_disconnect`, `camera_recover` | | `camera` argument | None | None | On every tool except `camera_discover`: the name your script knows the camera by | | [Studio's own tools](https://darkgrade.com/docs/ai/studio-tools.md) | Yes | No | No | | Setting values | Loose: `"daylight"` finds `"Daylight"` | Slate's spelling | Slate's spelling, as [the camera lists them](https://darkgrade.com/docs/functionality/connection.md#what-the-camera-can-do) | | Photos sent to the computer, and downloads | Not saved | Saved in `Pictures/Darkgrade`, or the `--output` folder | Saved by your [`saveFile`](#save-photos-and-downloads) | | `camera_run_benchmark` | Not offered | Offered; fails | Offered; fails unless your provider has `benchmark` | | Transport | HTTP on port 7461 | stdio | stdio or [HTTP](#serve-over-http) | | Server name | `darkgrade-studio` | `darkgrade` | `darkgrade` | Your server's instructions tell the model to read `camera_get_capabilities` before it writes, that a command is never resent, and that a busy camera is not a reason to switch USB or power. ## Save photos and downloads File bytes don't travel inside a tool result. Give the runtime a `saveFile`: it is called with each file an operation returns (a photo taken with `destination: "computer"`, a [download](https://darkgrade.com/docs/functionality/media.md#download-a-file), a live-view frame, a preview), and the path it returns goes into the result, where Claude can read it. ```typescript import { mkdir, writeFile } from 'node:fs/promises' import { homedir } from 'node:os' import { join } from 'node:path' // An AI app may start the script in any folder, so name a fixed one. const folder = join(homedir(), 'camera-files') const runtime = new CameraRuntime({ discover: () => Camera.discover(), camera: () => camera, assertAllowed: () => {}, // allow every operation saveFile: async (_camera, file) => { await mkdir(folder, { recursive: true }) const path = join(folder, file.name) await writeFile(path, file.data) return path }, }) ``` `file` has a `role` (`photo`, `frame`, `overlay`, `preview` or `download`), a `name`, a `mimeType` and its bytes as `data`. Frames, overlays and previews also reach the model as pictures, with or without `saveFile`. Without `saveFile`, a photo's or a download's bytes are dropped: Claude learns the file's name and size only. [Results and safety](https://darkgrade.com/docs/ai/results.md#what-a-tool-returns) shows the result's shape. ## Go further with the runtime The object you pass to `CameraRuntime` is its provider. [Host cameras for other processes](https://darkgrade.com/docs/slate/guides/runtime.md) is the full guide; these are the parts a tool server most often needs. | To | Read | | - | - | | Serve several cameras by name | [Write the provider](https://darkgrade.com/docs/slate/guides/runtime.md#write-the-provider). Then tell Claude the names: “the cameras are called wide and close.” | | Refuse an operation, or say “busy, try again” | [A busy camera](https://darkgrade.com/docs/slate/guides/runtime.md#a-busy-camera) | | Use the camera from your own code between Claude's calls | [The queue](https://darkgrade.com/docs/slate/guides/runtime.md#the-queue) | | Add the camera tools to an MCP server you already have | [Serve MCP tools](https://darkgrade.com/docs/slate/guides/runtime.md#serve-mcp-tools) | ## Serve over HTTP Serve over HTTP when the AI app should connect by address, as it does to Studio, or when several apps share one camera. Add the MCP SDK's Node.js adapter, at the version that pairs with `@modelcontextprotocol/server` 2.3.0: ```bash npm install @modelcontextprotocol/node@2.1.1 ``` ```typescript camera-mcp-http.mts import { createServer } from 'node:http' import { Camera } from '@darkgrade/slate' import { CameraRuntime } from '@darkgrade/slate/runtime' import { createCameraMcpServer } from '@darkgrade/slate/runtime/mcp' import { localhostHostValidation, localhostOriginValidation, toNodeHandler, } from '@modelcontextprotocol/node' import { createMcpHandler } from '@modelcontextprotocol/server' const camera = new Camera() await camera.connect() const runtime = new CameraRuntime({ discover: () => Camera.discover(), camera: () => camera, assertAllowed: () => {}, }) const handle = toNodeHandler( createMcpHandler(() => createCameraMcpServer(runtime)), ) const hostAllowed = localhostHostValidation() const originAllowed = localhostOriginValidation() createServer((request, response) => { if (!hostAllowed(request, response)) return if (!originAllowed(request, response)) return void handle(request, response) }).listen(7462, '127.0.0.1') ``` Start it with `node camera-mcp-http.mts` and add `http://127.0.0.1:7462/` to your AI app [the way you add Studio's address](https://darkgrade.com/docs/ai/clients.md). The two guards are the ones Studio uses: they answer only requests addressed to `localhost`, `127.0.0.1` or `[::1]`, and refuse requests from web pages on other sites. > [!WARNING] > > The server has no sign-in. Anything that can reach the port can run the camera. Keep it on `127.0.0.1`, or put your own authentication in front of it before listening on a network address. ## Relay to a process that already holds the camera Only one process can hold a camera. If yours already does and exposes its `CameraRuntime` over HTTP, a second process can serve the MCP tools without opening the camera: hand `createCameraMcpServer` an `HttpCameraClient` instead of a runtime. ```typescript import { HttpCameraClient } from '@darkgrade/slate/runtime' import { createCameraMcpServer, } from '@darkgrade/slate/runtime/mcp' import { serveStdio } from '@modelcontextprotocol/server/stdio' const host = new HttpCameraClient('http://127.0.0.1:8787') await serveStdio(() => createCameraMcpServer(host)) ``` Slate has the client; the host's HTTP routes are yours to write. [Call a runtime in another process](https://darkgrade.com/docs/slate/guides/runtime.md#call-a-runtime-in-another-process) lists them. Studio does not serve these routes: connect to Studio at its [MCP address](https://darkgrade.com/docs/ai/clients.md) instead. ## Next > [card] [Tool reference](https://darkgrade.com/docs/ai/tools.md) > > Every tool your server offers, and its arguments. > [card] [Camera API](https://darkgrade.com/docs/slate/getting_started/camera.md) > > The Slate operations behind the tools. > [card] [Results and safety](https://darkgrade.com/docs/ai/results.md) > > What tools return, and which ones change the camera. > [card] [What to ask](https://darkgrade.com/docs/ai/prompts.md) > > Prompts by task.