mcp issues

This commit is contained in:
larssand
2026-06-30 12:47:31 +02:00
parent 86065eca59
commit c76e260516
5 changed files with 55 additions and 30 deletions

View File

@@ -8,8 +8,10 @@ class _AggregateClient:
self.responses = list(responses)
self.arguments = []
self.schema = schema
self.probes = 0
def probe(self):
self.probes += 1
status = {"status": "connected"}
if self.schema:
status["tool_schemas"] = {"aggregate_messages": self.schema}
@@ -43,6 +45,14 @@ class GraylogAggregateTests(unittest.TestCase):
self.assertEqual(status["aggregate_status"], "error")
self.assertIn("probe_error", status["aggregate_error"])
def test_uses_existing_probe_status_without_reprobing(self):
client = _AggregateClient([
{"result": {"content": [{"type": "text", "text": '{"events": 9}'}]}}
])
status = GraylogAggregateSource(client, "firewall").fetch_count(probe_status={"status": "connected"})
self.assertEqual(status["aggregate_events"], 9)
self.assertEqual(client.probes, 0)
def test_tries_fallback_argument_shape_after_tool_error(self):
client = _AggregateClient([
{"result": {"isError": True, "content": [{"type": "text", "text": "bad metrics"}]}},

View File

@@ -6,8 +6,10 @@ from fgai.graylog_source import GraylogStreamSource
class _Client:
def __init__(self):
self.arguments = None
self.probes = 0
def probe(self):
self.probes += 1
return {"status": "connected"}
def call_tool(self, _name, arguments):
@@ -48,6 +50,11 @@ class GraylogSourceTests(unittest.TestCase):
GraylogStreamSource(client, "vpn").fetch(range_seconds=86_400)
self.assertEqual(client.arguments["range_seconds"], 86_400)
def test_uses_existing_probe_status_without_reprobing(self):
client = _Client()
GraylogStreamSource(client, "vpn").fetch(probe_status={"status": "connected"})
self.assertEqual(client.probes, 0)
def test_marks_stream_truncated_when_max_events_reached(self):
client = _Client()
events, status = GraylogStreamSource(client, "vpn").fetch(max_events=2)