feat: add SSE transport support and refactor CLI arg parsing#6
feat: add SSE transport support and refactor CLI arg parsing#6SlackJaw74 wants to merge 1 commit intokapillamba4:mainfrom
Conversation
Add SSE (Server-Sent Events) transport option to the MCP server, allowing a single shared instance to serve multiple MCP host clients over HTTP. - Add --transport, --port, and --host CLI arguments - Extract build_arg_parser() so tests validate the real CLI contract - Update README with SSE server setup and MCP host configuration examples - Update uv.lock
There was a problem hiding this comment.
Pull request overview
Adds an SSE (Server-Sent Events) transport option for running code-memory as a shared MCP server over HTTP, and refactors CLI parsing so tests can validate the actual CLI contract.
Changes:
- Added
--transport,--host, and--portCLI arguments and wired them intomain()to select stdio vs SSE. - Introduced
build_arg_parser()and added new tests to validate CLI defaults/flags andmain()behavior. - Expanded README with shared SSE server setup instructions and MCP host configuration examples (plus dependency lockfile updates).
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
server.py |
Adds build_arg_parser() and uses parsed args to configure/run the MCP server with stdio vs SSE. |
tests/test_main.py |
New tests for CLI parsing defaults/flags and verifying main() passes the right transport/settings to mcp. |
README.md |
Documents shared SSE mode usage and adds a CLI options table; also updates dev instructions. |
uv.lock |
Updates locked dependency graph/version metadata for the release and environment. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| uv build# Clone the repo | ||
| git clone https://github.com/kapillamba4/code-memory.git | ||
| cd code-memory | ||
|
|
||
| # Install dependencies | ||
| uv sync | ||
|
|
||
| # Run the MCP server (stdio transport) | ||
| uv run mcp run server.py | ||
|
|
||
| # Run the MCP server (SSE transport for shared usage) | ||
| uv run python server.py --transport sse | ||
|
|
There was a problem hiding this comment.
The development code block is malformed: uv build# Clone the repo concatenates two commands, and the subsequent clone/install/run instructions duplicate the existing “From Source” section earlier in the README. This breaks the rendered docs and makes the quickstart instructions confusing; split uv build onto its own line and move/remove the duplicated clone/setup steps (keep each set of instructions in one place).
| uv build# Clone the repo | |
| git clone https://github.com/kapillamba4/code-memory.git | |
| cd code-memory | |
| # Install dependencies | |
| uv sync | |
| # Run the MCP server (stdio transport) | |
| uv run mcp run server.py | |
| # Run the MCP server (SSE transport for shared usage) | |
| uv run python server.py --transport sse | |
| uv build |
| from server import build_arg_parser | ||
|
|
||
|
|
||
| class TestMainArgParsing: | ||
| """Tests for CLI argument parsing in main().""" | ||
|
|
||
| def _parse_args(self, argv: list[str]) -> argparse.Namespace: | ||
| """Parse args using the real CLI parser from server.py.""" |
There was a problem hiding this comment.
from server import build_arg_parser imports server.py at test module import time. Since server.py imports db.py, which imports sqlite_vec at module import time, these arg-parsing tests will error (not skip) in environments where sqlite_vec isn't installed. To make the tests robust, either import server lazily inside the tests after pytest.importorskip(...), or move build_arg_parser() into a lightweight module that doesn’t import the full server stack.
| from server import build_arg_parser | |
| class TestMainArgParsing: | |
| """Tests for CLI argument parsing in main().""" | |
| def _parse_args(self, argv: list[str]) -> argparse.Namespace: | |
| """Parse args using the real CLI parser from server.py.""" | |
| class TestMainArgParsing: | |
| """Tests for CLI argument parsing in main().""" | |
| def _parse_args(self, argv: list[str]) -> argparse.Namespace: | |
| """Parse args using the real CLI parser from server.py.""" | |
| pytest.importorskip("sqlite_vec", reason="sqlite_vec not installed") | |
| from server import build_arg_parser |
|
@copilot open a new pull request to apply changes based on the comments in this thread |
Add SSE (Server-Sent Events) transport option to the MCP server, allowing a single shared instance to serve multiple MCP host clients over HTTP.