coding-tools-mcp 0.1.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,37 @@
1
+ Coding Tools MCP Source-Available License v1.0
2
+
3
+ Copyright (c) 2026 Coding Tools MCP Contributors.
4
+ All rights reserved except as expressly granted below.
5
+
6
+ 1. Permitted Use
7
+
8
+ You may view, clone, build, run, and modify the Software solely for internal
9
+ evaluation, development, testing, and security review.
10
+
11
+ 2. Restrictions
12
+
13
+ Without prior written permission from the copyright holders, you may not:
14
+
15
+ - distribute, publish, sublicense, sell, lease, or otherwise transfer the
16
+ Software or modified versions of the Software;
17
+ - provide the Software or modified versions as a hosted, managed, or
18
+ software-as-a-service offering for third parties;
19
+ - use the Software or modified versions for production commercial purposes;
20
+ - remove or alter copyright, license, or attribution notices;
21
+ - use the project name, trademarks, or branding to imply endorsement.
22
+
23
+ 3. Contributions
24
+
25
+ Unless a separate written agreement says otherwise, any contribution submitted
26
+ to this project may be used by the copyright holders under this license and
27
+ under any future license chosen by the copyright holders.
28
+
29
+ 4. No Warranty
30
+
31
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33
+ FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
35
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM,
36
+ OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37
+ SOFTWARE.
@@ -0,0 +1,235 @@
1
+ Metadata-Version: 2.4
2
+ Name: coding-tools-mcp
3
+ Version: 0.1.3
4
+ Summary: Workspace-confined coding tools exposed as an MCP server.
5
+ Author: Coding Tools MCP Contributors
6
+ License-Expression: LicenseRef-Coding-Tools-MCP-Source-Available
7
+ Project-URL: Homepage, https://github.com/ytagent/codex-tool-runtime-mcp
8
+ Project-URL: Documentation, https://github.com/ytagent/codex-tool-runtime-mcp/tree/main/docs
9
+ Project-URL: Source, https://github.com/ytagent/codex-tool-runtime-mcp
10
+ Project-URL: Issues, https://github.com/ytagent/codex-tool-runtime-mcp/issues
11
+ Requires-Python: >=3.11
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Provides-Extra: dev
15
+ Requires-Dist: mypy<2.2,>=2.1; extra == "dev"
16
+ Requires-Dist: ruff<0.16,>=0.15; extra == "dev"
17
+ Requires-Dist: typing_extensions>=4.12; extra == "dev"
18
+ Provides-Extra: image
19
+ Requires-Dist: Pillow>=10.0; extra == "image"
20
+ Dynamic: license-file
21
+
22
+ # Coding Tools MCP
23
+
24
+ Coding Tools MCP is a model-neutral coding-agent runtime MCP server. It exposes local coding primitives to any MCP client:
25
+
26
+ ```text
27
+ inspect repo -> search/read files -> apply structured patches -> run tests/commands
28
+ -> interact with stdin sessions -> inspect git status/diff
29
+ ```
30
+
31
+ It is not a prompt wrapper. It does not expose external agent accounts, memory, cloud tasks, web search, image generation, model routing, plugin marketplace, or subagent orchestration as MCP tools.
32
+
33
+ ## Documentation Map
34
+
35
+ - [Quickstart](docs/quickstart.md)
36
+ - [MCP client configuration](docs/mcp-client-config.md)
37
+ - [Remote MCP](docs/remote-mcp.md)
38
+ - [Tools and schemas](docs/tools-and-schemas.md)
39
+ - [Security policy](SECURITY.md)
40
+ - [CI and test commands](docs/ci-and-tests.md)
41
+ - [Dogfood](docs/dogfood.md)
42
+ - [SWE-bench evaluation](docs/swe-bench.md)
43
+ - [Known limitations](docs/limitations.md)
44
+ - [Troubleshooting](docs/troubleshooting.md)
45
+ - [Competitive analysis](docs/competitive-analysis.md)
46
+ - Normative MCP runtime profile: [docs/profile-v0.1.md](docs/profile-v0.1.md)
47
+
48
+ ## Quickstart
49
+
50
+ Run directly with `uvx` against the current directory:
51
+
52
+ ```bash
53
+ uvx coding-tools-mcp --workspace .
54
+ ```
55
+
56
+ Use stdio for MCP clients:
57
+
58
+ ```bash
59
+ uvx coding-tools-mcp --stdio --workspace /path/to/repo
60
+ ```
61
+
62
+ If you are working from this checkout instead of a published package:
63
+
64
+ ```bash
65
+ cd /root/coding-tools-mcp
66
+ python -m pip install -e ".[dev]"
67
+ coding-tools-mcp --workspace /path/to/repo --host 127.0.0.1 --port 8765
68
+ ```
69
+
70
+ Install the optional image extra when you want `view_image` auto-resize support:
71
+
72
+ ```bash
73
+ python -m pip install -e ".[image]"
74
+ ```
75
+
76
+ HTTP endpoint:
77
+
78
+ ```text
79
+ http://127.0.0.1:8765/mcp
80
+ ```
81
+
82
+ Stdio:
83
+
84
+ ```bash
85
+ coding-tools-mcp --stdio --workspace /path/to/repo
86
+ ```
87
+
88
+ Set `CODING_TOOLS_MCP_TRACE=1` to emit redacted JSON tool-call trace events to stderr for local debugging. Logs stay off stdout so stdio JSON-RPC remains clean.
89
+
90
+ If your MCP client does not support permission elicitation and you explicitly want permission-gated operations to run, start with:
91
+
92
+ ```bash
93
+ coding-tools-mcp --dangerously-skip-all-permissions --workspace /path/to/repo
94
+ ```
95
+
96
+ This auto-grants permission-gated operations such as network-looking commands, destructive commands, shell expansion, and sensitive env passed through `exec_command`. Workspace path boundaries still apply.
97
+
98
+ ## MCP Client Examples
99
+
100
+ Generic stdio client:
101
+
102
+ ```toml
103
+ [mcp_servers.coding_tools]
104
+ command = "uvx"
105
+ args = ["coding-tools-mcp", "--stdio", "--workspace", "/path/to/repo"]
106
+ ```
107
+
108
+ Claude Code:
109
+
110
+ ```json
111
+ {
112
+ "mcpServers": {
113
+ "coding-tools": {
114
+ "command": "uvx",
115
+ "args": ["coding-tools-mcp", "--stdio", "--workspace", "/path/to/repo"]
116
+ }
117
+ }
118
+ }
119
+ ```
120
+
121
+ Cursor:
122
+
123
+ ```json
124
+ {
125
+ "mcpServers": {
126
+ "coding-tools": {
127
+ "command": "uvx",
128
+ "args": ["coding-tools-mcp", "--stdio", "--workspace", "/path/to/repo"]
129
+ }
130
+ }
131
+ }
132
+ ```
133
+
134
+ Generic Streamable HTTP clients should use MCP protocol version `2025-06-18` and point at `http://127.0.0.1:8765/mcp`.
135
+
136
+ ## Remote MCP
137
+
138
+ For remote MCP clients and local development over an HTTPS tunnel, keep the server bound to loopback and expose the tunnel URL with the safest profile your client can use. Anonymous tunnel testing should use `read-only` mode:
139
+
140
+ ```bash
141
+ CODING_TOOLS_MCP_AUTH_MODE=noauth \
142
+ CODING_TOOLS_MCP_TOOL_PROFILE=read-only \
143
+ ./scripts/tunnel.sh cloudflared /path/to/repo
144
+ ```
145
+
146
+ Configure the remote MCP client with the HTTPS tunnel URL:
147
+
148
+ ```text
149
+ URL: https://<tunnel-host>/mcp
150
+ ```
151
+
152
+ The tunnel scripts support `cloudflared`, `ngrok`, and Microsoft Dev Tunnel. If the selected tunnel CLI is missing, the script asks before installing it:
153
+
154
+ ```bash
155
+ scripts/tunnel.sh cloudflared /path/to/repo
156
+ scripts/tunnel.sh ngrok /path/to/repo
157
+ scripts/tunnel.sh devtunnel /path/to/repo
158
+ ```
159
+
160
+ For clients that support custom headers, use bearer-token auth with `Authorization: Bearer <token>`. Clients that cannot send custom bearer headers should use anonymous `read-only` mode only for local/testing tunnels, or be placed behind an external auth proxy for production use.
161
+
162
+ See [docs/remote-mcp.md](docs/remote-mcp.md) for the exact modes and security notes.
163
+
164
+ ## Tool Profiles
165
+
166
+ - `full`: exposes all tools with truthful annotations. This is the default for backward compatibility.
167
+ - `read-only`: recommended for remote or safe-mode clients; exposes only inspection tools, git read tools, image viewing, and default-cwd helpers.
168
+ - `compat-readonly-all`: exposes all tools but advertises every tool as read-only for clients that gate availability on `readOnlyHint`. This is not a safety mode; mutation-capable tools such as `apply_patch`, `exec_command`, `write_stdin`, and `kill_session` can still mutate local state.
169
+
170
+ ## Tools
171
+
172
+ P0 tools exposed by default:
173
+
174
+ - `server_info`
175
+ - `get_default_cwd`
176
+ - `set_default_cwd`
177
+ - `read_file`
178
+ - `list_dir`
179
+ - `list_files`
180
+ - `search_text`
181
+ - `apply_patch`
182
+ - `exec_command`
183
+ - `write_stdin`
184
+ - `kill_session`
185
+ - `git_status`
186
+ - `git_diff`
187
+ - `git_log`
188
+ - `git_show`
189
+ - `git_blame`
190
+ - `request_permissions`
191
+
192
+ Additional image tool exposed by default:
193
+
194
+ - `view_image`
195
+
196
+ For input/output schemas and result envelopes, see [docs/tools-and-schemas.md](docs/tools-and-schemas.md) and [docs/profile-v0.1.md](docs/profile-v0.1.md).
197
+
198
+ ## Safety Boundary
199
+
200
+ The runtime binds one workspace root per server process. Paths are workspace-relative by default. Absolute paths, `..` traversal, and symlink escapes are rejected. Recursive listing/search excludes `.git`, `.reference`, `node_modules`, `target`, `dist`, build outputs, virtualenvs, and common caches by default.
201
+
202
+ `exec_command` runs under policy controls with workspace-bound cwd, timeout, output caps, sensitive-value and loader/startup environment rejection, destructive command checks, network-looking command checks, shell-expansion permission gates, indirect absolute-path checks, cancellation/kill cleanup, session deadline watchdogs, and bounded session buffers. On Linux hosts with Landlock support it also applies filesystem confinement; on Windows, macOS, or Linux hosts without Landlock, command results include a warning and external sandboxing is required before running untrusted commands. This is still not a complete OS/container sandbox; see [SECURITY.md](SECURITY.md).
203
+
204
+ `--dangerously-skip-all-permissions` disables the permission gates above for operators who accept that risk. Do not use it for untrusted workspaces or untrusted MCP clients.
205
+
206
+ ## Compliance
207
+
208
+ ```bash
209
+ make compliance
210
+ ```
211
+
212
+ Compliance and CI commands are documented in [docs/ci-and-tests.md](docs/ci-and-tests.md). The checked-in report files are generated artifacts; inspect their `suite` field before treating them as full compliance evidence.
213
+
214
+ ## Dogfood And Benchmark
215
+
216
+ Dogfood and SWE-bench notes live in [docs/dogfood.md](docs/dogfood.md), [docs/swe-bench.md](docs/swe-bench.md), and [BENCHMARK.md](BENCHMARK.md). This repository does not claim a model-generated SWE-bench leaderboard result.
217
+
218
+ ## Development Commands
219
+
220
+ ```bash
221
+ make lint
222
+ make typecheck
223
+ make test
224
+ make compliance
225
+ make ci
226
+ ```
227
+
228
+ See [docs/ci-and-tests.md](docs/ci-and-tests.md) for the full test matrix.
229
+
230
+ ## License
231
+
232
+ This project is source-available, not open source. See [LICENSE](LICENSE).
233
+ Internal evaluation, development, testing, and security review are permitted;
234
+ redistribution, hosted third-party service use, and production commercial use
235
+ require prior written permission.
@@ -0,0 +1,214 @@
1
+ # Coding Tools MCP
2
+
3
+ Coding Tools MCP is a model-neutral coding-agent runtime MCP server. It exposes local coding primitives to any MCP client:
4
+
5
+ ```text
6
+ inspect repo -> search/read files -> apply structured patches -> run tests/commands
7
+ -> interact with stdin sessions -> inspect git status/diff
8
+ ```
9
+
10
+ It is not a prompt wrapper. It does not expose external agent accounts, memory, cloud tasks, web search, image generation, model routing, plugin marketplace, or subagent orchestration as MCP tools.
11
+
12
+ ## Documentation Map
13
+
14
+ - [Quickstart](docs/quickstart.md)
15
+ - [MCP client configuration](docs/mcp-client-config.md)
16
+ - [Remote MCP](docs/remote-mcp.md)
17
+ - [Tools and schemas](docs/tools-and-schemas.md)
18
+ - [Security policy](SECURITY.md)
19
+ - [CI and test commands](docs/ci-and-tests.md)
20
+ - [Dogfood](docs/dogfood.md)
21
+ - [SWE-bench evaluation](docs/swe-bench.md)
22
+ - [Known limitations](docs/limitations.md)
23
+ - [Troubleshooting](docs/troubleshooting.md)
24
+ - [Competitive analysis](docs/competitive-analysis.md)
25
+ - Normative MCP runtime profile: [docs/profile-v0.1.md](docs/profile-v0.1.md)
26
+
27
+ ## Quickstart
28
+
29
+ Run directly with `uvx` against the current directory:
30
+
31
+ ```bash
32
+ uvx coding-tools-mcp --workspace .
33
+ ```
34
+
35
+ Use stdio for MCP clients:
36
+
37
+ ```bash
38
+ uvx coding-tools-mcp --stdio --workspace /path/to/repo
39
+ ```
40
+
41
+ If you are working from this checkout instead of a published package:
42
+
43
+ ```bash
44
+ cd /root/coding-tools-mcp
45
+ python -m pip install -e ".[dev]"
46
+ coding-tools-mcp --workspace /path/to/repo --host 127.0.0.1 --port 8765
47
+ ```
48
+
49
+ Install the optional image extra when you want `view_image` auto-resize support:
50
+
51
+ ```bash
52
+ python -m pip install -e ".[image]"
53
+ ```
54
+
55
+ HTTP endpoint:
56
+
57
+ ```text
58
+ http://127.0.0.1:8765/mcp
59
+ ```
60
+
61
+ Stdio:
62
+
63
+ ```bash
64
+ coding-tools-mcp --stdio --workspace /path/to/repo
65
+ ```
66
+
67
+ Set `CODING_TOOLS_MCP_TRACE=1` to emit redacted JSON tool-call trace events to stderr for local debugging. Logs stay off stdout so stdio JSON-RPC remains clean.
68
+
69
+ If your MCP client does not support permission elicitation and you explicitly want permission-gated operations to run, start with:
70
+
71
+ ```bash
72
+ coding-tools-mcp --dangerously-skip-all-permissions --workspace /path/to/repo
73
+ ```
74
+
75
+ This auto-grants permission-gated operations such as network-looking commands, destructive commands, shell expansion, and sensitive env passed through `exec_command`. Workspace path boundaries still apply.
76
+
77
+ ## MCP Client Examples
78
+
79
+ Generic stdio client:
80
+
81
+ ```toml
82
+ [mcp_servers.coding_tools]
83
+ command = "uvx"
84
+ args = ["coding-tools-mcp", "--stdio", "--workspace", "/path/to/repo"]
85
+ ```
86
+
87
+ Claude Code:
88
+
89
+ ```json
90
+ {
91
+ "mcpServers": {
92
+ "coding-tools": {
93
+ "command": "uvx",
94
+ "args": ["coding-tools-mcp", "--stdio", "--workspace", "/path/to/repo"]
95
+ }
96
+ }
97
+ }
98
+ ```
99
+
100
+ Cursor:
101
+
102
+ ```json
103
+ {
104
+ "mcpServers": {
105
+ "coding-tools": {
106
+ "command": "uvx",
107
+ "args": ["coding-tools-mcp", "--stdio", "--workspace", "/path/to/repo"]
108
+ }
109
+ }
110
+ }
111
+ ```
112
+
113
+ Generic Streamable HTTP clients should use MCP protocol version `2025-06-18` and point at `http://127.0.0.1:8765/mcp`.
114
+
115
+ ## Remote MCP
116
+
117
+ For remote MCP clients and local development over an HTTPS tunnel, keep the server bound to loopback and expose the tunnel URL with the safest profile your client can use. Anonymous tunnel testing should use `read-only` mode:
118
+
119
+ ```bash
120
+ CODING_TOOLS_MCP_AUTH_MODE=noauth \
121
+ CODING_TOOLS_MCP_TOOL_PROFILE=read-only \
122
+ ./scripts/tunnel.sh cloudflared /path/to/repo
123
+ ```
124
+
125
+ Configure the remote MCP client with the HTTPS tunnel URL:
126
+
127
+ ```text
128
+ URL: https://<tunnel-host>/mcp
129
+ ```
130
+
131
+ The tunnel scripts support `cloudflared`, `ngrok`, and Microsoft Dev Tunnel. If the selected tunnel CLI is missing, the script asks before installing it:
132
+
133
+ ```bash
134
+ scripts/tunnel.sh cloudflared /path/to/repo
135
+ scripts/tunnel.sh ngrok /path/to/repo
136
+ scripts/tunnel.sh devtunnel /path/to/repo
137
+ ```
138
+
139
+ For clients that support custom headers, use bearer-token auth with `Authorization: Bearer <token>`. Clients that cannot send custom bearer headers should use anonymous `read-only` mode only for local/testing tunnels, or be placed behind an external auth proxy for production use.
140
+
141
+ See [docs/remote-mcp.md](docs/remote-mcp.md) for the exact modes and security notes.
142
+
143
+ ## Tool Profiles
144
+
145
+ - `full`: exposes all tools with truthful annotations. This is the default for backward compatibility.
146
+ - `read-only`: recommended for remote or safe-mode clients; exposes only inspection tools, git read tools, image viewing, and default-cwd helpers.
147
+ - `compat-readonly-all`: exposes all tools but advertises every tool as read-only for clients that gate availability on `readOnlyHint`. This is not a safety mode; mutation-capable tools such as `apply_patch`, `exec_command`, `write_stdin`, and `kill_session` can still mutate local state.
148
+
149
+ ## Tools
150
+
151
+ P0 tools exposed by default:
152
+
153
+ - `server_info`
154
+ - `get_default_cwd`
155
+ - `set_default_cwd`
156
+ - `read_file`
157
+ - `list_dir`
158
+ - `list_files`
159
+ - `search_text`
160
+ - `apply_patch`
161
+ - `exec_command`
162
+ - `write_stdin`
163
+ - `kill_session`
164
+ - `git_status`
165
+ - `git_diff`
166
+ - `git_log`
167
+ - `git_show`
168
+ - `git_blame`
169
+ - `request_permissions`
170
+
171
+ Additional image tool exposed by default:
172
+
173
+ - `view_image`
174
+
175
+ For input/output schemas and result envelopes, see [docs/tools-and-schemas.md](docs/tools-and-schemas.md) and [docs/profile-v0.1.md](docs/profile-v0.1.md).
176
+
177
+ ## Safety Boundary
178
+
179
+ The runtime binds one workspace root per server process. Paths are workspace-relative by default. Absolute paths, `..` traversal, and symlink escapes are rejected. Recursive listing/search excludes `.git`, `.reference`, `node_modules`, `target`, `dist`, build outputs, virtualenvs, and common caches by default.
180
+
181
+ `exec_command` runs under policy controls with workspace-bound cwd, timeout, output caps, sensitive-value and loader/startup environment rejection, destructive command checks, network-looking command checks, shell-expansion permission gates, indirect absolute-path checks, cancellation/kill cleanup, session deadline watchdogs, and bounded session buffers. On Linux hosts with Landlock support it also applies filesystem confinement; on Windows, macOS, or Linux hosts without Landlock, command results include a warning and external sandboxing is required before running untrusted commands. This is still not a complete OS/container sandbox; see [SECURITY.md](SECURITY.md).
182
+
183
+ `--dangerously-skip-all-permissions` disables the permission gates above for operators who accept that risk. Do not use it for untrusted workspaces or untrusted MCP clients.
184
+
185
+ ## Compliance
186
+
187
+ ```bash
188
+ make compliance
189
+ ```
190
+
191
+ Compliance and CI commands are documented in [docs/ci-and-tests.md](docs/ci-and-tests.md). The checked-in report files are generated artifacts; inspect their `suite` field before treating them as full compliance evidence.
192
+
193
+ ## Dogfood And Benchmark
194
+
195
+ Dogfood and SWE-bench notes live in [docs/dogfood.md](docs/dogfood.md), [docs/swe-bench.md](docs/swe-bench.md), and [BENCHMARK.md](BENCHMARK.md). This repository does not claim a model-generated SWE-bench leaderboard result.
196
+
197
+ ## Development Commands
198
+
199
+ ```bash
200
+ make lint
201
+ make typecheck
202
+ make test
203
+ make compliance
204
+ make ci
205
+ ```
206
+
207
+ See [docs/ci-and-tests.md](docs/ci-and-tests.md) for the full test matrix.
208
+
209
+ ## License
210
+
211
+ This project is source-available, not open source. See [LICENSE](LICENSE).
212
+ Internal evaluation, development, testing, and security review are permitted;
213
+ redistribution, hosted third-party service use, and production commercial use
214
+ require prior written permission.
@@ -0,0 +1,3 @@
1
+ """Coding Tools MCP server package."""
2
+
3
+ __version__ = "0.1.3"
@@ -0,0 +1,7 @@
1
+ from __future__ import annotations
2
+
3
+ from .server import main
4
+
5
+
6
+ if __name__ == "__main__":
7
+ raise SystemExit(main())
@@ -0,0 +1,64 @@
1
+ from __future__ import annotations
2
+
3
+ import ctypes
4
+ import os
5
+ import shutil
6
+ import sys
7
+ from typing import Any
8
+
9
+
10
+ PR_SET_NO_NEW_PRIVS = 38
11
+ SYS_LANDLOCK_RESTRICT_SELF = 446
12
+
13
+ _LIBC: Any | None = None
14
+
15
+
16
+ def landlock_libc() -> Any:
17
+ global _LIBC
18
+ if _LIBC is None:
19
+ _LIBC = ctypes.CDLL(None, use_errno=True)
20
+ return _LIBC
21
+
22
+
23
+ def libc_syscall(number: int, *args: object) -> int:
24
+ ctypes.set_errno(0)
25
+ return int(landlock_libc().syscall(number, *args))
26
+
27
+
28
+ def fail(message: str) -> int:
29
+ print(message, file=sys.stderr)
30
+ return 126
31
+
32
+
33
+ def main(argv: list[str] | None = None) -> int:
34
+ if sys.platform != "linux":
35
+ return fail("landlock_exec is only supported on Linux")
36
+ args = list(sys.argv[1:] if argv is None else argv)
37
+ if len(args) != 2:
38
+ return fail("landlock_exec requires: <ruleset-fd> <command>")
39
+ try:
40
+ ruleset_fd = int(args[0])
41
+ except ValueError:
42
+ return fail("landlock_exec received an invalid ruleset fd")
43
+ cmd = args[1]
44
+
45
+ rc = int(landlock_libc().prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0))
46
+ if rc != 0:
47
+ err = ctypes.get_errno()
48
+ return fail(f"failed to set no_new_privs before Landlock restrict: {os.strerror(err)}")
49
+ rc = libc_syscall(SYS_LANDLOCK_RESTRICT_SELF, ruleset_fd, 0)
50
+ if rc != 0:
51
+ err = ctypes.get_errno()
52
+ return fail(f"failed to apply Landlock restrict_self: {os.strerror(err)}")
53
+ try:
54
+ os.close(ruleset_fd)
55
+ except OSError:
56
+ pass
57
+
58
+ shell = os.environ.get("SHELL") or shutil.which("sh") or "/bin/sh"
59
+ os.execvpe(shell, [shell, "-c", cmd], os.environ)
60
+ return 127
61
+
62
+
63
+ if __name__ == "__main__":
64
+ raise SystemExit(main())