Skip to content

Conversation

@callicles
Copy link
Collaborator

@callicles callicles commented Oct 29, 2025

Note

Adds a new MCP tool diagnose_infrastructure with multiple ClickHouse diagnostics and wires it into the server alongside tests and docs updates.

  • MCP Server:
    • Registers new tool diagnose_infrastructure in list_tools and routes in call_tool.
    • Updates server instructions to mention diagnostics and source browsing.
    • Updates tests to account for 6 tools and validates tool names.
  • New Tool: infra_issues (ClickHouse diagnostics):
    • Core module infra_issues/mod.rs with params parsing, severity filtering, Redis-backed infra map usage, and aggregated JSON output with summaries.
    • Diagnostic providers:
      • MutationDiagnostic (system.mutations): stuck/failed mutations.
      • PartsDiagnostic (system.parts): excessive parts per partition.
      • MergeDiagnostic (system.merges): long-running merges.
      • ErrorStatsDiagnostic (system.errors): top recurring errors (system-wide).
      • S3QueueDiagnostic (system.s3queue_log): ingestion failures (S3Queue tables).
      • ReplicationDiagnostic (system.replication_queue/system.replicas): lag and health issues (replicated tables).
      • MergeFailureDiagnostic (system.metrics): background merge failures (system-wide).
      • StoppedOperationsDiagnostic: merges/replication possibly stopped.
  • Tool Registry:
    • Exposes infra_issues in tools/mod.rs.
  • Misc:
    • get_source.rs: remove unused SourceLocationNotAvailable error variant.

Written by Cursor Bugbot for commit 7c40c36. This will update automatically on new commits. Configure here.

@linear
Copy link

linear bot commented Oct 29, 2025

@vercel
Copy link

vercel bot commented Oct 29, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
docs-v2 Ready Ready Preview Comment Nov 12, 2025 7:39pm
framework-docs Ready Ready Preview Comment Nov 12, 2025 7:39pm
moosestack-framework-docs-v2 Ready Ready Preview Comment Nov 12, 2025 7:39pm

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Test Inconsistency with New Tool Addition

The test cases test_list_tools_count() and test_tool_names_are_consistent() are incomplete after adding the diagnose_infrastructure tool. The tests only verify 5 tools, but the list_tools() method now returns 6 tools (including the new infra_issues::tool_definition() at line 86). The test at line 212 asserts all_tools.len() == 5 but should be 6, and the expected_tools array at line 226 is missing the "diagnose_infrastructure" tool that is now returned by list_tools().

apps/framework-cli/src/mcp/server.rs#L203-L243

#[test]
fn test_list_tools_count() {
// Test that all expected tools are returned
let logs_tool = logs::tool_definition();
let infra_tool = infra_map::tool_definition();
let olap_tool = query_olap::tool_definition();
let stream_tool = sample_stream::tool_definition();
let get_source_tool = get_source::tool_definition();
// Ensure we have 5 tools
let all_tools = vec![
&logs_tool,
&infra_tool,
&olap_tool,
&stream_tool,
&get_source_tool,
];
assert_eq!(all_tools.len(), 5);
// Verify each tool has required fields
for tool in all_tools {
assert!(!tool.name.is_empty());
assert!(tool.description.is_some());
assert!(!tool.input_schema.is_empty());
}
}
#[test]
fn test_tool_names_are_consistent() {
// Ensure tool names match between routing and definitions
let expected_tools = [
"get_logs",
"get_infra_map",
"query_olap",
"get_stream_sample",
"get_source",
];
let logs_tool = logs::tool_definition();
let infra_tool = infra_map::tool_definition();
let olap_tool = query_olap::tool_definition();

Fix in Cursor Fix in Web


@callicles callicles requested a review from a team October 29, 2025 03:01
@onelesd
Copy link
Contributor

onelesd commented Nov 10, 2025

can you explain a bit the tools added and how they interact, perhaps with an example use case?

actually, just pasting the output of a session with tool calls would be illuminating

@callicles
Copy link
Collaborator Author

@onelesd Did you take a look at the issue? there is a bunch of context there

@callicles callicles force-pushed the nicolas/eng-1132-add-general-purpose-infrastructure-diagnostics-mcp-tool branch from d002009 to 360a8eb Compare November 11, 2025 18:54
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Test Fails to Validate New Tool Consistency

The test_tool_names_are_consistent test has an expected_tools array with only 5 tool names, missing "diagnose_infrastructure", and doesn't instantiate or check the infra_issues::tool_definition(). This causes the test to not validate the newly added tool's name consistency with the routing logic in call_tool.

apps/framework-cli/src/mcp/server.rs#L253-L272

#[test]
fn test_tool_names_are_consistent() {
// Ensure tool names match between routing and definitions
let expected_tools = [
"get_logs",
"get_infra_map",
"query_olap",
"get_stream_sample",
"get_source",
];
let logs_tool = logs::tool_definition();
let infra_tool = infra_map::tool_definition();
let olap_tool = query_olap::tool_definition();
let stream_tool = sample_stream::tool_definition();
let get_source_tool = get_source::tool_definition();
assert_eq!(logs_tool.name, expected_tools[0]);
assert_eq!(infra_tool.name, expected_tools[1]);
assert_eq!(olap_tool.name, expected_tools[2]);

Fix in Cursor Fix in Web


Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Test fails to validate all tools.

The test test_list_tools_count only validates 5 tool definitions but list_tools() now returns 6 tools including the newly added infra_issues tool. The test's comment claims to verify "all expected tools" but omits infra_issues_tool, leaving that tool's definition untested.

apps/framework-cli/src/mcp/server.rs#L232-L250

let stream_tool = sample_stream::tool_definition();
let get_source_tool = get_source::tool_definition();
// Ensure we have 5 tools
let all_tools = vec![
&logs_tool,
&infra_tool,
&olap_tool,
&stream_tool,
&get_source_tool,
];
assert_eq!(all_tools.len(), 5);
// Verify each tool has required fields
for tool in all_tools {
assert!(!tool.name.is_empty());
assert!(tool.description.is_some());
assert!(!tool.input_schema.is_empty());
}

Fix in Cursor Fix in Web


Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Tool Count Test: Expectation vs. Reality

The test_list_tools_count test checks only 5 tools but list_tools() now returns 6 tools including the new infra_issues::tool_definition(). The test doesn't include infra_issues_tool in the count verification, causing the test to assert an incorrect tool count that doesn't match the actual implementation.

apps/framework-cli/src/mcp/server.rs#L226-L248

#[test]
fn test_list_tools_count() {
// Test that all expected tools are returned
let logs_tool = logs::tool_definition();
let infra_tool = infra_map::tool_definition();
let olap_tool = query_olap::tool_definition();
let stream_tool = sample_stream::tool_definition();
let get_source_tool = get_source::tool_definition();
// Ensure we have 5 tools
let all_tools = vec![
&logs_tool,
&infra_tool,
&olap_tool,
&stream_tool,
&get_source_tool,
];
assert_eq!(all_tools.len(), 5);
// Verify each tool has required fields
for tool in all_tools {
assert!(!tool.name.is_empty());
assert!(tool.description.is_some());

Fix in Cursor Fix in Web


Copy link
Contributor

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, looking forward to giving this a try and improving on this! This is a really great start and I am quite happy because I think what is in here aligns really well with what we've been talking about!

@callicles callicles force-pushed the nicolas/eng-1132-add-general-purpose-infrastructure-diagnostics-mcp-tool branch from 685e3c0 to 7c40c36 Compare November 12, 2025 19:37
@callicles callicles enabled auto-merge November 12, 2025 19:44
@callicles callicles added this pull request to the merge queue Nov 12, 2025
Merged via the queue into main with commit e3dc317 Nov 12, 2025
54 checks passed
@callicles callicles deleted the nicolas/eng-1132-add-general-purpose-infrastructure-diagnostics-mcp-tool branch November 12, 2025 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants