Path: redb-route/redb.Route.Llm.Tools/HttpFetchTool.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Llm.Tools/HttpFetchTool.cs
----
using redb.Route.Abstractions;
using redb.Route.Core;
using redb.Route.Llm.Abstractions.Tools;
using redb.Route.Llm.Extensions;
namespace redb.Route.Llm.Tools;
///
/// Standalone RouteBuilder wrapper that mounts
/// behind a tool route. Prefer the
/// DSL extension .HttpFetch(opts) on any existing route — this shim is
/// only useful when you want a self-contained RouteBuilder to hand to
/// context.AddRoutes(...).
///
/// Input schema: {"url":"https://..."}. Response body is returned as
/// UTF-8 text in exchange.Out.Body; bytes past
/// are truncated.
///
///
public sealed class HttpFetchTool : RouteBuilder
{
private const string InputSchema = """
{
"type": "object",
"properties": {
"url": { "type": "string", "description": "Absolute http(s) URL to fetch." }
},
"required": ["url"],
"additionalProperties": false
}
""";
private readonly HttpFetchOptions _options;
/// Creates the tool with the given options.
public HttpFetchTool(HttpFetchOptions options)
{
_options = options ?? throw new ArgumentNullException(nameof(options));
}
///
protected override void Configure() =>
From(_options.EndpointUri)
.AsLlmTool(_options.ToolName)
.Description("Fetches a URL via HTTP GET and returns the response body as UTF-8 text.")
.Input(InputSchema)
.SideEffect(ToolSideEffect.External)
.Cost(ToolCostClass.Moderate)
.Then()
.HttpFetch(_options);
}