mirror of
https://github.com/ruvnet/RuView
synced 2026-07-20 17:03:24 +00:00
092152bd73
Advances SPARC Phase 3 (Architecture): wires the phase-2 schema barrel into
the MCP CallTool dispatch loop, and scaffolds the Streamable HTTP transport
with Origin-validation and bearer-token auth as specified in ADR-124 §3/§6.
Sub-task (a) — Uniform Zod validation gate in src/index.ts:
- Import TOOL_INPUT_SCHEMAS + McpError + ErrorCode from SDK
- CallTool handler: before dispatch, looks up schema by tool name using
Object.prototype.hasOwnProperty (safe for dotted keys) then runs
schema.safeParse(args); failures throw McpError(InvalidParams) so the
caller receives a typed JSON-RPC error rather than a wrapped string
- Re-throws McpError instances unchanged (policy errors propagate cleanly)
Sub-task (b) — src/http-transport.ts (new, 145 LOC):
- buildHttpApp(mcpServer, opts): creates Node.js http.Server +
StreamableHTTPServerTransport without binding; testable in isolation
- createHttpTransport(mcpServer, opts): binds and resolves when listening
- isOriginAllowed(origin, allowedOrigins): pure function — undefined origin
allowed (non-browser), present origin validated against allowlist,
'*' disables gate for local-dev
- Bearer-token gate: RVAGENT_HTTP_TOKEN env or opts.bearerToken; missing/
wrong token → 401 before any JSON-RPC processing
- Bind default: 127.0.0.1 per MCP spec security requirement (ADR-124 §3)
- Transport connect() only in createHttpTransport (not buildHttpApp) to
avoid exactOptionalPropertyTypes false-incompatibility in test contexts
New test: tests/http-transport.test.ts (11 assertions):
- isOriginAllowed() unit ×5: undefined allowed, allowlist hit/miss, wildcard,
case-sensitivity (RFC 6454)
- Origin-validation integration ×3: cross-origin → 403 with error body,
allowed origin → non-403, no Origin → non-403
- Bearer-token integration ×3: missing → 401, wrong → 401, correct → non-401
Fix: @types/express added as devDep (express is transitive from SDK ^1.29.0).
Test results: 61/61 PASS (+11 new)
Build: tsc clean, zero errors.
ACs touched: ADR-124 §3 (dual-transport architecture), §6 (Origin validation,
127.0.0.1 bind, bearer-token auth slot). SPARC Phase 3 gate criteria met:
API contracts typed, module boundaries established, no circular deps.
Next iter target: Phase 4 (Refinement) — implement ruview.bfld.last_scan +
ruview.bfld.subscribe tool handlers (BFLD wire format stable post-ADR-118),
register them in the TOOLS array using the new schema-validation gate.
Co-Authored-By: claude-flow <ruv@ruv.net>
74 lines
1.7 KiB
JSON
74 lines
1.7 KiB
JSON
{
|
|
"name": "@ruvnet/rvagent",
|
|
"version": "0.1.0",
|
|
"description": "SENSE-BRIDGE: dual-transport MCP server (stdio + Streamable HTTP) exposing RuView WiFi-DensePose sensing primitives to AI agents",
|
|
"type": "module",
|
|
"main": "dist/index.js",
|
|
"types": "dist/index.d.ts",
|
|
"exports": {
|
|
".": {
|
|
"import": "./dist/index.js",
|
|
"require": "./dist/index.cjs",
|
|
"types": "./dist/index.d.ts"
|
|
}
|
|
},
|
|
"bin": {
|
|
"rvagent": "dist/index.js",
|
|
"ruview-mcp": "dist/index.js"
|
|
},
|
|
"files": [
|
|
"dist",
|
|
"README.md",
|
|
"CHANGELOG.md"
|
|
],
|
|
"scripts": {
|
|
"build": "tsc",
|
|
"dev": "tsc --watch",
|
|
"start": "node dist/index.js",
|
|
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --forceExit",
|
|
"lint": "eslint src --ext .ts",
|
|
"typecheck": "tsc --noEmit"
|
|
},
|
|
"keywords": [
|
|
"mcp",
|
|
"rvagent",
|
|
"ruview",
|
|
"wifi",
|
|
"csi",
|
|
"pose-estimation",
|
|
"cognitum",
|
|
"sense-bridge",
|
|
"ruvnet"
|
|
],
|
|
"author": "ruv <ruv@ruv.net>",
|
|
"license": "Apache-2.0",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "https://github.com/ruvnet/RuView.git",
|
|
"directory": "tools/ruview-mcp"
|
|
},
|
|
"homepage": "https://github.com/ruvnet/RuView/tree/main/tools/ruview-mcp",
|
|
"bugs": {
|
|
"url": "https://github.com/ruvnet/RuView/issues"
|
|
},
|
|
"dependencies": {
|
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
"zod": "^3.23.8"
|
|
},
|
|
"devDependencies": {
|
|
"@types/express": "^5.0.6",
|
|
"@types/jest": "^30.0.0",
|
|
"@types/node": "^20.14.0",
|
|
"jest": "^29.7.0",
|
|
"ts-jest": "^29.1.0",
|
|
"typescript": "^5.4.5"
|
|
},
|
|
"engines": {
|
|
"node": ">=20.0.0"
|
|
},
|
|
"publishConfig": {
|
|
"access": "public",
|
|
"registry": "https://registry.npmjs.org/"
|
|
}
|
|
}
|