webtools

package
v1.261203.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: MPL-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package webtools is the single home for the builtin web-tool backends (DeepSeek, Serper, Keenable, Jina): backend selection, readiness, tool schemas and text rendering. It is the web-tool analog of internal/vision/visionproxy — a self-contained package with one entry point (Call), consumed by the stdio MCP server (internal/mcp/builtin_server) and the MCP runtime. It imports only internal/client, internal/typ and its own backend subpackages, never internal/mcp, so every layer can depend on it without a cycle.

Index

Constants

View Source
const (
	ToolWebSearch = constant.WebSearchToolName
	ToolWebFetch  = constant.WebFetchToolName
)

Tool names (canonical, defined in internal/constant). internal/mcp/tools re-exports the same values.

View Source
const (
	BackendDeepSeek = "deepseek"
	BackendSerper   = "serper"
	BackendKeenable = "keenable"
	BackendJina     = "jina"
)

Backend names.

View Source
const (
	StateReady          = "ready"
	StateNeedsKey       = "needs_key"
	StateInvalidBackend = "invalid_backend"
)

Display states of a web tool's configuration (KeyState).

Variables

This section is empty.

Functions

func BackendName

func BackendName(env map[string]string, tool string) (string, error)

BackendName resolves which backend serves tool under env, without building it. This is the one selection rule shared by discovery, readiness and execution: unset (or obsolete "auto") and an explicit DeepSeek both select DeepSeek for both tools; the legacy explicit Serper/Jina choices are honored, and an explicit Keenable choice selects Keenable for search. A missing DeepSeek token is deliberately NOT an error here — the tool stays selectable and the call fails with an actionable "enter a token" error on use (see .design/arch/web-server-tools-arch.md); gating it would drop the tool from injection instead.

func Backends added in v1.261203.1

func Backends(tool string) []string

Backends lists the backends tool can be served by, default first.

func Call

func Call(ctx context.Context, env map[string]string, tool string, args map[string]any) (string, error)

Call selects a backend for tool and executes it. It never sends an empty-token request: an unavailable DeepSeek backend returns its actionable error instead.

func EnvFromOS

func EnvFromOS() map[string]string

EnvFromOS collects the web-tool env contract from the process environment.

func IsTool

func IsTool(name string) bool

IsTool reports whether name is one of the builtin web tools.

func KeyEnv added in v1.261203.1

func KeyEnv(backend string) string

KeyEnv names the env key backend needs, or "" when it needs none.

func KeyState added in v1.261203.1

func KeyState(env map[string]string, tool string) string

KeyState is the honest display state of tool under env: unlike Ready, a DeepSeek backend without a token is "needs_key". Ready stays the injection gate; KeyState is only for telling the user what is missing.

func Ready

func Ready(env map[string]string, tool string) bool

Ready reports whether tool can serve given env. DeepSeek — the default — is deliberately not a readiness gate (a missing token fails with an actionable error on use, keeping the tool injectable); Serper needs its key; Jina has no external key requirement.

func SecretEnvKeys added in v1.261203.1

func SecretEnvKeys() []string

SecretEnvKeys are the env keys holding credentials. They are write-only in the settings API and masked wherever the source config is returned.

Types

type Backend

type Backend interface {
	Name() string
	Search(ctx context.Context, args map[string]any) (string, error)
	Fetch(ctx context.Context, args map[string]any) (string, error)
}

Backend is one web-tool provider. Serper serves only Search and Jina only Fetch; their unused method returns an error (selection never routes to them for the other tool).

func Resolve

func Resolve(env map[string]string, tool string) (Backend, error)

Resolve builds the backend env selects for tool.

type ToolDefinition

type ToolDefinition struct {
	Name        string
	Description string
	InputSchema map[string]any
}

ToolDefinition is a backend-neutral tool schema. internal/mcp builds MCP tools from it; discovery only needs name/description/schema.

func Definitions

func Definitions() []ToolDefinition

Definitions returns the static web-tool schemas. Being static lets disabled Server Tools stay discoverable without a process or credentials.

Directories

Path Synopsis
Package deepseek implements DeepSeek's read-only web APIs.
Package deepseek implements DeepSeek's read-only web APIs.
Package jina implements the Jina Reader web-fetch backend.
Package jina implements the Jina Reader web-fetch backend.
Package keenable implements the Keenable web-search backend (https://docs.keenable.ai/api-reference/search).
Package keenable implements the Keenable web-search backend (https://docs.keenable.ai/api-reference/search).
Package serper implements the Serper web-search backend.
Package serper implements the Serper web-search backend.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL