Skip to content

Commit 3468910

Browse files
authored
Now we don't need a 'docs fix' (#140)
* Now we don't need a 'docs fix' * Docs: fix requirements table * Update user facing messages to rename packages -> servers * Remove default 'latest' from add cmd * Short circuit checks in MCPM if version supplied * Fixes need for docs update. * Update references to v0.0.3 in preparation for v0.0.4 * Fix tests
1 parent d5d1178 commit 3468910

File tree

10 files changed

+55
-62
lines changed

10 files changed

+55
-62
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ CMD mcpd daemon \
7474
# -v $PWD/.mcpd.toml:/etc/mcpd/.mcpd.toml \
7575
# -v $HOME/.config/mcpd/secrets.dev.toml:/home/mcpd/.config/mcpd/secrets.prd.toml \
7676
# -e MCPD_LOG_LEVEL=debug \
77-
# mzdotai/mcpd:v0.0.3
77+
# mzdotai/mcpd:v0.0.4

cmd/add.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func NewAddCmd(baseCmd *internalcmd.BaseCmd, opt ...cmdopts.CmdOption) (*cobra.C
6161
cobraCommand.Flags().StringVar(
6262
&c.Version,
6363
"version",
64-
"latest",
64+
"",
6565
"Specify the version of the server package",
6666
)
6767

@@ -76,14 +76,14 @@ func NewAddCmd(baseCmd *internalcmd.BaseCmd, opt ...cmdopts.CmdOption) (*cobra.C
7676
&c.Runtime,
7777
"runtime",
7878
"",
79-
"Optional, specify the runtime of the server package (e.g. `uvx`, `npx`)",
79+
"Optional, specify the runtime of the server (e.g. uvx, npx)",
8080
)
8181

8282
cobraCommand.Flags().StringVar(
8383
&c.Source,
8484
"source",
8585
"",
86-
"Optional, specify the source registry of the server package (e.g. `mcpm`)",
86+
"Optional, specify the source registry of the server (e.g. mozilla-ai)",
8787
)
8888

8989
allowed := internalcmd.AllowedOutputFormats()
@@ -138,7 +138,7 @@ func (c *AddCmd) run(cmd *cobra.Command, args []string) error {
138138
pkg, err := reg.Resolve(name, c.options()...)
139139
if err != nil {
140140
logger.Warn(
141-
"package retrieval from registry failed",
141+
"server retrieval from registry failed",
142142
"name", name,
143143
"version", c.Version,
144144
"tools", strings.Join(c.Tools, ","),
@@ -147,7 +147,7 @@ func (c *AddCmd) run(cmd *cobra.Command, args []string) error {
147147
"error", err,
148148
)
149149
return handler.HandleError(fmt.Errorf(
150-
"⚠️ Failed to get package '%s@%s' from registry: %w",
150+
"⚠️ Failed to get server '%s@%s' from registry: %w",
151151
name,
152152
c.Version,
153153
err),
@@ -259,7 +259,7 @@ func parseServerEntry(pkg packages.Server, opts serverEntryOptions) (config.Serv
259259

260260
if installation.Package == "" {
261261
return config.ServerEntry{}, fmt.Errorf(
262-
"installation package name is missing for runtime '%s'",
262+
"installation server name is missing for runtime '%s'",
263263
selectedRuntime,
264264
)
265265
}
@@ -289,7 +289,7 @@ func parseServerEntry(pkg packages.Server, opts serverEntryOptions) (config.Serv
289289
func (c *AddCmd) options() []regopts.ResolveOption {
290290
var o []regopts.ResolveOption
291291

292-
if c.Version != "" && c.Version != "latest" {
292+
if c.Version != "" {
293293
o = append(o, regopts.WithResolveVersion(c.Version))
294294
}
295295
if c.Runtime != "" {

cmd/add_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ func TestParseServerEntry(t *testing.T) {
670670
requestedTools: []string{"convert_time"},
671671
arguments: packages.Arguments{},
672672
isErrorExpected: true,
673-
expectedErrorMessage: "installation package name is missing for runtime 'docker'",
673+
expectedErrorMessage: "installation server name is missing for runtime 'docker'",
674674
},
675675
{
676676
name: "requested tool not found",

cmd/search.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ func NewSearchCmd(baseCmd *internalcmd.BaseCmd, opt ...cmdopts.CmdOption) (*cobr
5858
&c.Version,
5959
"version",
6060
"",
61-
"Optional, specify the version of the server package",
61+
"Optional, specify the version of the server",
6262
)
6363

6464
cobraCommand.Flags().StringVar(
6565
&c.Runtime,
6666
"runtime",
6767
"",
68-
"Optional, specify the runtime of the server package (e.g. uvx, npx)",
68+
"Optional, specify the runtime of the server (e.g. uvx, npx)",
6969
)
7070

7171
cobraCommand.Flags().StringArrayVar(
@@ -79,14 +79,14 @@ func NewSearchCmd(baseCmd *internalcmd.BaseCmd, opt ...cmdopts.CmdOption) (*cobr
7979
&c.License,
8080
"license",
8181
"",
82-
"Optional, specify a partial match for the license of the server package (e.g. MIT, Apache)",
82+
"Optional, specify a partial match for the license of the server (e.g. MIT, Apache)",
8383
)
8484

8585
cobraCommand.Flags().StringVar(
8686
&c.Source,
8787
"source",
8888
"",
89-
"Optional, specify the source registry of the server package (e.g. mcpm)",
89+
"Optional, specify the source registry of the server (e.g. mozilla-ai)",
9090
)
9191

9292
cobraCommand.Flags().StringArrayVar(

docs/installation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ git clone git@github.com:mozilla-ai/mcpd.git
6666
cd mcpd
6767
# Checkout a specific tag (or build latest main)
6868
git fetch --tags
69-
git checkout v0.0.3
69+
git checkout v0.0.4
7070
# Use Makefile commands to build and install mcpd
7171
make build
7272
sudo make install # Installs mcpd 'globally' to /usr/local/bin
@@ -97,5 +97,5 @@ docker run -p 8090:8090 \
9797
-v $PWD/.mcpd.toml:/etc/mcpd/.mcpd.toml \
9898
-v $HOME/.config/mcpd/secrets.dev.toml:/home/mcpd/.config/mcpd/secrets.prd.toml \
9999
-e MCPD_LOG_LEVEL=debug \
100-
mzdotai/mcpd:v0.0.3
100+
mzdotai/mcpd:v0.0.4
101101
```

docs/requirements.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
To use `mcpd`, ensure the following tools are installed:
44

5-
| Tool | Purpose | Notes |
6-
|----------------|-------------------------------------------------------------|-------------------------------------------------------------------|
7-
| `Docker` | Required if you want to run `mcpd` in a local container | https://www.docker.com/products/docker-desktop/ |
8-
| `Go >= 1.24.4` | Required for building `mcpd` and running tests | https://go.dev/doc/install |
9-
| `uv` | for running `uvx` Python packages in `mcpd`, and local docs | https://docs.astral.sh/uv/getting-started/installation/ |
10-
| `npx` | for running JavaScript/TypeScript packages in `mcpd` | https://docs.npmjs.com/downloading-and-installing-node-js-and-npm |
5+
| Tool | Purpose | URL |
6+
|----------------|-------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|
7+
| `Docker` | Required if you want to run `mcpd` in a local container | [https://www.docker.com/products/docker-desktop/](https://www.docker.com/products/docker-desktop/) |
8+
| `Go >= 1.24.4` | Required for building `mcpd` and running tests | [https://go.dev/doc/install](https://go.dev/doc/install) |
9+
| `uv` | for running `uvx` Python packages in `mcpd`, and local docs | [https://docs.astral.sh/uv/getting-started/installation/](https://docs.astral.sh/uv/getting-started/installation/) |
10+
| `npx` | for running JavaScript/TypeScript packages in `mcpd` | [https://docs.npmjs.com/downloading-and-installing-node-js-and-npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) |
1111

1212
!!! note "Internet Connectivity"
1313
`mcpd` requires internet access to contact package registries and to allow MCP servers access to the internet if required when running.

internal/provider/mcpm/registry.go

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,13 @@ func (r *Registry) Resolve(name string, opt ...options.ResolveOption) (packages.
110110
return packages.Server{}, err
111111
}
112112

113+
// Handle unsupported filters.
114+
if opts.Version != "" {
115+
return packages.Server{}, fmt.Errorf("version is not supported by '%s' registry", r.ID())
116+
}
117+
113118
// Handle creation of filters.
114-
fs, err := options.PrepareFilters(options.ResolveFilters(opts), name, func(fs map[string]string) error {
115-
// Handle lack of 'version' support in mcpm.
116-
if v, ok := fs[options.FilterKeyVersion]; ok {
117-
r.logger.Warn(
118-
"'version' not supported on resolve operation, returning latest known definition",
119-
"name", name,
120-
options.FilterKeyVersion, v)
121-
// Clear 'version' for mcpm as it cannot be used.
122-
delete(fs, options.FilterKeyVersion)
123-
}
124-
return nil
125-
})
119+
fs, err := options.PrepareFilters(options.ResolveFilters(opts), name, nil)
126120
if err != nil {
127121
return packages.Server{}, fmt.Errorf("invalid filters for %s: %w", r.ID(), err)
128122
}
@@ -147,7 +141,7 @@ func (r *Registry) Resolve(name string, opt ...options.ResolveOption) (packages.
147141
return packages.Server{}, err
148142
}
149143
if !matches {
150-
return packages.Server{}, fmt.Errorf("package with name '%s' does not match requested filters", name)
144+
return packages.Server{}, fmt.Errorf("server with name '%s' does not match requested filters", name)
151145
}
152146

153147
return result, nil
@@ -169,19 +163,12 @@ func (r *Registry) Search(
169163
return nil, err
170164
}
171165

172-
fs, err := options.PrepareFilters(filters, name, func(fs map[string]string) error {
173-
// Handle lack of 'version' support in mcpm.
174-
if v, ok := fs[options.FilterKeyVersion]; ok {
175-
r.logger.Warn(
176-
"'version' not supported on search operation, returning latest known definition",
177-
"name", name,
178-
options.FilterKeyVersion, v,
179-
)
180-
// Clear 'version' for mcpm as it cannot be used.
181-
delete(fs, options.FilterKeyVersion)
182-
}
183-
return nil
184-
})
166+
// Handle unsupported filters.
167+
if v, ok := filters[options.FilterKeyVersion]; ok && v != "" {
168+
return nil, fmt.Errorf("version is not supported by '%s' registry", r.ID())
169+
}
170+
171+
fs, err := options.PrepareFilters(filters, name, nil)
185172
if err != nil {
186173
return nil, fmt.Errorf("invalid filters for %s: %w", r.ID(), err)
187174
}

internal/provider/mcpm/registry_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,10 @@ func TestRegistry_Resolve(t *testing.T) {
276276
name: "existing package with latest version",
277277
id: "time",
278278
version: "latest",
279-
expectError: false,
280-
expectedID: "time",
279+
expectError: true,
280+
expectedID: "",
281281
expectedEnv: []string{},
282-
expectedArgs: []string{"--local-timezone"},
282+
expectedArgs: []string{},
283283
},
284284
{
285285
name: "nonexistent package",
@@ -290,11 +290,11 @@ func TestRegistry_Resolve(t *testing.T) {
290290
expectedEnv: nil,
291291
},
292292
{
293-
name: "version ignored with warning",
293+
name: "version not supported error",
294294
id: "math",
295295
version: "1.0.0",
296-
expectError: false,
297-
expectedID: "math",
296+
expectError: true,
297+
expectedID: "",
298298
expectedEnv: []string{},
299299
expectedArgs: []string{},
300300
},

internal/provider/mozilla_ai/registry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (r *Registry) Resolve(name string, opt ...options.ResolveOption) (packages.
147147
return packages.Server{}, err
148148
}
149149
if !matches {
150-
return packages.Server{}, fmt.Errorf("package with name '%s' does not match requested filters", name)
150+
return packages.Server{}, fmt.Errorf("server with name '%s' does not match requested filters", name)
151151
}
152152

153153
return result, nil

internal/registry/registry.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package registry
22

33
import (
44
"fmt"
5+
"strings"
56

67
"github.com/hashicorp/go-hclog"
78

@@ -149,12 +150,17 @@ func (r *Registry) Resolve(name string, opt ...options.ResolveOption) (packages.
149150
return result, nil
150151
}
151152

152-
err = fmt.Errorf(
153-
"package '%s', version '%s', runtime '%s' not found in any registry",
154-
name,
155-
opts.Version,
156-
opts.Runtime,
157-
)
153+
// Build error message with only non-empty criteria
154+
var criteria []string
155+
criteria = append(criteria, fmt.Sprintf("server '%s'", name))
156+
if opts.Version != "" {
157+
criteria = append(criteria, fmt.Sprintf("version '%s'", opts.Version))
158+
}
159+
if opts.Runtime != "" {
160+
criteria = append(criteria, fmt.Sprintf("runtime '%s'", opts.Runtime))
161+
}
162+
163+
err = fmt.Errorf("%s not found in any registry", strings.Join(criteria, ", "))
158164
return packages.Server{}, err
159165
}
160166

@@ -187,7 +193,7 @@ func (r *Registry) Search(
187193

188194
var allResults []packages.Server
189195

190-
// If a specific source registry was requested, only check that one for packages.
196+
// If a specific source registry was requested, only check that one for server.
191197
if opts.Source != "" {
192198
reg, ok := r.registries[opts.Source]
193199
if !ok {
@@ -202,7 +208,7 @@ func (r *Registry) Search(
202208
return results, nil
203209
}
204210

205-
// Search all registries for packages.
211+
// Search all registries for servers.
206212
for _, reg := range r.registries {
207213
results, err := reg.Search(name, fs, opt...)
208214
if err != nil {

0 commit comments

Comments
 (0)