Jeremiah Lowin commited on
Commit
0dd7621
·
1 Parent(s): 2678311

Docs cleanup

Browse files
Files changed (2) hide show
  1. docs/clients/client.mdx +16 -4
  2. docs/servers/proxy.mdx +2 -2
docs/clients/client.mdx CHANGED
@@ -53,26 +53,38 @@ from fastmcp import Client, FastMCP
53
  # Example transports (more details in Transports page)
54
  server_instance = FastMCP(name="TestServer") # In-memory server
55
  http_url = "https://example.com/mcp" # HTTP server URL
56
- ws_url = "ws://localhost:9000" # WebSocket server URL
57
  server_script = "my_mcp_server.py" # Path to a Python server file
58
 
59
  # Client automatically infers the transport type
60
  client_in_memory = Client(server_instance)
61
  client_http = Client(http_url)
62
- client_ws = Client(ws_url)
63
  client_stdio = Client(server_script)
64
 
65
  print(client_in_memory.transport)
66
  print(client_http.transport)
67
- print(client_ws.transport)
68
  print(client_stdio.transport)
69
 
70
  # Expected Output (types may vary slightly based on environment):
71
  # <FastMCP(server='TestServer')>
72
  # <StreamableHttp(url='https://example.com/mcp')>
73
- # <WebSocket(url='ws://localhost:9000')>
74
  # <PythonStdioTransport(command='python', args=['/path/to/your/my_mcp_server.py'])>
75
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  <Tip>
77
  For more control over connection details (like headers for SSE, environment variables for Stdio), you can instantiate the specific `ClientTransport` class yourself and pass it to the `Client`. See the [Transports](/clients/transports) page for details.
78
  </Tip>
 
53
  # Example transports (more details in Transports page)
54
  server_instance = FastMCP(name="TestServer") # In-memory server
55
  http_url = "https://example.com/mcp" # HTTP server URL
 
56
  server_script = "my_mcp_server.py" # Path to a Python server file
57
 
58
  # Client automatically infers the transport type
59
  client_in_memory = Client(server_instance)
60
  client_http = Client(http_url)
61
+
62
  client_stdio = Client(server_script)
63
 
64
  print(client_in_memory.transport)
65
  print(client_http.transport)
 
66
  print(client_stdio.transport)
67
 
68
  # Expected Output (types may vary slightly based on environment):
69
  # <FastMCP(server='TestServer')>
70
  # <StreamableHttp(url='https://example.com/mcp')>
 
71
  # <PythonStdioTransport(command='python', args=['/path/to/your/my_mcp_server.py'])>
72
  ```
73
+
74
+ You can also initialize a client from an MCP configuration dictionary or `MCPConfig` file:
75
+
76
+ ```python
77
+ from fastmcp import Client
78
+
79
+ config = {
80
+ "mcpServers": {
81
+ "local": {"command": "python", "args": ["local_server.py"]},
82
+ "remote": {"url": "https://example.com/mcp"},
83
+ }
84
+ }
85
+
86
+ client_config = Client(config)
87
+ ```
88
  <Tip>
89
  For more control over connection details (like headers for SSE, environment variables for Stdio), you can instantiate the specific `ClientTransport` class yourself and pass it to the `Client`. See the [Transports](/clients/transports) page for details.
90
  </Tip>
docs/servers/proxy.mdx CHANGED
@@ -10,7 +10,7 @@ import { VersionBadge } from '/snippets/version-badge.mdx'
10
 
11
  FastMCP provides a powerful proxying capability that allows one FastMCP server instance to act as a frontend for another MCP server (which could be remote, running on a different transport, or even another FastMCP instance). This is achieved using the `FastMCP.as_proxy()` class method.
12
 
13
- `as_proxy()` accepts either an existing `Client` or any argument that can be passed to a `Client` as its `transport` parameter&mdash;such as another `FastMCP` instance or a URL to a remote server.
14
 
15
  ## What is Proxying?
16
 
@@ -46,7 +46,7 @@ from fastmcp import FastMCP
46
 
47
  # Provide the backend in any form accepted by Client
48
  proxy_server = FastMCP.as_proxy(
49
- "backend_server.py", # Could also be a FastMCP instance or a remote URL
50
  name="MyProxyServer" # Optional settings for the proxy
51
  )
52
 
 
10
 
11
  FastMCP provides a powerful proxying capability that allows one FastMCP server instance to act as a frontend for another MCP server (which could be remote, running on a different transport, or even another FastMCP instance). This is achieved using the `FastMCP.as_proxy()` class method.
12
 
13
+ `as_proxy()` accepts either an existing `Client` or any argument that can be passed to a `Client` as its `transport` parameter&mdash;such as another `FastMCP` instance, a URL to a remote server, or an MCP configuration dictionary.
14
 
15
  ## What is Proxying?
16
 
 
46
 
47
  # Provide the backend in any form accepted by Client
48
  proxy_server = FastMCP.as_proxy(
49
+ "backend_server.py", # Could also be a FastMCP instance, config dict, or a remote URL
50
  name="MyProxyServer" # Optional settings for the proxy
51
  )
52