Documentation
¶
Overview ¶
Package tools provides MCP tool definitions for DataHub operations. It implements the Toolkit pattern for composable MCP servers.
Index ¶
- Constants
- Variables
- func DefaultAnnotations(name ToolName) *mcp.ToolAnnotations
- func DefaultDescription(name ToolName) string
- func DefaultIcons() []mcp.Icon
- func ErrorResult(message string) *mcp.CallToolResult
- func JSONResult(v any) (*mcp.CallToolResult, error)
- func TextResult(text string) *mcp.CallToolResult
- type AccessFilterMiddleware
- type AddGlossaryTermInput
- type AddGlossaryTermOutput
- type AddLinkInput
- type AddLinkOutput
- type AddTagInput
- type AddTagOutput
- type AfterFunc
- type AuditLoggerMiddleware
- type BeforeFunc
- type Config
- type ConnectionInfoOutput
- type DataHubClient
- type GetColumnLineageInput
- type GetDataProductInput
- type GetEntityInput
- type GetGlossaryTermInput
- type GetLineageInput
- type GetQueriesInput
- type GetSchemaInput
- type ListConnectionsInput
- type ListConnectionsOutput
- type ListDataProductsInput
- type ListDomainsInput
- type ListTagsInput
- type MetadataEnricherMiddleware
- type RemoveGlossaryTermInput
- type RemoveGlossaryTermOutput
- type RemoveLinkInput
- type RemoveLinkOutput
- type RemoveTagInput
- type RemoveTagOutput
- type SearchInput
- type ToolContext
- type ToolMiddleware
- type ToolName
- type ToolOption
- type Toolkit
- func (t *Toolkit) Client() DataHubClient
- func (t *Toolkit) Config() Config
- func (t *Toolkit) ConnectionCount() int
- func (t *Toolkit) ConnectionInfos() []multiserver.ConnectionInfo
- func (t *Toolkit) HasManager() bool
- func (t *Toolkit) HasMiddleware() bool
- func (t *Toolkit) HasQueryProvider() bool
- func (t *Toolkit) Manager() *multiserver.Manager
- func (t *Toolkit) QueryProvider() integration.QueryProvider
- func (t *Toolkit) Register(server *mcp.Server, names ...ToolName)
- func (t *Toolkit) RegisterAll(server *mcp.Server)
- func (t *Toolkit) RegisterWith(server *mcp.Server, name ToolName, opts ...ToolOption)
- type ToolkitOption
- func WithAccessFilter(f integration.AccessFilter) ToolkitOption
- func WithAnnotations(anns map[ToolName]*mcp.ToolAnnotations) ToolkitOption
- func WithAuditLogger(l integration.AuditLogger, getUserID func(context.Context) string) ToolkitOption
- func WithDescriptions(descs map[ToolName]string) ToolkitOption
- func WithIcons(icons map[ToolName][]mcp.Icon) ToolkitOption
- func WithMetadataEnricher(e integration.MetadataEnricher) ToolkitOption
- func WithMiddleware(mw ToolMiddleware) ToolkitOption
- func WithQueryProvider(p integration.QueryProvider) ToolkitOption
- func WithToolMiddleware(name ToolName, mw ToolMiddleware) ToolkitOption
- func WithURNResolver(r integration.URNResolver) ToolkitOption
- type URNResolverMiddleware
- type UpdateDescriptionInput
- type UpdateDescriptionOutput
Constants ¶
const ( ContextKeyResolvedURN = "resolved_urn" ContextKeyAccessOK = "access_ok" )
Context keys for inter-middleware communication.
Variables ¶
var ErrAccessDenied = errors.New("access denied")
ErrAccessDenied is returned when access to a URN is denied.
Functions ¶
func DefaultAnnotations ¶ added in v0.7.0
func DefaultAnnotations(name ToolName) *mcp.ToolAnnotations
DefaultAnnotations returns the default annotations for a tool. Returns nil for unknown tool names.
func DefaultDescription ¶ added in v0.6.0
DefaultDescription returns the default description for a tool. Returns an empty string if the tool name is not recognized.
func DefaultIcons ¶ added in v0.7.1
DefaultIcons returns the default icons for DataHub tools.
func ErrorResult ¶
func ErrorResult(message string) *mcp.CallToolResult
ErrorResult creates an error result for tool responses.
func JSONResult ¶
func JSONResult(v any) (*mcp.CallToolResult, error)
JSONResult creates a JSON result for tool responses.
func TextResult ¶
func TextResult(text string) *mcp.CallToolResult
TextResult creates a text result for tool responses.
Types ¶
type AccessFilterMiddleware ¶ added in v0.2.0
type AccessFilterMiddleware struct {
// contains filtered or unexported fields
}
AccessFilterMiddleware wraps an AccessFilter to control access to entities.
func NewAccessFilterMiddleware ¶ added in v0.2.0
func NewAccessFilterMiddleware(f integration.AccessFilter) *AccessFilterMiddleware
NewAccessFilterMiddleware creates a middleware that controls access to entities.
func (*AccessFilterMiddleware) After ¶ added in v0.2.0
func (m *AccessFilterMiddleware) After( ctx context.Context, tc *ToolContext, result *mcp.CallToolResult, _ error, ) (*mcp.CallToolResult, error)
After implements ToolMiddleware - filters URNs from list results.
func (*AccessFilterMiddleware) Before ¶ added in v0.2.0
func (m *AccessFilterMiddleware) Before(ctx context.Context, tc *ToolContext) (context.Context, error)
Before implements ToolMiddleware.
type AddGlossaryTermInput ¶ added in v0.5.0
type AddGlossaryTermInput struct {
URN string `json:"urn" jsonschema_description:"The DataHub URN of the entity"`
TermURN string `json:"term_urn" jsonschema_description:"The URN of the glossary term to add (e.g., urn:li:glossaryTerm:Classification)"`
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
AddGlossaryTermInput is the input for the add_glossary_term tool.
type AddGlossaryTermOutput ¶ added in v0.7.0
type AddGlossaryTermOutput struct {
URN string `json:"urn"`
Term string `json:"term"`
Aspect string `json:"aspect"`
Action string `json:"action"`
}
AddGlossaryTermOutput is the structured output of the datahub_add_glossary_term tool.
type AddLinkInput ¶ added in v0.5.0
type AddLinkInput struct {
URN string `json:"urn" jsonschema_description:"The DataHub URN of the entity"`
URL string `json:"url" jsonschema_description:"The URL of the link to add"`
Description string `json:"description" jsonschema_description:"A description of the link"`
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
AddLinkInput is the input for the add_link tool.
type AddLinkOutput ¶ added in v0.7.0
type AddLinkOutput struct {
URN string `json:"urn"`
URL string `json:"url"`
Aspect string `json:"aspect"`
Action string `json:"action"`
}
AddLinkOutput is the structured output of the datahub_add_link tool.
type AddTagInput ¶ added in v0.5.0
type AddTagInput struct {
URN string `json:"urn" jsonschema_description:"The DataHub URN of the entity"`
TagURN string `json:"tag_urn" jsonschema_description:"The URN of the tag to add (e.g., urn:li:tag:PII)"`
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
AddTagInput is the input for the add_tag tool.
type AddTagOutput ¶ added in v0.7.0
type AddTagOutput struct {
URN string `json:"urn"`
Tag string `json:"tag"`
Aspect string `json:"aspect"`
Action string `json:"action"`
}
AddTagOutput is the structured output of the datahub_add_tag tool.
type AfterFunc ¶
type AfterFunc func(ctx context.Context, tc *ToolContext, result *mcp.CallToolResult, err error) (*mcp.CallToolResult, error)
AfterFunc is a convenience type for creating After-only middleware.
func (AfterFunc) After ¶
func (f AfterFunc) After(ctx context.Context, tc *ToolContext, result *mcp.CallToolResult, err error) (*mcp.CallToolResult, error)
After implements ToolMiddleware.
type AuditLoggerMiddleware ¶ added in v0.2.0
type AuditLoggerMiddleware struct {
// contains filtered or unexported fields
}
AuditLoggerMiddleware wraps an AuditLogger to log tool invocations.
func NewAuditLoggerMiddleware ¶ added in v0.2.0
func NewAuditLoggerMiddleware(l integration.AuditLogger, getUserID func(context.Context) string) *AuditLoggerMiddleware
NewAuditLoggerMiddleware creates a middleware that logs tool invocations.
func (*AuditLoggerMiddleware) After ¶ added in v0.2.0
func (m *AuditLoggerMiddleware) After( ctx context.Context, tc *ToolContext, result *mcp.CallToolResult, _ error, ) (*mcp.CallToolResult, error)
After implements ToolMiddleware - logs the tool call.
func (*AuditLoggerMiddleware) Before ¶ added in v0.2.0
func (m *AuditLoggerMiddleware) Before(ctx context.Context, _ *ToolContext) (context.Context, error)
Before implements ToolMiddleware (no-op).
type BeforeFunc ¶
BeforeFunc is a convenience type for creating Before-only middleware.
func (BeforeFunc) After ¶
func (f BeforeFunc) After(_ context.Context, _ *ToolContext, result *mcp.CallToolResult, _ error) (*mcp.CallToolResult, error)
After implements ToolMiddleware (no-op).
func (BeforeFunc) Before ¶
func (f BeforeFunc) Before(ctx context.Context, tc *ToolContext) (context.Context, error)
Before implements ToolMiddleware.
type Config ¶
type Config struct {
// DefaultLimit is the default search result limit. Default: 10.
DefaultLimit int
// MaxLimit is the maximum allowed limit. Default: 100.
MaxLimit int
// MaxLineageDepth is the maximum lineage traversal depth. Default: 5.
MaxLineageDepth int
// WriteEnabled enables write operations (add/remove tags, glossary terms, etc.).
// Default: false (read-only mode).
WriteEnabled bool
// Debug enables debug logging for toolkit operations.
Debug bool
// Logger is the logger for debug output. If nil and Debug is true, uses client.StdLogger.
Logger client.Logger
}
Config configures the DataHub toolkit behavior.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults.
type ConnectionInfoOutput ¶ added in v0.1.1
type ConnectionInfoOutput struct {
Name string `json:"name"`
URL string `json:"url"`
IsDefault bool `json:"is_default"`
}
ConnectionInfoOutput provides information about a single connection.
type DataHubClient ¶
type DataHubClient interface {
// Search searches for entities.
Search(ctx context.Context, query string, opts ...client.SearchOption) (*types.SearchResult, error)
// GetEntity retrieves a single entity by URN.
GetEntity(ctx context.Context, urn string) (*types.Entity, error)
// GetSchema retrieves schema for a dataset.
GetSchema(ctx context.Context, urn string) (*types.SchemaMetadata, error)
// GetSchemas retrieves schemas for multiple datasets by URN.
GetSchemas(ctx context.Context, urns []string) (map[string]*types.SchemaMetadata, error)
// GetLineage retrieves lineage for an entity.
GetLineage(ctx context.Context, urn string, opts ...client.LineageOption) (*types.LineageResult, error)
// GetColumnLineage retrieves fine-grained column-level lineage for a dataset.
GetColumnLineage(ctx context.Context, urn string) (*types.ColumnLineage, error)
// GetQueries retrieves queries for a dataset.
GetQueries(ctx context.Context, urn string) (*types.QueryList, error)
// GetGlossaryTerm retrieves a glossary term.
GetGlossaryTerm(ctx context.Context, urn string) (*types.GlossaryTerm, error)
// ListTags lists all tags.
ListTags(ctx context.Context, filter string) ([]types.Tag, error)
// ListDomains lists all domains.
ListDomains(ctx context.Context) ([]types.Domain, error)
// ListDataProducts lists all data products.
ListDataProducts(ctx context.Context) ([]types.DataProduct, error)
// GetDataProduct retrieves a data product by URN.
GetDataProduct(ctx context.Context, urn string) (*types.DataProduct, error)
// Ping tests the connection.
Ping(ctx context.Context) error
// Close closes the client.
Close() error
// UpdateDescription sets the editable description for an entity.
UpdateDescription(ctx context.Context, urn, description string) error
// AddTag adds a tag to an entity.
AddTag(ctx context.Context, urn, tagURN string) error
// RemoveTag removes a tag from an entity.
RemoveTag(ctx context.Context, urn, tagURN string) error
// AddGlossaryTerm adds a glossary term to an entity.
AddGlossaryTerm(ctx context.Context, urn, termURN string) error
// RemoveGlossaryTerm removes a glossary term from an entity.
RemoveGlossaryTerm(ctx context.Context, urn, termURN string) error
// AddLink adds a link to an entity.
AddLink(ctx context.Context, urn, linkURL, description string) error
// RemoveLink removes a link from an entity by URL.
RemoveLink(ctx context.Context, urn, linkURL string) error
}
DataHubClient defines the interface for DataHub operations. This allows for mocking in tests.
type GetColumnLineageInput ¶ added in v0.4.0
type GetColumnLineageInput struct {
URN string `json:"urn" jsonschema_description:"The DataHub URN of the dataset"`
// Connection is the named connection to use. Empty uses the default connection.
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
GetColumnLineageInput is the input for the get_column_lineage tool.
type GetDataProductInput ¶
type GetDataProductInput struct {
URN string `json:"urn" jsonschema_description:"The DataHub URN of the data product"`
// Connection is the named connection to use. Empty uses the default connection.
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
GetDataProductInput is the input for the get_data_product tool.
type GetEntityInput ¶
type GetEntityInput struct {
URN string `json:"urn" jsonschema_description:"The DataHub URN of the entity"`
// Connection is the named connection to use. Empty uses the default connection.
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
GetEntityInput is the input for the get_entity tool.
type GetGlossaryTermInput ¶
type GetGlossaryTermInput struct {
URN string `json:"urn" jsonschema_description:"The DataHub URN of the glossary term"`
// Connection is the named connection to use. Empty uses the default connection.
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
GetGlossaryTermInput is the input for the get_glossary_term tool.
type GetLineageInput ¶
type GetLineageInput struct {
URN string `json:"urn" jsonschema_description:"The DataHub URN of the entity"`
Direction string `json:"direction,omitempty" jsonschema_description:"Lineage direction: UPSTREAM or DOWNSTREAM (default: DOWNSTREAM)"`
Depth int `json:"depth,omitempty" jsonschema_description:"Maximum depth of lineage traversal (default: 1, max: 5)"`
// Connection is the named connection to use. Empty uses the default connection.
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
GetLineageInput is the input for the get_lineage tool.
type GetQueriesInput ¶
type GetQueriesInput struct {
URN string `json:"urn" jsonschema_description:"The DataHub URN of the dataset"`
// Connection is the named connection to use. Empty uses the default connection.
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
GetQueriesInput is the input for the get_queries tool.
type GetSchemaInput ¶
type GetSchemaInput struct {
URN string `json:"urn" jsonschema_description:"The DataHub URN of the dataset"`
// Connection is the named connection to use. Empty uses the default connection.
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
GetSchemaInput is the input for the get_schema tool.
type ListConnectionsInput ¶ added in v0.1.1
type ListConnectionsInput struct{}
ListConnectionsInput defines the input for the datahub_list_connections tool. This tool has no required parameters.
type ListConnectionsOutput ¶ added in v0.1.1
type ListConnectionsOutput struct {
Connections []ConnectionInfoOutput `json:"connections"`
Count int `json:"count"`
}
ListConnectionsOutput defines the output of the datahub_list_connections tool.
type ListDataProductsInput ¶
type ListDataProductsInput struct {
// Connection is the named connection to use. Empty uses the default connection.
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
ListDataProductsInput is the input for the list_data_products tool.
type ListDomainsInput ¶
type ListDomainsInput struct {
// Connection is the named connection to use. Empty uses the default connection.
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
ListDomainsInput is the input for the list_domains tool.
type ListTagsInput ¶
type ListTagsInput struct {
Filter string `json:"filter,omitempty" jsonschema_description:"Optional filter string to match tag names"`
// Connection is the named connection to use. Empty uses the default connection.
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
ListTagsInput is the input for the list_tags tool.
type MetadataEnricherMiddleware ¶ added in v0.2.0
type MetadataEnricherMiddleware struct {
// contains filtered or unexported fields
}
MetadataEnricherMiddleware wraps a MetadataEnricher to add custom metadata.
func NewMetadataEnricherMiddleware ¶ added in v0.2.0
func NewMetadataEnricherMiddleware(e integration.MetadataEnricher) *MetadataEnricherMiddleware
NewMetadataEnricherMiddleware creates a middleware that enriches entity responses.
func (*MetadataEnricherMiddleware) After ¶ added in v0.2.0
func (m *MetadataEnricherMiddleware) After( ctx context.Context, tc *ToolContext, result *mcp.CallToolResult, _ error, ) (*mcp.CallToolResult, error)
After implements ToolMiddleware - enriches entity results.
func (*MetadataEnricherMiddleware) Before ¶ added in v0.2.0
func (m *MetadataEnricherMiddleware) Before(ctx context.Context, _ *ToolContext) (context.Context, error)
Before implements ToolMiddleware (no-op).
type RemoveGlossaryTermInput ¶ added in v0.5.0
type RemoveGlossaryTermInput struct {
URN string `json:"urn" jsonschema_description:"The DataHub URN of the entity"`
TermURN string `json:"term_urn" jsonschema_description:"The URN of the glossary term to remove"`
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
RemoveGlossaryTermInput is the input for the remove_glossary_term tool.
type RemoveGlossaryTermOutput ¶ added in v0.7.0
type RemoveGlossaryTermOutput struct {
URN string `json:"urn"`
Term string `json:"term"`
Aspect string `json:"aspect"`
Action string `json:"action"`
}
RemoveGlossaryTermOutput is the structured output of the datahub_remove_glossary_term tool.
type RemoveLinkInput ¶ added in v0.5.0
type RemoveLinkInput struct {
URN string `json:"urn" jsonschema_description:"The DataHub URN of the entity"`
URL string `json:"url" jsonschema_description:"The URL of the link to remove"`
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
RemoveLinkInput is the input for the remove_link tool.
type RemoveLinkOutput ¶ added in v0.7.0
type RemoveLinkOutput struct {
URN string `json:"urn"`
URL string `json:"url"`
Aspect string `json:"aspect"`
Action string `json:"action"`
}
RemoveLinkOutput is the structured output of the datahub_remove_link tool.
type RemoveTagInput ¶ added in v0.5.0
type RemoveTagInput struct {
URN string `json:"urn" jsonschema_description:"The DataHub URN of the entity"`
TagURN string `json:"tag_urn" jsonschema_description:"The URN of the tag to remove (e.g., urn:li:tag:PII)"`
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
RemoveTagInput is the input for the remove_tag tool.
type RemoveTagOutput ¶ added in v0.7.0
type RemoveTagOutput struct {
URN string `json:"urn"`
Tag string `json:"tag"`
Aspect string `json:"aspect"`
Action string `json:"action"`
}
RemoveTagOutput is the structured output of the datahub_remove_tag tool.
type SearchInput ¶
type SearchInput struct {
Query string `json:"query" jsonschema_description:"Search query string"`
// EntityType: DATASET, DASHBOARD, DATA_FLOW, DATA_JOB, CONTAINER, TAG, GLOSSARY_TERM, DATA_PRODUCT, etc.
EntityType string `json:"entity_type,omitempty" jsonschema_description:"Entity type to search. Defaults to DATASET."`
Limit int `json:"limit,omitempty" jsonschema_description:"Maximum number of results (default: 10, max: 100)"`
Offset int `json:"offset,omitempty" jsonschema_description:"Result offset for pagination"`
// Connection is the named connection to use. Empty uses the default connection.
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
SearchInput is the input for the search tool.
type ToolContext ¶
type ToolContext struct {
// ToolName is the name of the tool being executed.
ToolName ToolName
// Input is the parsed input for the tool.
Input any
// StartTime is when the tool execution started.
StartTime time.Time
// Extra allows middleware to pass data between Before and After.
Extra map[string]any
}
ToolContext provides context for middleware about the current tool execution.
func NewToolContext ¶
func NewToolContext(name ToolName, input any) *ToolContext
NewToolContext creates a new ToolContext.
func (*ToolContext) Duration ¶
func (tc *ToolContext) Duration() time.Duration
Duration returns the time elapsed since the tool started.
func (*ToolContext) Get ¶
func (tc *ToolContext) Get(key string) (any, bool)
Get retrieves a value from Extra.
func (*ToolContext) GetString ¶ added in v0.6.0
func (tc *ToolContext) GetString(key string) string
GetString retrieves a string value from Extra. Returns an empty string if the key is not found or the value is not a string.
func (*ToolContext) Set ¶
func (tc *ToolContext) Set(key string, value any)
Set stores a value in Extra.
type ToolMiddleware ¶
type ToolMiddleware interface {
// Before is called before the tool handler executes.
// Return a modified context or an error to abort execution.
Before(ctx context.Context, tc *ToolContext) (context.Context, error)
// After is called after the tool handler executes.
// Can modify the result or handle errors.
After(ctx context.Context, tc *ToolContext, result *mcp.CallToolResult, err error) (*mcp.CallToolResult, error)
}
ToolMiddleware intercepts tool execution for cross-cutting concerns.
type ToolName ¶
type ToolName string
ToolName identifies a DataHub MCP tool.
const ( ToolSearch ToolName = "datahub_search" ToolGetEntity ToolName = "datahub_get_entity" ToolGetSchema ToolName = "datahub_get_schema" ToolGetLineage ToolName = "datahub_get_lineage" ToolGetColumnLineage ToolName = "datahub_get_column_lineage" ToolGetQueries ToolName = "datahub_get_queries" ToolGetGlossaryTerm ToolName = "datahub_get_glossary_term" ToolListTags ToolName = "datahub_list_tags" ToolListDomains ToolName = "datahub_list_domains" ToolListDataProducts ToolName = "datahub_list_data_products" ToolGetDataProduct ToolName = "datahub_get_data_product" ToolListConnections ToolName = "datahub_list_connections" // Write tool names. ToolUpdateDescription ToolName = "datahub_update_description" ToolAddTag ToolName = "datahub_add_tag" ToolRemoveTag ToolName = "datahub_remove_tag" ToolAddGlossaryTerm ToolName = "datahub_add_glossary_term" ToolRemoveGlossaryTerm ToolName = "datahub_remove_glossary_term" ToolAddLink ToolName = "datahub_add_link" ToolRemoveLink ToolName = "datahub_remove_link" )
Tool name constants.
func AllTools ¶
func AllTools() []ToolName
AllTools returns all available read-only tool names. This does not include write tools for backward compatibility.
func WriteTools ¶ added in v0.5.0
func WriteTools() []ToolName
WriteTools returns all write tool names.
type ToolOption ¶
type ToolOption func(*toolConfig)
ToolOption configures a single tool registration.
func WithAnnotation ¶ added in v0.7.0
func WithAnnotation(ann *mcp.ToolAnnotations) ToolOption
WithAnnotation overrides the annotations for a single tool registration. This is the highest priority override, taking precedence over both toolkit-level WithAnnotations and default annotations.
func WithDescription ¶ added in v0.6.0
func WithDescription(desc string) ToolOption
WithDescription overrides the description for a single tool registration. This is the highest priority override, taking precedence over both toolkit-level WithDescriptions and default descriptions.
func WithIcon ¶ added in v0.7.1
func WithIcon(icons []mcp.Icon) ToolOption
WithIcon overrides the icons for a single tool registration. This is the highest priority override, taking precedence over both toolkit-level WithIcons and default icons.
func WithPerToolMiddleware ¶
func WithPerToolMiddleware(mw ToolMiddleware) ToolOption
WithPerToolMiddleware adds middleware for a single tool registration.
type Toolkit ¶
type Toolkit struct {
// contains filtered or unexported fields
}
Toolkit provides MCP tools for DataHub operations. It's designed to be composable - you can add its tools to any MCP server.
func NewToolkit ¶
func NewToolkit(c DataHubClient, cfg Config, opts ...ToolkitOption) *Toolkit
NewToolkit creates a new DataHub toolkit. Accepts optional ToolkitOption arguments for middleware, etc. Maintains backwards compatibility - existing code works unchanged.
func NewToolkitWithManager ¶ added in v0.1.1
func NewToolkitWithManager(mgr *multiserver.Manager, cfg Config, opts ...ToolkitOption) *Toolkit
NewToolkitWithManager creates a Toolkit with multi-server support. Use this when you need to connect to multiple DataHub servers.
func (*Toolkit) Client ¶
func (t *Toolkit) Client() DataHubClient
Client returns the underlying DataHub client.
func (*Toolkit) ConnectionCount ¶ added in v0.1.1
ConnectionCount returns the number of configured connections.
func (*Toolkit) ConnectionInfos ¶ added in v0.1.1
func (t *Toolkit) ConnectionInfos() []multiserver.ConnectionInfo
ConnectionInfos returns information about all configured connections. Returns a single "default" connection in single-client mode.
func (*Toolkit) HasManager ¶ added in v0.1.1
HasManager returns true if multi-server mode is enabled.
func (*Toolkit) HasMiddleware ¶
HasMiddleware returns true if any middleware is configured.
func (*Toolkit) HasQueryProvider ¶ added in v0.2.0
HasQueryProvider returns true if a query provider is configured.
func (*Toolkit) Manager ¶ added in v0.1.1
func (t *Toolkit) Manager() *multiserver.Manager
Manager returns the connection manager, or nil if in single-client mode.
func (*Toolkit) QueryProvider ¶ added in v0.2.0
func (t *Toolkit) QueryProvider() integration.QueryProvider
QueryProvider returns the configured query provider, or nil if not configured.
func (*Toolkit) RegisterAll ¶
RegisterAll adds all DataHub tools to the given MCP server. If WriteEnabled is true, also registers write tools.
func (*Toolkit) RegisterWith ¶
func (t *Toolkit) RegisterWith(server *mcp.Server, name ToolName, opts ...ToolOption)
RegisterWith adds a tool with additional per-registration options.
type ToolkitOption ¶
type ToolkitOption func(*Toolkit)
ToolkitOption configures a Toolkit.
func WithAccessFilter ¶ added in v0.2.0
func WithAccessFilter(f integration.AccessFilter) ToolkitOption
WithAccessFilter adds access control capability to the toolkit. When configured, tools will check access before execution and filter results to only include accessible entities.
func WithAnnotations ¶ added in v0.7.0
func WithAnnotations(anns map[ToolName]*mcp.ToolAnnotations) ToolkitOption
WithAnnotations sets toolkit-level annotation overrides for multiple tools. These take priority over default annotations but are overridden by per-registration WithAnnotation options.
func WithAuditLogger ¶ added in v0.2.0
func WithAuditLogger(l integration.AuditLogger, getUserID func(context.Context) string) ToolkitOption
WithAuditLogger adds audit logging capability to the toolkit. When configured, all tool invocations will be logged with the tool name, parameters, and user ID.
The getUserID function extracts the user ID from the context. If nil, an empty user ID will be logged.
func WithDescriptions ¶ added in v0.6.0
func WithDescriptions(descs map[ToolName]string) ToolkitOption
WithDescriptions sets toolkit-level description overrides for multiple tools. These take priority over default descriptions but are overridden by per-registration WithDescription options.
func WithIcons ¶ added in v0.7.1
func WithIcons(icons map[ToolName][]mcp.Icon) ToolkitOption
WithIcons sets toolkit-level icon overrides for multiple tools. These take priority over default icons but are overridden by per-registration WithIcon options.
func WithMetadataEnricher ¶ added in v0.2.0
func WithMetadataEnricher(e integration.MetadataEnricher) ToolkitOption
WithMetadataEnricher adds metadata enrichment capability to the toolkit. When configured, entity responses will be enriched with custom metadata before being returned.
func WithMiddleware ¶
func WithMiddleware(mw ToolMiddleware) ToolkitOption
WithMiddleware adds global middleware to all tools.
func WithQueryProvider ¶ added in v0.2.0
func WithQueryProvider(p integration.QueryProvider) ToolkitOption
WithQueryProvider adds query execution context to the toolkit. When configured, tools will enrich their responses with query execution context from the provider (table resolution, query examples, availability).
This enables bidirectional integration with query engines like Trino.
func WithToolMiddleware ¶
func WithToolMiddleware(name ToolName, mw ToolMiddleware) ToolkitOption
WithToolMiddleware adds middleware to a specific tool.
func WithURNResolver ¶ added in v0.2.0
func WithURNResolver(r integration.URNResolver) ToolkitOption
WithURNResolver adds URN resolution capability to the toolkit. When configured, tools will resolve external identifiers to DataHub URNs before execution.
type URNResolverMiddleware ¶ added in v0.2.0
type URNResolverMiddleware struct {
// contains filtered or unexported fields
}
URNResolverMiddleware wraps a URNResolver to resolve external IDs to DataHub URNs.
func NewURNResolverMiddleware ¶ added in v0.2.0
func NewURNResolverMiddleware(r integration.URNResolver) *URNResolverMiddleware
NewURNResolverMiddleware creates a middleware that resolves external IDs to DataHub URNs.
func (*URNResolverMiddleware) After ¶ added in v0.2.0
func (m *URNResolverMiddleware) After(_ context.Context, _ *ToolContext, result *mcp.CallToolResult, _ error) (*mcp.CallToolResult, error)
After implements ToolMiddleware (no-op).
func (*URNResolverMiddleware) Before ¶ added in v0.2.0
func (m *URNResolverMiddleware) Before(ctx context.Context, tc *ToolContext) (context.Context, error)
Before implements ToolMiddleware.
type UpdateDescriptionInput ¶ added in v0.5.0
type UpdateDescriptionInput struct {
URN string `json:"urn" jsonschema_description:"The DataHub URN of the entity to update"`
Description string `json:"description" jsonschema_description:"The new description text"`
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
UpdateDescriptionInput is the input for the update_description tool.
type UpdateDescriptionOutput ¶ added in v0.7.0
type UpdateDescriptionOutput struct {
URN string `json:"urn"`
Aspect string `json:"aspect"`
Action string `json:"action"`
}
UpdateDescriptionOutput is the structured output of the datahub_update_description tool.
Source Files
¶
- annotations.go
- client_interface.go
- column_lineage.go
- config.go
- connections.go
- context.go
- dataproducts.go
- descriptions.go
- doc.go
- domains.go
- entity.go
- errors.go
- glossary.go
- icons.go
- integration_adapters.go
- lineage.go
- middleware.go
- names.go
- options.go
- outputs.go
- queries.go
- schema.go
- search.go
- tags.go
- toolkit.go
- write_description.go
- write_glossary_terms.go
- write_links.go
- write_tags.go