mcp/examples: move server example into example folder (#357)

For better organization.
This commit is contained in:
Sam Thanawalla 2025-08-26 09:13:30 -04:00 • committed by GitHub
commit 392f719bd1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -22,6 +22,18 @@ import (
const runAsServer = "_MCP_RUN_AS_SERVER"
type SayHiParams struct {
Name string `json:"name"`
}
func SayHi(ctx context.Context, req *mcp.CallToolRequest, args SayHiParams) (*mcp.CallToolResult, any, error) {
return &mcp.CallToolResult{
Content: []mcp.Content{
&mcp.TextContent{Text: "Hi " + args.Name},
},
}, nil, nil
}
func TestMain(m *testing.M) {
// If the runAsServer variable is set, execute the relevant serverFunc
// instead of running tests (aka the fork and exec trick).