MCPcopy Create free account
hub / github.com/modelcontextprotocol/go-sdk / samplingTool

Function samplingTool

examples/server/everything/main.go:225–235  ·  view source on GitHub ↗
(ctx context.Context, req *mcp.CallToolRequest, _ any)

Source from the content-addressed store, hash-verified

223}
224
225func samplingTool(ctx context.Context, req *mcp.CallToolRequest, _ any) (*mcp.CallToolResult, any, error) {
226 res, err := req.Session.CreateMessage(ctx, new(mcp.CreateMessageParams))
227 if err != nil {
228 return nil, nil, fmt.Errorf("sampling failed: %v", err)
229 }
230 return &mcp.CallToolResult{
231 Content: []mcp.Content{
232 res.Content,
233 },
234 }, nil, nil
235}
236
237func elicitFormTool(ctx context.Context, req *mcp.CallToolRequest, _ any) (*mcp.CallToolResult, any, error) {
238 res, err := req.Session.Elicit(ctx, &mcp.ElicitParams{

Callers

nothing calls this directly

Calls 1

CreateMessageMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…