@@ -17,17 +17,34 @@ want to run. The server name is the same as its name in the registry.
1717thv 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
2430thv 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:**
31481 . Pulls the image and launches a container using the configuration from the
3249 registry.
33502 . 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
4367See [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
538563thv 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
543701ToolHive allows you to export a server's configuration and run servers using
@@ -657,3 +815,57 @@ If a server crashes or exits unexpectedly:
6578154. 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