List Bluetooth Devices
list_bluetooth_devicesRetrieve all paired Bluetooth devices and check their current connection status.
Instructions
List paired Bluetooth devices with their connection status.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/system/tools.ts:390-396 (handler)Handler function that executes the list_bluetooth_devices tool by running a JXA script via runJxa.
async () => { try { return ok(await runJxa(listBluetoothDevicesScript())); } catch (e) { return errJxaFor("list bluetooth devices", e); } }, - src/system/tools.ts:379-388 (schema)Schema and metadata for the list_bluetooth_devices tool (no input parameters, read-only).
{ title: "List Bluetooth Devices", description: "List paired Bluetooth devices with their connection status.", inputSchema: {}, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, - src/system/tools.ts:377-397 (registration)Registration of the list_bluetooth_devices tool on the MCP server via server.registerTool.
server.registerTool( "list_bluetooth_devices", { title: "List Bluetooth Devices", description: "List paired Bluetooth devices with their connection status.", inputSchema: {}, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, }, async () => { try { return ok(await runJxa(listBluetoothDevicesScript())); } catch (e) { return errJxaFor("list bluetooth devices", e); } }, ); - src/system/scripts.ts:179-204 (helper)Helper function that returns a JXA script string which uses system_profiler to list Bluetooth devices with their connection status, address, and type.
export function listBluetoothDevicesScript(): string { return ` const app = Application.currentApplication(); app.includeStandardAdditions = true; const output = app.doShellScript('system_profiler SPBluetoothDataType -json 2>/dev/null'); const data = JSON.parse(output); const devices = []; const btData = data.SPBluetoothDataType || []; for (const section of btData) { const devicesMap = section.devices_list || section.device_connected || []; for (const entry of (Array.isArray(devicesMap) ? devicesMap : [devicesMap])) { if (typeof entry === 'object' && entry !== null) { for (const name of Object.keys(entry)) { const info = entry[name] || {}; devices.push({ name: name, connected: info.device_connected === 'device_connected_yes' || info.device_connected === 'attrib_Yes' || false, address: info.device_address || null, type: info.device_minorType || null }); } } } } JSON.stringify({total: devices.length, devices: devices}); `;