Skip to content

Commit 96306a7

Browse files
committed
ci: adds the remote mcp server section
1 parent 5630f05 commit 96306a7

File tree

2 files changed

+239
-7
lines changed

2 files changed

+239
-7
lines changed

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ 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 created at. Remote
21+
servers will show their target URL in url, and remote in package and tool type columns making it easy to identify them.
2122

2223
To include stopped servers in the list:
2324

@@ -60,7 +61,8 @@ thv stop <SERVER_NAME>
6061
```
6162

6263
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.
64+
entry from your configured clients, but keeps the container for future use. For
65+
remote servers, this terminates the proxy process but preserves the configuration.
6466

6567
Add the `--group` flag to stop all servers in a specific group:
6668

@@ -78,6 +80,11 @@ To restart a stopped MCP server and add it back to your configured clients:
7880
thv restart <SERVER_NAME>
7981
```
8082

83+
For remote servers, restarting will:
84+
1. Recreate the proxy process
85+
2. Re-establish connection to the remote server
86+
3. Re-authenticate with the remote server (triggers new OAuth flow)
87+
8188
Add the `--group` flag to restart all servers in a specific group:
8289

8390
```bash
@@ -94,7 +101,8 @@ thv rm <SERVER_NAME>
94101

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

99107
Add the `--group` flag to remove all servers in a specific group:
100108

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

111119
:::
112120

121+
### Remote server authentication
122+
123+
Remote servers with OAuth authentication will automatically refresh tokens
124+
when they expire during normal operation. However, restarting a remote server
125+
always triggers a new OAuth authentication flow:
126+
127+
```bash
128+
thv restart <REMOTE_SERVER_NAME>
129+
```
130+
131+
This will always prompt for re-authentication, even if valid tokens exist.
132+
113133
## Related information
114134

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

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

Lines changed: 216 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,34 @@ 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+
For remote MCP servers in the registry, such as the Neon or Stripe servers:
36+
37+
```bash
38+
thv run neon
39+
thv run stripe
40+
```
41+
2742
:::info[What's happening?]
2843

29-
When you run an MCP server from the registry, ToolHive:
44+
When you run an MCP server from the registry, ToolHive handles different server
45+
types automatically:
3046

47+
**For local containerized servers:**
3148
1. Pulls the image and launches a container using the configuration from the
3249
registry.
3350
2. Starts an HTTP proxy process on a random port to forward client requests to
@@ -38,10 +55,18 @@ When you run an MCP server from the registry, ToolHive:
3855
toolhive-name: <SERVER_NAME>
3956
```
4057
58+
**For remote MCP servers:**
59+
1. Automatically detects if the remote server requires authentication.
60+
2. Handles OAuth/OIDC authentication flows if needed.
61+
3. Starts an HTTP proxy process on a random port to forward client requests to
62+
the remote server.
63+
4. Manages the server like any other ToolHive workload. No conatainer is created for remote MCP servers.
64+
4165
:::
4266
4367
See [Run a custom MCP server](#run-a-custom-mcp-server) to run a server that is
44-
not in the registry.
68+
not in the registry, or [Run a remote MCP server](#run-a-remote-mcp-server) for
69+
more details about remote server configuration.
4570
4671
## Customize server settings
4772
@@ -538,6 +563,139 @@ thv run uvx://some-package
538563
thv run --ca-cert /path/to/special-ca.crt uvx://other-package
539564
```
540565

566+
## Run a remote MCP server
567+
568+
You can run remote MCP servers directly by providing their URL. This allows you to
569+
connect to MCP servers hosted elsewhere without needing to manage containers locally.
570+
ToolHive creates a transparent proxy that handles authentication and forwards requests
571+
to the remote server.
572+
573+
### Basic remote server setup
574+
575+
To run a remote MCP server, simply provide its URL:
576+
577+
```bash
578+
thv run <URL> [--name <SERVER_NAME>]
579+
```
580+
581+
For example:
582+
583+
```bash
584+
thv run https://api.example.com/mcp --name my-remote-server
585+
```
586+
587+
:::info[What's happening?]
588+
589+
When you run a remote MCP server, ToolHive:
590+
591+
1. Automatically detects if the remote server requires authentication.
592+
2. Handles OAuth/OIDC authentication flows if needed.
593+
3. Starts an HTTP proxy process on a random port to forward client requests to
594+
the remote server.
595+
4. Manages the server like any other ToolHive workload. No conatainer is created for remote MCP servers.
596+
597+
:::
598+
599+
### Authentication setup
600+
601+
Many remote MCP servers require authentication. ToolHive supports automatic
602+
authentication detection and OAuth/OIDC flows.
603+
604+
#### Auto-detect authentication
605+
606+
ToolHive can automatically detect if a remote server requires authentication by
607+
examining the server's response headers and status codes:
608+
609+
```bash
610+
thv run https://protected-api.com/mcp --name my-server
611+
```
612+
613+
If authentication is required, ToolHive will prompt you to complete the OAuth flow.
614+
615+
#### OAuth/OIDC authentication
616+
617+
For servers requiring OAuth or OIDC authentication, you can provide the issuer URL:
618+
619+
```bash
620+
thv run https://api.example.com/mcp \
621+
--name my-server \
622+
--remote-auth-issuer https://auth.example.com \
623+
--remote-auth-client-id my-client-id
624+
```
625+
626+
#### Dynamic client registration
627+
628+
When no client credentials are provided, ToolHive automatically registers an OAuth client
629+
with the authorization server using RFC 7591 dynamic client registration:
630+
631+
```bash
632+
thv run https://api.example.com/mcp --name my-server
633+
```
634+
635+
This eliminates the need to pre-configure client ID and secret, making it easier to
636+
connect to remote MCP servers.
637+
638+
#### Automatic token refresh
639+
640+
ToolHive automatically handles OAuth token refresh for remote MCP servers. When you
641+
authenticate with a remote server, ToolHive stores both the access token and refresh
642+
token securely. The refresh token is used to automatically obtain new access tokens
643+
when they expire, ensuring uninterrupted service without requiring manual re-authentication.
644+
645+
#### Custom OAuth endpoints
646+
647+
For non-OIDC OAuth servers, you can specify custom authorization and token endpoints:
648+
649+
```bash
650+
thv run https://api.example.com/mcp \
651+
--name my-server \
652+
--remote-auth-authorize-url https://auth.example.com/oauth/authorize \
653+
--remote-auth-token-url https://auth.example.com/oauth/token \
654+
--remote-auth-client-id my-client-id \
655+
--remote-auth-client-secret my-client-secret
656+
```
657+
658+
### Advanced remote server configuration
659+
660+
#### OAuth scopes and parameters
661+
662+
Specify custom OAuth scopes for the authentication flow:
663+
664+
```bash
665+
thv run https://api.example.com/mcp \
666+
⋮ \
667+
--remote-auth-scopes read,write,admin
668+
```
669+
670+
#### Custom authentication timeout
671+
672+
Adjust the authentication timeout for slow networks:
673+
674+
```bash
675+
thv run https://api.example.com/mcp \
676+
⋮ \
677+
--remote-auth-timeout 2m
678+
```
679+
680+
#### Skip browser authentication
681+
682+
For headless environments, skip the browser-based OAuth flow:
683+
684+
```bash
685+
thv run https://api.example.com/mcp \
686+
⋮ \
687+
--remote-auth-skip-browser
688+
```
689+
690+
### Remote server management
691+
692+
Remote MCP servers are managed like any other ToolHive workload:
693+
694+
- **List servers**: `thv list` shows remote servers with their target URLs
695+
- **View logs**: `thv logs <SERVER_NAME>` shows proxy and authentication logs
696+
- **Stop/restart**: `thv stop <SERVER_NAME>` and `thv restart <SERVER_NAME>`
697+
- **Remove**: `thv rm <SERVER_NAME>` removes the proxy and configuration
698+
541699
## Share and reuse server configurations
542700

543701
ToolHive allows you to export a server's configuration and run servers using
@@ -657,3 +815,57 @@ If a server crashes or exits unexpectedly:
657815
4. Verify the server's configuration and arguments
658816

659817
</details>
818+
819+
<details>
820+
<summary>Remote server authentication fails</summary>
821+
822+
If a remote MCP server authentication fails:
823+
824+
1. Check the server logs for authentication errors:
825+
826+
```bash
827+
thv logs <SERVER_NAME>
828+
```
829+
830+
2. Verify the issuer URL is correct and accessible
831+
832+
3. Check if the OAuth client ID and secret are valid
833+
834+
4. Ensure the remote server supports the OAuth flow you're using
835+
836+
5. Try re-authenticating by restarting the server:
837+
838+
```bash
839+
thv restart <SERVER_NAME>
840+
```
841+
842+
</details>
843+
844+
<details>
845+
<summary>Remote server connection issues</summary>
846+
847+
If you can't connect to a remote MCP server:
848+
849+
1. Verify the remote server URL is correct and accessible
850+
851+
2. Check your network connectivity:
852+
853+
```bash
854+
curl -I https://api.example.com/mcp
855+
```
856+
857+
3. Check if the remote server requires specific headers or authentication
858+
859+
4. Review the server logs for connection errors:
860+
861+
```bash
862+
thv logs <SERVER_NAME>
863+
```
864+
865+
5. Try running with debug mode for more detailed logs:
866+
867+
```bash
868+
thv run --debug https://api.example.com/mcp --name my-server
869+
```
870+
871+
</details>

0 commit comments

Comments
 (0)