mcp

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package mcp implements a Model Context Protocol server over stdio so an AI agent can operate Interseptor as a set of tools. It is a thin, well-described front end over the running control API (REST) — every tool maps to an endpoint the web UI also uses, so the human and the agent drive the same engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Activity

type Activity struct {
	Tool    string `json:"tool"`
	Summary string `json:"summary"` // short, human-readable gist of the arguments
	OK      bool   `json:"ok"`
	Result  string `json:"result"` // first line of the result / error, truncated
	Ms      int64  `json:"ms"`
	Intent  string `json:"intent,omitempty"` // the AI's stated "why", if it passed one
}

Activity is a record of one MCP tool call. It is reported to the control plane after every call so a human watching the UI can see, live, what the AI is doing — which tool, the gist of the arguments, and the outcome.

type Server

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

Server is an MCP stdio server backed by the control API at base.

func New

func New(baseURL string) *Server

New builds an MCP server that talks to the control API at baseURL (e.g. http://127.0.0.1:9966).

func (*Server) Call

func (s *Server) Call(name string, args map[string]any) (string, error)

Call invokes a registered tool by name in-process, returning its text result. It is the seam the autonomous pentest engine (internal/autopwn) uses to drive all tools without a JSON-RPC round-trip. Activity logging + FlagAI History tagging still happen via the tool's own REST calls, exactly as for JSON-RPC: Call routes through the same runTool helper as callTool, so the Activity report (timing, summary, intent, outcome) is emitted identically.

func (*Server) Serve

func (s *Server) Serve(in io.Reader, out io.Writer) error

Serve runs the JSON-RPC loop over newline-delimited messages until EOF.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the MCP "Streamable HTTP" transport over a single endpoint. A client POSTs a JSON-RPC message (or batch) and receives the JSON-RPC response as application/json. The server is stateless — no Mcp-Session-Id is required — and offers no server-initiated SSE stream, so GET returns 405 (per spec). This lets a hosted/remote agent drive Interseptor without launching the `interseptor mcp` stdio subcommand. Bind localhost-only; it shares the (unauthenticated, local) trust model of the control API it fronts.

func (*Server) SetActivityReporter added in v1.2.0

func (s *Server) SetActivityReporter(fn func(Activity))

SetActivityReporter replaces the Activity callback used after each tool call. Pass nil to disable reporting (useful in tests that race SQLite with the async /api/activity POST).

func (*Server) ToolNames

func (s *Server) ToolNames() []string

ToolNames returns the registered tool names in registration order, so the UI descriptor / docs can be checked against the actual toolset (no silent drift).

Jump to

Keyboard shortcuts

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