pyddock 0.3.7__tar.gz → 0.4.1__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.
- pyddock-0.4.1/.hypothesis/constants/004ea90a2254fd73 +4 -0
- pyddock-0.4.1/.hypothesis/constants/329a7eef502f7936 +4 -0
- pyddock-0.4.1/.hypothesis/constants/38dc47fb9773e379 +4 -0
- pyddock-0.4.1/.hypothesis/constants/391884b94a7115c7 +4 -0
- pyddock-0.4.1/.hypothesis/constants/3bb4e9ec203536d4 +4 -0
- pyddock-0.4.1/.hypothesis/constants/40349f5d8c70a617 +4 -0
- pyddock-0.4.1/.hypothesis/constants/5483fac6aa469e79 +4 -0
- pyddock-0.4.1/.hypothesis/constants/660384f7453fa1c6 +4 -0
- pyddock-0.4.1/.hypothesis/constants/710dd4cbc0f8f2b9 +4 -0
- pyddock-0.4.1/.hypothesis/constants/a5ac1ac916f50c87 +4 -0
- pyddock-0.4.1/.hypothesis/constants/b1a15c14c1b1e1a5 +4 -0
- pyddock-0.4.1/.hypothesis/constants/e6bd84b4fb5294e0 +4 -0
- pyddock-0.4.1/.hypothesis/tmp/tmp2j0w5x7e +0 -0
- pyddock-0.4.1/.hypothesis/tmp/tmpa_l48ktk +0 -0
- pyddock-0.4.1/.hypothesis/tmp/tmpfopee85f +0 -0
- pyddock-0.4.1/.hypothesis/tmp/tmpgt8q202z +0 -0
- pyddock-0.4.1/.hypothesis/tmp/tmpuczeruwd +0 -0
- pyddock-0.4.1/.hypothesis/tmp/tmpvztf8hes +0 -0
- pyddock-0.4.1/.hypothesis/tmp/tmpzz05pj63 +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/PKG-INFO +50 -5
- {pyddock-0.3.7 → pyddock-0.4.1}/README.md +48 -3
- pyddock-0.4.1/docs/mcp-tool-access.md +274 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/pyproject.toml +2 -2
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/_audit_enforcement.py +82 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/_enforcement.py +15 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/_fs_enforcement.py +25 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/_subprocess_patch.py +21 -14
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/config.py +161 -1
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/default_config.toml +37 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/executor.py +79 -1
- pyddock-0.4.1/src/pyddock/mcp_definitions.py +384 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/server.py +135 -6
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/shell_executor.py +208 -78
- pyddock-0.4.1/src/pyddock/shim/__init__.py +7 -0
- pyddock-0.4.1/src/pyddock/shim/pyddock_mcp.py +388 -0
- pyddock-0.4.1/src/pyddock/tools/mcp_call.py +77 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/venv_manager.py +89 -0
- pyddock-0.4.1/tests/test_mcp.py +928 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_shell_executor.py +149 -9
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_subst_trusted_path.py +7 -0
- pyddock-0.4.1/uv.lock +657 -0
- pyddock-0.3.7/uv.lock +0 -582
- {pyddock-0.3.7 → pyddock-0.4.1}/.gitignore +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/.gitignore +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/0527dc28646c9360 +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/106d94c8123c0256 +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/1685e03b3aa38c02 +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/1deca112ec6f2f3c +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/2488a3a95c48acfb +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/2a94d83a13979745 +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/30ee1be194c33a1d +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/453881856851f311 +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/499f1d5a639a382a +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/4ee6f24fa151b65d +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/5b1b2189b70f5ef2 +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/5d6f8b26b2137fe1 +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/5f020be48d90847d +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/61f9b905d7da14e0 +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/6627988645b1286c +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/671fefe2f5d9935c +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/67a7f4ab2d372f23 +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/6c6f5083ece3f86b +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/805cbcbb07e3332d +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/827e18b40f235443 +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/8401e4039d635fbc +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/8490e7baefc8c8c3 +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/93108f7a5abfd484 +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/a7c132b836381d0d +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/b395547bc71e5c52 +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/ca50661510a40488 +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/d115f833e13f93f9 +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/df249c25d70870dc +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/e2c54b7949469c07 +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/e78de40070f52f91 +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/constants/e8cd7befaa4dd723 +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/tmp/tmpl8oe65gb +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/tmp/tmpqwper0dp +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/unicode_data/15.1.0/charmap.json.gz +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/unicode_data/15.1.0/codec-utf-8.json.gz +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/unicode_data/16.0.0/charmap.json.gz +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/.hypothesis/unicode_data/16.0.0/codec-utf-8.json.gz +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/LICENSE +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/publish-to-pypi.ps1 +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/__init__.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/_base.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/_import_hook.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/_prewarm.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/_process_utils.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/_proxies.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/_runtime.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/ast_validator.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/cli.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/script_registry.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/tools/__init__.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/tools/fs_append.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/tools/fs_delete.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/tools/fs_find.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/tools/fs_grep.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/tools/read_file.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/tools/stat_file.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/src/pyddock/tools/str_replace.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/__init__.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/_config_helpers.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_ast_properties.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_attr_reflection_hardening.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_audit_hook_backstop.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_chmod_integration.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_config.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_deny_always_wins.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_deny_messages.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_env_policy.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_executor.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_file_tools.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_filesystem_guards.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_jailbreak_regression.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_proxy_properties.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_realistic.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_runtime.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_sandbox_escape_hardening.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_security_guards.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_server.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_shell_arg_paths.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_shell_properties.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_subprocess_enforcement.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_subprocess_properties.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_trusted_prefixes_uv_cache.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_venv_recreation.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_venv_stamp.py +0 -0
- {pyddock-0.3.7 → pyddock-0.4.1}/tests/test_workspace_imports.py +0 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\_enforcement.py
|
|
2
|
+
# hypothesis_version: 6.163.0
|
|
3
|
+
|
|
4
|
+
['*', ', ', '.', '.pyddock', '<frozen', 'PathLike', '_', '__doc__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '_current_frames', '_getframe', '_pyddock_format_tb', 'allow', 'allowed', 'altsep', 'argv', 'ast', 'attrgetter', 'block_attributes', 'byteorder', 'class_allow', 'class_deny', 'cpu_count', 'curdir', 'deny', 'deny_messages', 'devnull', 'exc_info', 'exec_prefix', 'executable', 'exit', 'extsep', 'float_info', 'fromlist', 'fspath', 'fstat', 'getattr', 'getcwd', 'getdefaultencoding', 'getenv', 'getlogin', 'getpid', 'getrecursionlimit', 'hash_info', 'import', 'imports', 'int_info', 'level', 'linesep', 'listdir', 'lstat', 'maxsize', 'message', 'meta_path', 'mode', 'module_allow', 'module_deny', 'name', 'os', 'os.path', 'pardir', 'path', 'path_hooks', 'path_importer_cache', 'pathsep', 'pattern', 'platform', 'prefix', 'restrictions', 'scandir', 'sep', 'stat', 'stderr', 'stdin', 'stdout', 'sys', 'threading', 'urandom', 'venv', 'version', 'version_info', 'walk', 'workspace']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\executor.py
|
|
2
|
+
# hypothesis_version: 6.163.0
|
|
3
|
+
|
|
4
|
+
[' )', ' del _pyddock_mcp', ' print(', '#', '.py', '__PYDDOCK_RESULT__', '_last_expr = None', '_pyddock_bootstrap_', 'allow', 'allowed', 'arg_paths', 'args', 'ast', 'audit', 'block_attributes', 'block_calls', 'class_allow', 'class_deny', 'command', 'default', 'deny', 'deny_messages', 'description', 'disposition', 'env', 'exec(_code, _ns)', 'execution', 'filesystem', 'guards', 'import ast as _ast', 'import sys', 'imports', 'mcp', 'message', 'mode', 'module_allow', 'module_deny', 'nt', 'output', 'pattern', 'readable_paths', 'replace', 'restrictions', 'servers', 'shell', 'shim_path', 'spawn_argvs', 'stderr', 'timeout', 'tools', 'try:', 'utf-8', 'w', 'workspace', 'writable_paths']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\_fs_enforcement.py
|
|
2
|
+
# hypothesis_version: 6.163.0
|
|
3
|
+
|
|
4
|
+
[511, 3584, '$', '*', ', ', '.', '.pyddock', '/', '<frozen', 'Lib', 'Path.chmod', 'Path.chmod()', 'Path.lchmod', 'Path.lchmod()', 'Path.mkdir', 'Path.open', 'Path.read_bytes', 'Path.read_text', 'Path.rename', 'Path.replace', 'Path.rmdir', 'Path.touch', 'Path.unlink', 'Path.write_bytes', 'Path.write_text', '\\', '\\.', '\\/', '\\\\', '^', '_io.FileIO', '_io.open', 'a', 'a+', 'a+b', 'a+t', 'ab', 'ab+', 'allow', 'at', 'at+', 'audit', 'audit.jsonl', 'builtins.open', 'command', 'deny', 'deny-agent', 'deny-all', 'disposition', 'env', 'filesystem', 'guards', 'imports', 'io.FileIO', 'io.open', 'lchmod', 'lib', 'link_to', 'mcp', 'mkdtemp', 'mkstemp', 'nt', 'nul', 'nul.', 'os', 'os.chmod()', 'pattern', 'r', 'r+', 'r+b', 'r+t', 'rb+', 'read', 'read-only', 'readable_paths', 'rt+', 'servers', 'shell', 'tempdir', 'tempfile', 'tmp', 'w', 'w+', 'w+b', 'w+t', 'wax+', 'wb', 'wb+', 'workspace', 'writable_paths', 'write', 'wt', 'wt+', 'x', 'x+', 'x+b', 'x+t', 'xb', 'xb+', 'xt', 'xt+']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\venv_manager.py
|
|
2
|
+
# hypothesis_version: 6.163.0
|
|
3
|
+
|
|
4
|
+
[300, '-c', '-e', '-m', '.pyddock', 'Lib', 'Scripts', '_is_gil_enabled', '_workspace_hashes', 'allowlist_hash', 'bin', 'freethreaded', 'gil', 'install', 'installed.json', 'interpreter_id', 'lib', 'mcp', 'mcp>=2,<3', 'pip', 'pyddock', 'pyddock_mcp.py', 'pyproject.toml', 'python', 'python.exe', 'pyvenv.cfg', 'setup.cfg', 'setup.py', 'shim', 'site-packages', 'utf-8', 'venv', 'venv_created', 'win32', 'workspace', '||']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\_fs_enforcement.py
|
|
2
|
+
# hypothesis_version: 6.163.0
|
|
3
|
+
|
|
4
|
+
[511, 3584, '$', '*', ', ', '.', '.pyddock', '/', '<frozen', 'Lib', 'Path.chmod', 'Path.chmod()', 'Path.lchmod', 'Path.lchmod()', 'Path.mkdir', 'Path.open', 'Path.read_bytes', 'Path.read_text', 'Path.rename', 'Path.replace', 'Path.rmdir', 'Path.touch', 'Path.unlink', 'Path.write_bytes', 'Path.write_text', '\\', '\\.', '\\/', '\\\\', '^', '_io.FileIO', '_io.open', 'a', 'a+', 'a+b', 'a+t', 'ab', 'ab+', 'allow', 'at', 'at+', 'audit', 'audit.jsonl', 'builtins.open', 'command', 'deny', 'deny-agent', 'deny-all', 'disposition', 'env', 'filesystem', 'guards', 'imports', 'io.FileIO', 'io.open', 'lchmod', 'lib', 'link_to', 'mcp', 'mkdtemp', 'mkstemp', 'nt', 'nul', 'nul.', 'os', 'os.chmod()', 'pattern', 'r', 'r+', 'r+b', 'r+t', 'rb+', 'read', 'read-only', 'readable_paths', 'rt+', 'servers', 'shell', 'tempdir', 'tempfile', 'tmp', 'w', 'w+', 'w+b', 'w+t', 'wax+', 'wb', 'wb+', 'workspace', 'writable_paths', 'write', 'wt', 'wt+', 'x', 'x+', 'x+b', 'x+t', 'xb', 'xb+', 'xt', 'xt+']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\mcp_definitions.py
|
|
2
|
+
# hypothesis_version: 6.163.0
|
|
3
|
+
|
|
4
|
+
['*', '.bat', '.cmd', '.cursor', '.exe', '.kiro', '.mcp.json', '.ps1', '.pyddock', '.vscode', '/', 'Lib', '\\', 'allow', 'args', 'command', 'deny-agent', 'deny-all', 'env', 'lib', 'mcp.json', 'mcpServers', 'read-only', 'servers', 'settings', 'tmp', 'url', 'utf-8', 'win32', 'workspace']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\server.py
|
|
2
|
+
# hypothesis_version: 6.163.0
|
|
3
|
+
|
|
4
|
+
['(none)', ', ', '--debug', '--workspace', '.py', '.pyddock', 'Configured commands:', 'Configured servers:', 'Modes:', 'Restrictions:', '_', '__main__', 'allow', 'arguments', 'content', 'context_lines', 'deny', 'end', 'end_line', 'exclude_regex', 'file_glob', 'file_regex', 'fs_append', 'fs_delete', 'fs_find', 'fs_grep', 'fs_readfile', 'fs_stat', 'fs_str_replace', 'grep_regex', 'max_results', 'max_results_per_file', 'mcp_call', 'newStr', 'oldStr', 'path', 'pyddock', 'pyddock serve', 'pyddock_mcp', 'read_file', 'run_mcp', 'run_python', 'run_shell', 'server', 'start', 'start_line', 'stat_file', 'stdio', 'store_true', 'str_replace', 'tmp', 'tool', 'utf-8', 'venv']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\mcp_definitions.py
|
|
2
|
+
# hypothesis_version: 6.163.0
|
|
3
|
+
|
|
4
|
+
['*', '.bat', '.cmd', '.cursor', '.exe', '.kiro', '.mcp.json', '.ps1', '.pyddock', '.vscode', '/', 'Lib', '\\', 'allow', 'args', 'command', 'deny-agent', 'deny-all', 'env', 'lib', 'mcp.json', 'mcpServers', 'read-only', 'servers', 'settings', 'tmp', 'url', 'utf-8', 'win32', 'workspace']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\shell_executor.py
|
|
2
|
+
# hypothesis_version: 6.163.0
|
|
3
|
+
|
|
4
|
+
['$', ', ', '-', '-ExecutionPolicy', '-File', '-NoProfile', '.', '.bat', '.ps1', '.py', '.pyddock', '.sh', '.~', '/', '//', '/c', ':', '=', 'Bypass', '\\', '\\.', '\\/', '\\\\', '^', 'bash', 'cmd', 'command', 'default', 'deny', 'deny pattern', 'does not exist', 'env', 'inert', 'is not a directory', 'items', 'no argument patterns', 'none', 'nt', 'output', 'powershell', 'pwsh', 'python', 'replace', 'snapshot', 'stderr', 'surrogateescape', 'tmp', 'utf-8', 'workspace']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\config.py
|
|
2
|
+
# hypothesis_version: 6.163.0
|
|
3
|
+
|
|
4
|
+
[30.0, 3600.0, '%s', ', ', '.', '.pyddock', '/', '[env]', '\\', 'agent-deny', 'allow', 'arg_paths', 'ast', 'audit', 'block_attributes', 'block_calls', 'class_allow', 'class_deny', 'command', 'default', 'default_config.toml', 'deny', 'deny-agent', 'deny-all', 'deny_messages', 'description', 'env', 'execution', 'filesystem', 'fs', 'fs-write', 'fs-write-pair', 'guards', 'imports', 'inert', 'max_timeout', 'mcp', 'mode', 'module_allow', 'module_deny', 'network', 'none', 'observe', 'protected', 'pyddock', 'pyddock.toml', 'read-only', 'readable_paths', 'restrictions', 'shell', 'snapshot', 'timeout', 'tools', 'utf-8', 'workspace', 'writable_paths']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\_audit_enforcement.py
|
|
2
|
+
# hypothesis_version: 6.163.0
|
|
3
|
+
|
|
4
|
+
[200, 300, 384, ' | ', '"', '*', '/', '<frozen', '<frozen importlib', '<unsummarizable>', 'AGENT', 'IMPORT', 'OTHER', 'O_APPEND', 'O_CREAT', 'O_RDWR', 'O_TRUNC', 'O_WRONLY', 'TRUSTED', '\\', 'agent-deny', 'allow', 'arg_paths', 'caller', 'command', 'decision', 'deny', 'detail', 'errors', 'event', 'fs', 'fs-write', 'fs-write-pair', 'fspath', 'import-exempt', 'mode', 'network', 'observe', 'open', 'os.system', 'pid', 'reentry', 'replace', 'shell', 'shim_path', 'socket.', 'spawn_argvs', 'subprocess.Popen', 'surrogateescape', 't', 'utf-8', 'workspace']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: C:\Dev\github\pyddock\src\pyddock\_subprocess_patch.py
|
|
2
|
+
# hypothesis_version: 6.163.0
|
|
3
|
+
|
|
4
|
+
['$', '(none configured)', ', ', 'Popen', '^', '_SafePopen', 'allow', 'arg_paths', 'command', 'cwd', 'deny', 'deny pattern', 'env', 'imports', 'mode', 'no argument patterns', 'os', 'shell', 'subprocess', 'subprocess.Popen', 'subprocess.run', 'workspace']
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyddock
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: MCP server that gives AI agents pre-approved Python, shell, and file I/O tools with declarative policy controls
|
|
5
5
|
Project-URL: Homepage, https://github.com/portablestew/pyddock
|
|
6
6
|
Project-URL: Repository, https://github.com/portablestew/pyddock
|
|
@@ -17,14 +17,14 @@ Classifier: Programming Language :: Python :: 3.14
|
|
|
17
17
|
Classifier: Topic :: Security
|
|
18
18
|
Classifier: Topic :: Software Development :: Libraries
|
|
19
19
|
Requires-Python: >=3.14
|
|
20
|
-
Requires-Dist: mcp
|
|
20
|
+
Requires-Dist: mcp<3,>=2
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
|
|
23
23
|
# pyddock
|
|
24
24
|
|
|
25
25
|
*py + paddock — an enclosed space where code can run freely within bounds. ([Worked great in Jurassic Park.](https://en.wikipedia.org/wiki/Jurassic_Park))*
|
|
26
26
|
|
|
27
|
-
MCP server that gives AI agents pre-approved `run_python`, `run_shell`, and file i/o tools. Safely replaces shell scripting for data processing, file analysis, computation, and external command execution — no user confirmation needed.
|
|
27
|
+
MCP server that gives AI agents pre-approved `run_python`, `run_shell`, `run_mcp`, and file i/o tools. Safely replaces shell scripting for data processing, file analysis, computation, and external command execution — no user confirmation needed.
|
|
28
28
|
|
|
29
29
|
## Why
|
|
30
30
|
|
|
@@ -53,7 +53,7 @@ pyddock provides Python execution and shell command access with declarative poli
|
|
|
53
53
|
"pyddock": {
|
|
54
54
|
"command": "uvx",
|
|
55
55
|
"args": ["pyddock", "serve", "--workspace", "<path-to-workspace>"],
|
|
56
|
-
"autoApprove": ["run_python","run_shell","fs_readfile","fs_stat","fs_find","fs_grep","fs_append","fs_delete","fs_str_replace"]
|
|
56
|
+
"autoApprove": ["run_python","run_shell","run_mcp","fs_readfile","fs_stat","fs_find","fs_grep","fs_append","fs_delete","fs_str_replace"]
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -77,10 +77,28 @@ The last expression in your snippet is captured as RESULT (like a Jupyter cell)
|
|
|
77
77
|
| `command` | string | Executable name or script path (must match a shell policy) |
|
|
78
78
|
| `args` | string[] | Arguments passed directly to the command (no shell interpretation) |
|
|
79
79
|
| `timeout` | number | Seconds (default: 30) |
|
|
80
|
+
| `cwd` | string | Working directory, relative to the workspace root (default: the workspace root) |
|
|
80
81
|
|
|
81
82
|
Commands are executed directly — no shell interpretation, pipes, redirects, chaining, or variable expansion. Only commands matching a `[shell.*]` policy in your config are permitted. The tool is only registered when at least one `[shell.*]` section exists in the config.
|
|
82
83
|
|
|
83
|
-
Script files get automatic interpreter mapping: `.ps1` → powershell, `.py` → python, `.sh` → bash, `.bat` → cmd /c.
|
|
84
|
+
Script files get automatic interpreter mapping: `.ps1` → powershell, `.py` → python, `.sh` → bash, `.bat` → cmd /c. A script or path-like command is resolved relative to the workspace root, never to `cwd`, so `cwd` cannot change which file executes.
|
|
85
|
+
|
|
86
|
+
`cwd` is subject to the command's `arg_paths` policy — normally it must be an existing directory inside the workspace and outside protected directories. Relative path arguments are resolved by the command against `cwd`, and are path-checked against both `cwd` and the workspace root.
|
|
87
|
+
|
|
88
|
+
## Tool: `run_mcp`
|
|
89
|
+
|
|
90
|
+
| Parameter | Type | Description |
|
|
91
|
+
|-----------|------|-------------|
|
|
92
|
+
| `server` | string | Configured server name. Omit to list servers and their tool policy |
|
|
93
|
+
| `tool` | string | Tool name. Omit to list that server's permitted tools with input schemas |
|
|
94
|
+
| `arguments` | object \| string | Tool arguments (a JSON string is also accepted) |
|
|
95
|
+
| `timeout` | number | Seconds (default: 30) |
|
|
96
|
+
|
|
97
|
+
Calls a pre-approved tool on another MCP server. Only registered when at least one `[mcp.*]` section resolves to a real server definition. The same capability is available inside `run_python` as `pyddock_mcp.call(server, tool, arguments)`, which is the preferred form for anything beyond a single lookup: a 60KB tool result parsed down to three numbers in a snippet never enters the agent's context at all.
|
|
98
|
+
|
|
99
|
+
This is one dispatcher, not a gateway — other servers' tools are never registered as individual pyddock tools, so your agent's tool list and the host's tool budget stay untouched. Intended for MCP servers you cannot replace with a library: host-provided tools with no API behind them, org-internal servers, and local dev tooling. For anything with a decent Python SDK, call the API directly instead.
|
|
100
|
+
|
|
101
|
+
See [docs/mcp-tool-access.md](docs/mcp-tool-access.md) for the design and threat model.
|
|
84
102
|
|
|
85
103
|
## Output format
|
|
86
104
|
|
|
@@ -295,6 +313,33 @@ Args are space-joined before matching: `["filelog", "//depot/..."]` becomes `"fi
|
|
|
295
313
|
|
|
296
314
|
When `subprocess` is enabled in `[imports]`, `run_python` code can call `subprocess.run([...])` with the same policy enforcement and interpreter mapping. This is useful for composing multiple commands, processing output between calls, or passing environment variables dynamically.
|
|
297
315
|
|
|
316
|
+
## MCP Policies
|
|
317
|
+
|
|
318
|
+
JSON says what can be launched; TOML says what may be called. Nothing in a JSON file ever grants anything.
|
|
319
|
+
|
|
320
|
+
**What may be called** comes only from `[mcp.<name>]` sections in your config:
|
|
321
|
+
|
|
322
|
+
```toml
|
|
323
|
+
[mcp.github]
|
|
324
|
+
description = "Read-only GitHub queries. Tools include get_issue, get_pull_request, list_commits."
|
|
325
|
+
tools = { "get_.*" = true, "list_.*" = true, "search_.*" = true }
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
- **tools**: pattern → bool, full-match anchored. Deny always wins (every `false` is checked before any `true`), and an unmatched tool is denied. Keep these read-only-shaped: nothing structurally prevents this policy from exceeding what your host permits.
|
|
329
|
+
- **description**: surfaced in the tool description. Descriptions are policy-only and never fetched from the server, so this is where you tell the agent what the patterns cover — saving it a discovery call, and keeping third-party tool descriptions out of your agent's always-present context.
|
|
330
|
+
|
|
331
|
+
Presence of the section is the only switch. Omitting `[mcp]` entirely disables the feature and `run_mcp` is not registered.
|
|
332
|
+
|
|
333
|
+
**What gets launched** comes from JSON definition files, scanned in this order (later wins): `~/.kiro/settings/mcp.json`, `~/.cursor/mcp.json`, `<workspace>/.kiro/settings/mcp.json`, `.vscode/mcp.json`, `.cursor/mcp.json`, `.mcp.json`, `.pyddock/mcp.json`.
|
|
334
|
+
|
|
335
|
+
Only `command`, `args`, and `env` are read. Host settings such as `disabled` and `autoApprove` are ignored — pyddock does not inherit another agent's trust decisions. A server disabled in your host config is still reachable via `run_mcp` if a `[mcp.*]` section enables it, which is deliberate: disabling a chatty MCP for direct agent use while keeping it available from Python is the point.
|
|
336
|
+
|
|
337
|
+
A definition file that agent code could write is refused with a warning, because it would let a snippet redirect an already-permitted server. This is checked against your *actual* filesystem policy, so widening `writable_paths` deactivates a location on its own. `.pyddock/mcp.json` always qualifies; `.kiro/settings` and `.claude/settings` qualify via their default `read-only` guards. Add a `read-only` guard to load definitions from anywhere else.
|
|
338
|
+
|
|
339
|
+
Servers are launched inside the sandbox as descendants of the snippet process, and the spawn allowlist is *derived* from (TOML-enabled servers ∩ scanned definitions) — never written by hand as `[shell.*]` sections. Commands are resolved to an absolute path at load time, so the directory the executable lives in becomes write-protected, same as a path-like shell policy. An MCP server is otherwise an ordinary unconstrained process, and `npx -y @foo/server` fetches and executes registry code, so pinned versions in definitions are worth having.
|
|
340
|
+
|
|
341
|
+
Current limits: stdio servers only (no `url`), tool-name gating only (no argument-level policy), no `${VAR}` interpolation in definition `env`, and the snippet timeout is the outer bound. Connections are request-scoped — one invocation, then torn down.
|
|
342
|
+
|
|
298
343
|
## CLI
|
|
299
344
|
|
|
300
345
|
```sh
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
*py + paddock — an enclosed space where code can run freely within bounds. ([Worked great in Jurassic Park.](https://en.wikipedia.org/wiki/Jurassic_Park))*
|
|
4
4
|
|
|
5
|
-
MCP server that gives AI agents pre-approved `run_python`, `run_shell`, and file i/o tools. Safely replaces shell scripting for data processing, file analysis, computation, and external command execution — no user confirmation needed.
|
|
5
|
+
MCP server that gives AI agents pre-approved `run_python`, `run_shell`, `run_mcp`, and file i/o tools. Safely replaces shell scripting for data processing, file analysis, computation, and external command execution — no user confirmation needed.
|
|
6
6
|
|
|
7
7
|
## Why
|
|
8
8
|
|
|
@@ -31,7 +31,7 @@ pyddock provides Python execution and shell command access with declarative poli
|
|
|
31
31
|
"pyddock": {
|
|
32
32
|
"command": "uvx",
|
|
33
33
|
"args": ["pyddock", "serve", "--workspace", "<path-to-workspace>"],
|
|
34
|
-
"autoApprove": ["run_python","run_shell","fs_readfile","fs_stat","fs_find","fs_grep","fs_append","fs_delete","fs_str_replace"]
|
|
34
|
+
"autoApprove": ["run_python","run_shell","run_mcp","fs_readfile","fs_stat","fs_find","fs_grep","fs_append","fs_delete","fs_str_replace"]
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -55,10 +55,28 @@ The last expression in your snippet is captured as RESULT (like a Jupyter cell)
|
|
|
55
55
|
| `command` | string | Executable name or script path (must match a shell policy) |
|
|
56
56
|
| `args` | string[] | Arguments passed directly to the command (no shell interpretation) |
|
|
57
57
|
| `timeout` | number | Seconds (default: 30) |
|
|
58
|
+
| `cwd` | string | Working directory, relative to the workspace root (default: the workspace root) |
|
|
58
59
|
|
|
59
60
|
Commands are executed directly — no shell interpretation, pipes, redirects, chaining, or variable expansion. Only commands matching a `[shell.*]` policy in your config are permitted. The tool is only registered when at least one `[shell.*]` section exists in the config.
|
|
60
61
|
|
|
61
|
-
Script files get automatic interpreter mapping: `.ps1` → powershell, `.py` → python, `.sh` → bash, `.bat` → cmd /c.
|
|
62
|
+
Script files get automatic interpreter mapping: `.ps1` → powershell, `.py` → python, `.sh` → bash, `.bat` → cmd /c. A script or path-like command is resolved relative to the workspace root, never to `cwd`, so `cwd` cannot change which file executes.
|
|
63
|
+
|
|
64
|
+
`cwd` is subject to the command's `arg_paths` policy — normally it must be an existing directory inside the workspace and outside protected directories. Relative path arguments are resolved by the command against `cwd`, and are path-checked against both `cwd` and the workspace root.
|
|
65
|
+
|
|
66
|
+
## Tool: `run_mcp`
|
|
67
|
+
|
|
68
|
+
| Parameter | Type | Description |
|
|
69
|
+
|-----------|------|-------------|
|
|
70
|
+
| `server` | string | Configured server name. Omit to list servers and their tool policy |
|
|
71
|
+
| `tool` | string | Tool name. Omit to list that server's permitted tools with input schemas |
|
|
72
|
+
| `arguments` | object \| string | Tool arguments (a JSON string is also accepted) |
|
|
73
|
+
| `timeout` | number | Seconds (default: 30) |
|
|
74
|
+
|
|
75
|
+
Calls a pre-approved tool on another MCP server. Only registered when at least one `[mcp.*]` section resolves to a real server definition. The same capability is available inside `run_python` as `pyddock_mcp.call(server, tool, arguments)`, which is the preferred form for anything beyond a single lookup: a 60KB tool result parsed down to three numbers in a snippet never enters the agent's context at all.
|
|
76
|
+
|
|
77
|
+
This is one dispatcher, not a gateway — other servers' tools are never registered as individual pyddock tools, so your agent's tool list and the host's tool budget stay untouched. Intended for MCP servers you cannot replace with a library: host-provided tools with no API behind them, org-internal servers, and local dev tooling. For anything with a decent Python SDK, call the API directly instead.
|
|
78
|
+
|
|
79
|
+
See [docs/mcp-tool-access.md](docs/mcp-tool-access.md) for the design and threat model.
|
|
62
80
|
|
|
63
81
|
## Output format
|
|
64
82
|
|
|
@@ -273,6 +291,33 @@ Args are space-joined before matching: `["filelog", "//depot/..."]` becomes `"fi
|
|
|
273
291
|
|
|
274
292
|
When `subprocess` is enabled in `[imports]`, `run_python` code can call `subprocess.run([...])` with the same policy enforcement and interpreter mapping. This is useful for composing multiple commands, processing output between calls, or passing environment variables dynamically.
|
|
275
293
|
|
|
294
|
+
## MCP Policies
|
|
295
|
+
|
|
296
|
+
JSON says what can be launched; TOML says what may be called. Nothing in a JSON file ever grants anything.
|
|
297
|
+
|
|
298
|
+
**What may be called** comes only from `[mcp.<name>]` sections in your config:
|
|
299
|
+
|
|
300
|
+
```toml
|
|
301
|
+
[mcp.github]
|
|
302
|
+
description = "Read-only GitHub queries. Tools include get_issue, get_pull_request, list_commits."
|
|
303
|
+
tools = { "get_.*" = true, "list_.*" = true, "search_.*" = true }
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
- **tools**: pattern → bool, full-match anchored. Deny always wins (every `false` is checked before any `true`), and an unmatched tool is denied. Keep these read-only-shaped: nothing structurally prevents this policy from exceeding what your host permits.
|
|
307
|
+
- **description**: surfaced in the tool description. Descriptions are policy-only and never fetched from the server, so this is where you tell the agent what the patterns cover — saving it a discovery call, and keeping third-party tool descriptions out of your agent's always-present context.
|
|
308
|
+
|
|
309
|
+
Presence of the section is the only switch. Omitting `[mcp]` entirely disables the feature and `run_mcp` is not registered.
|
|
310
|
+
|
|
311
|
+
**What gets launched** comes from JSON definition files, scanned in this order (later wins): `~/.kiro/settings/mcp.json`, `~/.cursor/mcp.json`, `<workspace>/.kiro/settings/mcp.json`, `.vscode/mcp.json`, `.cursor/mcp.json`, `.mcp.json`, `.pyddock/mcp.json`.
|
|
312
|
+
|
|
313
|
+
Only `command`, `args`, and `env` are read. Host settings such as `disabled` and `autoApprove` are ignored — pyddock does not inherit another agent's trust decisions. A server disabled in your host config is still reachable via `run_mcp` if a `[mcp.*]` section enables it, which is deliberate: disabling a chatty MCP for direct agent use while keeping it available from Python is the point.
|
|
314
|
+
|
|
315
|
+
A definition file that agent code could write is refused with a warning, because it would let a snippet redirect an already-permitted server. This is checked against your *actual* filesystem policy, so widening `writable_paths` deactivates a location on its own. `.pyddock/mcp.json` always qualifies; `.kiro/settings` and `.claude/settings` qualify via their default `read-only` guards. Add a `read-only` guard to load definitions from anywhere else.
|
|
316
|
+
|
|
317
|
+
Servers are launched inside the sandbox as descendants of the snippet process, and the spawn allowlist is *derived* from (TOML-enabled servers ∩ scanned definitions) — never written by hand as `[shell.*]` sections. Commands are resolved to an absolute path at load time, so the directory the executable lives in becomes write-protected, same as a path-like shell policy. An MCP server is otherwise an ordinary unconstrained process, and `npx -y @foo/server` fetches and executes registry code, so pinned versions in definitions are worth having.
|
|
318
|
+
|
|
319
|
+
Current limits: stdio servers only (no `url`), tool-name gating only (no argument-level policy), no `${VAR}` interpolation in definition `env`, and the snippet timeout is the outer bound. Connections are request-scoped — one invocation, then torn down.
|
|
320
|
+
|
|
276
321
|
## CLI
|
|
277
322
|
|
|
278
323
|
```sh
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
# MCP tool access from Python
|
|
2
|
+
|
|
3
|
+
## Problem
|
|
4
|
+
|
|
5
|
+
Agents can gather information in `run_python` snippets and parse it structurally. They
|
|
6
|
+
cannot do that with information that only exists behind another MCP tool. Today the only
|
|
7
|
+
path is: call the tool, read a wall of text into context, retype the interesting parts
|
|
8
|
+
into a snippet.
|
|
9
|
+
|
|
10
|
+
This matters most for capabilities pyddock's usual answer ("just call the API with
|
|
11
|
+
boto3/p4python") does not cover:
|
|
12
|
+
|
|
13
|
+
- host-provided tools with no API behind them (browser automation, LSP, indexing)
|
|
14
|
+
- org-internal MCP servers where the MCP *is* the only interface
|
|
15
|
+
- MCPs wrapping local dev tooling not worth reimplementing
|
|
16
|
+
|
|
17
|
+
The payoff is not only composition. `run_python` truncates at 64KB and the RESULT
|
|
18
|
+
sentinel encourages small returns, so `mcp.call(...)` → parse → return three numbers
|
|
19
|
+
means a 60KB tool result never enters the agent's context at all.
|
|
20
|
+
|
|
21
|
+
Scope: **for MCP servers you cannot replace with a library.**
|
|
22
|
+
|
|
23
|
+
## Shape
|
|
24
|
+
|
|
25
|
+
Two entry points, one implementation:
|
|
26
|
+
|
|
27
|
+
- **`run_mcp`** — single dispatcher (`server`, `tool`, `arguments`, `timeout`). One call,
|
|
28
|
+
raw result. Ergonomics and discovery. Implemented as a bundled script in `tools/`,
|
|
29
|
+
dispatched through `ScriptToolRegistry` exactly like the seven `fs_*` tools, so it runs
|
|
30
|
+
in the sandbox under identical enforcement and shares one code path with the shim.
|
|
31
|
+
- **`pyddock_mcp.call(...)`** inside `run_python` — composition across servers and
|
|
32
|
+
parse-down-before-returning.
|
|
33
|
+
|
|
34
|
+
Tool descriptions cross-reference each other, mirroring the existing `run_shell` ↔
|
|
35
|
+
`run_python` wording.
|
|
36
|
+
|
|
37
|
+
**Explicitly not a gateway.** MCP tools are never registered as individual pyddock MCP
|
|
38
|
+
tools. One dispatcher, never N proxied tools — that keeps the agent's tool list and the
|
|
39
|
+
host's tool budget untouched.
|
|
40
|
+
|
|
41
|
+
## Configuration: JSON defines, TOML permits
|
|
42
|
+
|
|
43
|
+
> JSON says what can be launched. TOML says what may be called. Nothing in a JSON ever
|
|
44
|
+
> grants anything.
|
|
45
|
+
|
|
46
|
+
**Definitions** come from scanned JSON files: `.pyddock/mcp.json` plus standard platform
|
|
47
|
+
locations. Only `command`/`args`/`env`/`url` are read. `disabled`, `autoApprove`, and
|
|
48
|
+
every other host setting is **ignored** — pyddock does not inherit trust decisions.
|
|
49
|
+
|
|
50
|
+
**Policy** is always `[mcp.<name>]` in `pyddock.toml`:
|
|
51
|
+
|
|
52
|
+
```toml
|
|
53
|
+
[mcp.github]
|
|
54
|
+
description = "Read-only GitHub queries. Tools are get_issue, get_pr, list_repos."
|
|
55
|
+
tools = { "get_.*" = true, "list_.*" = true }
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Presence in the TOML is the only switch. A host-`disabled` server becomes reachable if
|
|
59
|
+
the TOML enables it — which is a legitimate use case: disable a chatty MCP for the
|
|
60
|
+
agent's direct use precisely because it floods context, and reach it only from Python
|
|
61
|
+
where results get parsed down.
|
|
62
|
+
|
|
63
|
+
`tools` is a table rather than a list so argument-level policy can grow a value side
|
|
64
|
+
later without a breaking change (the same trick `[imports]` uses).
|
|
65
|
+
|
|
66
|
+
`[mcp]` is optional and not in `_REQUIRED_SECTIONS`, matching `[shell]`: absent means the
|
|
67
|
+
feature is off and `run_mcp` is not registered.
|
|
68
|
+
|
|
69
|
+
### Definition locations must not be agent-writable
|
|
70
|
+
|
|
71
|
+
If an agent can write a scanned location, it can redirect a server the user already
|
|
72
|
+
permitted:
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{ "mcpServers": { "github": { "command": "./notes/setup.sh" } } }
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Policy-in-TOML does not help — the agent isn't granting itself a tool, it's redirecting
|
|
79
|
+
one. So at boot, each candidate location is checked against the *actual* filesystem
|
|
80
|
+
policy, and definitions are refused from any path agent code could write:
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
mcp: ignoring .vscode/mcp.json — agent-writable under current filesystem policy
|
|
84
|
+
(add a "read-only" guard to load definitions from it)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
This is self-enforcing rather than a hand-maintained guard list: adding a scan location
|
|
88
|
+
cannot silently open a hole, and widening `writable_paths` deactivates the location on its
|
|
89
|
+
own. `.pyddock/mcp.json` passes via the blanket `.pyddock/` write exclusion;
|
|
90
|
+
`.kiro/settings`, `.kiro/agent`, and `.claude/settings` already have `read-only` guards.
|
|
91
|
+
|
|
92
|
+
Duplicate server names with differing commands are warned about — that is the signature
|
|
93
|
+
definition injection would leave. A TOML server with no definition warns at boot.
|
|
94
|
+
|
|
95
|
+
## Launch happens in the sandbox
|
|
96
|
+
|
|
97
|
+
The shim (`pyddock_mcp`) is installed into `.pyddock/venv`, so it sits under a trusted
|
|
98
|
+
prefix, and spawns stdio MCP servers itself.
|
|
99
|
+
|
|
100
|
+
**Installed, not importable.** The `mcp` SDK lands in the venv but is *not* added to the
|
|
101
|
+
`[imports]` allowlist. The shim imports it via `_caller_is_trusted`; agent code cannot
|
|
102
|
+
`import mcp` or `import httpx`. If `httpx` were agent-importable it would mean
|
|
103
|
+
unrestricted egress for any snippet via the `network` disposition's TRUSTED bypass.
|
|
104
|
+
|
|
105
|
+
### Why not launch from the parent
|
|
106
|
+
|
|
107
|
+
Considered and rejected. The parent-side design needs a launcher, an IPC channel, a
|
|
108
|
+
connection registry, per-server process groups, and teardown wired into the timeout path
|
|
109
|
+
— because parent-spawned MCP children are *siblings* of the sandbox process and survive
|
|
110
|
+
`kill_and_drain`. In-sandbox children are **descendants**, so the existing
|
|
111
|
+
`os.killpg` / `taskkill /F /T` tree-kill reaps them for free.
|
|
112
|
+
|
|
113
|
+
### The subprocess gate
|
|
114
|
+
|
|
115
|
+
`_validate_command` is caller-blind by design, and that is load-bearing: any spawn right
|
|
116
|
+
the shim has, a snippet would have identically, and it could then speak JSON-RPC directly
|
|
117
|
+
to the server and invoke any tool — making the `[mcp.*]` allowlist decorative.
|
|
118
|
+
|
|
119
|
+
So the gate is caller-scoped:
|
|
120
|
+
|
|
121
|
+
- the spawn allowlist is **derived** from (TOML-enabled servers ∩ scanned definitions),
|
|
122
|
+
never hand-written as `[shell.*]` sections
|
|
123
|
+
- permitted only when the **immediate calling frame** is inside the shim's install
|
|
124
|
+
directory — immediate-frame semantics, not `_caller_is_trusted`'s any-frame walk, which
|
|
125
|
+
closes callback re-entry without needing to reason about it
|
|
126
|
+
- `shell_protected_dirs` derivation extends to MCP commands, for the same
|
|
127
|
+
write-then-execute prevention the shell policies get. Because commands are resolved
|
|
128
|
+
(below), this protects the directory the executable actually lives in. A command
|
|
129
|
+
resolving to the workspace root is skipped: protecting the whole workspace costs more
|
|
130
|
+
than the exposure it removes, and the path-like heuristic already skips the same case
|
|
131
|
+
for `[shell.*]` patterns.
|
|
132
|
+
|
|
133
|
+
### Commands are resolved in the parent
|
|
134
|
+
|
|
135
|
+
The exact-argv match only works if both sides agree on what argv is. They do not agree by
|
|
136
|
+
default, because the SDK resolves the command in *userspace* before spawning:
|
|
137
|
+
`_get_executable_command` → `get_windows_executable_command` → `shutil.which`. So a
|
|
138
|
+
definition saying `uvx` reaches `subprocess.Popen` as `C:\...\uvx.EXE`, the allowlist
|
|
139
|
+
entry built from the definition never matches, and the spawn falls through to `[shell.*]`
|
|
140
|
+
and is denied. Every bare-name command — `uvx`, `npx`, `node` — was affected on Windows;
|
|
141
|
+
POSIX was unaffected because the SDK passes the command through untouched there.
|
|
142
|
+
|
|
143
|
+
`_normalize_spawn_args` states the assumption this violates: `tokens[0]` is "the command
|
|
144
|
+
name as written — NOT the resolved binary … the OS performs PATH resolution only *after*
|
|
145
|
+
this event". True of an ordinary spawn; false of a caller that resolves first.
|
|
146
|
+
|
|
147
|
+
So `mcp_definitions.resolve_launch_command` resolves once, in the parent, and the resolved form
|
|
148
|
+
becomes the single canonical value — it is both what the allowlist holds and what the shim
|
|
149
|
+
hands the SDK. Two properties keep that sound, and both have tests:
|
|
150
|
+
|
|
151
|
+
- **The result is a fixed point of the SDK's resolver.** `shutil.which` returns an
|
|
152
|
+
already-resolved path unchanged, so the SDK's second pass inside the sandbox is a no-op.
|
|
153
|
+
A test asserts this against the SDK's own function rather than against a copy of its
|
|
154
|
+
logic, since the copy is what would drift.
|
|
155
|
+
- **No path is ever fabricated.** An unresolvable command is kept as written and warned
|
|
156
|
+
about, so the failure surfaces as the SDK's own "cannot spawn" instead of a denial
|
|
157
|
+
naming an unrelated shell policy.
|
|
158
|
+
|
|
159
|
+
Resolving on POSIX too is not needed for the match, but it keeps one canonical form on
|
|
160
|
+
both platforms and gives the protected-dirs derivation a real directory. The extension
|
|
161
|
+
probe (`.cmd`/`.bat`/`.exe`/`.ps1`) stays Windows-only so the result remains a fixed point
|
|
162
|
+
of what the SDK itself would compute.
|
|
163
|
+
|
|
164
|
+
One deliberate side effect: the "defined differently" collision warning now compares
|
|
165
|
+
resolved commands, so two definitions naming the same executable different ways no longer
|
|
166
|
+
warn. They describe the same launch, so that is the right answer.
|
|
167
|
+
|
|
168
|
+
### Why the gate holds
|
|
169
|
+
|
|
170
|
+
The check is backed by capability removal, not by the check alone. To spawn without going
|
|
171
|
+
through the shim, a snippet must make its call appear to originate from the shim's path,
|
|
172
|
+
which requires one of:
|
|
173
|
+
|
|
174
|
+
| Vector | Status |
|
|
175
|
+
|---|---|
|
|
176
|
+
| `compile`/`exec`/`eval` with a forged filename | AST-blocked in the parent, pre-execution |
|
|
177
|
+
| Planting a `.py` in a trusted directory | Every trusted prefix is write-protected; `_build_trusted_prefixes` separately *refuses* to trust any agent-writable site-packages dir |
|
|
178
|
+
| `sys._getframe`, frame attributes | Blocked for everyone, trusted code included |
|
|
179
|
+
| `sys.modules`, `sys.meta_path` | Trusted-only and never-exposed respectively |
|
|
180
|
+
|
|
181
|
+
Forging provenance is therefore as hard as any other pyddock escape, which is the standard
|
|
182
|
+
the rest of the sandbox is held to.
|
|
183
|
+
|
|
184
|
+
### Residual risk is three shim invariants
|
|
185
|
+
|
|
186
|
+
1. **Return only plain data** — `dict`/`list`/`str`/`int`/`bool`/`None`. Never an object
|
|
187
|
+
holding `_proc` or a stream. A leaked pipe to something like `server-filesystem` is
|
|
188
|
+
arbitrary FS access, and reference leakage through proxied objects is this codebase's
|
|
189
|
+
recurring bug class (`os.path.os`, `func.__self__`).
|
|
190
|
+
2. **Never build argv from snippet input** — server name is an exact key lookup against
|
|
191
|
+
parsed config. No path joining, no interpolation.
|
|
192
|
+
3. **Never forward snippet kwargs to `Popen`** — notably `close_fds=False`/`pass_fds`.
|
|
193
|
+
|
|
194
|
+
Unchanged either way: an MCP server is an ordinary unconstrained process, and
|
|
195
|
+
`npx -y @foo/server` fetches and executes registry code. Pinned versions in definitions
|
|
196
|
+
are worth having.
|
|
197
|
+
|
|
198
|
+
## Lifecycle
|
|
199
|
+
|
|
200
|
+
Request-scoped. Connections live for one invocation and are torn down when it ends. A
|
|
201
|
+
snippet looping 20 calls against one server spawns once; separate snippets re-spawn, which
|
|
202
|
+
is the case where the agent should be batching anyway — and pyddock already accepts
|
|
203
|
+
fresh-process startup per call as the price of isolation.
|
|
204
|
+
|
|
205
|
+
No LRU, no idle TTL, no persistence. If spawn latency shows up in practice, the shape to
|
|
206
|
+
grow into is idle-TTL-primary with max-concurrent as a cap and LRU only as the backstop,
|
|
207
|
+
plus per-server opt-in — not LRU as the primary mechanism, since MCP usage is bursty and
|
|
208
|
+
LRU would keep long-idle servers resident.
|
|
209
|
+
|
|
210
|
+
`Client` cannot be reused after its `async with` block exits, so naive `asyncio.run()` per
|
|
211
|
+
call would respawn the server every call. The shim runs one loop on a background thread
|
|
212
|
+
with an `AsyncExitStack` holding entered clients for the snippet's lifetime.
|
|
213
|
+
|
|
214
|
+
## Descriptions are lazy and policy-only
|
|
215
|
+
|
|
216
|
+
The `run_mcp` description lists server names, the TOML tool patterns, and the author's
|
|
217
|
+
`description` line. It does **not** connect to servers at boot and does not list live
|
|
218
|
+
tools — which removes the entire boot-connection, tool-cache, and staleness subsystem.
|
|
219
|
+
|
|
220
|
+
Full schemas come from `run_mcp(server=...)` on demand. Errors list the allowed tools,
|
|
221
|
+
following the existing idiom where a blocked import raises listing the whole allowlist.
|
|
222
|
+
|
|
223
|
+
Keeping upstream tool descriptions out of the always-present context is also deliberate:
|
|
224
|
+
third-party descriptions are an injection surface, and they now only reach the agent when
|
|
225
|
+
it explicitly asks.
|
|
226
|
+
|
|
227
|
+
## Two enforcement changes the SDK required
|
|
228
|
+
|
|
229
|
+
Both were found by running a real server in the sandbox, and both are shared
|
|
230
|
+
enforcement code rather than MCP-specific, so they deserve to be visible.
|
|
231
|
+
|
|
232
|
+
**1. The SDK must be imported before enforcement is applied.** pydantic calls
|
|
233
|
+
`sys._getframe` at *class-definition* time (`parent_frame_namespace`) while
|
|
234
|
+
`mcp_types` is imported, and `sys._getframe` is blocked for everyone — trusted
|
|
235
|
+
callers included — because frame access leads to globals access. So importing the
|
|
236
|
+
SDK after `apply_all()` fails with `module 'sys' has no attribute '_getframe'`.
|
|
237
|
+
The shim's `_sdk()` is therefore cached and primed from `_install()` during the
|
|
238
|
+
prologue, the same approach `_prewarm.py` already takes for lazily-imported
|
|
239
|
+
stdlib internals. Frame protections are unchanged.
|
|
240
|
+
|
|
241
|
+
**2. `getattr(obj, blocked, default)` now returns the default instead of
|
|
242
|
+
raising.** anyio probes `getattr(factory, "__closure__", None)` to detect an
|
|
243
|
+
eager task factory and falls back to `loop.create_task()` otherwise; raising
|
|
244
|
+
there broke every anyio-based library in the sandbox. A three-argument `getattr`
|
|
245
|
+
is a *probe* — the caller has already declared what to do when the attribute is
|
|
246
|
+
unavailable — so answering "unavailable" serves the guard's purpose exactly. This
|
|
247
|
+
grants no new access: the blocked attribute is still never returned, and a caller
|
|
248
|
+
cannot even distinguish "blocked" from "absent" because the default is always
|
|
249
|
+
what comes back. The two-argument form still raises, and `operator.attrgetter`
|
|
250
|
+
(which has no default) is untouched.
|
|
251
|
+
|
|
252
|
+
## Known constraint
|
|
253
|
+
|
|
254
|
+
`readable_paths` must include the venv's site-packages, which the shipped default
|
|
255
|
+
(`["*"]`) satisfies. The SDK validates tool results against JSON Schema, and
|
|
256
|
+
`jsonschema_specifications` reads metaschema files from its own package
|
|
257
|
+
directory; a workspace narrowing reads to `["."]` will see MCP calls fail on that
|
|
258
|
+
read. Tool *listing* is unaffected — only `call` validates.
|
|
259
|
+
|
|
260
|
+
## Deferred
|
|
261
|
+
|
|
262
|
+
- **Argument-level policy.** Tool-name gating only. The existing policy vocabulary is
|
|
263
|
+
regex-over-strings and MCP arguments are structured JSON, so there is no pattern to
|
|
264
|
+
copy; `tools` being a table leaves room.
|
|
265
|
+
- **HTTP / remote servers.** stdio only. The 2026-07-28 revision makes remote servers
|
|
266
|
+
stateless, so this is additive later.
|
|
267
|
+
- **Env handling.** Definition `env` passes through the existing `_apply_env_policy`
|
|
268
|
+
unchanged, so `[env]` deny locks still apply (a server needing `PYTHONPATH` will not
|
|
269
|
+
work) and `${VAR}` is not interpolated.
|
|
270
|
+
- **Per-server timeouts.** The snippet timeout is the outer bound.
|
|
271
|
+
- **Host `autoApprove` inheritance.** Rejected: policy comes only from the TOML. The
|
|
272
|
+
consequence is that nothing structurally prevents the TOML from exceeding host policy,
|
|
273
|
+
so the shipped default should stay read-only-shaped (`get_.*`, `list_.*`, `search_.*`),
|
|
274
|
+
matching the commented-out `boto3` posture.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "pyddock"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.4.1"
|
|
4
4
|
description = "MCP server that gives AI agents pre-approved Python, shell, and file I/O tools with declarative policy controls"
|
|
5
5
|
requires-python = ">=3.14"
|
|
6
6
|
license = "MIT"
|
|
@@ -19,7 +19,7 @@ classifiers = [
|
|
|
19
19
|
"Topic :: Security",
|
|
20
20
|
]
|
|
21
21
|
dependencies = [
|
|
22
|
-
"mcp>=
|
|
22
|
+
"mcp>=2,<3",
|
|
23
23
|
]
|
|
24
24
|
|
|
25
25
|
[project.urls]
|