You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CLI _parse_file_path() splits with rsplit(":", 1), making _import_server()'s "module:object" syntax unreachable #3966
In src/mcp/cli/cli.py, _import_server() documents and implements "module:object" syntax for server_object (lines 124 and 180-191):
Docstring: server_object: Optional object name in format "module:object" or just "object"
Branch: if ":" in server_object: module_name, object_name = server_object.split(":", 1)
However, all CLI entrypoints (dev at line 246, run at line 328, and install at line 418) first pass file_spec to _parse_file_path() (cli.py:88-116), which splits on the last colon:
Because rsplit(":", 1) only strips the final :object segment, passing entry.py:pkg_srv:app splits into file_str="entry.py:pkg_srv" and server_object="app", then fails file_path.exists() and exits with File not found (SystemExit(1)). As a result, _import_server()'s "module:object" branch is unreachable from the CLI.
(Expected behavior: either split on the first non-drive colon after the file path so server_object can contain module:object, or update _import_server() / CLI help if "module:object" is no longer intended to be supported.)
(AI assistance disclosure: AI tools were used to assist in local reproduction and analysis; I have verified the behavior and reproduction output locally.)
Reproduced on the released mcp 2.3.0 package (Python 3.12.3, Linux x86_64) — the _parse_file_path code there is identical to the version on main quoted above:
entry.py → (entry.py, None)
entry.py:app → (entry.py, 'app')
entry.py:pkg_srv:app → logs File not found: .../entry.py:pkg_srv and raises SystemExit(1), exactly as reported.
One extra check that may help pin down where the fix belongs: calling _import_server(entry_path, "pkg_srv:app") directly, bypassing _parse_file_path, works fine — it imports pkg_srv and returns the MCPServer('demo') instance. So the module:object branch itself is functional; only the CLI parsing step makes it unreachable.
I'd like to take this on — could you assign #3966 to me? I'll put up a PR fixing _parse_file_path() so the module:object syntax reaches _import_server().
Activity
japan-opendata-lab commentedon Dec 3, 2026
Reproduced on the released mcp 2.3.0 package (Python 3.12.3, Linux x86_64) — the
_parse_file_pathcode there is identical to the version on main quoted above:entry.py→(entry.py, None)entry.py:app→(entry.py, 'app')entry.py:pkg_srv:app→ logsFile not found: .../entry.py:pkg_srvand raisesSystemExit(1), exactly as reported.One extra check that may help pin down where the fix belongs: calling
_import_server(entry_path, "pkg_srv:app")directly, bypassing_parse_file_path, works fine — it importspkg_srvand returns theMCPServer('demo')instance. So themodule:objectbranch itself is functional; only the CLI parsing step makes it unreachable.mia03ther commentedon Dec 3, 2026
I'd like to take this on — could you assign #3966 to me? I'll put up a PR fixing
_parse_file_path()so themodule:objectsyntax reaches_import_server().mia03ther commentedon Dec 3, 2026
PR opened: #3969 — fixes
_parse_file_path()soentry.py:pkg_srv:appparses as fileentry.py+ server objectpkg_srv:app.