Skip to content

feat: add SSE transport support and refactor CLI arg parsing#6

Open
SlackJaw74 wants to merge 1 commit intokapillamba4:mainfrom
SlackJaw74:sse
Open

feat: add SSE transport support and refactor CLI arg parsing#6
SlackJaw74 wants to merge 1 commit intokapillamba4:mainfrom
SlackJaw74:sse

Conversation

@SlackJaw74
Copy link
Copy Markdown

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

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
Copilot AI review requested due to automatic review settings March 22, 2026 18:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 --port CLI arguments and wired them into main() to select stdio vs SSE.
  • Introduced build_arg_parser() and added new tests to validate CLI defaults/flags and main() 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.

Comment on lines +132 to 144
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

Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment on lines +10 to +17
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."""
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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 uses AI. Check for mistakes.
@SlackJaw74
Copy link
Copy Markdown
Author

@copilot open a new pull request to apply changes based on the comments in this thread

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants