Agents pane: CLI-only MCP, yaak mcp --http, and plugin deprecation (#761)

This commit is contained in:
Gregory Schier authored and GitHub committed 2026-10-25 23:14:45 -07:00
1 parent 349e6f9197
commit 6132171791
32 files changed
+950 -524

No files matched your search

+17 -2
View File
@@ -93,8 +93,23 @@ pub enum Commands {
/// Response commands
Response(ResponseArgs),
/// Serve Yaak's MCP tools over stdio, for AI agents like Claude Code
Mcp,
/// Serve Yaak's MCP tools to AI agents like Claude Code, over stdio or with --http
Mcp(McpArgs),
}
#[derive(Args)]
pub struct McpArgs {
/// Serve over HTTP on 127.0.0.1 instead of stdio, for agents that cannot run this command
#[arg(long)]
pub http: bool,
/// Port to listen on with --http
#[arg(long, default_value_t = yaak_mcp::http::DEFAULT_PORT, requires = "http")]
pub port: u16,
/// Bearer token clients must send with --http; generated and printed when omitted
#[arg(long, requires = "http", value_name = "TOKEN")]
pub token: Option<String>,
}
#[derive(Args)]
+47 -2
View File
@@ -1,5 +1,8 @@
use crate::cli::McpArgs;
use crate::context::{CliContext, CliExecutionContext};
use crate::plugin_events::SendContexts;
use rand::Rng;
use std::net::{Ipv4Addr, SocketAddr};
use std::path::PathBuf;
use std::sync::Arc;
use yaak::send::{SendHttpRequestWithPluginsParams, send_http_request_with_plugins};
@@ -13,7 +16,27 @@ use yaak_models::util::UpdateSource;
use yaak_plugins::events::{PluginContext, ShowToastRequest};
use yaak_plugins::manager::PluginManager;
pub async fn run(ctx: &CliContext, environment: Option<&str>, cookie_jar_id: Option<&str>) -> i32 {
enum Transport {
Stdio,
Http { port: u16, token: Option<String> },
}
impl From<McpArgs> for Transport {
fn from(args: McpArgs) -> Self {
if args.http {
Transport::Http { port: args.port, token: args.token }
} else {
Transport::Stdio
}
}
}
pub async fn run(
ctx: &CliContext,
args: McpArgs,
environment: Option<&str>,
cookie_jar_id: Option<&str>,
) -> i32 {
let host = CliMcpHost {
query_manager: ctx.query_manager().clone(),
blob_manager: ctx.blob_manager().clone(),
@@ -25,7 +48,11 @@ pub async fn run(ctx: &CliContext, environment: Option<&str>, cookie_jar_id: Opt
environment_id: environment.map(str::to_string),
cookie_jar_id: cookie_jar_id.map(str::to_string),
};
match yaak_mcp::serve_stdio(host).await {
let result = match Transport::from(args) {
Transport::Stdio => yaak_mcp::serve_stdio(host).await,
Transport::Http { port, token } => serve_http(host, port, token).await,
};
match result {
Ok(()) => 0,
Err(error) => {
eprintln!("Error: {error}");
@@ -34,6 +61,24 @@ pub async fn run(ctx: &CliContext, environment: Option<&str>, cookie_jar_id: Opt
}
}
async fn serve_http(host: CliMcpHost, port: u16, token: Option<String>) -> Result<(), String> {
let token = token.unwrap_or_else(generate_token);
let addr = SocketAddr::from((Ipv4Addr::LOCALHOST, port));
let server = yaak_mcp::http::serve(Arc::new(host), addr, token.clone())
.await
.map_err(|e| format!("Failed to start MCP server on {addr}: {e}"))?;
eprintln!("Yaak MCP server listening on http://{}{}", server.addr, yaak_mcp::http::PATH);
eprintln!("Token: {token}");
eprintln!("Clients must send it as \"Authorization: Bearer <token>\". Press Ctrl+C to stop.");
tokio::signal::ctrl_c().await.map_err(|e| format!("Failed to wait for Ctrl+C: {e}"))?;
server.stop().await;
Ok(())
}
fn generate_token() -> String {
hex::encode(rand::thread_rng().r#gen::<[u8; 32]>())
}
/// Every workspace in the database is "open", and the global `--environment`
/// and `--cookie-jar` flags stand in for a window's selection.
struct CliMcpHost {
+3 -2
View File
@@ -184,7 +184,7 @@ async fn main() {
context.shutdown().await;
exit_code
}
Commands::Mcp => {
Commands::Mcp(args) => {
let mut context = CliContext::new(data_dir.clone(), app_id);
context
.init_plugins(CliExecutionContext {
@@ -194,7 +194,8 @@ async fn main() {
})
.await;
let exit_code =
commands::mcp::run(&context, environment.as_deref(), cookie_jar.as_deref()).await;
commands::mcp::run(&context, args, environment.as_deref(), cookie_jar.as_deref())
.await;
context.shutdown().await;
exit_code
}