diff --git a/Cargo.lock b/Cargo.lock index b311cf3..3011b8f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -415,6 +415,29 @@ dependencies = [ "uuid", ] +[[package]] +name = "crank-community-mcp" +version = "0.1.0" +dependencies = [ + "async-trait", + "axum", + "base64", + "crank-core", + "crank-registry", + "crank-runtime", + "crank-schema", + "futures-util", + "serde", + "serde_json", + "sha2", + "sqlx", + "thiserror", + "time", + "tokio", + "tracing", + "uuid", +] + [[package]] name = "crank-core" version = "0.1.0" @@ -1255,6 +1278,7 @@ dependencies = [ "async-trait", "axum", "base64", + "crank-community-mcp", "crank-core", "crank-mapping", "crank-registry", diff --git a/Cargo.toml b/Cargo.toml index 666a721..5a11fd4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ members = [ "apps/admin-api", "apps/mcp-server", "crates/crank-community-auth", + "crates/crank-community-mcp", "crates/crank-core", "crates/crank-schema", "crates/crank-mapping", diff --git a/TASKS.md b/TASKS.md index 6ac8053..80ec8d5 100644 --- a/TASKS.md +++ b/TASKS.md @@ -160,4 +160,5 @@ Progress: - Phase 0 / task `0.16`: phase verification gate пройден — `just fmt`, `just check`, `just test`, таргетные Community machine-auth tests и MCP initialize smoke (`requires_initialized_notification_before_tool_methods`) зеленые; runtime regression test обновлен под новый `RuntimeError::ProtocolAdapter` contract - Phase 1 / tasks `1.1`–`1.3`: strict-REST Community cleanup уже был закрыт ранее — non-REST adapters и `crank-proto` удалены из workspace, descriptor/premium UI surface убран из Community build, wizard и i18n приведены к REST-only baseline - Phase 1 / task `1.4`: создан crate `crank-community-auth`; в него вынесены password hashing/session cookie primitives и `PasswordIdentityProvider`, `admin-api` переключен на этот crate, а `login()` теперь реально делегирует credential check через `IdentityProvider` seam + - Phase 1 / task `1.5`: создан crate `crank-community-mcp`; в него вынесены `build_app`, `catalog`, `jsonrpc`, `session` и `auth` из `apps/mcp-server`, а `apps/mcp-server/src/main.rs` стал thin launcher с env parsing и DI wiring - backward-compatible alias `CommunityMachineCredentialVerifier` сохранен, поведение Community не изменено diff --git a/apps/mcp-server/Cargo.toml b/apps/mcp-server/Cargo.toml index 5f776bf..4885c23 100644 --- a/apps/mcp-server/Cargo.toml +++ b/apps/mcp-server/Cargo.toml @@ -13,6 +13,7 @@ path = "src/main.rs" async-trait = "0.1" axum.workspace = true base64.workspace = true +crank-community-mcp = { path = "../../crates/crank-community-mcp" } crank-core = { path = "../../crates/crank-core" } crank-registry = { path = "../../crates/crank-registry" } crank-runtime = { path = "../../crates/crank-runtime" } diff --git a/apps/mcp-server/src/main.rs b/apps/mcp-server/src/main.rs index 3678fe7..4c38411 100644 --- a/apps/mcp-server/src/main.rs +++ b/apps/mcp-server/src/main.rs @@ -1,11 +1,8 @@ -mod app; -mod auth; -mod catalog; -mod jsonrpc; -mod session; - use std::{env, net::SocketAddr, time::Duration}; +use crank_community_mcp::{ + auth::CommunityMachineCredentialVerifier, build_app, session::PostgresTransportSessionStore, +}; use crank_registry::{PostgresPoolConfig, PostgresRegistry}; use crank_runtime::{ RequestRateLimitConfig, RequestRateLimiter, RuntimeCacheConfig, RuntimeCacheStores, @@ -15,11 +12,6 @@ use sqlx::postgres::PgConnectOptions; use tokio::net::TcpListener; use tracing::info; -use crate::{ - app::build_app, auth::CommunityMachineCredentialVerifier, - session::PostgresTransportSessionStore, -}; - #[tokio::main] async fn main() -> Result<(), Box> { tracing_subscriber::fmt() @@ -184,8 +176,8 @@ mod tests { use tokio::time::sleep; use tracing_subscriber::{filter::LevelFilter, fmt::MakeWriter, prelude::*}; - use crate::{ - app::build_app, + use crank_community_mcp::{ + build_app, auth::{ CommunityMachineCredentialVerifier, MachineCredentialVerifier, MachineCredentialVerifierError, SharedMachineCredentialVerifier, diff --git a/crates/crank-community-mcp/Cargo.toml b/crates/crank-community-mcp/Cargo.toml new file mode 100644 index 0000000..7319dc2 --- /dev/null +++ b/crates/crank-community-mcp/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "crank-community-mcp" +edition.workspace = true +license.workspace = true +rust-version.workspace = true +version.workspace = true + +[dependencies] +async-trait = "0.1" +axum.workspace = true +base64.workspace = true +crank-core = { path = "../crank-core" } +crank-registry = { path = "../crank-registry" } +crank-runtime = { path = "../crank-runtime" } +crank-schema = { path = "../crank-schema" } +futures-util = "0.3" +serde.workspace = true +serde_json.workspace = true +sha2.workspace = true +sqlx.workspace = true +thiserror.workspace = true +time.workspace = true +tokio = { workspace = true, features = ["sync"] } +tracing.workspace = true +uuid.workspace = true diff --git a/apps/mcp-server/src/app.rs b/crates/crank-community-mcp/src/app.rs similarity index 100% rename from apps/mcp-server/src/app.rs rename to crates/crank-community-mcp/src/app.rs diff --git a/apps/mcp-server/src/auth.rs b/crates/crank-community-mcp/src/auth.rs similarity index 100% rename from apps/mcp-server/src/auth.rs rename to crates/crank-community-mcp/src/auth.rs diff --git a/apps/mcp-server/src/catalog.rs b/crates/crank-community-mcp/src/catalog.rs similarity index 100% rename from apps/mcp-server/src/catalog.rs rename to crates/crank-community-mcp/src/catalog.rs diff --git a/apps/mcp-server/src/jsonrpc.rs b/crates/crank-community-mcp/src/jsonrpc.rs similarity index 100% rename from apps/mcp-server/src/jsonrpc.rs rename to crates/crank-community-mcp/src/jsonrpc.rs diff --git a/crates/crank-community-mcp/src/lib.rs b/crates/crank-community-mcp/src/lib.rs new file mode 100644 index 0000000..5f9f08b --- /dev/null +++ b/crates/crank-community-mcp/src/lib.rs @@ -0,0 +1,7 @@ +mod app; +pub mod auth; +pub mod catalog; +pub mod jsonrpc; +pub mod session; + +pub use app::build_app; diff --git a/apps/mcp-server/src/session.rs b/crates/crank-community-mcp/src/session.rs similarity index 100% rename from apps/mcp-server/src/session.rs rename to crates/crank-community-mcp/src/session.rs