mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
Merge pull request #2811 from afjcjsbx/fix/mcp-streamable-http-support
fix(mcp): support streamable HTTP alias, request-response mode and integration tests
This commit is contained in:
@@ -1126,7 +1126,11 @@ type MCPServerConfig struct {
|
||||
Env map[string]string `json:"env,omitempty"`
|
||||
// EnvFile is the path to a file containing environment variables (stdio only)
|
||||
EnvFile string `json:"env_file,omitempty"`
|
||||
// Type is "stdio", "sse", or "http" (default: stdio if command is set, sse if url is set)
|
||||
// Type is "stdio", "sse", "http", or "streamable-http".
|
||||
// "http" and "streamable-http" both select streamable HTTP request-response
|
||||
// mode, while "sse" keeps the standalone SSE listener enabled for
|
||||
// server-initiated notifications. Defaults: stdio if command is set, sse if
|
||||
// url is set.
|
||||
Type string `json:"type,omitempty"`
|
||||
// URL is used for SSE/HTTP transport
|
||||
URL string `json:"url,omitempty"`
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package config
|
||||
|
||||
import "strings"
|
||||
|
||||
// NormalizeMCPTransportType canonicalizes MCP transport names used in config.
|
||||
// "http" is PicoClaw's streamable HTTP request-response mode, and
|
||||
// "streamable-http" is accepted as an explicit alias for the same transport.
|
||||
func NormalizeMCPTransportType(transport string) string {
|
||||
normalized := strings.ToLower(strings.TrimSpace(transport))
|
||||
|
||||
switch normalized {
|
||||
case "streamable-http", "streamable_http", "streamablehttp":
|
||||
return "http"
|
||||
default:
|
||||
return normalized
|
||||
}
|
||||
}
|
||||
|
||||
// EffectiveMCPTransportType returns the normalized configured transport, or the
|
||||
// inferred default when the config leaves Type empty.
|
||||
func EffectiveMCPTransportType(server MCPServerConfig) string {
|
||||
if transport := NormalizeMCPTransportType(server.Type); transport != "" {
|
||||
return transport
|
||||
}
|
||||
if server.URL != "" {
|
||||
return "sse"
|
||||
}
|
||||
if server.Command != "" {
|
||||
return "stdio"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
Reference in New Issue
Block a user