mcp

package
v0.0.0-...-26cc33b Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 16 Imported by: 1 module, 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.

README

MCP integration

The package adapts the ackOS kernel to MCP. Construct it with a runtime, executor, independent verifier, and independent recovery observer:

server, err := mcp.NewServer(runtime, executor, verifier, recoveryObserver)
if err != nil {
    return err
}

Use server.MCPServer() with mcp.StdioTransport for a local client, or server.StreamableHTTPHandler() for an HTTP deployment.

The executor and verifier are intentionally injected by the host application. This keeps provider-specific side effects outside the kernel while ensuring the MCP tool itself owns the executor call and verification path.

After an execution or verification failure, recovery evidence is obtained from the independent recovery observer with its real provider capture timestamp. The MCP caller's observed_state is never promoted into post-failure evidence. If provider evidence reports a state that differs from the kernel's committed root, recovery remains fail-closed rather than guessing whether the previous side effect succeeded.

The V0 adapter serializes complete control lifecycles because the runtime is a single mutable state machine. Verification is run with a context that survives MCP transport cancellation so a disconnected caller cannot strand the runtime in STARTED.

Documentation

Index

Constants

View Source
const (
	ToolControl = "ackos_control"
)
View Source
const ToolHTTPControl = "ackos_control"

Variables

This section is empty.

Functions

This section is empty.

Types

type ControlRequest

type ControlRequest struct {
	Subject        string `json:"subject" jsonschema:"the stable subject identity being controlled"`
	ObservedState  string `json:"observed_state" jsonschema:"the state observed before the requested transition"`
	DesiredState   string `json:"desired_state" jsonschema:"the exact desired state after the transition"`
	AuthorityTTLMS int64  `json:"authority_ttl_ms,omitempty" jsonschema:"optional authority lifetime in milliseconds; zero means no expiry"`
}

type ControlResponse

type ControlResponse struct {
	Phase       kernel.Phase              `json:"phase"`
	Observation kernel.Observation        `json:"observation"`
	Transition  kernel.Transition         `json:"transition"`
	Governance  kernel.GovernanceDecision `json:"governance"`
	Authority   kernel.Authority          `json:"authority"`
	Execution   kernel.ExecutionResult    `json:"execution"`
	Verified    bool                      `json:"verified"`
	Committed   bool                      `json:"committed"`
	Root        string                    `json:"root"`
}

type HTTPAPIAdapter

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

func NewHTTPAPIAdapter

func NewHTTPAPIAdapter(cfg HTTPAPIConfig) (*HTTPAPIAdapter, error)

func (*HTTPAPIAdapter) MCPServer

func (a *HTTPAPIAdapter) MCPServer() *mcpsdk.Server

MCPServer exposes the production-backed ackos_control tool. It intentionally does not construct a kernel runtime, executor, verifier, or Git provider.

type HTTPAPIConfig

type HTTPAPIConfig struct {
	BaseURL     string
	BearerToken string
	Timeout     time.Duration
	HTTPClient  *http.Client
}

HTTPAPIConfig configures the production MCP adapter. The adapter only calls ackos-api; all observation, authorization, execution, verification, and commitment remain behind that service's authenticated HTTP contract.

type HTTPControlRequest

type HTTPControlRequest struct {
	RepositoryID  string `json:"repository_id" jsonschema:"allowlisted repository ID configured on ackos-api"`
	Branch        string `json:"branch" jsonschema:"existing branch name in the configured repository"`
	Path          string `json:"path" jsonschema:"path of an existing tracked regular file"`
	Mode          string `json:"mode" jsonschema:"replacement file mode: 100644 or 100755"`
	ContentBase64 string `json:"content_base64" jsonschema:"canonical padded Base64 encoding of the complete replacement file bytes"`
}

HTTPControlRequest mirrors the enforceable ackos-api replacement-file contract. ContentBase64 is canonical padded Base64 for the exact file bytes.

type HTTPControlResponse

type HTTPControlResponse struct {
	ExecutionID string    `json:"execution_id"`
	Verified    bool      `json:"verified"`
	Committed   bool      `json:"committed"`
	CompletedAt time.Time `json:"completed_at"`
	State       string    `json:"state"`
}

type Observer

type Observer interface {
	Observe(context.Context, string) (kernel.Observation, error)
}

RecoveryObserver obtains fresh provider evidence after a failed attempt. Recovery must never manufacture a new observation from caller-supplied state.

type RecoveryObserver

type RecoveryObserver interface {
	Observe(context.Context, string) (kernel.Observation, error)
}

type Server

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

func NewServer

func NewServer(runtime *kernel.Runtime, executor kernel.Executor, verifier kernel.Verifier, observer Observer, recoveryObserver RecoveryObserver) (*Server, error)

func NewServerWithProvider

func NewServerWithProvider(runtime *kernel.Runtime, provider control.Provider) (*Server, error)

NewServerWithProvider constructs the MCP server using a control provider. Provider adapters are created per control call so execution errors remain request-scoped until the MCP result is constructed.

func (*Server) MCPServer

func (s *Server) MCPServer() *mcpsdk.Server

func (*Server) StreamableHTTPHandler

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

Jump to

Keyboard shortcuts

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