MCP servers: fields that can be emptied, addresses without passwords

From review. A server's description, timeout and rate can be emptied from
the console and the page (MCPServerRequest.Clear), where an empty field
used to leave them as they were. An address with a user and password in
it is refused (adminapi.CheckMCPAddress): the credential belongs in a
header, sealed, and the address is shown and audited as written. The
console accepts llmgw:admin and the page lets it be changed, address
fixed. A grant to a key that is not there is refused rather than said
done.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-29 10:03:27 +01:00
1 parent 721705b29d
commit f94d902cc3
5 files changed
+106 -18

No files matched your search

+35 -2
View File
@@ -57,6 +57,9 @@ type MCPServerRequest struct {
// RatePerMinute bounds each caller's calls to its tools; a negative
// number takes the bound away.
RatePerMinute int `json:"rate_per_minute,omitempty"`
// Clear empties what an empty field above would leave as it is:
// "description", "timeout" (back to the default), "rate".
Clear []string `json:"clear,omitempty"`
}
// MCPTestView is what the server said when asked: its tools, or why not.
@@ -171,8 +174,8 @@ func MCPServerFrom(ctx context.Context, st MCPStore, name string, req MCPServerR
if req.URL != "" {
m.URL = req.URL
}
if u, err := url.Parse(m.URL); m.URL != AdminMCPAddress && (err != nil || (u.Scheme != "https" && u.Scheme != "http") || u.Host == "") {
return m, errors.New("the server's url is an http:// or https:// address, or " + AdminMCPAddress + " for this cluster's own")
if err := CheckMCPAddress(m.URL); err != nil {
return m, err
}
if req.Description != "" {
m.Description = req.Description
@@ -209,9 +212,39 @@ func MCPServerFrom(ctx context.Context, st MCPStore, name string, req MCPServerR
case req.RatePerMinute < 0:
m.RatePerMinute = 0
}
for _, f := range req.Clear {
switch f {
case "description":
m.Description = ""
case "timeout":
m.Timeout = 0
case "rate":
m.RatePerMinute = 0
default:
return m, errors.New("clear names description, timeout or rate, not " + f)
}
}
return m, nil
}
// CheckMCPAddress refuses an address a server cannot be reached at: an
// http(s) one, or this cluster's own. Not one with a user and password in
// it: a credential is a header, kept sealed, and an address is shown and
// recorded in the audit log as written.
func CheckMCPAddress(addr string) error {
if addr == AdminMCPAddress {
return nil
}
u, err := url.Parse(addr)
if err != nil || (u.Scheme != "https" && u.Scheme != "http") || u.Host == "" {
return errors.New("the server's url is an http:// or https:// address, or " + AdminMCPAddress + " for this cluster's own")
}
if u.User != nil {
return errors.New("the server's url has a user and password in it: give the credential as a header, which is kept sealed")
}
return nil
}
// testMCPServer asks a server for its tools, with its credentials, as /mcp
// would.
func (a *API) testMCPServer(ctx context.Context, m store.MCPServer) MCPTestView {