webops

package
v0.0.0-...-fa6cd3d Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 17 Imported by: ? 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 webops is a mobile-first web executor for Model Context Protocol servers. See docs/webops-package.md for the threat model, architecture, and design notes.

Index

Examples

Constants

View Source
const (
	MDKeyFavorite = "webops.favorite"
	MDKeyLabel    = "webops.label"
	MDKeyGroup    = "webops.group"
)

MDKey* are the tool.Meta keys cli-mcp stamps onto MCP Tool entries. See docs/webops-package.md and cli-mcp's "Extension-namespace annotations".

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(ctx context.Context, target MCPTarget, opts Options) error

ListenAndServe is the package-level convenience: NewServer + Run.

func TestOnlyConnectAndList

func TestOnlyConnectAndList(ctx context.Context, s *Server) error

TestOnlyConnectAndList runs the MCP-connect + ListTools half of Server.Run. Test helper for mounting Handler under httptest.NewServer. Do not use in production.

Types

type Auth

type Auth interface {
	// Middleware wraps the protected handler.
	// Drivers may mount their own auth endpoints on inner before delegating.
	Middleware(inner http.Handler) http.Handler
}

Auth is the authentication backend interface; implementations gate every HTTP request. See docs/auth.md for built-in drivers and planned WebAuthn/TOTP work (#2).

type DangerouslyAllowAllAuth

type DangerouslyAllowAllAuth struct{}

DangerouslyAllowAllAuth lets every request through with no authentication. STUB for dev/tests only; NEVER deploy. See docs/auth.md.

func (DangerouslyAllowAllAuth) Middleware

func (DangerouslyAllowAllAuth) Middleware(inner http.Handler) http.Handler

Middleware implements Auth.

type Field

type Field struct {
	Name        string
	Type        string // "text" "number" "checkbox"
	Required    bool
	Description string
	Default     string
	Enum        []string
}

Field is one rendered input on a tool's form.

type MCPTarget

type MCPTarget struct {
	// Command launches an MCP server as a subprocess and speaks stdio.
	// Path-style: ["myapp", "--mcp-mode"] (first element is the binary).
	Command []string

	// Env is appended to the subprocess environment if Command is set.
	Env []string

	// HTTP is reserved for the planned HTTP/SSE transport. Setting it
	// currently returns an error.
	HTTP string
}

MCPTarget describes how the server connects to its upstream MCP server. Exactly one of Command or HTTP must be set.

type Options

type Options struct {
	// Addr is the TCP address to bind. Required.
	Addr string

	// Auth is the authentication backend. Required. Stub:
	// DangerouslyAllowAllAuth{} (never deploy with that).
	Auth Auth

	// DangerouslySkipTailscale bypasses the Tailscale-interface bind gate.
	// Listen addr must still be loopback. See docs/webops-package.md.
	DangerouslySkipTailscale bool

	// DangerouslyBindAnywhere also bypasses the loopback check.
	// Test-only; never set in production. See docs/webops-package.md.
	DangerouslyBindAnywhere bool

	// ShowAllTools exposes every tool, not just webops.favorite ones, on
	// the home screen.
	ShowAllTools bool

	// CommandTimeout caps how long a single tool call may take before the
	// SSE stream is closed and the upstream call is cancelled.
	CommandTimeout time.Duration

	// TailscaleInterface overrides the interface name(s) considered
	// Tailscale-managed.
	TailscaleInterface []string

	// MCPClientName / MCPClientVersion identify webops to the MCP server.
	// Sensible defaults are used when empty.
	MCPClientName    string
	MCPClientVersion string
}

Options configure the web server.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the webops HTTP server.

func NewServer

func NewServer(target MCPTarget, opts Options) (*Server, error)

NewServer prepares a Server. Does not open the MCP connection (that happens in Run).

Example

Build a webops.Server that talks to an MCP server subprocess over stdio. MCP is the trust boundary; see docs/webops-package.md.

package main

import (
	"fmt"

	"github.com/coilysiren/cli-web-ops/webops"
)

func main() {
	srv, err := webops.NewServer(
		webops.MCPTarget{
			Command: []string{"cli-mcp-binary"},
		},
		webops.Options{
			Addr:                     "127.0.0.1:8443",
			Auth:                     webops.DangerouslyAllowAllAuth{}, // STUB - do not deploy
			DangerouslySkipTailscale: true,                             // dev only
		},
	)
	fmt.Println("ok:", srv != nil && err == nil)
}
Output:
ok: true

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the http.Handler with auth middleware applied. See docs/webops-package.md for the embed-behind-another-listener pattern.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run opens the MCP session, performs ListTools, and starts the HTTP server. Returns on ctx cancel or listener close; tears the MCP subprocess down on return.

Jump to

Keyboard shortcuts

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