Skip to content

feat: Add WithServerInstructions() constructor. #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion examples/http_example/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ func main() {
transport := http.NewHTTPTransport("/mcp").WithAddr(":8081")

// Create a new server with the transport
server := mcp_golang.NewServer(transport, mcp_golang.WithName("mcp-golang-stateless-http-example"), mcp_golang.WithVersion("0.0.1"))
server := mcp_golang.NewServer(
transport,
mcp_golang.WithName("mcp-golang-stateless-http-example"),
mcp_golang.WithInstructions("A simple example of a stateless HTTP server using mcp-golang"),
mcp_golang.WithVersion("0.0.1"),
)

// Register a simple tool
err := server.RegisterTool("time", "Returns the current time in the specified format", func(args TimeArgs) (*mcp_golang.ToolResponse, error) {
Expand Down
7 changes: 7 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ func WithName(name string) ServerOptions {
}
}

func WithInstructions(instructions string) ServerOptions {
return func(s *Server) {
instructionsCopy := instructions
s.serverInstructions = &instructionsCopy
}
}

func WithVersion(version string) ServerOptions {
return func(s *Server) {
s.serverVersion = version
Expand Down