Documentation
¶
Index ¶
- Variables
- type CallBuffer
- type CallEntry
- type Registry
- func (r *Registry) AllowsURL(candidate *url.URL) bool
- func (r *Registry) Count() int
- func (r *Registry) ExplainBlockedRedirect(candidate *url.URL) *redirectMismatchDetails
- func (r *Registry) Lookup(label string) (Target, bool)
- func (r *Registry) RegisterTarget(target Target) error
- func (r *Registry) Resolve(label string) (*url.URL, error)
- func (r *Registry) SummarizeTargets() []map[string]string
- func (r *Registry) TargetForURL(candidate *url.URL) (Target, bool)
- func (r *Registry) Targets() []Target
- func (r *Registry) WaitForTarget(ctx context.Context, label string) (Target, error)
- type Server
- type ServerOption
- type Target
- type TargetRegistrar
Constants ¶
This section is empty.
Variables ¶
var Module = fx.Module( "harpoon", fx.Provide(newHarpoonService, newHarpoonGuardedMux, newHostBusSubscriber, newHostBus), fx.Invoke(registerAdditionalTransport, startHostRegistration), )
Module wires the harpoon MCP server.
Functions ¶
This section is empty.
Types ¶
type CallBuffer ¶
type CallBuffer struct {
// contains filtered or unexported fields
}
CallBuffer keeps a fixed-size ring buffer of recent calls.
func NewCallBuffer ¶
func NewCallBuffer() *CallBuffer
NewCallBuffer constructs a ring buffer for recent calls.
func (*CallBuffer) RecordCall ¶
func (b *CallBuffer) RecordCall(entry CallEntry)
RecordCall records a call entry into the ring buffer.
type CallEntry ¶
type CallEntry struct {
Timestamp time.Time `json:"timestamp"`
Label string `json:"label"`
URL string `json:"url"`
Method string `json:"method"`
Status int `json:"status"`
LatencyMS int `json:"latency_ms"`
ResponseContentType string `json:"response_content_type,omitempty"`
ReqBytes int `json:"req_bytes"`
RespBytes int `json:"resp_bytes"`
Error string `json:"error,omitempty"`
RequestBody string `json:"request_body,omitempty"`
ResponseBody string `json:"response_body,omitempty"`
ResponseBodyTransformed string `json:"response_body_transformed,omitempty"`
BodyIsBase64 bool `json:"body_is_base64,omitempty"`
}
CallEntry captures a recent harpoon call for the admin UI.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry stores allowed targets keyed by label.
func NewRegistry ¶
NewRegistry constructs a registry seeded with the provided targets and a default limit.
func NewRegistryWithLimit ¶
func NewRegistryWithLimit(logger *slog.Logger, allowPlaintext bool, targets []Target, limit int) (*Registry, error)
NewRegistryWithLimit constructs a registry with a maximum number of targets.
func (*Registry) AllowsURL ¶
AllowsURL reports whether the URL exactly matches any registered target after normalization.
func (*Registry) ExplainBlockedRedirect ¶
ExplainBlockedRedirect classifies why a redirect target missed the allow list.
func (*Registry) RegisterTarget ¶
RegisterTarget adds a target to the registry after validation.
func (*Registry) SummarizeTargets ¶
SummarizeTargets returns a stable, log-friendly projection of targets.
func (*Registry) TargetForURL ¶
TargetForURL returns the configured target whose URL exactly matches candidate.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server provides MCP tools for constrained HTTP access.
func NewServer ¶
func NewServer(cfg *config.HarpoonConfig, registry *Registry, buffer *CallBuffer, logger *slog.Logger, opts ...ServerOption) (*Server, error)
NewServer constructs a harpoon MCP server.
type ServerOption ¶
type ServerOption func(*serverOptions)
ServerOption configures optional server behavior.
func WithHTTPTransport ¶
func WithHTTPTransport(rt http.RoundTripper) ServerOption
WithHTTPTransport sets the HTTP transport used for Harpoon outbound calls.
func WithMeter ¶
func WithMeter(meter metric.Meter) ServerOption
WithMeter configures the meter used for Harpoon metrics.
type Target ¶
type Target struct {
Label string
Description string
Category string
Source string
Tags []string
InclusionReason string
BaseURL *url.URL
UnixSocketPath string
}
Target describes a registered outbound HTTP target.
type TargetRegistrar ¶
TargetRegistrar allows programmatic target registration during startup.
func WithTarget ¶
func WithTarget(target Target) TargetRegistrar
WithTarget returns a registrar that registers the provided target.