systemprompt-mcp 0.1.12

Core MCP (Model Context Protocol) functionality for systemprompt.io OS
Documentation
pub mod capabilities;
pub mod cli;
pub mod error;
pub mod extension;
pub mod middleware;
pub mod models;
pub mod orchestration;
pub mod repository;
pub mod response;
pub mod schema;
pub mod services;
pub mod tool;

pub use extension::McpExtension;

pub use error::{McpError, McpResult};

pub use capabilities::{
    build_experimental_capabilities, default_tool_visibility, mcp_apps_ui_extension,
    model_only_visibility, tool_ui_meta, visibility_to_json, WEBSITE_URL,
};
// NOTE: result_ui_meta was removed - MCP Apps spec uses static templates with
// ui/notifications/tool-result
pub use repository::{CreateMcpArtifact, McpArtifactRecord, McpArtifactRepository};
pub use response::McpResponseBuilder;
pub use schema::McpOutputSchema;
pub use tool::{call_tool, McpToolHandler};

pub use systemprompt_models::mcp::{
    Deployment, DeploymentConfig, McpAuthState, McpServerConfig, OAuthRequirement, Settings, ERROR,
    RUNNING, STARTING, STOPPED,
};

pub use services::monitoring::health::HealthStatus;
pub use services::registry::trait_impl::McpDeploymentProviderImpl;
pub use services::registry::McpServerRegistry;
pub use services::tool_provider::McpToolProvider;
pub use services::{EventBus as McpEventBus, McpEvent, McpManager, ServiceManager};

pub use orchestration::{
    McpServerConnectionInfo, McpServerMetadata, McpServiceState, McpToolLoader, ServerStatus,
    ServiceStateManager, SkillLoadingResult,
};

pub use systemprompt_models::mcp::{
    DynMcpDeploymentProvider, DynMcpRegistry, DynMcpToolProvider, McpDeploymentProvider,
    McpProvider, McpRegistry, McpServerState,
};

pub fn mcp_protocol_version() -> String {
    ProtocolVersion::LATEST.to_string()
}

pub mod registry {
    pub use crate::services::registry::RegistryManager;
}

pub use cli::{list_services, show_status, start_services, stop_services};

pub mod state;

pub use rmcp::model::ProtocolVersion;
use rmcp::transport::streamable_http_server::StreamableHttpServerConfig;
use rmcp::transport::StreamableHttpService;
use rmcp::ServerHandler;
use std::time::Duration;
use systemprompt_database::DbPool;
use tokio_util::sync::CancellationToken;

use crate::middleware::DatabaseSessionManager;

pub use state::McpState;

pub fn create_router<S>(server: S, db_pool: &DbPool) -> axum::Router
where
    S: ServerHandler + Clone + Send + Sync + 'static,
{
    let config = StreamableHttpServerConfig {
        stateful_mode: true,
        sse_keep_alive: Some(Duration::from_secs(30)),
        sse_retry: Some(Duration::from_secs(3)),
        cancellation_token: CancellationToken::new(),
    };

    let session_manager = DatabaseSessionManager::new(db_pool);

    let service =
        StreamableHttpService::new(move || Ok(server.clone()), session_manager.into(), config);

    axum::Router::new().nest_service("/mcp", service)
}