Repository navigation
Commit e9181a1
fix(tray): path-escape server names in tray API requests (#1752)
# Pull Request
## Description
Same class as MCP-1118, on the tray side. The core decodes a
`%2F`-encoded `{id}` on `/api/v1/servers/{id}/*`, but
`cmd/mcpproxy-tray/internal/api/client.go` builds its per-server
endpoints with a raw `fmt.Sprintf("/api/v1/servers/%s/...",
serverName)`. For an official-registry server (`io.github.owner/repo`)
the slash splits the name across path segments, so the request hits a
different route.
**Trigger.** Reachable from the tray menu: Enable / Disable
(`EnableServer`), Quarantine (`QuarantineServer`) and Sign in
(`TriggerOAuthLogin`) via `internal/tray/managers.go` and
`internal/tray/tray.go:1907` → `api.ServerAdapter`. `RestartServer` and
`GetServerTools` use the same shape and are fixed in the same way.
`buildURL` keeps the escape: `url.Parse` records it in `RawPath` and
`ResolveReference` goes through `EscapedPath`, so `%2F` reaches the
wire. The test checks this end to end.
## Testing
- [x] I have tested these changes locally
- [x] I have added/updated tests that prove my fix is effective or my
feature works
- [x] All existing tests pass
`TestClientServerActions_EscapeSlashServerName`
(`cmd/mcpproxy-tray/internal/api/server_path_escape_test.go`) calls all
six methods against an `httptest` server and checks
`r.URL.EscapedPath()`.
```
go test ./cmd/mcpproxy-tray/internal/api -count=1 # ok
# with client.go reverted:
go test ./cmd/mcpproxy-tray/internal/api -run TestClientServerActions -count=1 # FAIL, 6 of 6
enable: request path = "/api/v1/servers/io.github.owner/repo/enable", want ".../io.github.owner%2Frepo/enable"
gofmt -l cmd/mcpproxy-tray/internal/api # clean
```
(Run with `SDKROOT=.../MacOSX26.5.sdk` because my local Command Line
Tools linker cannot read the 27.0 SDK stubs; unrelated to this change.)
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent b05d78e commit e9181a1
2 files changed
Lines changed: 54 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
586 | 586 | | |
587 | 587 | | |
588 | 588 | | |
589 | | - | |
| 589 | + | |
590 | 590 | | |
591 | | - | |
| 591 | + | |
592 | 592 | | |
593 | 593 | | |
594 | 594 | | |
| |||
605 | 605 | | |
606 | 606 | | |
607 | 607 | | |
608 | | - | |
| 608 | + | |
609 | 609 | | |
610 | 610 | | |
611 | 611 | | |
| |||
640 | 640 | | |
641 | 641 | | |
642 | 642 | | |
643 | | - | |
| 643 | + | |
644 | 644 | | |
645 | 645 | | |
646 | 646 | | |
| |||
713 | 713 | | |
714 | 714 | | |
715 | 715 | | |
716 | | - | |
| 716 | + | |
717 | 717 | | |
718 | 718 | | |
719 | 719 | | |
| |||
754 | 754 | | |
755 | 755 | | |
756 | 756 | | |
757 | | - | |
| 757 | + | |
758 | 758 | | |
759 | 759 | | |
760 | 760 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
0 commit comments