Tools API Reference¶
Complete API reference for the tools package.
Toolkit¶
NewToolkit¶
Creates a new toolkit instance.
Parameters:
client: A DataHub client implementing theDataHubClientinterfaceopts: Optional configuration options
Example:
RegisterAll¶
Registers all available tools with the MCP server.
Register¶
Registers specific tools with the MCP server.
Example:
RegisterWith¶
Registers a tool with per-tool options.
Options¶
WithMiddleware¶
Adds global middleware to all tools.
WithToolMiddleware¶
Adds middleware to a specific tool.
Tool Names¶
Available tool name constants:
const (
ToolSearch ToolName = "datahub_search"
ToolGetEntity ToolName = "datahub_get_entity"
ToolGetSchema ToolName = "datahub_get_schema"
ToolGetLineage ToolName = "datahub_get_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"
)
Middleware¶
ToolMiddleware Interface¶
type ToolMiddleware interface {
Before(ctx context.Context, tc *ToolContext) (context.Context, error)
After(ctx context.Context, tc *ToolContext, result *mcp.CallToolResult, err error) (*mcp.CallToolResult, error)
}
BeforeFunc¶
Creates middleware that runs before tool execution.
func BeforeFunc(fn func(ctx context.Context, tc *ToolContext) (context.Context, error)) ToolMiddleware
AfterFunc¶
Creates middleware that runs after tool execution.
func AfterFunc(fn func(ctx context.Context, tc *ToolContext, result *mcp.CallToolResult, err error) (*mcp.CallToolResult, error)) ToolMiddleware
Helper Functions¶
TextResult¶
Creates a text result.
JSONResult¶
Creates a JSON result.
ErrorResult¶
Creates an error result.