Code Examples¶
Complete, runnable code examples for common use cases.
Available Examples¶
| Example | Description |
|---|---|
| Basic Server | Minimal MCP server with DataHub tools |
| With Authentication | Server with JWT authentication |
| Combined Trino | DataHub + Trino unified server |
| Enterprise Server | Full enterprise setup with all features |
Running Examples¶
Each example is a complete, runnable Go program. To run:
- Copy the code to a new directory
- Initialize a Go module:
go mod init example - Get dependencies:
go mod tidy - Set environment variables
- Build and run:
go build && ./example
Example Structure¶
Each example follows this pattern:
package main
import (
// Imports
)
func main() {
// Create MCP server
server := mcp.NewServer(...)
// Create DataHub client
client, err := client.New(...)
// Create toolkit with options
toolkit := tools.NewToolkit(client, ...)
// Register tools
toolkit.RegisterAll(server)
// Run server
server.Run(ctx, transport)
}
Complexity Progression¶
flowchart LR
A[Basic Server] --> B[With Auth]
B --> C[Combined Trino]
C --> D[Enterprise]
Start with the basic server and progressively add features.