convez.ai
MCP ServerDevOps & InfraestruturaAvançado
LNSTT369

VALKYRIE - MCP Server de Execução com PolicyGate Zero-Trust

LNSTT369/NIGHTWATCH3R

Gateway zero-trust para sinais de trading com verificação criptográfica

Ver no GitHub
InicialPluginScore · de 0 a 100

Servidor MCP construído em Cloudflare Workers que implementa um gateway de políticas criptográficas para execução segura de sinais de trading. Cada ordem passa por filtros determinísticos (Kelly Criterion, VaR, detecção de regime) antes de chegar ao broker, com assinatura HMAC e rastreabilidade completa. Interface web integrada para onboarding e monitoramento em tempo real.

Instalação

$npx convez-ai LNSTT369/NIGHTWATCH3R

1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.

Métricas

Estrelas
0
Forks
0
Acompanhando
0
Saúde
42%
Último commit
há 1 mês
Versão
—
Issues abertas
0
Contribuidores
1

Casos de uso

  • Execução segura de sinais de trading com validação antes do broker
  • Gerenciamento de risco quantitativo em tempo real (Kelly, VaR, regime)
  • Auditoria e rastreabilidade completa de ordens com HMAC-signing
  • Paper trading e backtesting via Alpaca sandbox com dashboards

Veredito

Solução sofisticada e bem arquitetada para quem precisa de execução segura em finanças quantitativas. O design zero-trust e o PolicyGate criptográfico resolvem um problema real, mas exige profundo entendimento de trading, risco e infra Cloudflare para explorar seu potencial.

README

A tradução para o português deste README ainda está na fila.

VALKYRIE

Zero-Trust Execution Rail & Algorithmic PolicyGate for Quantitative Finance.

Cloudflare Workers TypeScript Alpaca API


What This Actually Is

Most trading bots are trust-fund software: they generate signals, assume the signals are right, and wire them straight to an exchange. One hallucination, one regime shift, one dead API call — and you're holding a bag of losses with no audit trail.

VALKYRIE inverts that stack. Every trade signal must pass through a deterministic, cryptographic PolicyGate before it ever touches Alpaca. No signal reaches the execution broker without a verifiable trust chain. HMAC-signed approval tokens. Real-time position sizing via Kelly Criterion. Volatility-aware regime detection. If the policy rejects it, the order never ships. That's the whole point.

Built on Cloudflare Workers. Secured by Durable Objects. Executed through Alpaca. Zero marginal cost per trade. Zero blind trust, either.

Interface Preview


Quick Start — 3 Steps, Paper Trading

git clone https://github.com/LNSTT369/VALKYRIE.git
cd VALKYRIE

./start.sh
# → Auto-installs dependencies (if missing)
# → Provisions a local D1 SQLite database with migrations
# → Boots wrangler on port 8787

That's the entire setup. The boot banner shows you every endpoint. No config file? You get a banner, not a crash.

Then open: http://localhost:8787/portal

Follow the multi-step onboarding flow: accept the risk disclaimer → enter your Developer Key → plug in your Alpaca paper-trading credentials (API Key, Secret, starting equity) → you're live.

Inject a signal through the Alpha Portal UI or via MCP tools. Watch the PolicyGate approve it. Watch the equity curve update. Watch the paper order hit Alpaca's sandbox. Done.


Architecture at a Glance

RESEARCH ──▶ ALPHA SOCKET ──▶ POLICYGATE ──▶ ALPACA
    │              │                  │                │
    │         Signals          Risk & Regime         Market Fill
    │        Ingestion           Filter            HMAC-Verified

Every component is a Durable Object. Every signal is signed. Every trade is reconcilable.

PolicyGate (The Moat)

Pre-execution risk filter that runs on every single order:

CheckWhat It DoesFail Condition
Kelly CriterionDynamically scales position size based on calculated edgeBankroll or edge below threshold
Value at RiskMonte Carlo portfolio exposure modelingPortfolio VaR exceeds config limit
Regime DetectionClassifies current volatility regime, adjusts sizingHigh-vol mode caps all new positions
Position LimitsHard cap on open positions and notional per tradeHits max open or daily loss %

All configuration is overridable via D1 — the defaults in wrangler.toml are sane starting points.

Alpha Socket (Signal Ingestion)

A unified ingestion API that accepts signals from any source: MCP agent, webhook alert, backtest pipeline, or GitHub repo deploy. Validates structure before processing. Cryptographic HMAC signing for all inter-component comms.

Reconciler (Audit Trail)

A 60-second cron-driven Durable Object that aligns broker state with internal state. Checks Alpaca's position data against what VALKYRIE thinks is open. Logs discrepancies. Acts as the single source of truth for any trade audit.


The Onboarding Flow

The Alpha Portal walks you through setup in four steps:

  1. Intro — What this is, how it works, why it exists. Two screens max.
  2. Risk Disclaimer — Mandatory acceptance before any configuration.
  3. Developer Key — Authenticate your tenancy with a cryptographic key.
  4. Alpaca Setup — API Keys, Paper Trading toggle, Starting Equity.

No form is submitted without validation. No key is accepted without format check. The portal itself runs as static assets served from the same Cloudflare Workers runtime.


Endpoints

EndpointMethodPurpose
/healthGETHealth check, returns environment & timestamp
/GETRoot — service manifest with all known endpoints
/portalGETAlpha Portal dashboard (static assets)
/api/signalPOSTSubmit a trade signal for policy review
/api/signalGETList recent signals and their status
/api/signal/deployPOSTDeploy a strategy from a GitHub repo URL
/alpha-socket/repoPOSTIngest strategy via the Alpha Socket
/alpha-socket/repo/statusGETCheck deployment status
/alpha-socket/repo/historyGETDeployment history for your tenancy
/api/v3/regimeGETCurrent volatility regime detection
/api/v3/riskPOSTQuery policy risk configuration
/api/v3/signalsGETLive signals from active strategies
/api/v3/configGETRuntime policy configuration
/api/v3/statusGETExecution rail status & health
/api/v3/strategiesGETList deployed strategies on this tenancy
/mcpPOSTMCP agent endpoint (Durable Object)

Run http://localhost:8787/ in your browser to see the full service manifest.


Tech Stack

LayerTechnologyWhy
ComputeCloudflare WorkersZero cold-start, global edge, $0 marginal compute cost
StateD1 + KV + DODeterministic state machine per tenancy
DatabaseCloudflare D1 (SQLite)SQL on the edge. Local mode for dev, D1 for prod
ExecutionAlpaca Markets APIPaper trading in dev, live equity in prod
AI/MLMCP ServerClaude/Cursor integration, multi-provider cascade (OpenAI → Gemini → Ollama)
StreamingWebSocketLive equity curve, real-time signal updates

Local-First Development

This project is designed for self-hosting. You don't need a Cloudflare account to run it locally:

./start.sh          # Auto-installs deps, provisions local D1, boots dev server

The start.sh script handles:

  • Node.js version check (requires >= 18)
  • Auto npm install if node_modules is missing
  • .dev.vars warning banner with clear instructions if config is empty
  • Local D1 provisioning via SQLite — no Cloudflare API needed
  • Migration execution from 0001_initial.sql in the migrations directory
  • Boot banner showing all endpoints and their purposes

When you deploy to production (npm run deploy), it hits real Cloudflare Workers with a real D1 database. But dev runs entirely local-first. That's the design: self-host, test, verify before you touch live capital.


Philosophy

  "Most systems are designed for the happy path.
   This one is not."

The architecture assumes every signal could be wrong. Every API call could fail. Every trade could be reversed. The PolicyGate exists because the happy path is a liability, not a feature.

No signal reaches the execution broker without a verifiable trust chain. Zero marginal cost per trade. Zero blind trust.


Project Links

ResourcePurpose
Cloudflare WorkersRuntime platform
Alpaca MarketsExecution broker
MCP SpecificationAgent protocol standard

Ver o original no GitHub

Bom para

Relacionados