Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,170 changes: 934 additions & 1,236 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 13 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "screenly"
version = "1.0.5"
version = "1.1.0"
edition = "2021"

[[bin]]
Expand Down Expand Up @@ -30,28 +30,32 @@ rayon = "1.7.0"
regex = "1.9.3"
reqwest = { version = "0.12.22", features = ["json", "blocking", "multipart"] }
rpassword = "7.2.0"
sentry = "0.42.0"
sentry-anyhow = "0.42.0"
sentry = "0.46"
sentry-anyhow = "0.46"
serde = { version = "1.0.147", features = ["derive"] }
serde_json = "1.0.87"
serde_with = "3.8.3"
serde_yaml = "0.9.17"
sha1 = "0.10.5"
sha2 = "0.10.7"
simple_logger = { version = "4.0.0", features = ["colors"] }
simple_logger = { version = "5", features = ["colors"] }
strum = "0.27"
strum_macros = "0.27"
temp-env = "0.3.6"
term = "1.1.0"
thiserror = "2.0.12"
tokio = { version = "1.32.0", features = ["rt-multi-thread"] }
tokio = { version = "1.32.0", features = ["rt-multi-thread", "macros"] }
tokio-stream = "0.1.14"
walkdir = "2.3.3"
warp = "0.3.5"
warp = "0.3"

# MCP server dependencies
rmcp = { version = "0.12", features = ["schemars", "server", "transport-io"] }
schemars = "0.8"

[dev-dependencies]
envtestkit = "1.1.2"
httpmock = "0.6"
swc_common = { version = "14.0.4", default-features = false, features = [] }
swc_ecma_parser = { version = "24.0.2", default-features = false, features = [] }
httpmock = "0.8"
swc_common = { version = "18", default-features = false, features = [] }
swc_ecma_parser = { version = "32", default-features = false, features = ["typescript"] }
tempfile = "3.8"
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM alpine:3 as builder

WORKDIR /usr/src/screenly-cli
RUN apk add --no-cache wget tar
ARG RELEASE=v1.0.5
ARG RELEASE=v1.1.0
RUN wget "https://github.com/Screenly/cli/releases/download/$RELEASE/screenly-cli-x86_64-unknown-linux-musl.tar.gz"
RUN tar xfz screenly-cli-x86_64-unknown-linux-musl.tar.gz

Expand Down
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,57 @@ $ API_SERVER_NAME=local cargo build --release

Explore available commands [here](https://developer.screenly.io/cli/#commands).

## MCP Server (AI Assistant Integration)

The Screenly CLI includes a built-in [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server, enabling AI assistants like Claude, Cursor, and others to interact with your Screenly digital signage network.

### Starting the MCP Server

```bash
$ screenly mcp
```

The server communicates over stdio and exposes the full Screenly API as tools.

### Available Tools

| Category | Tools |
|----------|-------|
| **Screens** | `screen_list`, `screen_get` |
| **Assets** | `asset_list`, `asset_get`, `asset_create`, `asset_update`, `asset_delete` |
| **Asset Groups** | `asset_group_list`, `asset_group_create`, `asset_group_update`, `asset_group_delete` |
| **Playlists** | `playlist_list`, `playlist_create`, `playlist_update`, `playlist_delete` |
| **Playlist Items** | `playlist_item_list`, `playlist_item_create`, `playlist_item_update`, `playlist_item_delete` |
| **Labels** | `label_list`, `label_create`, `label_update`, `label_delete`, `label_link_screen`, `label_unlink_screen`, `label_link_playlist`, `label_unlink_playlist` |
| **Shared Playlists** | `shared_playlist_list`, `shared_playlist_create`, `shared_playlist_delete` |
| **Edge Apps** | `edge_app_list`, `edge_app_list_settings`, `edge_app_list_instances` |

### Configuration Examples

#### Cursor / Claude Desktop

Add to your MCP configuration file:

```json
{
"mcpServers": {
"screenly": {
"command": "screenly",
"args": ["mcp"],
"env": {
"API_TOKEN": "your-api-token-here"
}
}
}
}
```

#### Authentication

The MCP server uses the same authentication as the CLI:
- Set the `API_TOKEN` environment variable, or
- Run `screenly login` to store credentials in `~/.screenly`

## GitHub Action

Integrate Screenly CLI into your GitHub workflows:
Expand Down
10 changes: 10 additions & 0 deletions docs/CommandLineHelp.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ This document contains the help content for the `screenly` command-line program.
* [`screenly edge-app deploy`↴](#screenly-edge-app-deploy)
* [`screenly edge-app delete`↴](#screenly-edge-app-delete)
* [`screenly edge-app validate`↴](#screenly-edge-app-validate)
* [`screenly mcp`↴](#screenly-mcp)

## `screenly`

Expand All @@ -61,6 +62,7 @@ Command line interface is intended for quick interaction with Screenly through t
* `asset` — Asset related commands
* `playlist` — Playlist related commands
* `edge-app` — Edge App related commands
* `mcp` — Starts the MCP (Model Context Protocol) server on stdio for AI assistant integration

###### **Options:**

Expand Down Expand Up @@ -633,6 +635,14 @@ Validates Edge App manifest file



## `screenly mcp`

Starts the MCP (Model Context Protocol) server on stdio for AI assistant integration

**Usage:** `screenly mcp`



<hr/>

<small><i>
Expand Down
23 changes: 23 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ pub enum Commands {
/// Edge App related commands.
#[command(subcommand)]
EdgeApp(EdgeAppCommands),
/// Starts the MCP (Model Context Protocol) server on stdio for AI assistant integration.
Mcp {},
/// For generating `docs/CommandLineHelp.md`.
#[clap(hide = true)]
PrintHelpMarkdown {},
Expand Down Expand Up @@ -526,12 +528,33 @@ pub fn handle_cli(cli: &Cli) {
info!("Logout successful.");
std::process::exit(0);
}
Commands::Mcp {} => {
handle_cli_mcp_command();
}
Commands::PrintHelpMarkdown {} => {
clap_markdown::print_help_markdown::<Cli>();
}
}
}

pub fn handle_cli_mcp_command() {
use crate::mcp::ScreenlyMcpServer;

let server = match ScreenlyMcpServer::new() {
Ok(s) => s,
Err(e) => {
error!("Failed to initialize MCP server: {}", e);
std::process::exit(1);
}
};

let rt = tokio::runtime::Runtime::new().expect("Failed to create Tokio runtime");
if let Err(e) = rt.block_on(server.run()) {
error!("MCP server error: {}", e);
std::process::exit(1);
}
}

fn get_user_input() -> String {
let stdin = io::stdin();
let mut user_input = String::new();
Expand Down
8 changes: 4 additions & 4 deletions src/commands/edge_app/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ mod tests {
);

// get_entrypoint_mock.assert();
last_versions_mock.assert_hits(2);
last_versions_mock.assert_calls(2);
assets_mock.assert();
file_tree_from_version_mock.assert();
settings_mock.assert();
Expand Down Expand Up @@ -1627,13 +1627,13 @@ mod tests {
let upload_assets_mock = mock_server.mock(|when, then| {
when.method(POST)
.path("/v4/assets")
.body_contains("test222");
.body_includes("test222");
then.status(201).body("");
});
let upload_assets_mock2 = mock_server.mock(|when, then| {
when.method(POST)
.path("/v4/assets")
.body_contains("test333");
.body_includes("test333");
then.status(201).body("");
});

Expand Down Expand Up @@ -1785,7 +1785,7 @@ mod tests {
&changed_files,
);

upload_assets_mock.assert_hits(0);
upload_assets_mock.assert_calls(0);
copy_assets_mock.assert();

assert!(result.is_ok());
Expand Down
10 changes: 0 additions & 10 deletions src/commands/edge_app/setting.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::collections::HashMap;
use std::str;

use log::debug;
use serde::{Deserialize, Serialize};

use crate::api::edge_app::setting::Setting;
use crate::commands::edge_app::EdgeAppCommand;
Expand Down Expand Up @@ -32,14 +30,6 @@ impl EdgeAppCommand {

let _is_setting_global = self.api.is_setting_global(&app_id, setting_key)?;

#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
struct SettingValue {
name: String,
#[serde(rename = "type")]
type_field: String,
edge_app_setting_values: Vec<HashMap<String, String>>,
}

let server_setting_value = {
if _is_setting_global {
self.api.get_global_setting(&app_id, setting_key)?
Expand Down
2 changes: 1 addition & 1 deletion src/commands/playlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ mod tests {

delete_mock.assert();
post_mock.assert();
get_mock.assert_hits(2);
get_mock.assert_calls(2);
get_items_mock.assert();
assert!(result.is_ok());
}
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ mod api;
mod authentication;
mod cli;
mod commands;
mod mcp;
mod pb_signature;
mod signature;

Expand Down
12 changes: 12 additions & 0 deletions src/mcp/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//! MCP (Model Context Protocol) server implementation for Screenly CLI.
//!
//! This module provides an MCP server that exposes the Screenly v4 API as tools
//! that can be used by AI assistants.

pub mod server;
pub mod tools;

#[cfg(test)]
mod tests;

pub use server::ScreenlyMcpServer;
Loading
Loading