mcp

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package mcp provides an MCP (Model Context Protocol) server that exposes Pacto contract operations as tools for AI agents.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCapabilityServer added in v2.6.0

func NewCapabilityServer(bundle *contract.Bundle, opts CapabilityOptions, version string, stderr io.Writer) (*mcpsdk.Server, error)

NewCapabilityServer builds an MCP server that exposes both the authoring tools and the bundle's capability tools + pacto_skill. The server's instructions describe the capability tools so an agent knows they invoke the live service.

func NewServer

func NewServer(_ *app.Service, version string) *mcpsdk.Server

NewServer creates a new MCP server with all Pacto authoring tools registered.

func RegisterCapabilities added in v2.6.0

func RegisterCapabilities(server *mcpsdk.Server, bundle *contract.Bundle, opts CapabilityOptions, stderr io.Writer) error

RegisterCapabilities registers one executable MCP tool per OpenAPI operation in the bundle's http interfaces, plus a pacto_skill tool exposing skills/*.md. Mutating operations (POST/PUT/PATCH/DELETE) are only registered when opts.AllowWrites is set.

Types

type CapabilityOptions added in v2.6.0

type CapabilityOptions struct {
	BaseURL     string
	Creds       capability.Credentials
	AllowWrites bool
	HTTPClient  *http.Client
}

CapabilityOptions configures capability-tool registration for a bundle.

type CheckResult

type CheckResult struct {
	Valid       bool             `json:"valid"`
	Summary     ContractSummary  `json:"summary"`
	Errors      []ValidationItem `json:"errors,omitempty"`
	Warnings    []ValidationItem `json:"warnings,omitempty"`
	Suggestions []Suggestion     `json:"suggestions,omitempty"`
}

CheckResult holds the result of a check operation.

func Check

func Check(path string) (*CheckResult, error)

Check validates an existing contract and returns structured results.

type ConfigProperty

type ConfigProperty struct {
	Name     string `json:"name"`
	Type     string `json:"type"`
	Required bool   `json:"required,omitempty"`
}

ConfigProperty describes a configuration property.

type ContractSummary

type ContractSummary struct {
	Name         string            `json:"name"`
	Version      string            `json:"version"`
	Owner        string            `json:"owner,omitempty"`
	Interfaces   []string          `json:"interfaces,omitempty"`
	Dependencies []string          `json:"dependencies,omitempty"`
	Workload     string            `json:"workload,omitempty"`
	StateType    string            `json:"stateType,omitempty"`
	Sections     map[string]string `json:"sections"`
}

ContractSummary provides a high-level overview of a contract.

type CreateInput

type CreateInput struct {
	Path        string
	Name        string
	Description string
	Version     string
	Owner       string

	Interfaces   []InterfaceInput
	Dependencies []DependencyInput

	Workload                  string
	StoresData                bool
	DataSurvivesRestart       bool
	DataSharedAcrossInstances bool
	DataLossImpact            string

	ConfigProperties []ConfigProperty
	Replicas         *int
	MinReplicas      *int
	MaxReplicas      *int
	Metadata         map[string]any

	DryRun bool
}

CreateInput holds the parameters for creating a new contract.

type CreateResult

type CreateResult struct {
	Path      string          `json:"path"`
	Summary   ContractSummary `json:"summary"`
	Derived   []string        `json:"derived"`
	FileCount int             `json:"fileCount"`
}

CreateResult holds the result of a create operation.

func Create

func Create(input CreateInput) (*CreateResult, error)

Create builds a new pacto contract from structured input.

type DependencyInput

type DependencyInput struct {
	Name          string `json:"name"`
	Ref           string `json:"ref"`
	Required      bool   `json:"required,omitempty"`
	Compatibility string `json:"compatibility,omitempty"`
}

DependencyInput describes a dependency to add.

type EditInput

type EditInput struct {
	Path string

	Name    *string
	Version *string
	Owner   *string

	AddInterfaces    []InterfaceInput
	RemoveInterfaces []string
	AddDependencies  []DependencyInput
	RemoveDeps       []string

	Workload                  *string
	StoresData                *bool
	DataSurvivesRestart       *bool
	DataSharedAcrossInstances *bool
	DataLossImpact            *string

	AddConfigProperties []ConfigProperty
	Replicas            *int
	MinReplicas         *int
	MaxReplicas         *int
	SetMetadata         map[string]any
	RemoveMetadata      []string

	DryRun bool
}

EditInput holds the parameters for editing an existing contract.

type EditResult

type EditResult struct {
	Path    string          `json:"path"`
	Summary ContractSummary `json:"summary"`
	Changes []string        `json:"changes"`
}

EditResult holds the result of an edit operation.

func Edit

func Edit(input EditInput) (*EditResult, error)

Edit modifies an existing pacto contract.

type InterfaceInput

type InterfaceInput struct {
	Name       string `json:"name"`
	Type       string `json:"type"`
	Port       *int   `json:"port,omitempty"`
	Visibility string `json:"visibility,omitempty"`
}

InterfaceInput describes an interface to add.

type Suggestion

type Suggestion struct {
	Message  string    `json:"message"`
	ToolCall *ToolCall `json:"toolCall,omitempty"`
}

Suggestion represents an improvement suggestion with an optional tool call.

type ToolCall

type ToolCall struct {
	Tool   string         `json:"tool"`
	Params map[string]any `json:"params"`
}

ToolCall represents a suggested MCP tool invocation.

type ValidationItem

type ValidationItem struct {
	Path    string `json:"path"`
	Code    string `json:"code"`
	Message string `json:"message"`
}

ValidationItem represents a single validation error or warning.

Jump to

Keyboard shortcuts

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