aKode fase 5: test e snapshot adeguati alla rinomina, 429 distinto (ProviderRateLimited), cargo fmt dopo il cambio dei prefissi

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-11 12:47:01 +01:00
parent 8b73331037
commit ad43f9281a
919 changed files with 2358 additions and 2430 deletions

View File

@@ -3,9 +3,9 @@
use std::sync::Arc;
use std::time::Duration;
use anyhow::Result;
use akode_login::AuthChangeState;
use akode_rmcp_client::RmcpClient;
use anyhow::Result;
use rmcp::model::ServerCapabilities;
use serde_json::json;
use tokio::sync::watch;

View File

@@ -6,13 +6,13 @@ use std::future::Future;
use std::sync::Arc;
use std::time::Duration;
use anyhow::Context;
use anyhow::Result;
use akode_config::AppToolApproval;
use akode_exec_server::FileSystemSandboxContext;
use akode_protocol::mcp::CallToolResult;
use akode_protocol::models::PermissionProfile;
use akode_utils_absolute_path::AbsolutePathBuf;
use anyhow::Context;
use anyhow::Result;
use rmcp::model::ListResourceTemplatesResult;
use rmcp::model::ListResourcesResult;
use rmcp::model::PaginatedRequestParams;

View File

@@ -80,7 +80,8 @@ async fn test_step(
);
let tool_catalog = Arc::new(ClientToolCatalog::new(
vec![tool.clone()],
/*meta*/ None));
/*meta*/ None,
));
let managed_client = Arc::new(ManagedClient {
connection_sharing: Default::default(),
shared_elicitation: None,

View File

@@ -324,7 +324,6 @@ pub struct McpCatalogBuilder {
}
impl McpCatalogBuilder {
pub fn register(&mut self, registration: McpServerRegistration) {
self.actions
.push(CatalogAction::Register(Box::new(registration)));

View File

@@ -11,10 +11,10 @@ use std::sync::atomic::AtomicU64;
use std::sync::atomic::Ordering;
use std::time::Duration;
use akode_rmcp_client::ToolListRevision;
use anyhow::Context;
use anyhow::Result;
use anyhow::bail;
use akode_rmcp_client::ToolListRevision;
use tokio::sync::Mutex;
use tokio::sync::RwLock;
use tokio::time::Instant;
@@ -153,8 +153,7 @@ impl ClientToolCatalog {
Fut: Future<Output = R>,
{
let current = self.read(|snapshot| snapshot).await;
if current.revision != expected.revision
&& !catalogs_match(&current.tools, &expected.tools)
if current.revision != expected.revision && !catalogs_match(&current.tools, &expected.tools)
{
return None;
}

View File

@@ -58,10 +58,6 @@ use crate::server::McpServerMetadata;
use crate::tools::ToolFilter;
use crate::tools::ToolInfo;
use crate::tools::filter_tools;
use anyhow::Context;
use anyhow::Result;
use anyhow::anyhow;
use anyhow::bail;
use akode_config::McpServerTransportConfig;
use akode_config::McpStartupReadiness;
use akode_diagnostics::Gauge;
@@ -77,6 +73,10 @@ use akode_protocol::protocol::McpStartupFailureReason;
use akode_protocol::protocol::McpStartupStatus;
use akode_protocol::protocol::McpStartupUpdateEvent;
use akode_rmcp_client::determine_streamable_http_auth_status_from_credentials;
use anyhow::Context;
use anyhow::Result;
use anyhow::anyhow;
use anyhow::bail;
use futures::FutureExt;
use futures::future::join_all;
use tokio::sync::watch;
@@ -372,13 +372,13 @@ impl McpConnectionSet {
let mut eager_workers = Vec::new();
let mut deferred_workers = Vec::new();
let elicitation_previous = previous.filter(|previous| {
!previous.servers.is_empty()
&& previous.elicitation_requests.update(
Arc::clone(&config),
elicitation_reviewer.clone(),
elicitation_lifecycle.clone(),
)
});
!previous.servers.is_empty()
&& previous.elicitation_requests.update(
Arc::clone(&config),
elicitation_reviewer.clone(),
elicitation_lifecycle.clone(),
)
});
let reusable_previous = previous.filter(|_| elicitation_previous.is_some());
let elicitation_requests = if let Some(previous) = elicitation_previous {
previous.elicitation_requests.clone()
@@ -739,8 +739,7 @@ impl McpConnectionSet {
}
if let Some(tx_event) = tx_event.as_ref() {
let auth_state = match &outcome {
Err(error) if error.is_authentication_required() =>
{
Err(error) if error.is_authentication_required() => {
match &configured_config.transport {
McpServerTransportConfig::StreamableHttp {
url,

View File

@@ -3,9 +3,9 @@
use super::McpConnectionSet;
use crate::MCP_NETWORK_POLICY_META_CAPABILITY;
use crate::rmcp_client::ManagedClient;
use anyhow::Context;
use akode_network_proxy::NetworkMode;
use akode_protocol::models::PermissionProfile;
use anyhow::Context;
use rmcp::model::ServerCapabilities;
use serde::Serialize;
use serde_json::Value;

View File

@@ -122,12 +122,11 @@ async fn tool_calls_never_deliver_network_policy_and_strip_forged_metadata() ->
));
let catalog = catalog.build();
assert!(catalog.server("docs").is_some());
let extensions = crate::client_capabilities::server_mcp_extensions(
&ClientMcpExtensions::new([(
let extensions =
crate::client_capabilities::server_mcp_extensions(&ClientMcpExtensions::new([(
MCP_NETWORK_POLICY_META_CAPABILITY.to_string(),
json!({"forged": true}),
)]),
);
)]));
let client_supports_policy = extensions
.iter()
.any(|(id, _)| id == MCP_NETWORK_POLICY_META_CAPABILITY);

View File

@@ -1,8 +1,8 @@
use std::collections::HashSet;
use akode_protocol::protocol::McpStartupFailure;
use anyhow::Result;
use anyhow::anyhow;
use akode_protocol::protocol::McpStartupFailure;
use tracing::Instrument;
use tracing::info_span;

View File

@@ -1,7 +1,5 @@
use std::collections::HashMap;
use anyhow::Result;
use async_channel::Sender;
use akode_config::McpServerConfig;
use akode_config::McpServerTransportConfig;
use akode_protocol::protocol::Event;
@@ -10,6 +8,8 @@ use akode_protocol::protocol::McpStartupFailureReason;
use akode_protocol::protocol::McpStartupUpdateEvent;
use akode_rmcp_client::McpAuthState;
use akode_rmcp_client::McpLoginRequirement;
use anyhow::Result;
use async_channel::Sender;
use crate::rmcp_client::DEFAULT_STARTUP_TIMEOUT;
use crate::rmcp_client::StartupOutcomeError;

View File

@@ -3,9 +3,9 @@ use std::collections::HashSet;
use std::sync::Arc;
use std::sync::atomic::Ordering;
use akode_config::McpStartupReadiness;
use anyhow::Context;
use anyhow::Result;
use akode_config::McpStartupReadiness;
use futures::future::join_all;
use tracing::Instrument;
use tracing::instrument;
@@ -294,8 +294,9 @@ impl McpConnectionSet {
);
let catalog_metrics = akode_otel::global();
let catalog_measurement_enabled = catalog_log_enabled || catalog_metrics.is_some();
let product_sku = akode_otel::bounded_product_sku(Some(crate::mcp::MCP_CATALOG_PRODUCT_SKU))
.unwrap_or("unknown");
let product_sku =
akode_otel::bounded_product_sku(Some(crate::mcp::MCP_CATALOG_PRODUCT_SKU))
.unwrap_or("unknown");
let optional_mcp_startup_grace = config.optional_mcp_startup_grace;
let server_snapshots = join_all(self.servers.iter().map(|(server_name, view)| async move {
if !view
@@ -557,8 +558,7 @@ impl McpConnectionSet {
.tools
.iter()
.find(|tool| {
tool.server_name == *server_name
&& tool.tool.name == advertised_tool.tool.name
tool.server_name == *server_name && tool.tool.name == advertised_tool.tool.name
})
.ok_or_else(unavailable)?;
let mut tool_info = crate::rmcp_client::prepare_regular_mcp_tools_for_model(

View File

@@ -24,7 +24,6 @@ use crate::tools::ToolFilter;
use crate::tools::ToolInfo;
use crate::tools::filter_tools;
use crate::tools::normalize_tools_for_model_with_prefix;
use assert_matches::assert_matches;
use akode_config::AppToolApproval;
use akode_config::Constrained;
use akode_config::McpServerAuth;
@@ -51,6 +50,7 @@ use akode_rmcp_client::McpLoginRequirement;
use akode_rmcp_client::McpOAuthRefreshMode;
use akode_rmcp_client::RmcpClient;
use akode_utils_path_uri::PathUri;
use assert_matches::assert_matches;
use futures::FutureExt;
use futures::future::BoxFuture;
use pretty_assertions::assert_eq;
@@ -453,8 +453,7 @@ async fn create_test_managed_client(tools: Vec<ToolInfo>) -> ManagedClient {
.expect("create in-process RMCP client"),
),
server_info: create_test_server_info("Ready"),
tool_catalog: Arc::new(ClientToolCatalog::new(
tools, /*meta*/ None)),
tool_catalog: Arc::new(ClientToolCatalog::new(tools, /*meta*/ None)),
tool_timeout: None,
server_instructions: None,
server_supports_sandbox_state_meta_capability: false,
@@ -679,7 +678,11 @@ fn cached_tool_catalog_context(
&ElicitationCapability::default(),
&ClientMcpExtensions::default(),
),
Some((&identity, McpProtocolMode::Legacy, /*agent_plugin*/ false)),
Some((
&identity,
McpProtocolMode::Legacy,
/*agent_plugin*/ false,
)),
)
.expect("tool catalog cache context");
cache_context.publish_if_newest(cache_context.begin_fetch(), tools, /*meta*/ None);
@@ -751,11 +754,7 @@ async fn disabled_permissions_auto_accept_elicitation_with_empty_form_schema() {
ElicitationRequestRouter::default(),
);
let (tx_event, _rx_event) = async_channel::bounded(1);
let sender = manager.make_sender(
"server".to_string(),
Some(tx_event),
);
let sender = manager.make_sender("server".to_string(), Some(tx_event));
let response = sender(
NumberOrString::Number(1),
@@ -789,11 +788,7 @@ async fn disabled_permissions_do_not_auto_accept_elicitation_with_requested_fiel
ElicitationRequestRouter::default(),
);
let (tx_event, _rx_event) = async_channel::bounded(1);
let sender = manager.make_sender(
"server".to_string(),
Some(tx_event),
);
let sender = manager.make_sender("server".to_string(), Some(tx_event));
let response = sender(
NumberOrString::Number(1),
@@ -884,11 +879,7 @@ async fn assert_elicitation_declined_with_reviewer_calls(
full_access_form_input_enabled_router(),
);
let (tx_event, rx_event) = async_channel::bounded(1);
let sender = manager.make_sender(
server_name.to_string(),
Some(tx_event),
);
let sender = manager.make_sender(server_name.to_string(), Some(tx_event));
let response = tokio::select! {
biased;
@@ -928,11 +919,7 @@ async fn assert_requested_user_input_is_declined(
router,
);
let (tx_event, rx_event) = async_channel::bounded(1);
let sender = manager.make_sender(
"server".to_string(),
Some(tx_event),
);
let sender = manager.make_sender("server".to_string(), Some(tx_event));
let response = tokio::select! {
biased;
@@ -1019,11 +1006,7 @@ async fn assert_disabled_permissions_surface_requested_user_input(
router.clone(),
);
let (tx_event, rx_event) = async_channel::bounded(1);
let sender = manager.make_sender(
"server".to_string(),
Some(tx_event),
);
let sender = manager.make_sender("server".to_string(), Some(tx_event));
let requested_schema = requested_user_input_schema();
let mut pending = tokio::spawn(sender(
NumberOrString::Number(1),
@@ -1168,11 +1151,7 @@ async fn disabled_permissions_decline_user_input_without_an_event_channel() {
/*lifecycle*/ None,
full_access_form_input_enabled_router(),
);
let sender = manager.make_sender(
"server".to_string(),
/*tx_event*/ None,
);
let sender = manager.make_sender("server".to_string(), /*tx_event*/ None);
let response = sender(
NumberOrString::Number(1),
@@ -1230,11 +1209,7 @@ async fn concurrent_authority_updates_never_auto_approve_mixed_policy() {
));
}
});
let sender = manager.make_sender(
"server".to_string(),
/*tx_event*/ None,
);
let sender = manager.make_sender("server".to_string(), /*tx_event*/ None);
let elicitation =
akode_rmcp_client::Elicitation::Mcp(ElicitRequestParams::FormElicitationParams {
meta: None,
@@ -1301,16 +1276,8 @@ async fn shared_elicitation_router_targets_the_exact_pending_request() {
router.clone(),
);
let (tx_event, rx_event) = async_channel::bounded(2);
let sender_a = manager_a.make_sender(
"server".to_string(),
Some(tx_event.clone()),
);
let sender_b = manager_b.make_sender(
"server".to_string(),
Some(tx_event),
);
let sender_a = manager_a.make_sender("server".to_string(), Some(tx_event.clone()));
let sender_b = manager_b.make_sender("server".to_string(), Some(tx_event));
let elicitation =
akode_rmcp_client::Elicitation::Mcp(ElicitRequestParams::FormElicitationParams {
meta: None,
@@ -1405,11 +1372,7 @@ async fn cancelled_elicitation_is_removed_without_affecting_other_pending_reques
router.clone(),
);
let (tx_event, rx_event) = async_channel::bounded(2);
let sender = manager.make_sender(
"server".to_string(),
Some(tx_event),
);
let sender = manager.make_sender("server".to_string(), Some(tx_event));
let elicitation =
akode_rmcp_client::Elicitation::Mcp(ElicitRequestParams::FormElicitationParams {
meta: None,
@@ -2118,11 +2081,7 @@ async fn capture_binding_exposes_cached_tools_before_startup() {
startup_started.send(()).expect("signal client startup");
startup_released.await.expect("release client startup");
startup_complete_for_client.store(true, std::sync::atomic::Ordering::Release);
Ok(create_test_managed_client(vec![create_test_tool(
"cached",
"client_local_tool",
)])
.await)
Ok(create_test_managed_client(vec![create_test_tool("cached", "client_local_tool")]).await)
}
.boxed()
.shared();
@@ -2181,11 +2140,8 @@ async fn capture_binding_exposes_cached_tools_before_startup() {
);
let manager_for_startup = Arc::clone(&manager);
let startup = tokio::spawn(async move {
manager_for_startup
.wait_for_server_startup("cached")
.await
});
let startup =
tokio::spawn(async move { manager_for_startup.wait_for_server_startup("cached").await });
wait_for_startup.await.expect("client startup should begin");
release_startup.send(()).expect("release client startup");
@@ -2841,11 +2797,8 @@ async fn capture_binding_resolves_concurrently_and_rechecks_cached_clients() {
let manager = Arc::new(manager);
let manager_for_startup = Arc::clone(&manager);
let startup = tokio::spawn(async move {
manager_for_startup
.wait_for_server_startup("cached")
.await
});
let startup =
tokio::spawn(async move { manager_for_startup.wait_for_server_startup("cached").await });
tokio::time::timeout(Duration::from_secs(1), cached_started)
.await
.expect("cached server startup should begin")
@@ -2860,7 +2813,9 @@ async fn capture_binding_resolves_concurrently_and_rechecks_cached_clients() {
.await
.expect("both uncached servers should start before either is released");
release_cached.send(()).expect("release cached server startup");
release_cached
.send(())
.expect("release cached server startup");
assert!(startup.await.expect("cached server startup task"));
release_first.send(()).expect("release first server");
release_second.send(()).expect("release second server");
@@ -4138,9 +4093,7 @@ async fn reconciliation_reuses_connection_without_relisting_regular_tools() -> a
_auth_change_notifications: None,
client: Arc::clone(&client),
server_info: create_test_server_info("Mutable tools"),
tool_catalog: Arc::new(ClientToolCatalog::new(
initial_tools,
initial_meta)),
tool_catalog: Arc::new(ClientToolCatalog::new(initial_tools, initial_meta)),
tool_timeout: None,
server_instructions: initialize.instructions,
server_supports_sandbox_state_meta_capability: false,
@@ -4831,11 +4784,9 @@ async fn reconciliation_updates_elicitation_policy_without_restarting_ready_serv
router.clone(),
);
let (tx_event, events) = async_channel::unbounded();
let sender = previous.elicitation_requests.make_sender(
"docs".to_string(),
Some(tx_event),
);
let sender = previous
.elicitation_requests
.make_sender("docs".to_string(), Some(tx_event));
let elicitation =
akode_rmcp_client::Elicitation::Mcp(ElicitRequestParams::FormElicitationParams {
meta: None,

View File

@@ -222,8 +222,7 @@ pub(crate) fn startup(
/*server_instructions*/ None,
)
.await?;
client.tool_catalog =
Arc::new(ClientToolCatalog::new(tools, meta));
client.tool_catalog = Arc::new(ClientToolCatalog::new(tools, meta));
client.connection_sharing = sharing;
Ok(client)
}

View File

@@ -16,10 +16,6 @@ use std::sync::atomic::Ordering;
use crate::McpConfig;
use crate::mcp::McpPermissionPromptAutoApproveContext;
use crate::mcp::mcp_permission_prompt_is_auto_approved;
use anyhow::Context;
use anyhow::Result;
use anyhow::anyhow;
use async_channel::Sender;
use akode_protocol::approvals::ElicitationAbandonedEvent;
use akode_protocol::approvals::ElicitationRequest;
use akode_protocol::approvals::ElicitationRequestEvent;
@@ -34,6 +30,10 @@ use akode_protocol::protocol::EventMsg;
use akode_rmcp_client::Elicitation;
use akode_rmcp_client::ElicitationResponse;
use akode_rmcp_client::SendElicitation;
use anyhow::Context;
use anyhow::Result;
use anyhow::anyhow;
use async_channel::Sender;
use futures::future::BoxFuture;
use futures::future::FutureExt;
use rmcp::model::ElicitationAction;
@@ -45,7 +45,6 @@ static NEXT_ELICITATION_REQUEST_ID: AtomicU64 = AtomicU64::new(0);
const STRICT_AUTO_REVIEW_DECLINE_MESSAGE: &str = "Automated review of this operation failed. Do not proceed without asking the user for explicit approval.";
#[derive(Debug, Clone)]
pub struct ElicitationReviewRequest {
pub server_name: String,

View File

@@ -1,9 +1,9 @@
use super::*;
use crate::McpServerPermissions;
use crate::mcp::tests::test_elicitation_config;
use async_channel::Receiver;
use akode_protocol::models::PermissionProfile;
use akode_protocol::protocol::GranularApprovalConfig;
use async_channel::Receiver;
use pretty_assertions::assert_eq;
use rmcp::model::ElicitRequestParams;
use rmcp::model::ElicitationSchema;
@@ -400,10 +400,7 @@ fn elicitation_fixture(
ElicitationRequestRouter::default(),
);
let (tx_event, events) = async_channel::bounded(1);
let sender = manager.make_sender(
"independent-mcp".to_string(),
Some(tx_event),
);
let sender = manager.make_sender("independent-mcp".to_string(), Some(tx_event));
(manager, events, sender)
}
@@ -661,10 +658,7 @@ async fn strict_auto_review_respects_explicit_elicitation_denials() {
("independent-mcp", Some(json!(false))),
("another-independent-mcp", None),
] {
let sender = manager.make_sender(
server_name.into(),
/*tx_event*/ None,
);
let sender = manager.make_sender(server_name.into(), /*tx_event*/ None);
assert_eq!(
send_elicitation(&sender, marker).await,
ElicitationResponse {
@@ -789,14 +783,8 @@ async fn reused_elicitation_senders_follow_each_servers_latest_permission_author
/*lifecycle*/ None,
ElicitationRequestRouter::default(),
);
let attached = manager.make_sender(
"attached".to_string(),
/*tx_event*/ None,
);
let hosted = manager.make_sender(
"local".to_string(),
/*tx_event*/ None,
);
let attached = manager.make_sender("attached".to_string(), /*tx_event*/ None);
let hosted = manager.make_sender("local".to_string(), /*tx_event*/ None);
assert_eq!(
send_elicitation(&attached, /*marker*/ None).await.action,
@@ -863,11 +851,8 @@ fn verification_fixture(
approval_policy: AskForApproval,
reviewer: Option<Arc<RecordingReviewer>>,
) -> (ElicitationRequestManager, Receiver<Event>, SendElicitation) {
let mut config = test_elicitation_config(
"codex_apps",
approval_policy,
PermissionProfile::Disabled,
);
let mut config =
test_elicitation_config("codex_apps", approval_policy, PermissionProfile::Disabled);
let mut catalog = crate::catalog::ResolvedMcpCatalog::builder();
catalog.register(crate::catalog::McpServerRegistration::from_extension(
"codex_apps".to_string(),
@@ -883,20 +868,14 @@ fn verification_fixture(
ElicitationRequestRouter::default(),
);
let (tx, events) = async_channel::bounded(1);
let sender = manager.make_sender(
"codex_apps".into(),
Some(tx),
);
let sender = manager.make_sender("codex_apps".into(), Some(tx));
(manager, events, sender)
}
#[tokio::test]
async fn user_verification_cancels_when_no_app_can_receive_the_request() {
let (manager, _, _) = verification_fixture(AskForApproval::OnRequest, /*reviewer*/ None);
let sender = manager.make_sender(
"codex_apps".into(),
/*tx_event*/ None,
);
let sender = manager.make_sender("codex_apps".into(), /*tx_event*/ None);
assert_eq!(
sender(
RequestId::Number(7),
@@ -921,10 +900,7 @@ async fn user_verification_cancels_when_no_app_can_receive_the_request() {
async fn user_verification_cancels_for_an_event_receiver_without_host_activation() {
let (manager, _, _) = verification_fixture(AskForApproval::OnRequest, /*reviewer*/ None);
let (tx, events) = async_channel::bounded(1);
let sender = manager.make_sender(
"codex_apps".into(),
Some(tx),
);
let sender = manager.make_sender("codex_apps".into(), Some(tx));
let response = tokio::time::timeout(
std::time::Duration::from_secs(1),
sender(
@@ -968,10 +944,7 @@ async fn user_verification_rejects_attached_servers_even_if_they_use_the_plugin_
config.mcp_server_catalog = catalog.build();
}
let (tx, events) = async_channel::bounded(1);
let sender = manager.make_sender(
name.into(),
Some(tx),
);
let sender = manager.make_sender(name.into(), Some(tx));
assert_eq!(
sender(
RequestId::Number(7),

View File

@@ -1,8 +1,8 @@
pub use akode_rmcp_client::McpProtocolMode;
pub use binding::McpBinding;
pub use binding::McpPermissionSource;
pub use binding::PreparedMcpCall;
pub use client_capabilities::client_mcp_extensions;
pub use akode_rmcp_client::McpProtocolMode;
pub use connection_manager::NetworkPolicyMetadata;
pub use connection_manager::NetworkPolicyMetadataProvider;
pub use connection_manager::tool_is_model_visible;

View File

@@ -1,7 +1,6 @@
use std::collections::HashMap;
use std::sync::Arc;
use anyhow::Result;
use akode_config::McpServerAuth;
use akode_config::McpServerConfig;
use akode_config::McpServerTransportConfig;
@@ -18,6 +17,7 @@ use akode_rmcp_client::determine_streamable_http_auth_status;
use akode_rmcp_client::determine_streamable_http_auth_status_from_credentials;
use akode_rmcp_client::discover_streamable_http_oauth;
use akode_rmcp_client::resolve_mcp_oauth_callback_url;
use anyhow::Result;
use futures::FutureExt;
use futures::future::join_all;
use tracing::warn;

View File

@@ -6,8 +6,8 @@ use crate::connection_manager::tests::create_ready_async_managed_client;
use crate::mcp::auth::McpAuthStatusEntry;
use crate::rmcp_client::StartupOutcomeError;
use crate::server::McpCredentialPolicy;
use anyhow::Context;
use akode_config::Constrained;
use akode_config::McpServerTransportConfig;
use akode_config::types::AppToolApproval;
use akode_config::types::AuthKeyringBackendKind;
use akode_exec_server_test_support::environment_manager_without_environments;
@@ -17,8 +17,8 @@ use akode_protocol::models::PermissionProfile;
use akode_protocol::permissions::NetworkSandboxPolicy;
use akode_protocol::protocol::AskForApproval;
use akode_protocol::protocol::GranularApprovalConfig;
use akode_config::McpServerTransportConfig;
use akode_rmcp_client::McpAuthState;
use anyhow::Context;
use futures::FutureExt;
use pretty_assertions::assert_eq;
use std::collections::HashMap;

View File

@@ -1,10 +1,10 @@
use std::sync::Arc;
use std::sync::Weak;
use anyhow::Context;
use anyhow::Result;
use akode_protocol::mcp::Resource;
use akode_protocol::mcp::ResourceContent;
use anyhow::Context;
use anyhow::Result;
use rmcp::model::PaginatedRequestParams;
use rmcp::model::ReadResourceRequestParams;

View File

@@ -49,9 +49,6 @@ use crate::server::has_explicit_http_authorization;
use crate::tool_catalog_cache::McpToolCatalogCacheContext;
use crate::tool_catalog_cache::McpToolCatalogFetchTicket;
use crate::tools::ToolInfo;
use anyhow::Result;
use anyhow::anyhow;
use async_channel::Sender;
use akode_async_utils::CancelErr;
use akode_async_utils::OrCancelExt;
use akode_config::McpServerAuth;
@@ -75,6 +72,9 @@ use akode_rmcp_client::StreamableHttpBearerToken;
use akode_rmcp_client::StreamableHttpRedirectMode;
use akode_rmcp_client::ToolWithConnectorId;
use akode_rmcp_client::is_authentication_required_error;
use anyhow::Result;
use anyhow::anyhow;
use async_channel::Sender;
use futures::future::BoxFuture;
use futures::future::FutureExt;
use futures::future::Shared;
@@ -141,10 +141,7 @@ struct ManagedClientStartup {
}
impl ManagedClientStartup {
fn start(
&self,
sharing_declined: Option<CancellationToken>,
) -> ManagedClientFuture {
fn start(&self, sharing_declined: Option<CancellationToken>) -> ManagedClientFuture {
// A new attempt must not expose capabilities from an earlier connection.
*self
.server_capabilities
@@ -196,7 +193,7 @@ impl ManagedClientStartup {
oauth_refresh_mode,
runtime_context,
resolved_environment,
protocol_mode,
protocol_mode,
),
)
.await
@@ -760,8 +757,7 @@ async fn start_server_task(
catalog_item_limit,
server_capabilities,
} = params;
let send_elicitation =
elicitation_requests.make_sender(server_name.clone(), tx_event);
let send_elicitation = elicitation_requests.make_sender(server_name.clone(), tx_event);
let client_supports_network_policy_meta =
client_mcp_extensions.contains(MCP_NETWORK_POLICY_META_CAPABILITY);
let (sharing_negotiation, send_elicitation) = if let Some(sharing_declined) = sharing_declined {
@@ -794,11 +790,7 @@ async fn start_server_task(
let initialize_result = client
.initialize(params, startup_timeout, send_elicitation)
.await;
record_protocol_discovery_metrics(
client.protocol_mode(),
started_at,
&initialize_result,
);
record_protocol_discovery_metrics(client.protocol_mode(), started_at, &initialize_result);
let initialize_result = initialize_result.map_err(StartupOutcomeError::from)?;
if client.protocol_mode() == McpProtocolMode::DiscoverLocalStdio
&& !initialize_result.protocol_version.has_initialize()
@@ -1305,7 +1297,6 @@ mod tests {
Some("kept")
);
}
}
#[cfg(test)]

View File

@@ -8,11 +8,11 @@ use std::time::Duration;
use crate::client_tool_catalog::ClientToolCatalog;
use crate::connection_pool::ConnectionSharing;
use crate::tools::ToolInfo;
use anyhow::Result;
use anyhow::anyhow;
use akode_protocol::mcp::McpServerInfo;
use akode_rmcp_client::RmcpClient;
use akode_rmcp_client::SendElicitation;
use anyhow::Result;
use anyhow::anyhow;
use rmcp::model::ListResourceTemplatesResult;
use rmcp::model::ListResourcesResult;
use rmcp::model::PaginatedRequestParams;

View File

@@ -22,8 +22,6 @@ use std::sync::atomic::AtomicU64;
use std::sync::atomic::Ordering;
use std::time::Duration;
use arc_swap::ArcSwap;
use async_channel::Sender;
use akode_config::types::McpServerDisabledReason;
use akode_exec_server::Environment;
use akode_exec_server::EnvironmentManager;
@@ -38,6 +36,8 @@ use akode_protocol::protocol::Event;
use akode_protocol::protocol::TurnEnvironmentSelection;
use akode_rmcp_client::ElicitationResponse;
use akode_rmcp_client::with_http_headers_helper;
use arc_swap::ArcSwap;
use async_channel::Sender;
use rmcp::model::ReadResourceRequestParams;
use rmcp::model::ReadResourceResult;
use rmcp::model::RequestId;
@@ -1013,7 +1013,8 @@ mod tests {
.test_client("docs")
.ready_client()
.expect("ready test client");
let mut refreshed_tool = crate::connection_manager::tests::create_test_tool("docs", "search");
let mut refreshed_tool =
crate::connection_manager::tests::create_test_tool("docs", "search");
refreshed_tool.tool.description = Some("refreshed".into());
client
.tool_catalog

View File

@@ -182,7 +182,7 @@ impl McpServerConnectionIdentity {
oauth_refresh_mode: McpOAuthRefreshMode,
resolved_environment: &Result<Option<Arc<Environment>>, String>,
runtime_context: &McpRuntimeContext,
client_elicitation_capability: ElicitationCapability,
client_elicitation_capability: ElicitationCapability,
client_mcp_extensions: ClientMcpExtensions,
previous_identity: Option<&Self>,
) -> Self {

View File

@@ -4,10 +4,10 @@ use std::sync::Arc;
use crate::McpServerSource;
use crate::PreparedMcpCall;
use anyhow::Context;
use akode_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID;
use akode_config::McpServerTransportConfig;
use akode_protocol::ThreadId;
use anyhow::Context;
use futures::future::BoxFuture;
use serde_json::Value;

View File

@@ -124,8 +124,7 @@ where
let mut candidates = Vec::new();
for tool in tools {
// The trailing separator keeps hashed names stable across catalog versions.
let raw_namespace_identity =
format!("{}\0{}\0", tool.server_name, tool.callable_namespace);
let raw_namespace_identity = format!("{}\0{}\0", tool.server_name, tool.callable_namespace);
let raw_tool_identity = format!(
"{}\0{}\0{}",
raw_namespace_identity, tool.callable_name, tool.tool.name