@@ -17,10 +17,11 @@ To run an MCP server from the [ToolHive registry](./registry.md), use the
17
17
want to run. The server name is the same as its name in the registry.
18
18
19
19
``` bash
20
- thv run < server-name >
20
+ thv run < SERVER_NAME >
21
21
```
22
22
23
- For example:
23
+ For example, to run the ` fetch ` server, which is a simple MCP server that
24
+ fetches website contents:
24
25
25
26
``` bash
26
27
thv run fetch
@@ -32,18 +33,18 @@ When you run an MCP server from the registry, ToolHive:
32
33
33
34
1 . Pulls the image and launches a container using the configuration from the
34
35
registry.
35
- 2 . Launches an HTTP proxy on a random port to forward client requests to the
36
- container.
36
+ 2 . Starts an HTTP proxy process on a random port to forward client requests to
37
+ the container.
37
38
3 . Labels the container so it can be tracked by ToolHive:
38
39
``` yaml
39
40
toolhive : true
40
- toolhive-name : <server-name >
41
+ toolhive-name : <SERVER_NAME >
41
42
` ` `
42
43
43
44
:::
44
45
45
- See [Running custom MCP servers ](#run-a-custom-mcp-server) to run a server that
46
- is not in the registry.
46
+ See [Run a custom MCP server ](#run-a-custom-mcp-server) to run a server that is
47
+ not in the registry.
47
48
48
49
## Customize server settings
49
50
@@ -62,7 +63,7 @@ is automatically generated from the image name when you run a custom server. To
62
63
give your server instance a custom name, use the `--name` option :
63
64
64
65
` ` ` bash
65
- thv run --name my-custom-name <server-name >
66
+ thv run --name <FRIENDLY_NAME> <SERVER >
66
67
` ` `
67
68
68
69
For example :
@@ -80,7 +81,7 @@ starting the server.
80
81
To pass a secret to an MCP server, use the `--secret` option :
81
82
82
83
` ` ` bash
83
- thv run --secret <secret-name >,target=<env-var-name > <server-name >
84
+ thv run --secret <SECRET_NAME >,target=<ENV_VAR_NAME > <SERVER >
84
85
` ` `
85
86
86
87
The `target` parameter specifies the name of the environment variable in the MCP
@@ -121,20 +122,20 @@ The filesystem server can now access the contents of `~/code/toolhive` as
121
122
` /projects/toolhive` in the container (the filesystem MCP server expects
122
123
directories to be mounted at `/projects` by default).
123
124
124
- # ## Pass additional arguments
125
+ # ## Add command-line arguments
125
126
126
127
Some MCP servers require additional arguments to run correctly. You can pass
127
128
these arguments after the server name in the
128
129
[`thv run`](../reference/cli/thv_run.md) command :
129
130
130
131
` ` ` bash
131
- thv run <server-name > -- <additional-args >
132
+ thv run <SERVER > -- <ARGS >
132
133
` ` `
133
134
134
- For example, to run the `fetch` server with custom arguments :
135
+ For example :
135
136
136
137
` ` ` bash
137
- thv run fetch -- --arg1 value1 --arg2 value2
138
+ thv run my-mcp-server:latest -- --arg1 value1 --arg2 value2
138
139
` ` `
139
140
140
141
Check the MCP server's documentation for the required arguments.
@@ -146,7 +147,7 @@ container. This is the port that client applications connect to. To set a
146
147
specific proxy port instead, use the `--proxy-port` flag :
147
148
148
149
` ` ` bash
149
- thv run --proxy-port <port-number > <server-name >
150
+ thv run --proxy-port <PORT_NUMBER > <SERVER >
150
151
` ` `
151
152
152
153
# # Run a custom MCP server
@@ -195,7 +196,7 @@ name for the server instance, the transport method, and any additional arguments
195
196
required by the MCP server.
196
197
197
198
` ` ` bash
198
- thv run [--name <friendly-name >] [--transport <stdio/sse/streamable-http>] <image-name:tag > -- <server-args >
199
+ thv run [--name <FRIENDLY_NAME >] [--transport <stdio/sse/streamable-http>] <IMAGE_REFERENCE > -- <ARGS >
199
200
` ` `
200
201
201
202
For example, to run an MCP server from a Docker image named
@@ -215,7 +216,7 @@ When you run an MCP server from a Docker image, ToolHive:
215
216
1. Pulls the image (`my-mcp-server-image:latest`) and launches a container with
216
217
the options and arguments you specified.
217
218
2. Launches an HTTP proxy on a random port (optionally, add
218
- ` --proxy-port <port-number >` to specify the port).
219
+ ` --proxy-port <PORT_NUMBER >` to specify the port).
219
220
3. Labels the container so it can be tracked by ToolHive :
220
221
` ` ` yaml
221
222
toolhive: true
@@ -241,7 +242,7 @@ Currently, three protocol schemes are supported:
241
242
- `go://` : For Go-based MCP servers
242
243
243
244
` ` ` bash
244
- thv run <protocol >://<package-name >@<version >
245
+ thv run <uvx|npx|go >://<PACKAGE_NAME >@<VERSION|latest >
245
246
` ` `
246
247
247
248
You'll likely need to specify additional arguments like the transport method,
@@ -313,6 +314,55 @@ thv run go:///path/to/my-go-project
313
314
</TabItem>
314
315
</Tabs>
315
316
317
+ # ## Configure network transport
318
+
319
+ When you run custom MCP servers using the SSE (`--transport sse`) or Streamable
320
+ HTTP (`--transport streamable-http`) transport method, ToolHive automatically
321
+ selects a random port to expose from the container to the host and sets the
322
+ ` MCP_PORT` and `FASTMCP_PORT` environment variables in the container.
323
+
324
+ ` ` ` mermaid
325
+ graph LR
326
+ A[MCP client] -->|HTTP request to<br/>proxy port: 5432| B[ToolHive proxy<br/>process<br/>Port: 5432]
327
+ B -->|Forwards to<br/>host port: 9876| C[<strong>MCP container</strong><br/>Host: 9876 → Container: 7654<br/>ENV: MCP_PORT=7654]
328
+ C -->|Response| B
329
+ B -->|Response| A
330
+ ` ` `
331
+
332
+ This is equivalent to running a Docker container with
333
+ ` docker run -p <random_host_port>:<random_container_port> ...`
334
+
335
+ For MCP servers that use a specific port or don't recognize those environment
336
+ variables, specify the container port for ToolHive to expose using the
337
+ `--target-port` flag :
338
+
339
+ ` ` ` bash
340
+ thv run --transport streamable-http --target-port <PORT_NUMBER> <SERVER>
341
+ ` ` `
342
+
343
+ ToolHive still maps the container port to a random port on the host to avoid
344
+ conflicts with commonly used ports. This is equivalent to running a Docker
345
+ container with `docker run -p <random_port>:<PORT_NUMBER> ...`
346
+
347
+ ` ` ` mermaid
348
+ graph LR
349
+ A[MCP client] -->|HTTP request to<br/>proxy port: 5432| B[ToolHive proxy<br/>process<br/>Port: 5432]
350
+ B -->|Forwards to<br/>host port: 9876| C["<strong>MCP container</strong><br/>(--target-port 3000)<br/>Host: 9876 → Container: 3000<br/>ENV: MCP_PORT=3000"]
351
+ C -->|Response| B
352
+ B -->|Response| A
353
+ ` ` `
354
+
355
+ Some MCP servers use command-line arguments to specify their transport and port.
356
+ For example, if your server expects the transport type as a positional argument
357
+ and requires the `--port` flag, you can pass it like this :
358
+
359
+ ` ` ` bash
360
+ thv run --transport streamable-http --target-port <PORT_NUMBER> <SERVER> -- http --port <PORT_NUMBER>
361
+ ` ` `
362
+
363
+ Check your MCP server's documentation for the required transport and port
364
+ configuration.
365
+
316
366
# ## Add a custom CA certificate
317
367
318
368
In corporate environments with TLS inspection or custom certificate authorities,
@@ -409,7 +459,7 @@ If a server starts but isn't accessible:
409
459
1. Check the server logs :
410
460
411
461
` ` ` bash
412
- thv logs <server-name >
462
+ thv logs <SERVER_NAME >
413
463
` ` `
414
464
415
465
2. Verify the port isn't blocked by a firewall
@@ -433,15 +483,11 @@ If a server crashes or exits unexpectedly:
433
483
2. Check the logs for error messages :
434
484
435
485
` ` ` bash
436
- thv logs <server-name >
486
+ thv logs <SERVER_NAME >
437
487
` ` `
438
488
439
- 3. Try running with a different permission profile :
440
-
441
- ` ` ` bash
442
- thv run --permission-profile network <server-name>
443
- ` ` `
489
+ 3. Check if the server requires any secrets or environment variables
444
490
445
- 4. Check if the server requires any secrets or environment variables
491
+ 4. Verify the server's configuration and arguments
446
492
447
493
</details>
0 commit comments