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

Method CreateMessageWithTools

mcp/server.go:1223–1236  ·  view source on GitHub ↗

CreateMessageWithTools sends a sampling request with tools to the client, returning a [CreateMessageWithToolsResult] that supports array content (for parallel tool calls). Use this instead of [ServerSession.CreateMessage] when the request includes tools.

(ctx context.Context, params *CreateMessageWithToolsParams)

Source from the content-addressed store, hash-verified

1221// (for parallel tool calls). Use this instead of [ServerSession.CreateMessage]
1222// when the request includes tools.
1223func (ss *ServerSession) CreateMessageWithTools(ctx context.Context, params *CreateMessageWithToolsParams) (*CreateMessageWithToolsResult, error) {
1224 if err := ss.checkInitialized(methodCreateMessage); err != nil {
1225 return nil, err
1226 }
1227 if params == nil {
1228 params = &CreateMessageWithToolsParams{Messages: []*SamplingMessageV2{}}
1229 }
1230 if params.Messages == nil {
1231 p2 := *params
1232 p2.Messages = []*SamplingMessageV2{} // avoid JSON "null"
1233 params = &p2
1234 }
1235 return handleSend[*CreateMessageWithToolsResult](ctx, methodCreateMessage, newServerRequest(ss, orZero[Params](params)))
1236}
1237
1238// Elicit sends an elicitation request to the client asking for user input.
1239func (ss *ServerSession) Elicit(ctx context.Context, params *ElicitParams) (*ElicitResult, error) {

Calls 2

checkInitializedMethod · 0.95
newServerRequestFunction · 0.85