UNPKG

@neirth/sony-camera-mcp

Version:

MCP Server for controlling Sony Alpha 6100 camera

172 lines 7.47 kB
import { CameraConfig, DeviceDescription, ShootMode, ZoomDirection, ZoomMovement, LiveviewSize, ServiceType, TakePictureUrl } from './models'; export default class SonyCamera { private serviceEndpoints; private deviceDescription; private readonly cameraIp; private readonly cameraPort; private readonly ddXmlPort; private readonly debug; private connected; private cameraEndpoint; private ddXmlUrl; /** * Creates a new instance of the Sony Camera client * @param {CameraConfig} config - The camera configuration object * @param {string} [config.cameraIp='192.168.122.1'] - The IP address of the camera * @param {string} [config.cameraPort='10000'] - The port used for camera control * @param {string} [config.ddXmlPort='64321'] - The port used for device description XML * @param {boolean} [config.debug=false] - Enable debug logging */ constructor(config?: CameraConfig); /** * Internal method for logging debug messages * @param {string} message - The message to log * @private */ private log; /** * Internal method for logging objects with debug information * @param {string} message - The message to log * @param {unknown} obj - The object to stringify and log * @private */ private logObject; /** * Makes an API call to the camera * @param {ServiceType} service - The service to call (camera, guide, etc.) * @param {string} method - The method name to call * @param {any[]} params - Parameters to pass to the method * @returns {Promise<UnwrappedApiResponse<T>>} The API response * @private * @template T - The expected response type * @throws {Error} If the camera is not connected or if the API call fails */ private apiCall; /** * Main method to establish connection with the camera * @returns {Promise<boolean>} True if connection is successful * @throws {Error} If connection fails or XML parsing fails */ connect(): Promise<boolean>; /** * Extract service endpoints from the device description * Goes through multiple strategies to find service endpoints in the XML structure * @private * @throws {Error} If no service endpoints are found or if the XML structure is invalid */ private extractServiceEndpoints; /** * Retrieves the device description from a specific URL * @param {string} locationUrl - The URL to fetch the device description from * @returns {Promise<DeviceDescription>} A promise that resolves with the device description * @throws {Error} If unable to fetch or parse the device description */ getDeviceDescription(locationUrl: string): Promise<DeviceDescription>; /** * Retrieves the list of available API methods for a given service * @param {ServiceType} service - The service to get API list from (defaults to "camera") * @returns {Promise<string[]>} Array of available API methods * @throws {Error} If unable to retrieve API list from both camera and guide services */ getAvailableApiList(service?: ServiceType): Promise<string[]>; /** * Gets information about the camera application * @returns {Promise<Record<string, any>>} Object containing application information * @throws {Error} If unable to retrieve application information */ getApplicationInfo(): Promise<Record<string, any>>; /** * Gets the available exposure compensation values * @returns {Promise<[number, number, number, number]>} Array containing [current, max, min, step] values * @throws {Error} If unable to retrieve exposure compensation values */ getAvailableExposureCompensation(): Promise<[number, number, number, number]>; /** * Gets the current exposure compensation value from the camera * @returns {Promise<number[]>} Array with the current exposure compensation value. Returns [0] as default if error occurs */ getExposureCompensation(): Promise<number[]>; /** * Sets the exposure compensation value * @param {number} value - The exposure compensation value to set * @throws {Error} If value is out of valid range or if setting fails */ setExposureCompensation(value: number): Promise<void>; /** * Takes a picture and returns the URL where the image can be downloaded * @returns {Promise<TakePictureUrl>} The URL to download the captured image * @throws {Error} If unable to take picture or get valid response after multiple attempts */ takePicture(): Promise<TakePictureUrl>; /** * Sets the shooting mode of the camera * @param {ShootMode} mode - The shooting mode to set * @throws {Error} If mode is null or if setting the mode fails */ setShootMode(mode: ShootMode): Promise<void>; /** * Gets the current shooting mode * @returns {Promise<ShootMode[]>} Array containing the current shoot mode */ getShootMode(): Promise<ShootMode[]>; /** * Gets the list of available shooting modes * @returns {Promise<ShootMode[]>} Array of available shooting modes */ getAvailableShootMode(): Promise<ShootMode[]>; /** * Starts the liveview feed * @param {LiveviewSize} [size=null] - The size of the liveview feed * @returns {Promise<string[]>} Array containing the liveview URL(s) * @throws {Error} If size is invalid or if starting liveview fails */ startLiveview(size?: LiveviewSize): Promise<string[] | (string & any[])>; /** * Stops the liveview feed * @returns {Promise<void>} */ stopLiveview(): Promise<unknown>; /** * Controls the camera's zoom * @param {ZoomDirection} direction - The direction to zoom (in/out) * @param {ZoomMovement} movement - The type of zoom movement * @returns {Promise<void>} * @throws {Error} If direction or movement parameters are null */ zoom(direction: ZoomDirection, movement: ZoomMovement): Promise<unknown>; /** * Gets the list of available ISO speed rates * @returns {Promise<string[]>} Array of available ISO values * @throws {Error} If unable to retrieve ISO values */ getAvailableIsoSpeedRate(): Promise<string[]>; /** * Gets the current ISO speed rate * @returns {Promise<string[]>} Array containing the current ISO value */ getIsoSpeedRate(): Promise<string[]>; /** * Sets the ISO speed rate * @param {string} isoValue - The ISO value to set * @throws {Error} If ISO value is null or not in the list of valid values */ setIsoSpeedRate(isoValue: string): Promise<void>; /** * Gets the list of available shutter speeds * @returns {Promise<string[]>} Array of available shutter speed values * @throws {Error} If unable to retrieve shutter speed values */ getAvailableShutterSpeed(): Promise<string[]>; /** * Gets the current shutter speed * @returns {Promise<string[]>} Array containing the current shutter speed value */ getShutterSpeed(): Promise<string[]>; /** * Sets the shutter speed * @param {string} shutterSpeedValue - The shutter speed value to set * @throws {Error} If shutter speed value is null or not in the list of valid values */ setShutterSpeed(shutterSpeedValue: string): Promise<void>; } //# sourceMappingURL=sony-camera.d.ts.map