Skip to content

Commit 33dbb65

Browse files
authored
CLI: Add remote server docs (#183)
* ci: adds the remote mcp server docs
1 parent 031998b commit 33dbb65

File tree

2 files changed

+286
-9
lines changed

2 files changed

+286
-9
lines changed

docs/toolhive/guides-cli/manage-mcp-servers.md

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ To see all currently running MCP servers:
1717
thv list
1818
```
1919

20-
This shows the server name, status, transport method, port, and URL.
20+
This shows the server name, package, status, url, port, tool type, group, and
21+
created at. Remote servers display their target URL in the URL column. The word
22+
'remote' is indicated in both the package and tool type columns, making it easy
23+
to identify remote servers.
2124

2225
To include stopped servers in the list:
2326

@@ -27,7 +30,9 @@ thv list --all
2730

2831
### View server logs
2932

30-
To view the logs of a running or stopped MCP server, use the
33+
#### Containerized servers
34+
35+
To view the logs of a running or stopped containerized MCP server, use the
3136
[`thv logs`](../reference/cli/thv_logs.md) command. You can optionally follow
3237
the logs with the `--follow` option, which shows the most recent log entries and
3338
updates in real time.
@@ -36,7 +41,11 @@ updates in real time.
3641
thv logs <SERVER_NAME> [--follow]
3742
```
3843

39-
Logs are stored in the ToolHive application directory. The path depends on your
44+
#### Remote servers
45+
46+
The thv logs command only works with local containers. For remote MCP servers,
47+
there’s no container to read logs from, so you’ll need to check the log files
48+
directly in the ToolHive application directory. The path depends on your
4049
platform:
4150

4251
- **macOS**: `~/Library/Application Support/toolhive/logs/<SERVER_NAME>.log`
@@ -60,7 +69,9 @@ thv stop <SERVER_NAME>
6069
```
6170

6271
This stops the server and the associated proxy process, removes the MCP server's
63-
entry from your configured clients, but keeps the container for future use.
72+
entry from your configured clients, but keeps the container for future use. For
73+
remote servers, this terminates the proxy process but preserves the
74+
configuration.
6475

6576
Add the `--group` flag to stop all servers in a specific group:
6677

@@ -78,6 +89,12 @@ To restart a stopped MCP server and add it back to your configured clients:
7889
thv restart <SERVER_NAME>
7990
```
8091

92+
For remote servers, restarting will:
93+
94+
1. Recreate the proxy process
95+
2. Re-establish connection to the remote server
96+
3. Re-authenticate with the remote server (triggers new OAuth flow)
97+
8198
Add the `--group` flag to restart all servers in a specific group:
8299

83100
```bash
@@ -94,7 +111,8 @@ thv rm <SERVER_NAME>
94111

95112
This removes the container and cleans up the MCP server's entry in your
96113
configured clients. If the server is still running, it will be stopped as part
97-
of the removal.
114+
of the removal. For remote servers, this removes the proxy process,
115+
configuration, and stored authentication tokens.
98116

99117
Add the `--group` flag to remove all servers in a specific group:
100118

@@ -110,6 +128,18 @@ won't clean up the MCP server's entry in your configured clients. Use
110128

111129
:::
112130

131+
### Remote server authentication
132+
133+
Remote servers with OAuth authentication will automatically refresh tokens when
134+
they expire during normal operation. However, restarting a remote server always
135+
triggers a new OAuth authentication flow:
136+
137+
```bash
138+
thv restart <REMOTE_SERVER_NAME>
139+
```
140+
141+
This will always prompt for re-authentication, even if valid tokens exist.
142+
113143
## Related information
114144

115145
- [`thv list` command reference](../reference/cli/thv_list.md)

docs/toolhive/guides-cli/run-mcp-servers.mdx

Lines changed: 251 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,60 @@ want to run. The server name is the same as its name in the registry.
1717
thv run <SERVER_NAME>
1818
```
1919

20-
For example, to run the `fetch` server, which is a simple MCP server that
21-
fetches website contents:
20+
The ToolHive registry contains both local containerized MCP servers and remote
21+
MCP servers. ToolHive automatically handles the appropriate setup based on the
22+
server type.
23+
24+
### Local containerized servers
25+
26+
For example, to run the `fetch` server, which is a local containerized MCP
27+
server that fetches website contents:
2228

2329
```bash
2430
thv run fetch
2531
```
2632

33+
### Remote MCP servers
34+
35+
Remote MCP servers in the registry don't run as local containers but instead use
36+
ToolHive's transparent HTTP proxy to forward requests to remote servers. For
37+
example:
38+
39+
```bash
40+
thv run neon
41+
thv run stripe
42+
```
43+
44+
When you run a remote server from the registry, ToolHive uses the pre-configured
45+
remote URL and authentication settings.
46+
47+
:::note[Naming convention]
48+
49+
Remote MCP servers use the `-remote` suffix **when they have a local
50+
containerized counterpart** to distinguish between the two versions. For
51+
example:
52+
53+
- `notion-remote` indicates this is the remote version of a server that also has
54+
a local `notion` version
55+
- `neon` and `stripe` don't have local counterparts, so they don't use the
56+
`-remote` suffix
57+
58+
To run a remote notion mcp server, you should use the `notion-remote` name.
59+
60+
```bash
61+
thv run notion-remote
62+
```
63+
64+
Use `thv search <NAME>` or `thv registry list` to discover available servers.
65+
66+
:::
67+
2768
:::info[What's happening?]
2869

29-
When you run an MCP server from the registry, ToolHive:
70+
When you run an MCP server from the registry, ToolHive handles different server
71+
types automatically:
72+
73+
**For local containerized servers:**
3074

3175
1. Pulls the image and launches a container using the configuration from the
3276
registry.
@@ -38,10 +82,21 @@ When you run an MCP server from the registry, ToolHive:
3882
toolhive-name: <SERVER_NAME>
3983
```
4084
85+
**For remote MCP servers:**
86+
87+
1. Uses the pre-configured remote URL from the registry.
88+
2. Automatically detects if the remote server requires authentication.
89+
3. Handles OAuth/OIDC authentication flows if needed.
90+
4. Starts an HTTP proxy process on a random port to forward client requests to
91+
the remote server.
92+
5. Manages the server like any other ToolHive workload. No container is created
93+
for remote MCP servers.
94+
4195
:::
4296
4397
See [Run a custom MCP server](#run-a-custom-mcp-server) to run a server that is
44-
not in the registry.
98+
not in the registry, or [Run a remote MCP server](#run-a-remote-mcp-server) for
99+
more details about remote server configuration.
45100
46101
## Customize server settings
47102
@@ -538,6 +593,146 @@ thv run uvx://some-package
538593
thv run --ca-cert /path/to/special-ca.crt uvx://other-package
539594
```
540595

596+
## Run a remote MCP server
597+
598+
You can run remote MCP servers directly by providing their URL. This allows you
599+
to connect to MCP servers hosted elsewhere without needing to manage containers
600+
locally. ToolHive creates a transparent proxy that handles authentication and
601+
forwards requests to the remote server.
602+
603+
### Basic remote server setup
604+
605+
To run a remote MCP server, simply provide its URL:
606+
607+
```bash
608+
thv run <URL> [--name <SERVER_NAME>]
609+
```
610+
611+
For example:
612+
613+
```bash
614+
thv run https://api.example.com/mcp
615+
```
616+
617+
If you don't specify a name with `--name`, ToolHive will automatically derive a
618+
name from the URL by extracting the main domain name (e.g., `notion` from
619+
`https://api.notion.com/mcp`).
620+
621+
By default, remote servers use the `streamable-http` transport. If the server
622+
uses Server-Sent Events (SSE), specify the transport flag:
623+
624+
```bash
625+
thv run https://api.example.com/sse --transport sse
626+
```
627+
628+
:::info[What's happening?]
629+
630+
When you run a remote MCP server, ToolHive:
631+
632+
1. Automatically detects if the remote server requires authentication.
633+
2. Handles OAuth/OIDC authentication flows if needed.
634+
3. Starts an HTTP proxy process on a random port to forward client requests to
635+
the remote server.
636+
4. Manages the server like any other ToolHive workload. No container is created
637+
for remote MCP servers.
638+
639+
:::
640+
641+
### Authentication setup
642+
643+
Many remote MCP servers require authentication. ToolHive supports automatic
644+
authentication detection and OAuth/OIDC flows.
645+
646+
#### Auto-detect authentication
647+
648+
ToolHive can automatically detect if a remote server requires authentication by
649+
examining the server's response headers and status codes:
650+
651+
```bash
652+
thv run https://protected-api.com/mcp --name my-server
653+
```
654+
655+
If authentication is required, ToolHive will prompt you to complete the OAuth
656+
flow. When no client credentials are provided, ToolHive automatically registers
657+
an OAuth client with the authorization server using RFC 7591 dynamic client
658+
registration, eliminating the need to pre-configure client ID and secret.
659+
660+
#### OIDC authentication
661+
662+
For servers using OpenID Connect (OIDC), provide the issuer URL, client ID, and
663+
client secret obtained from the application provider:
664+
665+
```bash
666+
thv run https://api.example.com/mcp \
667+
--name my-server \
668+
--remote-auth-issuer https://auth.example.com \
669+
--remote-auth-client-id my-client-id \
670+
--remote-auth-client-secret my-client-secret
671+
```
672+
673+
#### OAuth2 authentication
674+
675+
For servers using OAuth2, specify the authorization and token URLs along with
676+
the client ID and secret obtained from the application provider:
677+
678+
```bash
679+
thv run https://api.example.com/mcp \
680+
--name my-server \
681+
--remote-auth-authorize-url https://auth.example.com/oauth/authorize \
682+
--remote-auth-token-url https://auth.example.com/oauth/token \
683+
--remote-auth-client-id my-client-id \
684+
--remote-auth-client-secret my-client-secret
685+
```
686+
687+
#### Automatic token refresh
688+
689+
ToolHive automatically handles OAuth token refresh for remote MCP servers. When
690+
you authenticate with a remote server, ToolHive stores both the access token and
691+
refresh token securely. The refresh token is used to automatically obtain new
692+
access tokens when they expire, ensuring uninterrupted service without requiring
693+
manual re-authentication.
694+
695+
### Advanced remote server configuration
696+
697+
#### OAuth scopes and parameters
698+
699+
Specify custom OAuth scopes for the authentication flow:
700+
701+
```bash
702+
thv run https://api.example.com/mcp \
703+
... \
704+
--remote-auth-scopes read,write,admin
705+
```
706+
707+
#### Custom authentication timeout
708+
709+
Adjust the authentication timeout for slow networks:
710+
711+
```bash
712+
thv run https://api.example.com/mcp \
713+
... \
714+
--remote-auth-timeout 2m
715+
```
716+
717+
#### Skip browser authentication
718+
719+
For headless environments, skip the browser-based OAuth flow:
720+
721+
```bash
722+
thv run https://api.example.com/mcp \
723+
... \
724+
--remote-auth-skip-browser
725+
```
726+
727+
### Remote server management
728+
729+
Remote MCP servers are managed like any other ToolHive workload:
730+
731+
- **List servers**: `thv list` shows remote servers with their target URLs
732+
- **View logs**: `thv logs <SERVER_NAME>` shows proxy and authentication logs
733+
- **Stop/restart**: `thv stop <SERVER_NAME>` and `thv restart <SERVER_NAME>`
734+
- **Remove**: `thv rm <SERVER_NAME>` removes the proxy and configuration
735+
541736
## Share and reuse server configurations
542737

543738
ToolHive allows you to export a server's configuration and run servers using
@@ -657,3 +852,55 @@ If a server crashes or exits unexpectedly:
657852
4. Verify the server's configuration and arguments
658853

659854
</details>
855+
856+
<details>
857+
<summary>Remote server authentication fails</summary>
858+
859+
If a remote MCP server authentication fails:
860+
861+
1. Check the server logs for authentication errors (see
862+
[View server logs](./manage-mcp-servers.md#view-server-logs) for the correct
863+
log file path on your platform)
864+
865+
2. Verify the issuer URL is correct and accessible
866+
867+
3. Check if the OAuth client ID and secret are valid
868+
869+
4. Ensure the remote server supports the OAuth flow you're using
870+
871+
5. Try re-authenticating by restarting the server:
872+
873+
```bash
874+
thv restart <SERVER_NAME>
875+
```
876+
877+
</details>
878+
879+
<details>
880+
<summary>Remote server connection issues</summary>
881+
882+
If you can't connect to a remote MCP server:
883+
884+
1. Verify the remote server URL is correct and accessible
885+
886+
2. Check your network connectivity:
887+
888+
```bash
889+
curl -I https://api.example.com/mcp
890+
```
891+
892+
3. Check if the remote server requires specific headers or authentication
893+
894+
4. Review the server logs for connection errors:
895+
896+
```bash
897+
thv logs <SERVER_NAME>
898+
```
899+
900+
5. Try running with debug mode for more detailed logs:
901+
902+
```bash
903+
thv run --debug https://api.example.com/mcp --name my-server
904+
```
905+
906+
</details>

0 commit comments

Comments
 (0)