Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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,168 changes: 933 additions & 1,235 deletions Cargo.lock

Large diffs are not rendered by default.

20 changes: 12 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
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"
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
13 changes: 7 additions & 6 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
group_imports = "StdExternalCrate"
imports_granularity = "Module"
unstable_features = true
format_generated_files = false

ignore = ["furiousfilter/**"]
# Note: These options require nightly rustfmt (`cargo +nightly fmt`)
# On stable, they are ignored with warnings. Uncomment to use with nightly.
# group_imports = "StdExternalCrate"
# imports_granularity = "Module"
# unstable_features = true
# format_generated_files = false
# ignore = ["furiousfilter/**"]
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