mcp

package
v0.9.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ToolEntityList       = "entity_list"
	ToolEntityShow       = "entity_show"
	ToolObjectList       = "object_list"
	ToolObjectGet        = "object_get"
	ToolRepositoryExport = "repository_export"
	ToolFilesList        = "files_list"
)

Variables

View Source
var (
	// ErrUnknownEntity reports that the requested entity does not exist in the repository config.
	ErrUnknownEntity = errors.New("mcp: unknown entity")
	// ErrEntityNotAllowed reports that the requested entity is blocked by the configured allow-list.
	ErrEntityNotAllowed = errors.New("mcp: entity not allowed")
	// ErrObjectNotFound reports that the requested object does not exist for the exact entity query.
	ErrObjectNotFound = errors.New("mcp: object not found")
)

Functions

func NewHTTPHandler

func NewHTTPHandler(service *Service, opts HTTPHandlerOptions) (http.Handler, error)

NewHTTPHandler constructs the single supported HTTP transport mode: streamable HTTP mounted at one base path in stateless JSON-response mode.

func NewServer

func NewServer(service *Service) *sdkmcp.Server

NewServer constructs an MCP server exposing the initial read-only Mergeway tools.

func Run

func Run(ctx context.Context, opts RunOptions) error

Run starts the MCP server over the currently supported transport.

Types

type FileEntry

type FileEntry struct {
	Type string `json:"type" yaml:"type"`
	File string `json:"file" yaml:"file"`
}

FileEntry describes one configured backing file for an entity.

type HTTPHandlerOptions

type HTTPHandlerOptions struct {
	BasePath string
}

HTTPHandlerOptions configures the mounted HTTP handler.

type RunOptions

type RunOptions struct {
	Service      *Service
	Transport    string
	Stdin        io.Reader
	Stdout       io.Writer
	HTTPListen   string
	HTTPBasePath string
}

RunOptions configures server startup for the currently supported transports.

type Service

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

Service exposes read-only Mergeway repository queries for MCP handlers.

func NewService

func NewService(root string, allowedEntities []string) (*Service, error)

NewService constructs a read-only query service rooted at the given repository.

func (*Service) AllowedEntities

func (s *Service) AllowedEntities() []string

AllowedEntities reports the normalized exact-name entity allow-list.

func (*Service) EntityList

func (s *Service) EntityList() ([]string, error)

EntityList returns the visible entity names after allow-list filtering.

func (*Service) EntityShow

func (s *Service) EntityShow(typeName string) (*config.TypeDefinition, error)

EntityShow returns the schema/config details for one visible entity.

func (*Service) FilesList

func (s *Service) FilesList(typeName string) ([]FileEntry, error)

FilesList returns configured backing files for visible entities. When typeName is empty, it includes all visible entities.

func (*Service) ObjectGet

func (s *Service) ObjectGet(typeName, id string) (*data.Object, error)

ObjectGet returns one object declared exactly as typeName.

func (*Service) ObjectList

func (s *Service) ObjectList(typeName string) ([]*data.Object, error)

ObjectList returns objects declared exactly as typeName after allow-list enforcement.

func (*Service) RepositoryExport

func (s *Service) RepositoryExport(include []string) (map[string][]map[string]any, error)

RepositoryExport returns a structured snapshot of the requested visible entities. When include is empty, all visible entities are exported.

func (*Service) Root

func (s *Service) Root() string

Root reports the configured repository root.

Jump to

Keyboard shortcuts

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