MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / serve_resolved_project

Function serve_resolved_project

src/serve.rs:458–485  ·  view source on GitHub ↗

Serves a startup-resolved project: proxy to the daemon when one owns the socket, otherwise run the in-process MCP engine.

(
    cg: TraceDecay,
    original_cwd: Option<std::path::PathBuf>,
    timings: bool,
    peeked_line: Option<String>,
    allow_initialize_root_routing: bool,
)

Source from the content-addressed store, hash-verified

456/// Serves a startup-resolved project: proxy to the daemon when one owns the
457/// socket, otherwise run the in-process MCP engine.
458async fn serve_resolved_project(
459 cg: TraceDecay,
460 original_cwd: Option<std::path::PathBuf>,
461 timings: bool,
462 peeked_line: Option<String>,
463 allow_initialize_root_routing: bool,
464) -> Result<()> {
465 let scope_prefix = serve_scope_prefix(original_cwd.as_deref(), cg.project_root());
466 let mut handshake = crate::daemon::DaemonHandshake::for_current_client(
467 Some(cg.project_root().to_path_buf()),
468 scope_prefix,
469 timings,
470 false,
471 )?;
472 handshake.allow_initialize_root_routing = allow_initialize_root_routing;
473 let socket_path = crate::daemon::default_socket_path()?;
474 if crate::daemon::should_proxy_serve_to_daemon(&socket_path).await {
475 crate::daemon::proxy_stdio_to_daemon(&socket_path, &handshake, peeked_line).await
476 } else {
477 let server = crate::mcp::McpServer::new(cg, handshake.scope_prefix.clone()).await;
478 server.set_initialize_root_routing_enabled(allow_initialize_root_routing);
479 let mut transport = ReplayTransport::new(StdioTransport::new());
480 if let Some(line) = peeked_line {
481 transport.push_replay(line);
482 }
483 Box::pin(server.run(&mut transport)).await
484 }
485}
486
487/// The scope prefix for a serve session: the relative path from the project
488/// root to the directory serve was launched from, when the latter is inside

Callers 1

run_serveFunction · 0.85

Calls 8

serve_scope_prefixFunction · 0.85
default_socket_pathFunction · 0.85
proxy_stdio_to_daemonFunction · 0.85
push_replayMethod · 0.80
project_rootMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected