Files
wehub-resource-sync e071084ebe
govulncheck / govulncheck (push) Has been cancelled
Lint / golangci-lint (push) Has been cancelled
Run Tests / Unit Tests (push) Has been cancelled
Run Tests / Etcd Integration Tests (push) Has been cancelled
Harness (E2E) / Harnesses (mock LLM) (push) Has been cancelled
Harness (E2E) / Provider harnesses (live LLM conformance) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:40:33 +08:00

30 lines
674 B
Go

package mcp
import (
"go-micro.dev/v6/service"
)
// WithMCP returns a service option that starts an MCP gateway alongside the
// service, making all registered handlers discoverable as AI agent tools.
// The address parameter specifies where the MCP gateway listens (e.g., ":3000").
//
// Usage:
//
// import "go-micro.dev/v6/gateway/mcp"
//
// service := micro.NewService("users",
// mcp.WithMCP(":3000"),
// )
func WithMCP(address string) service.Option {
return func(o *service.Options) {
o.AfterStart = append(o.AfterStart, func() error {
go func() {
_ = ListenAndServe(address, Options{
Registry: o.Registry,
})
}()
return nil
})
}
}