mcp: handle the Mcp-Protocol-Version header correctly
Handle the protocol version header according to section 2.7 of the spec (and the other SDKs). Fixes #198
This commit is contained in:
parent
3f10c19b45
commit
79f063bc98
1 changed files with 192 additions and 65 deletions
|
|
@ -859,18 +859,11 @@ func (ss *ServerSession) initialize(ctx context.Context, params *InitializeParam
|
|||
state.InitializeParams = params
|
||||
})
|
||||
|
||||
// If we support the client's version, reply with it. Otherwise, reply with our
|
||||
// latest version.
|
||||
version := params.ProtocolVersion
|
||||
if !slices.Contains(supportedProtocolVersions, params.ProtocolVersion) {
|
||||
version = latestProtocolVersion
|
||||
}
|
||||
|
||||
s := ss.server
|
||||
return &InitializeResult{
|
||||
// TODO(rfindley): alter behavior when falling back to an older version:
|
||||
// reject unsupported features.
|
||||
ProtocolVersion: version,
|
||||
ProtocolVersion: negotiatedVersion(params.ProtocolVersion),
|
||||
Capabilities: s.capabilities(),
|
||||
Instructions: s.opts.Instructions,
|
||||
ServerInfo: s.impl,
|
||||
|
|
|
|||
Loading…
Reference in a new issue