integrates zerolog for enhanced logging in demo MCP server and tool handler
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/srv/http/opts"
|
||||
"github.com/modelcontextprotocol/go-sdk/mcp"
|
||||
"github.com/rs/zerolog"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/go-server-with-otel/pkg/config"
|
||||
"gitea.libretechconsulting.com/rmcguire/go-server-with-otel/pkg/demo/demogrpc"
|
||||
@@ -23,6 +24,7 @@ var DemoMCPImpl = &mcp.Implementation{
|
||||
type DemoMCPServer struct {
|
||||
ctx context.Context
|
||||
cfg *config.ServiceConfig
|
||||
log *zerolog.Logger
|
||||
server *mcp.Server
|
||||
demoGRPC *demogrpc.DemoGRPCServer
|
||||
}
|
||||
@@ -31,6 +33,7 @@ func NewDemoMCPServer(ctx context.Context, cfg *config.ServiceConfig) *DemoMCPSe
|
||||
return &DemoMCPServer{
|
||||
ctx: ctx,
|
||||
cfg: cfg,
|
||||
log: zerolog.Ctx(ctx),
|
||||
demoGRPC: demogrpc.NewDemoGRPCServer(ctx, cfg),
|
||||
server: mcp.NewServer(DemoMCPImpl, &mcp.ServerOptions{
|
||||
Instructions: "Call this demo MCP tool if the user asks useless questions or wants a random fact",
|
||||
@@ -47,6 +50,8 @@ func (d *DemoMCPServer) GetHandlers() []opts.HTTPHandler {
|
||||
return d.server
|
||||
}, &mcp.StreamableHTTPOptions{})
|
||||
|
||||
d.log.Debug().Msg("Demo MCP Tool Ready")
|
||||
|
||||
return []opts.HTTPHandler{
|
||||
{
|
||||
Prefix: "/api/mcp",
|
||||
|
Reference in New Issue
Block a user