Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ tools:
my-server:
command: npx
args: ["-y", "my-mcp-server"]
cwd: /path/to/working/directory # Optional working directory
```

**Configuration options**:
Expand All @@ -213,6 +214,15 @@ tools:
| `max_content_size` | `50000` | Maximum content size in characters. Content exceeding this limit is automatically truncated with a notice to prevent context window exhaustion |
| `servers` | (optional) | Inline server configuration (overrides .amplifier/mcp.json) |

**Per-server configuration options**:

| Option | Required | Description |
|--------|----------|-------------|
| `command` | Yes | Command to execute (e.g., `npx`, `python`, `node`) |
| `args` | No | Arguments for the command |
| `env` | No | Environment variables for the server process |
| `cwd` | No | Working directory for the server process. Falls back to `AMPLIFIER_WORK_DIRECTORY` env var if not specified |

**Environment variable override**:
```bash
# Enable verbose output without changing bundle config
Expand Down
4 changes: 4 additions & 0 deletions amplifier_module_tool_mcp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __init__(
command: str,
args: list[str],
env: dict[str, str] | None = None,
cwd: str | Path | None = None,
reconnection_config: ReconnectionConfig | None = None,
verbose_servers: bool = False,
server_log_dir: Path | None = None,
Expand All @@ -61,6 +62,7 @@ def __init__(
command: Command to execute (e.g., "npx", "python")
args: Arguments for the command
env: Optional environment variables
cwd: Optional working directory for the server process
reconnection_config: Reconnection configuration (uses defaults if None)
verbose_servers: Whether to show server stderr output (default: False)
server_log_dir: Directory for server logs when suppressed (default: ~/.amplifier/logs/mcp-servers/)
Expand All @@ -69,6 +71,7 @@ def __init__(
self.command = command
self.args = args
self.env = env or {}
self.cwd = cwd
self.session: ClientSession | None = None
self.tools: list[dict[str, Any]] = []
self.resources: list[dict[str, Any]] = []
Expand Down Expand Up @@ -143,6 +146,7 @@ async def _connection_task_impl(self) -> None:
command=self.command,
args=self.args,
env=merged_env,
cwd=self.cwd,
)

# Open log file if needed
Expand Down
9 changes: 8 additions & 1 deletion amplifier_module_tool_mcp/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,16 @@ async def _start_stdio_server(self, server_name: str, server_config: dict[str, A
# Substitute environment variables
env = {k: MCPConfig.substitute_env_vars(v) for k, v in env.items()}

# Get working directory from config, or fall back to AMPLIFIER_WORK_DIRECTORY env var
cwd = server_config.get("cwd")
if not cwd:
cwd = os.environ.get("AMPLIFIER_WORK_DIRECTORY")
if cwd:
logger.debug(f"Server '{server_name}' will use working directory: {cwd}")

# Create and connect client with verbose settings
client = MCPClient(
server_name, command, args, env, verbose_servers=self.verbose_servers, server_log_dir=self.server_log_dir
server_name, command, args, env, cwd=cwd, verbose_servers=self.verbose_servers, server_log_dir=self.server_log_dir
)
await client.connect()

Expand Down