Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

feat: bring mcp server to lime-light (#1647)

Divanshu Grover009fb76f4940
diff --git a/content/docs/bun.lockb b/content/docs/bun.lockb
index 0f41ad6df..43f89376e 100755
Binary files a/content/docs/bun.lockb and b/content/docs/bun.lockb differ
diff --git a/content/docs/docs.json b/content/docs/docs.json
index df9e5c5e1..5ca093384 100644
--- a/content/docs/docs.json
+++ b/content/docs/docs.json
@@ -20,7 +20,8 @@
"pages/docs/cli-reference",
"pages/docs/plugins",
"pages/docs/contributing",
- "pages/docs/faq"
+ "pages/docs/faq",
+ "pages/docs/mcp-server"
]
},
{
diff --git a/content/docs/pages/docs/_meta.js b/content/docs/pages/docs/_meta.js
index 0029a13fa..bbf8ecdcc 100644
--- a/content/docs/pages/docs/_meta.js
+++ b/content/docs/pages/docs/_meta.js
@@ -6,5 +6,6 @@ export default {
"api-reference": "api reference",
"cli-reference": "cli reference",
"contributing": "contributing",
- "faq": "faq"
+ "faq": "faq",
+ "mcp-server": "mcp server"
};
diff --git a/content/docs/pages/docs/mcp-server.mdx b/content/docs/pages/docs/mcp-server.mdx
new file mode 100644
index 000000000..64fa861a5
--- /dev/null
+++ b/content/docs/pages/docs/mcp-server.mdx
@@ -0,0 +1,230 @@
+import { Tabs, Tab } from 'nextra/components'
+import Image from 'next/image'
+
+# Using Screenpipe with MCP Clients
+
+Screenpipe offers robust capabilities for integrating with various MCP clients, allowing users to leverage its features across different platforms. This guide will walk you through the setup and usage of Screenpipe with supported MCP clients.
+
+## Prerequisites
+
+Before setting up the MCP server, ensure you have the following installed:
+
+### 1. Python
+Install Python from the [official Python website](https://www.python.org/). Make sure to add Python to your system's PATH during installation.
+
+### 2. uv Package Manager
+Install uv using one of these commands based on your operating system:
+
+<Tabs items={['macOS/Linux', 'Windows']}>
+ <Tab>
+ ```bash
+ curl -LsSf https://astral.sh/uv/install.sh | sh
+ ```
+ </Tab>
+ <Tab>
+ ```powershell
+ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
+ ```
+ </Tab>
+</Tabs>
+
+Verify the installation by running:
+```bash
+uv --version
+```
+
+## Supported MCP Clients
+
+- [Claude Desktop](#claude-desktop)
+- [5ire Desktop App](#5ire-desktop-app)
+- [Cursor IDE](#cursor-ide)
+
+## Setting Up the MCP Server
+
+To set up the MCP server, execute the following command in your terminal:
+
+```bash
+screenpipe mcp setup
+```
+
+Upon successful setup, you will see the following confirmation:
+
+```
+MCP setup completed successfully
+Directory: C:\Users\divan\.screenpipe\mcp
+Config file: C:\Users\divan\.screenpipe\mcp\config.json
+
+To run the MCP server, use this command:
+$ uv --directory C:\Users\divan\.screenpipe\mcp run screenpipe-mcp --port 3030
+```
+
+## Configuration
+
+The configuration for the MCP server is stored in `config.json` located in the `.screenpipe\mcp` directory. Here is an example configuration:
+
+```json
+{
+ "mcpServers": {
+ "screenpipe": {
+ "args": [
+ "--directory",
+ "C:\\Users\\divan\\.screenpipe\\mcp",
+ "run",
+ "screenpipe-mcp",
+ "--port",
+ "3030"
+ ],
+ "command": "uv"
+ }
+ }
+}
+```
+
+## Claude Desktop
+
+Screenpipe integrates with **Claude Desktop**, allowing seamless interaction via MCP. Follow this guide to set it up properly.
+
+### 1. Open the Configuration File
+
+<Tabs items={['Windows', 'Mac']}>
+ <Tab>
+ Open the configuration file using Notepad:
+ <Tabs items={['PowerShell', 'CMD']}>
+ <Tab>
+ ```powershell
+ notepad $env:AppData\Claude\claude_desktop_config.json
+ ```
+ </Tab>
+ <Tab>
+ ```cmd
+ notepad %APPDATA%\Claude\claude_desktop_config.json
+ ```
+ </Tab>
+ </Tabs>
+ </Tab>
+ <Tab>
+ Open the configuration file using your preferred editor (e.g., VSCode, Cursor, or Vim):
+ ```bash
+ code "~/Library/Application Support/Claude/claude_desktop_config.json"
+ ```
+ </Tab>
+</Tabs>
+
+### 2. Update the Configuration
+
+Modify the `claude_desktop_config.json` file to include the following configuration:
+
+```json
+{
+ "mcpServers": {
+ "screenpipe": {
+ "command": "uv",
+ "args": [
+ "--directory",
+ "C:\\Users\\divan\\.screenpipe\\mcp",
+ "run",
+ "screenpipe-mcp",
+ "--port",
+ "3030"
+ ]
+ }
+ }
+}
+```
+
+> **Note:** Ensure that this configuration matches the generated `config.json` by the [MCP server setup](#setting-up-the-mcp-server).
+
+### 3. Restart Claude Desktop
+
+After making changes to the configuration, restart Claude Desktop to apply the updates.
+
+<Image
+ src="/claude-setup.gif"
+ alt="Claude Desktop App"
+ width={800}
+ height={450}
+ className="rounded-lg"
+ unoptimized
+/>
+
+If the setup is successful, you'll see a **hammer icon** appear in the interface.
+
+## 5ire Desktop App
+
+Screenpipe allows seamless integration with the **5ire Desktop App**, enabling users to utilize its features efficiently. This guide walks you through the setup process.
+
+Before configuring the 5ire Desktop App, you need to set up the **MCP server**. If you haven't done so yet, refer to the following [MCP Server Setup](#setting-up-the-mcp-server) :
+
+### 1. Open the 5ire Desktop App
+Launch the **5ire Desktop App** on your system.
+
+### 2. Configure the MCP Tool
+- Click on **"Tools"** from the left sidebar.
+- Click on the **"New"** button to add a new tool.
+- In the **"Tool Key"** field, enter:
+ ```
+ screenpipe
+ ```
+
+### 3. Enter the Command
+In the **"Command"** field, enter the **MCP server run command** obtained from the setup:
+
+```
+uv --directory C:\Users\divan\.screenpipe\mcp run screenpipe-mcp --port 3030
+```
+
+> **Note:** This command is the same as the one shown in the [MCP Server Setup](#setting-up-the-mcp-server) section.
+
+### 4. Save the Configuration
+Click the **"Save"** button to finalize the setup.
+ <Image
+ src="/5ire-setup.gif"
+ alt="5ire Desktop App"
+ width={800}
+ height={450}
+ className="rounded-lg"
+ unoptimized
+ />
+
+### 5. Enable the Tool
+After saving, toggle the switch to **enable** the tool.
+
+### 6. Start Using Screenpipe
+Once enabled, navigate to **New Chat** and begin using Screenpipe within the 5ire Desktop App.
+
+
+## Cursor IDE
+
+
+Screenpipe MCP can be integrated with **Cursor IDE** to make it available across all your projects. Follow these steps to set it up.
+
+### 1. Open Cursor Settings
+- Launch **Cursor IDE**.
+- Click on the **gear icon** to open **Settings**.
+- In the left sidebar, select **MCP**.
+
+### 2. Add a Global MCP Server
+- Click on **"Add New Global MCP Server"**.
+- If the configuration file doesn't exist yet, click **"Create File"** (as shown in Cursor IDE).
+- Paste the configuration from the [Configuration](#configuration) section.
+
+### 3. Restart MCP in Cursor
+- Navigate back to the **Cursor Settings** tab.
+- Click the **refresh icon** next to MCP servers.
+ <Image
+ src="/cursor-setup.gif"
+ alt="Cursor IDE"
+ width={800}
+ height={450}
+ className="rounded-lg"
+ unoptimized
+ />
+
+That's it! Now Cursor IDE should recognize and use the Screenpipe MCP server.
+- Start by opening a new Composer and enable Agent mode
+- From there onwards you can use this tool
+
+
+## Important Note
+
+For more detailed information, please refer to our [GitHub repository](https://github.com/mediar-ai/screenpipe/tree/main/screenpipe-integrations/screenpipe-mcp).
\ No newline at end of file
diff --git a/content/docs/public/5ire-setup.gif b/content/docs/public/5ire-setup.gif
new file mode 100644
index 000000000..f85ae18f4
--- /dev/null
+++ b/content/docs/public/5ire-setup.gif
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:dfd865a1acd5026b53c12011b4f3df18578223602ac0d06e8f52f257654cdc7e
+size 417759
diff --git a/content/docs/public/claude-setup.gif b/content/docs/public/claude-setup.gif
new file mode 100644
index 000000000..eb328e545
--- /dev/null
+++ b/content/docs/public/claude-setup.gif
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:52d63fd8635663f413861cb85359245beaaf5ad6dbb5d40f6bacafd9eb9498c6
+size 422366
diff --git a/content/docs/public/cursor-setup.gif b/content/docs/public/cursor-setup.gif
new file mode 100644
index 000000000..79bf7d0c1
--- /dev/null
+++ b/content/docs/public/cursor-setup.gif
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4525fb0664336f72034666c04207bb2548d649f233352b3806aec0e27a2f185a
+size 598444
diff --git a/screenpipe-server/src/bin/screenpipe-server.rs b/screenpipe-server/src/bin/screenpipe-server.rs
index f14218e41..f30a607a6 100644
--- a/screenpipe-server/src/bin/screenpipe-server.rs
+++ b/screenpipe-server/src/bin/screenpipe-server.rs
@@ -2,6 +2,7 @@ use clap::Parser;
#[allow(unused_imports)]
use colored::Colorize;
use dirs::home_dir;
+use reqwest::Client;
use futures::pin_mut;
use port_check::is_local_ipv4_port_free;
use screenpipe_audio::{
@@ -17,7 +18,7 @@ use screenpipe_db::{
use screenpipe_server::{
cli::{
AudioCommand, Cli, CliAudioTranscriptionEngine, CliOcrEngine, Command, MigrationSubCommand,
- OutputFormat, PipeCommand, VisionCommand,
+ OutputFormat, PipeCommand, VisionCommand, McpCommand,
},
handle_index_command,
pipe_manager::PipeInfo,
@@ -38,6 +39,9 @@ use tracing_appender::rolling::{RollingFileAppender, Rotation};
use tracing_subscriber::util::SubscriberInitExt;
use tracing_subscriber::{fmt, EnvFilter};
use tracing_subscriber::{prelude::__tracing_subscriber_SubscriberExt, Layer};
+use serde::Deserialize;
+use std::path::Path;
+use reqwest::header::{HeaderMap, HeaderValue, USER_AGENT};
const DISPLAY: &str = r"
_
@@ -49,6 +53,16 @@ const DISPLAY: &str = r"
";
+// Add the struct definition with proper derive attributes
+#[derive(Deserialize, Debug)]
+struct GitHubContent {
+ name: String,
+ path: String,
+ download_url: Option<String>,
+ #[serde(rename = "type")]
+ content_type: String,
+}
+
fn get_base_dir(custom_path: &Option<String>) -> anyhow::Result<PathBuf> {
let default_path = home_dir()
.ok_or_else(|| anyhow::anyhow!("failed to get home directory"))?
@@ -527,6 +541,10 @@ async fn main() -> anyhow::Result<()> {
.await?;
return Ok(());
}
+ Command::Mcp { subcommand } => {
+ handle_mcp_command(subcommand, &local_data_dir_clone).await?;
+ return Ok(());
+ }
}
}
@@ -1391,3 +1409,271 @@ async fn handle_pipe_command(
}
Ok(())
}
+
+pub async fn handle_mcp_command(command: &McpCommand, local_data_dir: &PathBuf) -> Result<(), anyhow::Error> {
+ let client = Client::new();
+
+ // Check if Python is installed
+ if !is_command_available("python") {
+ warn!("note: python is not installed. please install it from the official website: https://www.python.org/");
+ }
+
+ // Check if uv is installed
+ if !is_command_available("uv") {
+ warn!("note: uv is not installed. please install it using the instructions at: https://docs.astral.sh/uv/#installation");
+ }
+
+ match command {
+ McpCommand::Setup { directory, output, port, update, purge } => {
+ let mcp_dir = directory
+ .as_ref()
+ .map(PathBuf::from)
+ .unwrap_or_else(|| local_data_dir.join("mcp"));
+
+ // If purge flag is set, just remove the directory and return
+ if *purge {
+ if mcp_dir.exists() {
+ info!("Purging MCP directory: {}", mcp_dir.display());
+ tokio::fs::remove_dir_all(&mcp_dir).await?;
+
+ match output {
+ OutputFormat::Json => println!(
+ "{}",
+ serde_json::to_string_pretty(&json!({
+ "data": {
+ "message": "MCP directory purged successfully",
+ "directory": mcp_dir.to_string_lossy(),
+ },
+ "success": true
+ }))?
+ ),
+ OutputFormat::Text => {
+ println!("MCP directory purged successfully");
+ println!("Directory: {}", mcp_dir.display());
+ }
+ }
+ } else {
+ match output {
+ OutputFormat::Json => println!(
+ "{}",
+ serde_json::to_string_pretty(&json!({
+ "data": {
+ "message": "MCP directory does not exist",
+ "directory": mcp_dir.to_string_lossy(),
+ },
+ "success": true
+ }))?
+ ),
+ OutputFormat::Text => {
+ println!("MCP directory does not exist: {}", mcp_dir.display());
+ }
+ }
+ }
+ return Ok(());
+ }
+
+ let should_download = if mcp_dir.exists() {
+ if *update {
+ tokio::fs::remove_dir_all(&mcp_dir).await?;
+ true
+ } else {
+ let mut entries = tokio::fs::read_dir(&mcp_dir).await?;
+ entries.next_entry().await?.is_none()
+ }
+ } else {
+ true
+ };
+
+ // Create config regardless of download status
+ let config = json!({
+ "mcpServers": {
+ "screenpipe": {
+ "command": "uv",
+ "args": [
+ "--directory",
+ mcp_dir.to_string_lossy().to_string(),
+ "run",
+ "screenpipe-mcp",
+ "--port",
+ port.to_string()
+ ]
+ }
+ }
+ });
+
+ let run_command = format!(
+ "uv --directory {} run screenpipe-mcp --port {}",
+ mcp_dir.to_string_lossy(),
+ port
+ );
+
+ let config_path = mcp_dir.join("config.json");
+
+ if should_download {
+ tokio::fs::create_dir_all(&mcp_dir).await?;
+
+ // Log the start of the download process
+ info!("starting download process for MCP directory");
+
+ let owner = "mediar-ai";
+ let repo = "screenpipe";
+ let branch = "main";
+ let target_dir = "screenpipe-integrations/screenpipe-mcp";
+
+ let api_url = format!(
+ "https://api.github.com/repos/{}/{}/contents/{}?ref={}",
+ owner, repo, target_dir, branch
+ );
+
+ // Setup ctrl+c handler
+ let (tx, mut rx) = tokio::sync::mpsc::channel(1);
+ let cancel_handle = tokio::spawn(async move {
+ if signal::ctrl_c().await.is_ok() {
+ let _ = tx.send(()).await;
+ }
+ });
+
+ // Download with cancellation support
+ let download_result = tokio::select! {
+ result = download_mcp_directory(&client, &api_url, &mcp_dir) => result,
+ _ = rx.recv() => {
+ info!("Received ctrl+c, canceling download...");
+ Err(anyhow::anyhow!("Download cancelled by user"))
+ }
+ };
+
+ // Clean up cancel handler
+ cancel_handle.abort();
+
+ // Handle download result
+ match download_result {
+ Ok(_) => {
+ tokio::fs::write(&config_path, serde_json::to_string_pretty(&config)?).await?;
+ }
+ Err(e) => {
+ // Clean up on failure
+ if mcp_dir.exists() {
+ let _ = tokio::fs::remove_dir_all(&mcp_dir).await;
+ }
+ return Err(e);
+ }
+ }
+ }
+
+ // Always create/update config.json regardless of download
+ tokio::fs::write(&config_path, serde_json::to_string_pretty(&config)?).await?;
+
+ match output {
+ OutputFormat::Json => println!(
+ "{}",
+ serde_json::to_string_pretty(&json!({
+ "data": {
+ "message": if should_download { "MCP setup completed successfully" } else { "MCP files already exist" },
+ "config": config,
+ "config_path": config_path.to_string_lossy(),
+ "directory": mcp_dir.to_string_lossy(),
+ "port": port
+ },
+ "success": true
+ }))?
+ ),
+ OutputFormat::Text => {
+ if should_download {
+ println!("MCP setup completed successfully");
+ } else {
+ println!("MCP files already exist at: {}", mcp_dir.display());
+ println!("Use --update flag to force update or --purge to start fresh");
+ }
+ println!("Directory: {}", mcp_dir.display());
+ println!("Config file: {}", config_path.display());
+ println!("\nTo run the MCP server, use this command:");
+ println!("$ {}", run_command);
+ }
+ }
+ }
+ }
+
+ Ok(())
+}
+
+async fn download_mcp_directory(
+ client: &Client,
+ api_url: &str,
+ target_dir: &Path,
+) -> Result<(), anyhow::Error> {
+ let mut headers = HeaderMap::new();
+ headers.insert(USER_AGENT, HeaderValue::from_static("screenpipe-cli"));
+
+ let response = client
+ .get(api_url)
+ .headers(headers)
+ .send()
+ .await
+ .map_err(|e| anyhow::anyhow!("Failed to send request: {}", e))?;
+
+ if !response.status().is_success() {
+ let status = response.status();
+ let error_text = response.text().await.unwrap_or_default();
+ return Err(anyhow::anyhow!("GitHub API error (status {}): {}", status, error_text));
+ }
+
+ let contents: Vec<GitHubContent> = response
+ .json()
+ .await
+ .map_err(|e| anyhow::anyhow!("Failed to parse GitHub API response: {}", e))?;
+
+ for item in contents {
+ let target_path = target_dir.join(&item.name);
+
+ match item.content_type.as_str() {
+ "file" => {
+ if let Some(download_url) = item.download_url {
+ let file_response = client
+ .get(&download_url)
+ .send()
+ .await
+ .map_err(|e| anyhow::anyhow!("Failed to download file {}: {}", download_url, e))?;
+
+ let content = file_response
+ .bytes()
+ .await
+ .map_err(|e| anyhow::anyhow!("Failed to get file content: {}", e))?;
+
+ tokio::fs::write(&target_path, content)
+ .await
+ .map_err(|e| anyhow::anyhow!("Failed to write file {}: {}", target_path.display(), e))?;
+
+ debug!("Downloaded file: {}", target_path.display());
+ }
+ }
+ "dir" => {
+ tokio::fs::create_dir_all(&target_path)
+ .await
+ .map_err(|e| anyhow::anyhow!("Failed to create directory {}: {}", target_path.display(), e))?;
+
+ let subdir_api_url = format!(
+ "https://api.github.com/repos/{}/{}/contents/{}?ref={}",
+ "mediar-ai", "screenpipe", item.path, "main"
+ );
+
+ // Fix recursion with Box::pin
+ let future = Box::pin(download_mcp_directory(client, &subdir_api_url, &target_path));
+ future.await?;
+ }
+ _ => {
+ warn!("Skipping unsupported content type: {}", item.content_type);
+ }
+ }
+ }
+
+ Ok(())
+}
+
+// Helper function to check if a command is available
+fn is_command_available(command: &str) -> bool {
+ std::process::Command::new(command)
+ .arg("--version")
+ .output()
+ .map(|output| output.status.success())
+ .unwrap_or(false)
+}
\ No newline at end of file
diff --git a/screenpipe-server/src/cli.rs b/screenpipe-server/src/cli.rs
index 68161ad1d..57501d216 100644
--- a/screenpipe-server/src/cli.rs
+++ b/screenpipe-server/src/cli.rs
@@ -322,6 +322,11 @@ pub enum Command {
#[command(subcommand)]
subcommand: PipeCommand,
},
+ /// MCP Server management commands
+ Mcp {
+ #[command(subcommand)]
+ subcommand: McpCommand,
+ },
/// Add video files to existing screenpipe data (OCR only) - DOES NOT SUPPORT AUDIO
Add {
/// Path to folder containing video files
@@ -508,6 +513,28 @@ pub enum PipeCommand {
},
}
+#[derive(Subcommand)]
+pub enum McpCommand {
+ /// Setup MCP server configuration
+ Setup {
+ /// Directory to save MCP files (default: $HOME/.screenpipe/mcp)
+ #[arg(long, value_hint = ValueHint::DirPath)]
+ directory: Option<String>,
+ /// Output format
+ #[arg(short, long, value_enum, default_value_t = OutputFormat::Text)]
+ output: OutputFormat,
+ /// Server port
+ #[arg(short = 'p', long, default_value_t = 3030)]
+ port: u16,
+ /// Force update existing files
+ #[arg(long)]
+ update: bool,
+ /// Purge existing MCP directory before setup
+ #[arg(long)]
+ purge: bool,
+ },
+}
+
#[derive(Clone, Debug, ValueEnum, PartialEq)]
pub enum OutputFormat {
Text,