mcp

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package mcp compiles route exposures into an immutable Datly MCP catalog and a fresh upstream protocol registry.

Index

Constants

View Source
const (
	SkillListTool = "skills/list"
	SkillGetTool  = "skills/get"
)
View Source
const DefaultResourceBaseURI = "datly://localhost"
View Source
const ToolSourceMetaKey = "viant.datly/source"

ToolSourceMetaKey is the MCP tool metadata entry identifying the exact published Datly component that backs a tool. Hosts supply this entry from their authoritative publication catalog; ordinary Datly components do not synthesize a source version.

Variables

This section is empty.

Functions

This section is empty.

Types

type Catalog added in v1.0.0

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

func (*Catalog) ResourceCatalog added in v1.0.0

func (c *Catalog) ResourceCatalog() *mcpresource.Catalog

func (*Catalog) Tool added in v1.0.0

func (c *Catalog) Tool(name string) (*tool.Plan, bool)

func (*Catalog) ToolNames added in v1.0.0

func (c *Catalog) ToolNames() []string

type ComponentLoader added in v1.0.0

type ComponentLoader interface {
	LoadComponent(context.Context, spec.Key) (*registry.RegisteredComponent, error)
}

type ComponentRouteResolver added in v1.0.0

type ComponentRouteResolver interface {
	ResolveComponentRoute(method, path string) (spec.Key, *spec.Route, bool)
}

type Config added in v1.0.0

type Config struct {
	Folders           []mcpresource.Folder
	Components        []*registry.RegisteredComponent
	Invoker           exec.ComponentInvoker
	Client            xmcp.Client
	Resources         *bindresource.Store
	ResourceBaseURI   string
	Authorization     *authorization.Policy
	AuthorizeTool     func(context.Context, exec.ComponentTarget) error
	AuthorizeResource func(context.Context, string) error
	// ToolMetadata supplies host-owned, exact component identity metadata for
	// MCP tools. The compiler merges it into schema.Tool.Meta without allowing
	// a host to replace the tool name or input/output contract.
	ToolMetadata func(context.Context, exec.ComponentTarget) (map[string]interface{}, error)
	// Catalog callbacks authorize metadata independently of execution. They are
	// evaluated for the request's pinned generation, never from skill frontmatter.
	AuthorizeCatalogTool     func(context.Context, exec.ComponentTarget, string) error
	AuthorizeCatalogResource func(context.Context, string, string) error
	// Indexed publishes tool identities without eager component contracts.
	Indexed []*spec.Component
	Loader  ComponentLoader
}

func (Config) Compile added in v1.0.0

func (config Config) Compile(ctx context.Context) (*Service, error)

Compile stages resource snapshots in the caller's generation context.

type Service added in v1.0.0

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

func New added in v1.0.0

func New(config Config) (*Service, error)

func (*Service) Authorization added in v1.0.0

func (s *Service) Authorization() *authorization.Policy

Authorization returns a detached copy of the validated transport policy.

func (*Service) AuthorizeCatalogResource added in v1.1.0

func (s *Service) AuthorizeCatalogResource(ctx context.Context, uri, action string) error

func (*Service) AuthorizeCatalogTool added in v1.1.0

func (s *Service) AuthorizeCatalogTool(ctx context.Context, name, action string) error

func (*Service) AuthorizeResourceRead added in v1.1.0

func (s *Service) AuthorizeResourceRead(ctx context.Context, uri string) error

func (*Service) Catalog added in v1.0.0

func (s *Service) Catalog() *Catalog

func (*Service) ListVisibleSkills added in v1.1.0

func (s *Service) ListVisibleSkills(ctx context.Context, cursor *string) (*schema.ListSkillsResult, *jsonrpc.Error)

func (*Service) PrepareTool added in v1.0.0

func (s *Service) PrepareTool(ctx context.Context, name string) error

func (*Service) PrepareTools added in v1.0.0

func (s *Service) PrepareTools(ctx context.Context) error

func (*Service) ReadResource added in v1.0.0

func (*Service) Registry added in v1.0.0

func (s *Service) Registry() *mcpserver.Registry

type ToolSourceIdentity added in v1.1.0

type ToolSourceIdentity struct {
	Tenant   string `json:"tenant"`
	ReportID string `json:"reportId"`
	Version  int    `json:"version"`
}

ToolSourceIdentity is the host-attested component identity carried under ToolSourceMetaKey. A consumer must still evaluate its own current ACL and require an exact match with the configured resource before calling the tool.

Directories

Path Synopsis
Package developer exposes explicitly configured authoring tools separately from Datly's business component catalog and runtime invocation engine.
Package developer exposes explicitly configured authoring tools separately from Datly's business component catalog and runtime invocation engine.
skills
Package skills contains the complete canonical authoring skill snapshot.
Package skills contains the complete canonical authoring skill snapshot.
Package input projects compiled MCP payloads into canonical Bindly request providers.
Package input projects compiled MCP payloads into canonical Bindly request providers.
Package invocation adapts MCP calls to the protocol-neutral component port.
Package invocation adapts MCP calls to the protocol-neutral component port.
Package resource compiles and resolves MCP resource route exposures.
Package resource compiles and resolves MCP resource route exposures.
Package server adapts a compiled Datly MCP service to the upstream protocol handler.
Package server adapts a compiled Datly MCP service to the upstream protocol handler.
Package tool compiles route-effective component contracts into MCP tools.
Package tool compiles route-effective component contracts into MCP tools.

Jump to

Keyboard shortcuts

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