ViteHub is still experimental. Expect bugs and breaking changes.

Fetch

Expose named HTTP request tools for developer-approved endpoints.

fetch() adds model-facing HTTP tools that the developer names and defines. Use it for specific endpoints, not for unrestricted web browsing.

The Capability creates one tool per entry in tools. Each tool can validate input, build a request, parse JSON or text, validate the response, and transform the output.

Configure HTTP requests

Define at least one named fetch tool. Keep the endpoint and method explicit.

server/agents/status.ts
import { defineAgent } from 'vite-hub/agent'
import { fetch } from 'vite-hub/agent/capabilities'

export default defineAgent({
  driver: { model },
  capabilities: [
    fetch({
      tools: {
        serviceStatus: {
          description: 'Fetch current service status.',
          method: 'GET',
          url: 'https://status.example.com/api/status',
        },
      },
    }),
  ],
})

How requests work

ViteHub validates the configured tool map and creates internal Agent tools. At invocation time, each tool resolves the request, executes the HTTP call, parses the configured response type, and returns either the parsed data or a transformed output.

Requirements

fetch({ tools }) requires at least one tool definition. Each tool must provide a URL directly or return one from its request resolver.

Use schemas for input and response validation when the endpoint accepts arguments or returns data that model behavior depends on.

Driver support

Agent DriverSupport
Model-backedReceives the named fetch tools.
Provider-backedReceives the named fetch tools through the provider MCP bridge.
Custom-run-backedReceives prepared context; driver.run decides whether to call HTTP endpoints directly.

Verify HTTP requests

Inspect the Agent tool list and confirm only the named fetch tools appear. Run one invocation with invalid input when a schema is configured and verify the request does not leave the process.

Options

OptionTypeDefaultDescription
toolsRecord<string, FetchCapabilityToolOptions>requiredNamed fetch tools exposed to the model.
tools.*.descriptionstringFetch <name>.Tool description.
tools.*.urlstring | URLnoneStatic request URL.
tools.*.requestobject | functionnoneStatic or input-derived request definition.
tools.*.method"GET" | "HEAD" | "POST""GET"HTTP method used when the request definition does not override it.
tools.*.request.urlstring | URLtools.*.urlRequest URL. A request resolver can derive it from validated tool input.
tools.*.request.method"GET" | "HEAD" | "POST"tools.*.method, then "GET"Per-request HTTP method override.
tools.*.request.headersRecord<string, string>noneRequest headers.
tools.*.request.queryRecord<string, unknown>noneQuery parameters appended to the URL.
tools.*.request.bodyunknownnoneRequest body.
tools.*.request.timeoutnumbernoneRequest timeout in milliseconds.
tools.*.inputSchemaStandard SchemanoneValidates model tool input before request construction.
tools.*.schemaStandard SchemanoneValidates parsed response data.
tools.*.responseType"json" | "text""json"Response parser.
tools.*.transform(data, input) => outputnoneMaps validated response data before returning it to the model.