Skip to main content
GuidesRun the camera MCP server without Studio

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 wantUse
Claude running your camera, with Studio openStudio. No code.
The same without Studio, for one cameraOne command: npx darkgrade mcp
Several cameras, HTTP, or your own rulesYour own server, written with Slate

Run it with one command

The CLI serves the tools itself. Add it to Claude Code:

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 has the flags and each app's configuration.

Write the server

  1. 1

    Install Slate and the MCP SDK

    Install Slate in a project, then add the MCP SDK and zod. Slate lists both as optional peer dependencies at these exact versions.

    npm install @modelcontextprotocol/server@2.3.0 zod@4.6.6
  2. 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.

    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 runs each tool call through Camera 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.

  3. 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.

    claude mcp add darkgrade -- node /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 says where each app keeps its config.

  4. 4

    Ask

    What camera is connected?

    Claude calls camera_get_info with camera: "main", or any other name: this script holds one camera and answers for every name.

On macOS, connect() fails with an access or busy error until you stop the system's own camera service. Prepare your computer shows how. Studio does this for you.

What differs from Studio

Your server offers every tool in the tool reference. Compared with Studio's server and with darkgrade mcp:

Studiodarkgrade mcpYour own process
Connection toolsNot offered: Studio connects for youcamera_discover and camera_recover: the server connects and disconnects for youcamera_discover, camera_connect, camera_disconnect, camera_recover
camera argumentNoneNoneOn every tool except camera_discover: the name your script knows the camera by
Studio's own toolsYesNoNo
Setting valuesLoose: "daylight" finds "Daylight"Slate's spellingSlate's spelling, as the camera lists them
Photos sent to the computer, and downloadsNot savedSaved in Pictures/Darkgrade, or the --output folderSaved by your saveFile
camera_run_benchmarkNot offeredOffered; failsOffered; fails unless your provider has benchmark
TransportHTTP on port 7461stdiostdio or HTTP
Server namedarkgrade-studiodarkgradedarkgrade

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, a live-view frame, a preview), and the path it returns goes into the result, where Claude can read it.

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 shows the result's shape.

Go further with the runtime

The object you pass to CameraRuntime is its provider. Host cameras for other processes is the full guide; these are the parts a tool server most often needs.

ToRead
Serve several cameras by nameWrite 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
Use the camera from your own code between Claude's callsThe queue
Add the camera tools to an MCP server you already haveServe 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:

npm install @modelcontextprotocol/node@2.1.1
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. 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.

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.

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 lists them. Studio does not serve these routes: connect to Studio at its MCP address instead.

Next

⌘I