Skip to content

Add Streamable HTTP transport, CORS support, and SSE fixes to MCP server#68

Open
danstarns wants to merge 1 commit intoneo4j-labs:mainfrom
danstarns:main
Open

Add Streamable HTTP transport, CORS support, and SSE fixes to MCP server#68
danstarns wants to merge 1 commit intoneo4j-labs:mainfrom
danstarns:main

Conversation

@danstarns
Copy link

  • Added Streamable HTTP transport (--transport streamable-http) — single endpoint, no SSE handshake, works with browser clients
  • Added CORS middleware to both HTTP transports (SSE and Streamable HTTP), defaults to *, configurable via --allow-origin
  • Fixed SSE transport: added _NoOpResponse for Starlette compat, changed /messages from Route to Mount since the handler is a raw ASGI app
  • Added --openai-api-key CLI flag

@vercel
Copy link

vercel bot commented Feb 19, 2026

@danstarns is attempting to deploy a commit to the lyonwj's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Feb 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agent-memory Ready Ready Preview, Comment Feb 23, 2026 0:51am

Copy link
Contributor

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 browser-friendly MCP HTTP serving options and improves SSE compatibility, plus updates docs to help users get started quickly.

Changes:

  • Added Streamable HTTP transport (--transport streamable-http) with CORS support.
  • Improved SSE transport compatibility (no-op response + /messages mounted as ASGI app) and added CORS middleware.
  • Added --allow-origin and --openai-api-key CLI flags; added new MCP Server Quick Start doc and linked it from README.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
src/neo4j_agent_memory/mcp/server.py Adds Streamable HTTP transport, CORS configuration, SSE routing/response fixes, and new CLI flags integration.
README.md Links to the new MCP server quick start.
QUICKSTART.md New quick start guide documenting transports, CORS, and flags.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


inner_app = Starlette(
routes=[
Mount("/", app=handle_mcp),
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

run_streamable_http mounts the Streamable HTTP handler at / (via Mount("/", ...)), but the Quick Start/docs in this PR state the endpoint is /mcp. This mismatch will lead to 404s for clients following the docs; either mount at /mcp here or update the docs to point to /.

Suggested change
Mount("/", app=handle_mcp),
Mount("/mcp", app=handle_mcp),

Copilot uses AI. Check for mistakes.
Comment on lines +404 to +415
parser.add_argument(
"--allow-origin",
action="append",
dest="allow_origins",
help="Allowed CORS origin (repeatable, defaults to '*'). "
"Example: --allow-origin https://example.com --allow-origin https://app.example.com",
)
parser.add_argument(
"--openai-api-key",
default=os.environ.get("OPENAI_API_KEY", ""),
help="OpenAI API key (for embeddings/extraction)",
)
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

Now that --transport supports both SSE and streamable HTTP, the CLI help text for --host/--port still says “for SSE transport”. Consider updating those help strings to refer to “HTTP transports” to match the updated run_server docstring and avoid user confusion.

Copilot uses AI. Check for mistakes.
Comment on lines +24 to +25
Server runs at `http://localhost:5000/mcp`. All CORS origins allowed by default.

Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

Docs say the Streamable HTTP server runs at http://localhost:5000/mcp, but the implementation in Neo4jMemoryMCPServer.run_streamable_http() mounts the handler at /. Update the documented URL or adjust the server mount path so the Quick Start is accurate.

Copilot uses AI. Check for mistakes.
Comment on lines +35 to +36
Endpoint: `http://localhost:5000/mcp` — POST JSON-RPC, get JSON back.

Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

The Streamable HTTP “Endpoint:” line references /mcp, but the current server code mounts the Streamable HTTP handler at /. Please align this endpoint string with the actual mount path so users can copy/paste the example successfully.

Copilot uses AI. Check for mistakes.
Comment on lines +69 to +78
## CORS

All origins allowed by default. To restrict:

```bash
uv run python -m neo4j_agent_memory.mcp.server \
--transport streamable-http --port 5000 --neo4j-password test-password \
--allow-origin https://app.example.com \
--allow-origin https://admin.example.com
```
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

The documentation here promotes a default CORS configuration of allowing all origins for the MCP HTTP endpoints, which combined with the server’s lack of authentication makes data exfiltration from a locally running instance trivial via a malicious web page. A site an operator visits can issue cross-origin fetch/EventSource calls to http://localhost:<port>/mcp or the SSE endpoints and, because of Access-Control-Allow-Origin: *, read sensitive memory and graph data from their Neo4j-backed store. Consider recommending a restricted default (or explicitly marking * as development-only) and documenting that in production or when binding to 0.0.0.0, operators should explicitly set --allow-origin to trusted origins only.

Copilot uses AI. Check for mistakes.
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