Skip to content

Commit 9a535a0

Browse files
committed
Remove the data resource group helper, make sure views are exported by the template export command
1 parent f827f1f commit 9a535a0

4 files changed

Lines changed: 16 additions & 85 deletions

File tree

src/SeqCli/Mcp/Data/DataResourceGroupHelper.cs

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/SeqCli/Mcp/Tools/Search/SearchAndQueryToolType.cs

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
using Seq.Api.Model.Signals;
3131
using Seq.Syntax.Templates;
3232
using SeqCli.Mapping;
33-
using SeqCli.Mcp.Data;
3433
using SeqCli.Output;
3534
using SeqCli.Signals;
3635
using Serilog;
@@ -278,10 +277,14 @@ public async Task<CallToolResult> QueryAsync(
278277
"To avoid consuming excessive resources, add a time bound such as `where @Timestamp >= now() - 1d`.", isError: true);
279278
}
280279

280+
SignalExpressionPart? parsedSignalExpression = null;
281+
if (!string.IsNullOrWhiteSpace(signal))
282+
parsedSignalExpression = SignalExpressionParser.ParseExpression(signal);
283+
281284
QueryResultPart result;
282285
try
283286
{
284-
result = await DataResourceGroupHelper.QueryPreserveErrorResponsesAsync(connection, signal, query, cancellationToken);
287+
result = await connection.Data.TryQueryAsync(query, signal: parsedSignalExpression, cancellationToken: cancellationToken);
285288
}
286289
catch (Exception ex)
287290
{
@@ -291,35 +294,12 @@ public async Task<CallToolResult> QueryAsync(
291294
}
292295

293296
var error = ex.GetBaseException() is SeqApiException ? ex.GetBaseException().Message : ex.ToString();
294-
return SimpleTextResult($"The search failed. {error}", isError: true);
295-
}
296-
297-
if (result.Error != null)
298-
{
299-
return new CallToolResult
300-
{
301-
IsError = true,
302-
Content =
303-
[
304-
new TextContentBlock
305-
{
306-
Text = $"The query could not be executed. {result.Error}"
307-
},
308-
new TextContentBlock
309-
{
310-
Text = string.Join(" ", result.Reasons)
311-
},
312-
new TextContentBlock
313-
{
314-
Text = result.Suggestion != null ? $"Did you mean: {result.Suggestion}?" : ""
315-
}
316-
]
317-
};
297+
return SimpleTextResult($"The query failed. {error}", isError: true);
318298
}
319-
299+
320300
var output = new StringWriter();
321301
NativeFormatter.WriteQueryResult(output, result);
322-
return SimpleTextResult(output.ToString());
302+
return SimpleTextResult(output.ToString(), isError: !string.IsNullOrWhiteSpace(result.Error));
323303
}
324304

325305
[McpServerTool(Name = "seq_new_session", ReadOnly = true, Title = "Begin a new Search/Query Session")]

src/SeqCli/Templates/Export/TemplateSetExporter.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Seq.Api.Model.Alerting;
1010
using Seq.Api.Model.Dashboarding;
1111
using Seq.Api.Model.Indexing;
12+
using Seq.Api.Model.Metrics;
1213
using Seq.Api.Model.Retention;
1314
using Seq.Api.Model.Signals;
1415
using Seq.Api.Model.Queries;
@@ -87,6 +88,12 @@ await ExportTemplates<ExpressionIndexEntity>(
8788
? expressionIndex.Expression
8889
: expressionIndex.Id.Replace("expressionindex-", ""),
8990
templateValueMap);
91+
92+
await ExportTemplates<ViewEntity>(
93+
id => _connection.Views.FindAsync(id),
94+
() => _connection.Views.ListAsync(shared: true),
95+
view => view.Title,
96+
templateValueMap);
9097
}
9198

9299
async Task ExportTemplates<TEntity>(

src/SeqCli/Templates/Import/TemplateSetImporter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static class TemplateSetImporter
4040
{
4141
var ordering = new List<string> {"users", "signals", "apps", "appinstances",
4242
"dashboards", "sqlqueries", "workspaces", "retentionpolicies",
43-
"alerts", "expressionindexes"};
43+
"alerts", "expressionindexes", "views"};
4444

4545
var sorted = templates.OrderBy(t => ordering.IndexOf(t.ResourceGroup));
4646

0 commit comments

Comments
 (0)