sampling/createMessage 请求messages 数组包含要发送到 LLM 的对话历史记录。 每条消息都有:role: “user” 或 “assistant”contenttext 字段的文本内容data(base64 编码)和 mimeType 字段的图像内容modelPreferences 对象允许服务器指定其模型选择偏好:hints: 客户端可用于选择合适模型的模型名称建议数组:name: 可以匹配完整或部分模型名称的字符串(例如,“claude-3”,“sonnet”)costPriority: 最小化成本的重要性speedPriority: 低延迟响应的重要性intelligencePriority: 高级模型能力的重要性systemPrompt 字段允许服务器请求特定的系统提示(system prompt)。 客户端可以修改或忽略此提示。includeContext 参数指定要包含的 MCP 上下文:"none":无其他上下文"thisServer":包含来自请求服务器的上下文"allServers":包含来自所有连接的 MCP 服务器的上下文temperature: 控制随机性(0.0 到 1.0)maxTokens: 要生成的最大令牌(token)数stopSequences: 停止生成的序列数组metadata: 其他特定于提供程序的参数{
"method": "sampling/createMessage",
"params": {
"messages": [
{
"role": "user",
"content": {
"type": "text",
"text": "What files are in the current directory?"
}
}
],
"systemPrompt": "You are a helpful file system assistant.",
"includeContext": "thisServer",
"maxTokens": 100
}
}includeContext 包含相关上下文