internal/mcp: sampling
Implement sampling (the CreateMessage method). Change-Id: Ie44a671dd62831122b25cd7386b5bfcdece7ff60 Reviewed-on: https://go-review.googlesource.com/c/tools/+/673176 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
bac1b78b4a
commit
9bcc6c758f
1 changed files with 192 additions and 27 deletions
|
|
@ -32,20 +32,12 @@ type ResourceHandler func(context.Context, *ServerSession, *ReadResourceParams)
|
|||
// not be found.
|
||||
func ResourceNotFoundError(uri string) error {
|
||||
return &jsonrpc2.WireError{
|
||||
Code: codeResourceNotFound,
|
||||
Code: CodeResourceNotFound,
|
||||
Message: "Resource not found",
|
||||
Data: json.RawMessage(fmt.Sprintf(`{"uri":%q}`, uri)),
|
||||
}
|
||||
}
|
||||
|
||||
// The error code to return when a resource isn't found.
|
||||
// See https://modelcontextprotocol.io/specification/2025-03-26/server/resources#error-handling
|
||||
// However, the code they chose in in the wrong space
|
||||
// (see https://github.com/modelcontextprotocol/modelcontextprotocol/issues/509).
|
||||
// so we pick a different one, arbirarily for now (until they fix it).
|
||||
// The immediate problem is that jsonprc2 defines -32002 as "server closing".
|
||||
const codeResourceNotFound = -31002
|
||||
|
||||
// readFileResource reads from the filesystem at a URI relative to dirFilepath, respecting
|
||||
// the roots.
|
||||
// dirFilepath and rootFilepaths are absolute filesystem paths.
|
||||
|
|
|
|||
Loading…
Reference in a new issue