Skip to content

Commit b477ff5

Browse files
feat: Add WithServerInstructions() constructor. (#102)
1 parent d21987a commit b477ff5

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

examples/http_example/server/main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ func main() {
1818
transport := http.NewHTTPTransport("/mcp").WithAddr(":8081")
1919

2020
// Create a new server with the transport
21-
server := mcp_golang.NewServer(transport, mcp_golang.WithName("mcp-golang-stateless-http-example"), mcp_golang.WithVersion("0.0.1"))
21+
server := mcp_golang.NewServer(
22+
transport,
23+
mcp_golang.WithName("mcp-golang-stateless-http-example"),
24+
mcp_golang.WithInstructions("A simple example of a stateless HTTP server using mcp-golang"),
25+
mcp_golang.WithVersion("0.0.1"),
26+
)
2227

2328
// Register a simple tool
2429
err := server.RegisterTool("time", "Returns the current time in the specified format", func(args TimeArgs) (*mcp_golang.ToolResponse, error) {

server.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@ func WithName(name string) ServerOptions {
163163
}
164164
}
165165

166+
func WithInstructions(instructions string) ServerOptions {
167+
return func(s *Server) {
168+
instructionsCopy := instructions
169+
s.serverInstructions = &instructionsCopy
170+
}
171+
}
172+
166173
func WithVersion(version string) ServerOptions {
167174
return func(s *Server) {
168175
s.serverVersion = version

0 commit comments

Comments
 (0)