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
- func BackendName(env map[string]string, tool string) (string, error)
- func Backends(tool string) []string
- func Call(ctx context.Context, env map[string]string, tool string, args map[string]any) (string, error)
- func EnvFromOS() map[string]string
- func IsTool(name string) bool
- func KeyEnv(backend string) string
- func KeyState(env map[string]string, tool string) string
- func Ready(env map[string]string, tool string) bool
- func SecretEnvKeys() []string
- type Backend
- type ToolDefinition
Constants ¶
const ( ToolWebSearch = constant.WebSearchToolName ToolWebFetch = constant.WebFetchToolName )
Tool names (canonical, defined in internal/constant). internal/mcp/tools re-exports the same values.
const ( BackendDeepSeek = "deepseek" BackendSerper = "serper" BackendKeenable = "keenable" BackendJina = "jina" )
Backend names.
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 ¶
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
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 KeyEnv ¶ added in v1.261203.1
KeyEnv names the env key backend needs, or "" when it needs none.
func KeyState ¶ added in v1.261203.1
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 ¶
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).
type ToolDefinition ¶
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. |