Skip to content

Commit b82bf0f

Browse files
author
LittleCoinCoin
committed
Merge branch 'feat/codex-support' into dev
2 parents a1ede86 + f1880ce commit b82bf0f

21 files changed

+1181
-92
lines changed

.augmentignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__reports__/

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ envs/
55
Laghari/
66
__temp__/
77

8+
# IDEs
9+
## Kiro
10+
.kiro/
11+
12+
## VS Code
13+
.vscode/
14+
15+
816
# vvvvvvv Default Python Ignore vvvvvvvv
917
# Byte-compiled / optimized / DLL files
1018
__pycache__/

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
## Introduction
66

7-
Hatch is the package manager for managing Model Context Protocol (MCP) servers with environment isolation, multi-type dependency resolution, and multi-host deployment. Deploy MCP servers to Claude Desktop, VS Code, Cursor, Kiro, and other platforms with automatic dependency management.
7+
Hatch is the package manager for managing Model Context Protocol (MCP) servers with environment isolation, multi-type dependency resolution, and multi-host deployment. Deploy MCP servers to Claude Desktop, VS Code, Cursor, Kiro, Codex, and other platforms with automatic dependency management.
88

99
The canonical documentation is at `docs/index.md` and published at <https://hatch.readthedocs.io/en/latest/>.
1010

1111
## Key Features
1212

1313
- **Environment Isolation** — Create separate, isolated workspaces for different projects without conflicts
1414
- **Multi-Type Dependency Resolution** — Automatically resolve and install system packages, Python packages, Docker containers, and Hatch packages
15-
- **Multi-Host Deployment**Deploy MCP servers to Claude Desktop, Claude Code, VS Code, Cursor, Kiro, LM Studio, and Google Gemini CLI
15+
- **Multi-Host Deployment**Configure MCP servers on multiple host platforms
1616
- **Package Validation** — Ensure packages meet schema requirements before distribution
1717
- **Development-Focused** — Optimized for rapid development and testing of MCP server ecosystems
1818

@@ -25,6 +25,7 @@ Hatch supports deployment to the following MCP host platforms:
2525
- **VS Code** — Visual Studio Code with the MCP extension for tool integration
2626
- **Cursor** — AI-first code editor with built-in MCP server support
2727
- **Kiro** — Kiro IDE with MCP support
28+
- **Codex** — OpenAI Codex with MCP server configuration support
2829
- **LM Studio** — Local LLM inference platform with MCP server integration
2930
- **Google Gemini CLI** — Command-line interface for Google's Gemini model with MCP support
3031

docs/articles/users/CLIReference.md

Lines changed: 66 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -395,29 +395,35 @@ Syntax:
395395

396396
`hatch mcp configure <server-name> --host <host> (--command CMD | --url URL) [--args ARGS] [--env-var ENV] [--header HEADER] [--dry-run] [--auto-approve] [--no-backup]`
397397

398-
| Argument / Flag | Type | Description | Default |
399-
|---:|---|---|---|
400-
| `server-name` | string (positional) | Name of the MCP server to configure | n/a |
401-
| `--host` | string | Target host platform (claude-desktop, cursor, etc.) | n/a |
402-
| `--command` | string | Command to execute for local servers (mutually exclusive with --url) | none |
403-
| `--url` | string | URL for remote MCP servers (mutually exclusive with --command) | none |
404-
| `--http-url` | string | HTTP streaming endpoint URL (Gemini only) | none |
405-
| `--args` | string | Arguments for MCP server command (only with --command) | none |
406-
| `--env-var` | string | Environment variables format: KEY=VALUE (can be used multiple times) | none |
407-
| `--header` | string | HTTP headers format: KEY=VALUE (only with --url) | none |
408-
| `--timeout` | int | Request timeout in milliseconds (Gemini) | none |
409-
| `--trust` | flag | Bypass tool call confirmations (Gemini) | false |
410-
| `--cwd` | string | Working directory for stdio transport (Gemini) | none |
411-
| `--include-tools` | multiple | Tool allowlist - only these tools will be available (Gemini). Space-separated values. | none |
412-
| `--exclude-tools` | multiple | Tool blocklist - these tools will be excluded (Gemini). Space-separated values. | none |
413-
| `--env-file` | string | Path to environment file (Cursor, VS Code, LM Studio) | none |
414-
| `--input` | multiple | Input variable definitions format: type,id,description[,password=true] (VS Code) | none |
415-
| `--disabled` | flag | Disable the MCP server (Kiro) | false |
416-
| `--auto-approve-tools` | multiple | Tool names to auto-approve (Kiro). Can be used multiple times. | none |
417-
| `--disable-tools` | multiple | Tool names to disable (Kiro). Can be used multiple times. | none |
418-
| `--dry-run` | flag | Preview configuration without applying changes | false |
419-
| `--auto-approve` | flag | Skip confirmation prompts | false |
420-
| `--no-backup` | flag | Skip backup creation before configuration | false |
398+
| Argument / Flag | Hosts | Type | Description | Default |
399+
|---:|---|---|---|---|
400+
| `server-name` | all | string (positional) | Name of the MCP server to configure | n/a |
401+
| `--host` | all | string | Target host platform (claude-desktop, cursor, etc.) | n/a |
402+
| `--command` | all | string | Command to execute for local servers (mutually exclusive with --url) | none |
403+
| `--url` | all except Claude Desktop/Code | string | URL for remote MCP servers (mutually exclusive with --command) | none |
404+
| `--http-url` | gemini | string | HTTP streaming endpoint URL | none |
405+
| `--args` | all | string | Arguments for MCP server command (only with --command) | none |
406+
| `--env-var` | all | string | Environment variables format: KEY=VALUE (can be used multiple times) | none |
407+
| `--header` | all except Claude Desktop/Code | string | HTTP headers format: KEY=VALUE (only with --url) | none |
408+
| `--timeout` | gemini | int | Request timeout in milliseconds | none |
409+
| `--trust` | gemini | flag | Bypass tool call confirmations | false |
410+
| `--cwd` | gemini, codex | string | Working directory for stdio transport | none |
411+
| `--include-tools` | gemini, codex | multiple | Tool allowlist / enabled tools. Space-separated values. | none |
412+
| `--exclude-tools` | gemini, codex | multiple | Tool blocklist / disabled tools. Space-separated values. | none |
413+
| `--env-file` | cursor, vscode, lmstudio | string | Path to environment file | none |
414+
| `--input` | vscode | multiple | Input variable definitions format: type,id,description[,password=true] | none |
415+
| `--disabled` | kiro | flag | Disable the MCP server | false |
416+
| `--auto-approve-tools` | kiro | multiple | Tool names to auto-approve. Can be used multiple times. | none |
417+
| `--disable-tools` | kiro | multiple | Tool names to disable. Can be used multiple times. | none |
418+
| `--env-vars` | codex | multiple | Environment variable names to whitelist/forward. Can be used multiple times. | none |
419+
| `--startup-timeout` | codex | int | Server startup timeout in seconds (default: 10) | none |
420+
| `--tool-timeout` | codex | int | Tool execution timeout in seconds (default: 60) | none |
421+
| `--enabled` | codex | flag | Enable the MCP server | false |
422+
| `--bearer-token-env-var` | codex | string | Name of env var containing bearer token for Authorization header | none |
423+
| `--env-header` | codex | multiple | HTTP header from env var format: KEY=ENV_VAR_NAME. Can be used multiple times. | none |
424+
| `--dry-run` | all | flag | Preview configuration without applying changes | false |
425+
| `--auto-approve` | all | flag | Skip confirmation prompts | false |
426+
| `--no-backup` | all | flag | Skip backup creation before configuration | false |
421427

422428
**Behavior**:
423429

@@ -509,6 +515,42 @@ Configure MCP server 'my-server' on host 'kiro'? [y/N]: y
509515
[SUCCESS] Successfully configured MCP server 'my-server' on host 'kiro'
510516
```
511517

518+
**Example - Codex Configuration with Timeouts and Tool Filtering**:
519+
520+
```bash
521+
$ hatch mcp configure context7 --host codex --command npx --args "-y" "@upstash/context7-mcp" --env-vars PATH --env-vars HOME --startup-timeout 15 --tool-timeout 120 --enabled --include-tools read write --exclude-tools delete
522+
523+
Server 'context7' created for host 'codex':
524+
name: UPDATED None --> 'context7'
525+
command: UPDATED None --> 'npx'
526+
args: UPDATED None --> ['-y', '@upstash/context7-mcp']
527+
env_vars: UPDATED None --> ['PATH', 'HOME']
528+
startup_timeout_sec: UPDATED None --> 15
529+
tool_timeout_sec: UPDATED None --> 120
530+
enabled: UPDATED None --> True
531+
enabled_tools: UPDATED None --> ['read', 'write']
532+
disabled_tools: UPDATED None --> ['delete']
533+
534+
Configure MCP server 'context7' on host 'codex'? [y/N]: y
535+
[SUCCESS] Successfully configured MCP server 'context7' on host 'codex'
536+
```
537+
538+
**Example - Codex HTTP Server with Authentication**:
539+
540+
```bash
541+
$ hatch mcp configure figma --host codex --url https://mcp.figma.com/mcp --bearer-token-env-var FIGMA_OAUTH_TOKEN --env-header "X-Figma-Region=FIGMA_REGION" --header "X-Custom=static-value"
542+
543+
Server 'figma' created for host 'codex':
544+
name: UPDATED None --> 'figma'
545+
url: UPDATED None --> 'https://mcp.figma.com/mcp'
546+
bearer_token_env_var: UPDATED None --> 'FIGMA_OAUTH_TOKEN'
547+
env_http_headers: UPDATED None --> {'X-Figma-Region': 'FIGMA_REGION'}
548+
http_headers: UPDATED None --> {'X-Custom': 'static-value'}
549+
550+
Configure MCP server 'figma' on host 'codex'? [y/N]: y
551+
[SUCCESS] Successfully configured MCP server 'figma' on host 'codex'
552+
```
553+
512554
**Example - Remote Server Configuration**:
513555

514556
```bash
@@ -550,6 +592,7 @@ Different MCP hosts support different configuration fields. The conversion repor
550592
- **Cursor / LM Studio**: Supports universal fields + envFile
551593
- **VS Code**: Supports universal fields + envFile, inputs
552594
- **Gemini CLI**: Supports universal fields + 14 additional fields (cwd, timeout, trust, OAuth settings, etc.)
595+
- **Codex**: Supports universal fields + Codex-specific fields for URL-based servers (http_headers, env_http_headers, bearer_token_env_var, enabled, startup_timeout_sec, tool_timeout_sec, env_vars)
553596

554597
When configuring a server with fields not supported by the target host, those fields are marked as UNSUPPORTED in the report and automatically excluded from the configuration.
555598

docs/articles/users/MCPHostConfiguration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Hatch currently supports configuration for these MCP host platforms:
2020
- **VS Code** - Microsoft Visual Studio Code with MCP extensions
2121
- **Cursor** - AI-powered code editor
2222
- **Kiro** - Kiro IDE with MCP support
23+
- **Codex** - OpenAI Codex with MCP server configuration support
2324
- **LM Studio** - Local language model interface
2425
- **Gemini** - Google's AI development environment
2526

docs/articles/users/tutorials/04-mcp-host-configuration/01-host-platform-overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Hatch currently supports configuration for these MCP host platforms:
5454
- [**Cursor**](https://cursor.com/) - AI-powered code editor
5555
- [**VS Code**](https://code.visualstudio.com/) - Microsoft Visual Studio Code
5656
- [**Kiro**](https://kiro.ai/) - Kiro IDE with MCP support
57+
- [**Codex**](https://github.com/openai/codex) - OpenAI Codex with MCP server configuration support
5758
- [**LM Studio**](https://lmstudio.ai/) - Local language model interface
5859
- [**Gemini**](https://github.com/google-gemini/gemini-cli) - Google's AI Command Line Interface
5960

docs/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Welcome to the documentation for Hatch, the official package manager for the Hat
66

77
Hatch provides powerful tools for managing MCP server packages, environments, and interacting with the Hatch registry. It serves as the package management foundation for [Hatchling](https://github.com/CrackingShells/Hatchling) and other projects in the ecosystem.
88

9+
Hatch also supports MCP host configuration across popular platforms including Claude Desktop/Code, VS Code, Cursor, Kiro, Codex, LM Studio, and Gemini.
10+
911
## Documentation Sections
1012

1113
### For Users

hatch/cli_hatch.py

Lines changed: 90 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,12 @@ def handle_mcp_configure(
716716
disabled: Optional[bool] = None,
717717
auto_approve_tools: Optional[list] = None,
718718
disable_tools: Optional[list] = None,
719+
env_vars: Optional[list] = None,
720+
startup_timeout: Optional[int] = None,
721+
tool_timeout: Optional[int] = None,
722+
enabled: Optional[bool] = None,
723+
bearer_token_env_var: Optional[str] = None,
724+
env_header: Optional[list] = None,
719725
no_backup: bool = False,
720726
dry_run: bool = False,
721727
auto_approve: bool = False,
@@ -837,6 +843,27 @@ def handle_mcp_configure(
837843
if disable_tools is not None:
838844
omni_config_data["disabledTools"] = disable_tools
839845

846+
# Host-specific fields (Codex)
847+
if env_vars is not None:
848+
omni_config_data["env_vars"] = env_vars
849+
if startup_timeout is not None:
850+
omni_config_data["startup_timeout_sec"] = startup_timeout
851+
if tool_timeout is not None:
852+
omni_config_data["tool_timeout_sec"] = tool_timeout
853+
if enabled is not None:
854+
omni_config_data["enabled"] = enabled
855+
if bearer_token_env_var is not None:
856+
omni_config_data["bearer_token_env_var"] = bearer_token_env_var
857+
if env_header is not None:
858+
# Parse KEY=ENV_VAR_NAME format into dict
859+
env_http_headers = {}
860+
for header_spec in env_header:
861+
if '=' in header_spec:
862+
key, env_var_name = header_spec.split('=', 1)
863+
env_http_headers[key] = env_var_name
864+
if env_http_headers:
865+
omni_config_data["env_http_headers"] = env_http_headers
866+
840867
# Partial update merge logic
841868
if is_update:
842869
# Merge with existing configuration
@@ -1568,101 +1595,137 @@ def main():
15681595
mcp_configure_parser = mcp_subparsers.add_parser(
15691596
"configure", help="Configure MCP server directly on host"
15701597
)
1571-
mcp_configure_parser.add_argument("server_name", help="Name for the MCP server")
1598+
mcp_configure_parser.add_argument(
1599+
"server_name", help="Name for the MCP server [hosts: all]"
1600+
)
15721601
mcp_configure_parser.add_argument(
15731602
"--host",
15741603
required=True,
1575-
help="Host platform to configure (e.g., claude-desktop, cursor)",
1604+
help="Host platform to configure (e.g., claude-desktop, cursor) [hosts: all]",
15761605
)
15771606

15781607
# Create mutually exclusive group for server type
15791608
server_type_group = mcp_configure_parser.add_mutually_exclusive_group()
15801609
server_type_group.add_argument(
15811610
"--command",
15821611
dest="server_command",
1583-
help="Command to execute the MCP server (for local servers)",
1612+
help="Command to execute the MCP server (for local servers) [hosts: all]",
15841613
)
15851614
server_type_group.add_argument(
1586-
"--url", help="Server URL for remote MCP servers (SSE transport)"
1615+
"--url", help="Server URL for remote MCP servers (SSE transport) [hosts: all except claude-desktop, claude-code]"
15871616
)
15881617
server_type_group.add_argument(
1589-
"--http-url", help="HTTP streaming endpoint URL (Gemini only)"
1618+
"--http-url", help="HTTP streaming endpoint URL [hosts: gemini]"
15901619
)
15911620

15921621
mcp_configure_parser.add_argument(
15931622
"--args",
15941623
nargs="*",
1595-
help="Arguments for the MCP server command (only with --command)",
1624+
help="Arguments for the MCP server command (only with --command) [hosts: all]",
15961625
)
15971626
mcp_configure_parser.add_argument(
1598-
"--env-var", action="append", help="Environment variables (format: KEY=VALUE)"
1627+
"--env-var",
1628+
action="append",
1629+
help="Environment variables (format: KEY=VALUE) [hosts: all]",
15991630
)
16001631
mcp_configure_parser.add_argument(
16011632
"--header",
16021633
action="append",
1603-
help="HTTP headers for remote servers (format: KEY=VALUE, only with --url)",
1634+
help="HTTP headers for remote servers (format: KEY=VALUE, only with --url) [hosts: all except claude-desktop, claude-code]",
16041635
)
16051636

16061637
# Host-specific arguments (Gemini)
16071638
mcp_configure_parser.add_argument(
1608-
"--timeout", type=int, help="Request timeout in milliseconds (Gemini)"
1639+
"--timeout", type=int, help="Request timeout in milliseconds [hosts: gemini]"
16091640
)
16101641
mcp_configure_parser.add_argument(
1611-
"--trust", action="store_true", help="Bypass tool call confirmations (Gemini)"
1642+
"--trust", action="store_true", help="Bypass tool call confirmations [hosts: gemini]"
16121643
)
16131644
mcp_configure_parser.add_argument(
1614-
"--cwd", help="Working directory for stdio transport (Gemini)"
1645+
"--cwd", help="Working directory for stdio transport [hosts: gemini, codex]"
16151646
)
16161647
mcp_configure_parser.add_argument(
16171648
"--include-tools",
16181649
nargs="*",
1619-
help="Tool allowlist - only these tools will be available (Gemini)",
1650+
help="Tool allowlist / enabled tools [hosts: gemini, codex]",
16201651
)
16211652
mcp_configure_parser.add_argument(
16221653
"--exclude-tools",
16231654
nargs="*",
1624-
help="Tool blocklist - these tools will be excluded (Gemini)",
1655+
help="Tool blocklist / disabled tools [hosts: gemini, codex]",
16251656
)
16261657

16271658
# Host-specific arguments (Cursor/VS Code/LM Studio)
16281659
mcp_configure_parser.add_argument(
1629-
"--env-file", help="Path to environment file (Cursor, VS Code, LM Studio)"
1660+
"--env-file", help="Path to environment file [hosts: cursor, vscode, lmstudio]"
16301661
)
16311662

16321663
# Host-specific arguments (VS Code)
16331664
mcp_configure_parser.add_argument(
16341665
"--input",
16351666
action="append",
1636-
help="Input variable definitions in format: type,id,description[,password=true] (VS Code)",
1667+
help="Input variable definitions in format: type,id,description[,password=true] [hosts: vscode]",
16371668
)
16381669

16391670
# Host-specific arguments (Kiro)
16401671
mcp_configure_parser.add_argument(
16411672
"--disabled",
16421673
action="store_true",
1643-
help="Disable the MCP server (Kiro)"
1674+
help="Disable the MCP server [hosts: kiro]"
16441675
)
16451676
mcp_configure_parser.add_argument(
16461677
"--auto-approve-tools",
16471678
action="append",
1648-
help="Tool names to auto-approve without prompting (Kiro)"
1679+
help="Tool names to auto-approve without prompting [hosts: kiro]"
16491680
)
16501681
mcp_configure_parser.add_argument(
16511682
"--disable-tools",
16521683
action="append",
1653-
help="Tool names to disable (Kiro)"
1684+
help="Tool names to disable [hosts: kiro]"
1685+
)
1686+
1687+
# Codex-specific arguments
1688+
mcp_configure_parser.add_argument(
1689+
"--env-vars",
1690+
action="append",
1691+
help="Environment variable names to whitelist/forward [hosts: codex]"
1692+
)
1693+
mcp_configure_parser.add_argument(
1694+
"--startup-timeout",
1695+
type=int,
1696+
help="Server startup timeout in seconds (default: 10) [hosts: codex]"
1697+
)
1698+
mcp_configure_parser.add_argument(
1699+
"--tool-timeout",
1700+
type=int,
1701+
help="Tool execution timeout in seconds (default: 60) [hosts: codex]"
1702+
)
1703+
mcp_configure_parser.add_argument(
1704+
"--enabled",
1705+
action="store_true",
1706+
help="Enable the MCP server [hosts: codex]"
1707+
)
1708+
mcp_configure_parser.add_argument(
1709+
"--bearer-token-env-var",
1710+
type=str,
1711+
help="Name of environment variable containing bearer token for Authorization header [hosts: codex]"
1712+
)
1713+
mcp_configure_parser.add_argument(
1714+
"--env-header",
1715+
action="append",
1716+
help="HTTP header from environment variable in KEY=ENV_VAR_NAME format [hosts: codex]"
16541717
)
16551718

16561719
mcp_configure_parser.add_argument(
16571720
"--no-backup",
16581721
action="store_true",
1659-
help="Skip backup creation before configuration",
1722+
help="Skip backup creation before configuration [hosts: all]",
16601723
)
16611724
mcp_configure_parser.add_argument(
1662-
"--dry-run", action="store_true", help="Preview configuration without execution"
1725+
"--dry-run", action="store_true", help="Preview configuration without execution [hosts: all]"
16631726
)
16641727
mcp_configure_parser.add_argument(
1665-
"--auto-approve", action="store_true", help="Skip confirmation prompts"
1728+
"--auto-approve", action="store_true", help="Skip confirmation prompts [hosts: all]"
16661729
)
16671730

16681731
# Remove MCP commands (object-action pattern)
@@ -2724,6 +2787,12 @@ def main():
27242787
getattr(args, "disabled", None),
27252788
getattr(args, "auto_approve_tools", None),
27262789
getattr(args, "disable_tools", None),
2790+
getattr(args, "env_vars", None),
2791+
getattr(args, "startup_timeout", None),
2792+
getattr(args, "tool_timeout", None),
2793+
getattr(args, "enabled", None),
2794+
getattr(args, "bearer_token_env_var", None),
2795+
getattr(args, "env_header", None),
27272796
args.no_backup,
27282797
args.dry_run,
27292798
args.auto_approve,

0 commit comments

Comments
 (0)