Skip to content

feat: FastMCP Stabilization & SSE Protocol Realignment (CM-46) - #135

Merged
mikhailkogan17 merged 14 commits into
mainfrom
feat/CM-46-fastmcp-stabilization
Feb 18, 2026
Merged

feat: FastMCP Stabilization & SSE Protocol Realignment (CM-46)#135
mikhailkogan17 merged 14 commits into
mainfrom
feat/CM-46-fastmcp-stabilization

Conversation

@mikhailkogan17-agent

@mikhailkogan17-agent mikhailkogan17-agent commented Feb 18, 2026

Copy link
Copy Markdown
Collaborator

Feature Decomposition

Requirements

  • Stable FastMCP server with session tracking enabled (stateless: false).
  • Implementation of enableJsonResponse: true for tool call compatibility.
  • Native FastMCP authentication for X-Client-Name identification.
  • Realignment of E2E tests with the discovered httpStream handshake protocol.

Existing Patterns

  • Reference: packages/mcp/e2e/api.spec.ts
  • Pattern: Follow two-step handshake: 1. POST /mcp (initialize) -> 2. GET /mcp (stream).

Edge Cases

  • Failure Mode 1: Handshake 400/406 (Resolved by protocol alignment).
  • Failure Mode 2: SSE Stream Teardown (Resolved by custom transport listener).

Verification

Stabilized the MCP core and verified with the updated E2E suite.

Automated Tests

  • npm run test:e2e (Local)
  • sse_transport.spec.ts (Handshake verified)
  • sse_transport_multi.spec.ts (100% pass)

Environments Verified

  • Local (localhost:8626)
  • Local (k3d)
  • RPi (Lan)
  • RPi (Tailscale)

Visual Proof (Screenshots/Videos)

  • N/A (Backend logic and test realignment).

📋 Linear Issue: CM-46

@linear

linear Bot commented Feb 18, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Feb 18, 2026

Copy link
Copy Markdown
Contributor
Warnings
⚠️ Big PR! 📉 Consider breaking this into smaller PRs for better review.

Generated by 🚫 dangerJS against bb29958

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR implements a significant architectural refactor of the CyberMem MCP server, migrating from a custom MCP SDK implementation to the FastMCP framework. The changes aim to stabilize the SSE transport layer and realign with the MCP protocol's httpStream handshake pattern while maintaining backward compatibility through the tool-based API.

Changes:

  • Complete rewrite of MCP server implementation using FastMCP framework (packages/mcp/src/index.ts reduced from ~600 to ~192 lines)
  • Database schema migration renaming 'operation' column to 'tool' across stats and audit log tables
  • E2E test suite migrated from direct HTTP API calls to proper MCP SDK client with SSE transport
  • Dashboard and metrics API updated to use 'tool' terminology instead of 'operation'
  • Docker configuration changes: Ollama service no longer profile-gated, new OLLAMA_URL environment variable, updated Traefik routing
  • Auth-sidecar security improvements: placeholder token rejection, Node.js 24 upgrade
  • Build process enhancement: automatic shebang injection for executable compatibility

Reviewed changes

Copilot reviewed 12 out of 20 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
packages/mcp/src/index.ts Complete FastMCP migration with simplified tool registration and httpStream transport
packages/mcp/package.json Added fastmcp dependency and postbuild script for shebang injection
packages/mcp/e2e/api.spec.ts Migrated tests to use MCP Client SDK instead of direct HTTP calls
packages/mcp/e2e/sse_transport.spec.ts Updated SSE transport tests with increased chunk reading (3→10 iterations)
packages/mcp/e2e/sse_transport_multi.spec.ts Enhanced multi-session test resilience with extended chunk reading
packages/dashboard/components/dashboard/logs/log-viewer.tsx Updated UI to display 'Tool' instead of 'Operation'
packages/dashboard/app/api/metrics/route.ts Updated queries to use 'tool' column with specific tool names (add_memory, query_memory, etc.)
packages/dashboard/app/api/audit-logs/route.ts Updated log processing to map tool names to friendly labels
packages/cli/templates/docker-compose.yml Added OLLAMA_URL env var, ollama dependency, removed ollama profile
packages/cli/dist/templates/docker-compose.yml Updated Traefik routing to include /message endpoint
packages/cli/dist/templates/auth-sidecar/server.js Enhanced security with insecure placeholder detection
packages/cli/dist/templates/auth-sidecar/Dockerfile Upgraded to Node.js 24
packages/cli/dist/templates/ansible/playbooks/deploy-cybermem.yml Added no_log for sensitive operations, increased health check retries
packages/cli/src/commands/install.ts Updated installation instructions to point to root URL instead of /client-setup
GEMINI.md Added constraint against changing binary names without approval
.gitignore Generalized ignore patterns using wildcards for better maintainability

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

Comment thread packages/mcp/src/index.ts
Comment thread packages/dashboard/app/api/audit-logs/route.ts Outdated
Comment thread packages/cli/src/commands/install.ts
Comment thread packages/mcp/package.json Outdated
Comment thread packages/cli/templates/docker-compose.yml Outdated
Comment thread packages/mcp/src/index.ts Outdated
Comment thread packages/mcp/e2e/api.spec.ts Outdated
Comment thread packages/mcp/src/index.ts
Comment thread packages/mcp/src/index.ts
Comment thread packages/cli/templates/docker-compose.yml
Repository owner deleted a comment from Copilot AI Feb 18, 2026
- Fix e2e global-setup readiness check (use /mcp listTools)
- Add validation to update_memory tool
- Implement robust migration for 'tool' column
- Add descriptions to all tools
- Add try-catch logging to tool execution
- Add dashboard API fallback for legacy schemas
- Replace shell postbuild with portable Node.js script

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 16 out of 25 changed files in this pull request and generated 2 comments.


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

Comment thread packages/mcp/src/index.ts
Comment thread packages/mcp/scripts/postbuild.js Outdated
Mikhail Kogan added 2 commits February 18, 2026 07:17
- Fix postbuild script path resolution
- Add robust migration logic for cybermem_stats tool column
@mikhailkogan17
mikhailkogan17 enabled auto-merge (squash) February 18, 2026 05:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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


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

Comment thread packages/mcp/e2e/sse_transport_multi.spec.ts Outdated
Comment thread packages/mcp/e2e/api.spec.ts Outdated
Comment thread packages/mcp/src/index.ts Outdated
Comment thread e2e/global-setup.ts Outdated
Comment thread packages/mcp/e2e/api.spec.ts Outdated
Antigravity Agent added 3 commits February 18, 2026 12:05
…ORRUPT

- Rewrite mcpRpc helper in api.spec.ts to use Node fetch with SSE
  stream parsing instead of Playwright request.post()
- Fix operation→tool property rename in api.spec.ts assertions
  and ui.spec.ts mock data
- Add MCP container restart step in global-setup.ts after DB reset
  to prevent SQLITE_CORRUPT from stale WAL/journal files
- Update legacy /add references to /mcp in test attachments
- Set stateless: true in MCP server httpStream transport

All 17 E2E tests pass locally.
The MCP Streamable HTTP transport requires mcp-session-id headers for
the handshake protocol. stateless: true in FastMCP suppresses session
ID generation, causing E2E tests to fail with 'No mcp-session-id
received'. Setting stateless: false enables proper session management.
- Extract FastMCPHandshakeTransport to shared e2e/utils/ module
- Replace hardcoded 200ms/500ms delay with event-driven stream readiness
- Make database migration errors fatal (process.exit(1))
- Add MCP JSON-RPC protocol handshake verification to global-setup
- Remove unused addUrl variable from global-setup
@mikhailkogan17
mikhailkogan17 merged commit 9e5a684 into main Feb 18, 2026
4 checks passed
@mikhailkogan17
mikhailkogan17 deleted the feat/CM-46-fastmcp-stabilization branch February 18, 2026 23:28
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.

3 participants