T-180: M2.1p — PostgreSQL composition root for the MCP copilot: createPostgresResearchCopilotServer wiring one injected executor into the symbol-search, trial-ref, findings, knowledge-reader and exchange-calendar adapters in libs/research/src/mcp/adapters/postgres-copilot.ts (injected store, library-card reader, session-date port, clock and id source; no new deps, no live Postgres, no entrypoint/bin)

This commit is contained in:
Studio 2026-12-02 16:34:12 -05:00
parent 0fa33eadcc
commit bc0f2c30a2
4 changed files with 1168 additions and 0 deletions

View file

@ -280,6 +280,7 @@ Server-only, dependency-free JSON-RPC 2.0 / Model Context Protocol core exported
### Copilot Server
- **`createResearchCopilotMcpServer(options)`** (exported from `@stock-bot/research/mcp` alongside `ResearchCopilotMcpServerOptions` and the frozen `RESEARCH_COPILOT_TOOL_NAMES` tuple) composes all six research tools into one transport-agnostic `McpServer` in the fixed registration order `search_symbols`, `query_data`, `analyze_signal`, `event_study`, `file_finding`, `read_knowledge`. It accepts `name` and `version`, shared authoritative `store`, `vaultContext`, `ledger`, and `principalId`, plus the per-tool injected ports (`searchSymbols`, `eventStudy.resolveExchangeCalendars`, `fileFinding`, `readKnowledge`), fails closed on duplicate, missing, unexpected, or out-of-order tool names, and pairs directly with `runStdioServer(server, ...)` for headless newline-delimited JSON-RPC sessions.
- **`createPostgresResearchCopilotServer(options)`** (exported from `@stock-bot/research/mcp` alongside `PostgresResearchCopilotServerOptions` and `PostgresResearchCopilotExecutor`) wires one shared PostgreSQL executor into `createPostgresSymbolSearchPort`, `createPostgresTrialRefPort`, `createPostgresFindingWritePort`, `createPostgresKnowledgeReaders`, `createPostgresListingCalendarPort` + `createExchangeCalendarResolver`, and `trial_ledger`, while keeping `store`, `listLibraryCards`, `sessionDates` (with optional `earlyCloses`), `newId`, and `now` caller-supplied. `vaultContext.vaultCutoffTs` is the single authoritative Vault cutoff for all Vault-fenced tools and `trial_ledger` visibility lookups. When `schema` is supplied, the schema-aware adapters qualify their tables with `"<schema>".`, while `trial_ledger` writes and cluster DSR reads resolve through the executor's `search_path`.
### Remaining M2 MCP Items (Later Tasks)