MCP servers: fields that can be emptied, addresses without passwords
CI / test (push) Failing after 6m34s

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

+20 -6
View File
@@ -34,6 +34,7 @@ type MCPAdmin interface {
PutLimits(ctx context.Context, l store.Limits) error
GrantTools(ctx context.Context, scope store.Scope, id, server string, tools []string) (store.ToolGrant, error)
RevokeTools(ctx context.Context, scope store.Scope, id, server string) error
KeyByID(ctx context.Context, id string) (store.Key, error)
Tree(ctx context.Context) ([]store.TreeOrg, error)
Users(ctx context.Context, state store.UserState) ([]store.User, error)
}
@@ -193,12 +194,20 @@ func (p *AccountPages) RegisterAdminMCP(mux *http.ServeMux, s MCPAdmin, local fu
mux.HandleFunc("POST /admin/mcp/{name}/edit", adminsOnly(func(w http.ResponseWriter, r *http.Request, admin store.User) {
l, name := langOf(r), r.PathValue("name")
timeout, rate, err := mcpBounds(l, r.FormValue("timeout"), r.FormValue("rate"))
if err == nil && rate == 0 {
rate = -1 // an empty rate takes the bound away
}
if err == nil {
err = put(r, admin, name, adminapi.MCPServerRequest{URL: strings.TrimSpace(r.FormValue("url")),
Description: strings.TrimSpace(r.FormValue("description")), TimeoutSeconds: timeout, RatePerMinute: rate})
req := adminapi.MCPServerRequest{URL: strings.TrimSpace(r.FormValue("url")),
Description: strings.TrimSpace(r.FormValue("description")), TimeoutSeconds: timeout, RatePerMinute: rate}
// An emptied field empties it, rather than leaving it as it was.
if req.Description == "" {
req.Clear = append(req.Clear, "description")
}
if timeout == 0 {
req.Clear = append(req.Clear, "timeout")
}
if rate == 0 {
req.Clear = append(req.Clear, "rate")
}
err = put(r, admin, name, req)
}
done(w, r, admin, "mcp server "+name, l.T("mcp.changed", name), err)
}))
@@ -357,7 +366,12 @@ func mcpResolve(ctx context.Context, s MCPAdmin, l *Lang, scope store.Scope, whi
}
switch scope {
case store.ScopeKey:
return which, which, nil
// A key that is not there would be granted nothing, and said granted.
k, err := s.KeyByID(ctx, which)
if err != nil {
return "", "", errors.New(l.T("mcp.err.no_such", which))
}
return k.ID, k.Name + " (" + k.Prefix + "…)", nil
case store.ScopeUser:
users, err := s.Users(ctx, "")
if err != nil {