наблюдаемость: измерять бюджет каталога MCP
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use crank_community_mcp::manifest::tool_definitions;
|
||||
use crank_community_mcp::manifest::{analyze_published_tool_catalog, tool_definitions};
|
||||
use crank_core::{
|
||||
ExecutionConfig, HttpMethod, Operation, OperationId, OperationSecurityLevel, OperationStatus,
|
||||
Protocol, RestTarget, Target, ToolDescription, WorkspaceId,
|
||||
@@ -57,6 +57,20 @@ fn marks_destructive_tools_as_two_step_confirmation_calls() {
|
||||
assert_eq!(definition["inputSchema"]["required"], json!(["base"]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn catalog_budget_uses_the_same_definitions_as_tools_list() {
|
||||
let tool = published_tool();
|
||||
let definitions = tool_definitions(&tool);
|
||||
let analysis = analyze_published_tool_catalog(&[tool]).unwrap();
|
||||
|
||||
assert_eq!(analysis.budget.tool_count, definitions.len());
|
||||
assert_eq!(
|
||||
analysis.budget.serialized_bytes,
|
||||
serde_json::to_vec(&definitions[0]).unwrap().len()
|
||||
);
|
||||
assert!(!analysis.budget.exceeds_recommended_budget);
|
||||
}
|
||||
|
||||
fn published_tool() -> PublishedAgentTool {
|
||||
PublishedAgentTool {
|
||||
workspace_id: WorkspaceId::new("ws_01"),
|
||||
|
||||
Reference in New Issue
Block a user