1pub mod capabilities;
2pub mod cli;
3pub mod error;
4pub mod extension;
5pub mod jobs;
6pub mod middleware;
7pub mod models;
8pub mod orchestration;
9pub mod progress;
10pub mod repository;
11pub mod resources;
12pub mod response;
13pub mod schema;
14pub mod services;
15pub mod tool;
16
17pub use extension::McpExtension;
18
19pub use error::McpError as McpDomainError;
20pub use rmcp::ErrorData as McpError;
21pub type McpResult<T> = Result<T, McpError>;
22
23pub use capabilities::{
24 build_experimental_capabilities, default_tool_visibility, mcp_apps_ui_extension,
25 model_only_visibility, tool_ui_meta, visibility_to_json, WEBSITE_URL,
26};
27pub use repository::{CreateMcpArtifact, McpArtifactRecord, McpArtifactRepository};
28pub use response::McpResponseBuilder;
29pub use progress::{create_progress_callback, ProgressCallback};
30pub use resources::{
31 build_artifact_viewer_resource, default_server_icons, read_artifact_viewer_resource,
32 ArtifactViewerConfig,
33};
34pub use schema::McpOutputSchema;
35pub use tool::{McpToolExecutor, McpToolHandler};
36
37pub use systemprompt_models::mcp::{
38 Deployment, DeploymentConfig, McpAuthState, McpServerConfig, OAuthRequirement, Settings, ERROR,
39 RUNNING, STARTING, STOPPED,
40};
41
42pub use services::monitoring::health::HealthStatus;
43pub use services::registry::trait_impl::McpDeploymentProviderImpl;
44pub use services::registry::McpServerRegistry;
45pub use services::tool_provider::McpToolProvider;
46pub use services::{EventBus as McpEventBus, McpEvent, McpManager, ServiceManager};
47
48pub use orchestration::{
49 McpServerConnectionInfo, McpServerMetadata, McpServiceState, McpToolLoader, ServerStatus,
50 ServiceStateManager, SkillLoadingResult,
51};
52
53pub use systemprompt_models::mcp::{
54 DynMcpDeploymentProvider, DynMcpRegistry, DynMcpToolProvider, McpDeploymentProvider,
55 McpProvider, McpRegistry, McpServerState,
56};
57
58pub fn mcp_protocol_version() -> String {
59 ProtocolVersion::LATEST.to_string()
60}
61
62pub mod registry {
63 pub use crate::services::registry::RegistryManager;
64}
65
66pub use cli::{list_services, show_status, start_services, stop_services};
67
68pub mod state;
69
70pub use rmcp::model::ProtocolVersion;
71use rmcp::transport::streamable_http_server::StreamableHttpServerConfig;
72use rmcp::transport::StreamableHttpService;
73use rmcp::ServerHandler;
74use std::time::Duration;
75use systemprompt_database::DbPool;
76use tokio_util::sync::CancellationToken;
77
78use crate::middleware::DatabaseSessionManager;
79
80pub use state::McpState;
81
82pub fn create_router<S>(server: S, db_pool: &DbPool) -> axum::Router
83where
84 S: ServerHandler + Clone + Send + Sync + 'static,
85{
86 let config = StreamableHttpServerConfig {
87 stateful_mode: true,
88 sse_keep_alive: Some(Duration::from_secs(15)),
89 sse_retry: Some(Duration::from_secs(3)),
90 cancellation_token: CancellationToken::new(),
91 json_response: false,
92 };
93
94 let session_manager = DatabaseSessionManager::new(db_pool);
95
96 let service =
97 StreamableHttpService::new(move || Ok(server.clone()), session_manager.into(), config);
98
99 axum::Router::new()
100 .nest_service("/mcp", service)
101 .layer(axum::middleware::map_response(
102 |mut response: http::Response<_>| async move {
103 response
104 .headers_mut()
105 .insert("x-accel-buffering", http::HeaderValue::from_static("no"));
106 response
107 },
108 ))
109}