@@ -36,13 +36,9 @@ config = MCPServersConfig.from_file("~/Library/Application\ Support/Claude/claud
3636config = MCPServersConfig.from_file(" ~/.cursor/mcp.yaml" ) # Not yet supported in Cursor but maybe soon...?!
3737config = MCPServersConfig.from_file(" ~/Library/Application\ Support/Claude/claude_desktop_config.yaml" ) # Maybe someday...?!
3838
39- # Load with input substitution
40- config = MCPServersConfig.from_file(
41- " .vscode/mcp.json" ,
42- inputs = {" api-key" : " secret" }
43- )
39+ config = MCPServersConfig.from_file(" .vscode/mcp.json" )
4440
45- mcp_server = config.servers[ " time" ]
41+ mcp_server = config.server( " time" )
4642print (mcp_server.command)
4743print (mcp_server.args)
4844print (mcp_server.env)
@@ -261,13 +257,12 @@ When loading the configuration, provide input values:
261257` ` ` python
262258from mcp.client.config.mcp_servers_config import MCPServersConfig
263259
264- # Load with input substitution
265- config = MCPServersConfig.from_file(
266- "config.yaml",
267- inputs={
268- "api-key": "secret-key-123",
269- "server-host": "api.example.com"
270- }
260+ config = MCPServersConfig.from_file("config.yaml")
261+
262+ # Substitute input values into the configuration
263+ server = config.server(
264+ "dynamic-server",
265+ input_values={"api-key": "secret-key-123", "server-host": "api.example.com"},
271266)
272267` ` `
273268
@@ -351,26 +346,3 @@ servers:
351346 my-server:
352347 command: python -m server
353348` ` `
354-
355- # # Error Handling
356-
357- # ## Missing YAML Dependency
358-
359- ` ` ` python
360- try:
361- config = MCPServersConfig.from_file("config.yaml")
362- except ImportError as e:
363- print("Install YAML support: pip install 'mcp[yaml]'")
364- ` ` `
365-
366- # ## Missing Input Values
367-
368- ` ` ` python
369- try:
370- config = MCPServersConfig.from_file("config.yaml", inputs={})
371- except ValueError as e:
372- print(f"Configuration error: {e}")
373- # Error: Missing required input values:
374- # - api-key: Your API key
375- # - server-host: Server hostname
376- ` ` `
0 commit comments