To implement MCP functionality and chat functionality, libvault is used.#7
To implement MCP functionality and chat functionality, libvault is used.#7wujian0327 wants to merge 47 commits intogitmono-dev:mainfrom
Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds MCP server support (stdio + SSE), introduces an encrypted peer-to-peer chat feature backed by SQLite storage, and replaces rcgen-based certificate generation with libvault/openssl while evolving DB schema and repo metadata.
Changes:
- Add MCP servers: stdio JSON-RPC handler and an Axum-based SSE endpoint.
- Add encrypted P2P chat messages (gossip message types, sender task, DB persistence, CLI commands).
- Update storage schema/ORM models (repos/refs/chat_messages) and enhance repo metadata (language/size/latest_commit_at); migrate cert generation to libvault.
Reviewed changes
Copilot reviewed 36 out of 38 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/gossip_three_nodes.rs | Use per-node cert files; add cleanup of generated certs. |
| tests/git_pack.rs | Minor modern Rust array arg usage for Command::args. |
| tests/bundle_two_nodes.rs | Minor string handling cleanup; add cert file cleanup. |
| src/transport/quic.rs | Improve connection close logging; serialize tests + add cert cleanup; add “no shared CA” test configs. |
| src/transport/config.rs | Use rustls provider-supported signature schemes; add QUIC client transport keepalive/idle timeout. |
| src/transport/cert.rs | Switch certificate generation to libvault + openssl and add tests for idempotency/recovery. |
| src/storage/repo_model.rs | Update repo DB model fields (language/size/latest_commit_at) and switch to pooled get_db_conn(). |
| src/storage/ref_model.rs | Move refs to composite primary key and add created_at; update CRUD to use (repo_id, ref_name) lookup. |
| src/storage/node_model.rs | Switch DB access from init_db() to get_db_conn(). |
| src/storage/mod.rs | Add schema management/migrations, introduce chat_messages table, replace init_db() with get_db_conn() pool-by-path. |
| src/storage/chat_message.rs | New SeaORM entity + helpers for chat message persistence and status updates. |
| src/repo/repo_manager.rs | Update tests/fixtures to new P2PDescription fields. |
| src/repo/repo.rs | Replace timestamp with language/latest_commit_at/size in P2PDescription. |
| src/node/node_manager.rs | Remove NodeManager implementation and tests. |
| src/node/node_id.rs | Small test cleanup (avoid redundant borrow). |
| src/node/node.rs | Minor test assertion cleanup. |
| src/node/mod.rs | Stop exporting removed node_manager module. |
| src/mcp/sse_server.rs | New Axum SSE-based MCP endpoint with session handling and JSON-RPC routing. |
| src/mcp/mod.rs | New MCP module exports. |
| src/mcp/mcp_server.rs | New stdio JSON-RPC MCP server with repo tools (list/details/clone). |
| src/main.rs | Add chat and mcp CLI commands; add node flags for MCP; route logs to stderr. |
| src/lib.rs | Export new chat and mcp modules. |
| src/identity/keypair.rs | Add message encryption/decryption helpers (ChaCha20Poly1305 + curve25519-dalek). |
| src/gossip/service.rs | Add sender mismatch check; add chat/chat-ack handling; reuse shared Envelope. |
| src/gossip/message.rs | Add chat message types and shared Envelope; adjust message hashing canonicalization. |
| src/git/pack.rs | Add post-clone checkout/reset steps when restoring from bundle. |
| src/git/git_repo.rs | Include remote branch refs; add get_latest_commit_time(). |
| src/cli/repo.rs | Add language detection, repo size computation, improved output; store new metadata fields. |
| src/cli/node.rs | Start chat sender background task; add MCP SSE server spawning; warn about stdio MCP during node start. |
| src/cli/mod.rs | Wire in new chat CLI module. |
| src/cli/chat.rs | New chat CLI for send/list using DB queue + history display. |
| src/chat/service.rs | New chat sender loop, encryption, inbound processing, and ACK handling via gossip. |
| src/chat/mod.rs | New chat module export. |
| src/bundle/transfer.rs | Chunked transfer: consolidate chunk size const; write chunks by seek offset + ensure truncation at start. |
| README.md | Document chat usage. |
| Cargo.toml | Add dependencies: libvault/openssl, axum/tower-http, uuid/futures, chacha20poly1305/curve25519-dalek, etc. |
| Cargo.lock | Lockfile updates for new dependencies. |
| .gitignore | Ensure tmp/* is ignored and add dist/. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d2ffa5ab1f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 96e39b9afc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
This PR adds MCP (stdio + optional SSE) and encrypted peer-to-peer chat capabilities, while updating certificate generation to use libvault and expanding the SQLite schema to support new repo metadata and chat message persistence.
Changes:
- Add MCP server (stdio JSON-RPC) and an Axum-based SSE gateway for MCP requests.
- Introduce encrypted P2P chat over gossip, plus CLI commands and DB persistence for chat messages.
- Replace certificate generation with
libvault/OpenSSL and evolve the SQLite schema (repos/refs/chat_messages), including migration logic.
Reviewed changes
Copilot reviewed 36 out of 38 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/gossip_three_nodes.rs | Uses unique cert filenames and cleans up generated certs. |
| tests/git_pack.rs | Minor args API modernization for Command. |
| tests/bundle_two_nodes.rs | Uses an isolated temp cert directory and improves cleanup. |
| src/transport/quic.rs | Improves connection cleanup logging; serializes transport tests + cert cleanup; adds “no shared CA” test. |
| src/transport/config.rs | Uses rustls crypto provider schemes; adds client transport keepalive/idle timeout. |
| src/transport/cert.rs | Switches cert generation to libvault/OpenSSL; adds unit tests. |
| src/storage/repo_model.rs | Updates repo schema fields and switches to get_db_conn. |
| src/storage/ref_model.rs | Moves refs to composite primary key and adds created_at; switches to get_db_conn. |
| src/storage/node_model.rs | Switches DB access to get_db_conn. |
| src/storage/mod.rs | Adds schema creation + migration logic and new pooled get_db_conn. |
| src/storage/chat_message.rs | Adds SeaORM entity + helpers for chat message persistence. |
| src/repo/repo_manager.rs | Updates repo test descriptions to new metadata fields. |
| src/repo/repo.rs | Updates P2PDescription to language/size/latest_commit_at. |
| src/node/node_manager.rs | Removes NodeManager module (deleted). |
| src/node/node_id.rs | Minor test cleanup. |
| src/node/node.rs | Minor assertion style cleanup in tests. |
| src/node/mod.rs | Removes node_manager export. |
| src/mcp/sse_server.rs | Adds Axum SSE MCP gateway with session management. |
| src/mcp/mod.rs | Exposes MCP entrypoints. |
| src/mcp/mcp_server.rs | Adds stdio JSON-RPC MCP server and repo tools implementation. |
| src/main.rs | Adds chat and mcp CLI commands; adds node flags for MCP SSE; routes logging to stderr. |
| src/lib.rs | Exports new chat and mcp modules. |
| src/identity/keypair.rs | Adds ECDH+ChaCha20Poly1305 message encryption/decryption helpers. |
| src/gossip/service.rs | Adds sender-id consistency check; integrates chat/chat-ack handling; uses shared Envelope type. |
| src/gossip/message.rs | Adds chat message/ack types and shared Envelope; tweaks SignedMessage hashing. |
| src/git/pack.rs | Ensures bundle clone checks out a branch/reset to populate working tree. |
| src/git/git_repo.rs | Reads remote refs too; adds latest commit time helper. |
| src/cli/repo.rs | Adds language detection, repo size, and latest commit time; improves CLI output formatting. |
| src/cli/node.rs | Starts chat sender task; optionally starts MCP SSE server; warns about stdio MCP on node start. |
| src/cli/mod.rs | Exposes chat command handler. |
| src/cli/chat.rs | Adds chat send and chat list CLI commands. |
| src/chat/service.rs | Implements chat sending (DB queue + background), receiving, and ack processing. |
| src/chat/mod.rs | Adds chat module export. |
| src/bundle/transfer.rs | Writes chunks by offset (seek) and pre-truncates file on START. |
| README.md | Documents chat usage. |
| Cargo.toml | Adds libvault/openssl/axum/chat crypto deps. |
| Cargo.lock | Dependency lock updates for new crates. |
| .gitignore | Ignores tmp/ and dist/. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds MCP (stdio + optional SSE) and encrypted P2P chat capabilities to MegaEngine, while also switching certificate generation to libvault/openssl and extending the local SQLite schema to persist additional repo/ref/chat metadata.
Changes:
- Add MCP server (stdio) plus an Axum-based SSE endpoint for MCP tool calls.
- Add encrypted node-to-node chat with DB-backed message queueing and delivery ACKs.
- Replace
rcgencertificate generation withlibvault/OpenSSL and migrate storage schema (repos/refs/chat tables + new DB connection helper).
Reviewed changes
Copilot reviewed 36 out of 38 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/gossip_three_nodes.rs | Updates test cert filenames and adds cleanup of generated cert files. |
| tests/git_pack.rs | Minor command args ergonomics updates. |
| tests/bundle_two_nodes.rs | Uses per-test temp cert directory and improves cleanup; minor iterator/string handling tweaks. |
| src/transport/quic.rs | Improves connection close logging; adds test serialization lock + cert cleanup; adds “no shared CA” test configs. |
| src/transport/config.rs | Uses rustls provider-supported schemes; sets Quinn transport idle timeout + keepalive. |
| src/transport/cert.rs | Replaces rcgen with libvault/OpenSSL-based CA/server cert generation; adds unit tests. |
| src/storage/repo_model.rs | Updates repo schema mapping (language/size/latest_commit_at) and switches to get_db_conn(). |
| src/storage/ref_model.rs | Switches refs to composite primary key and adds created_at; switches to get_db_conn(). |
| src/storage/node_model.rs | Switches node DB access to get_db_conn(). |
| src/storage/mod.rs | Introduces schema migration/rebuild helpers and path-scoped DB connection caching via get_db_conn(). |
| src/storage/chat_message.rs | Adds SeaORM entity + helpers for persisting chat messages and statuses. |
| src/repo/repo_manager.rs | Updates tests to new repo description fields. |
| src/repo/repo.rs | Extends P2PDescription with language/latest_commit_at/size. |
| src/node/node_manager.rs | Removes NodeManager implementation and its tests. |
| src/node/node_id.rs | Minor string usage cleanup in test. |
| src/node/node.rs | Test assertion style cleanup. |
| src/node/mod.rs | Removes node_manager module export. |
| src/mcp/sse_server.rs | Adds Axum SSE server for MCP JSON-RPC over HTTP + session management. |
| src/mcp/mod.rs | Exposes MCP modules and server starters. |
| src/mcp/mcp_server.rs | Adds MCP stdio JSON-RPC server and repo tools (list/details/clone). |
| src/main.rs | Adds chat and mcp CLI commands; adds node flags for MCP (deprecated stdio) + SSE port. |
| src/lib.rs | Exposes new chat and mcp modules. |
| src/identity/keypair.rs | Adds custom ECDH+ChaCha20Poly1305 encryption/decryption for chat payloads. |
| src/gossip/service.rs | Adds sender-id consistency check; logs ref diffs; handles chat + ack messages. |
| src/gossip/message.rs | Adds chat/ack message types and shared Envelope; adjusts hashing approach. |
| src/git/pack.rs | Adds post-clone checkout/reset steps when restoring from bundle. |
| src/git/git_repo.rs | Enhances ref reading to distinguish local vs remote branches; adds latest commit timestamp helper. |
| src/cli/repo.rs | Adds language detection, size calculation, latest commit time; improves output formatting. |
| src/cli/node.rs | Starts background chat sender task; warns that --mcp stdio is ignored; optionally starts MCP SSE server. |
| src/cli/mod.rs | Wires in chat CLI. |
| src/cli/chat.rs | Adds chat send (queue to DB) and chat list commands. |
| src/chat/service.rs | Adds background sender, message encryption, inbound decrypt + persistence, and ACK handling. |
| src/chat/mod.rs | Exposes chat service module. |
| src/bundle/transfer.rs | Refactors chunking constant; writes bundle chunks at offsets (seek/write) and truncates on start. |
| README.md | Documents chat feature usage. |
| Cargo.toml | Adds deps for libvault/openssl, axum SSE stack, uuid/futures, and chat crypto deps. |
| Cargo.lock | Dependency graph updates for new crates. |
| .gitignore | Adjusts tmp ignore and adds dist/. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4fa5621c34
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8f0122aace
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Start mcp server
To start a MegaEngine node with MCP enabled, launch the node as usual and add the --mcp flag, for example:
if you also want an MCP SSE endpoint, add --mcp-sse-port 3001 (or another port), such as:
Send a message to node1:
Use libvault
Generate certificates using libvault