jev-flash-router 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +284 -0
  3. package/dist/index.js +145 -0
  4. package/package.json +19 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ravinder82
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,284 @@
1
+ # jev-flash-router
2
+
3
+ [![npm version](https://img.shields.io/npm/v/jev-flash-router)](https://www.npmjs.com/package/jev-flash-router)
4
+ [![License: MIT](https://img.shields.io/npm/l/jev-flash-router)](LICENSE)
5
+ [![Node.js](https://img.shields.io/npm/dependency-version/jev-flash-router/peer/nodejs)](https://nodejs.org)
6
+ [![MCP](https://img.shields.io/badge/Model%20Context%20Protocol-MCP-blue)](https://modelcontextprotocol.io)
7
+ [![OpenRouter](https://img.shields.io/badge/OpenRouter-Decisions%20API-red)](https://openrouter.ai)
8
+
9
+ > **Zero-token-output decision router MCP server powered by TypeSafe Jev.**
10
+
11
+ AI coding agents waste hundreds of reasoning tokens just deciding which file to edit, which route to pick, or whether a diff breaks tests. **jev-flash-router** evaluates context, code diffs, logs, or planning options and returns calibrated probabilities in ~150ms — with **$0.00 output token cost**.
12
+
13
+ ---
14
+
15
+ ## ✨ Features
16
+
17
+ - ⚡ **~150ms decisions** — Lightning-fast evaluation via OpenRouter Decisions API
18
+ - 💸 **Zero output token cost** — `output_tokens: 0` on every call
19
+ - 🧠 **TypeSafe Jev** — Powered by the cutting-edge `~typesafe/jev-latest` model
20
+ - 🔌 **MCP-native** — Works seamlessly with Cursor, Windsurf, Claude Desktop & Claude Code
21
+ - 📦 **Zero-config** — Install via `npx` and go
22
+ - 🎯 **Three decision formats**: `noul` (binary), `choice` (categorical), `score` (rubric)
23
+
24
+ ---
25
+
26
+ ## 🚀 Quick Start
27
+
28
+ ### 1. Install as an MCP server
29
+
30
+ No local clone needed — anyone can run it instantly:
31
+
32
+ ```bash
33
+ npx -y jev-flash-router
34
+ ```
35
+
36
+ Or install globally via npm:
37
+
38
+ ```bash
39
+ npm install -g jev-flash-router
40
+ ```
41
+
42
+ ### 2. Set your OpenRouter API key
43
+
44
+ Set the `OPENROUTER_API_KEY` environment variable with your [OpenRouter](https://openrouter.ai) API key (required).
45
+
46
+ ### 3. Use the tool
47
+
48
+ In your IDE's agent chat, call:
49
+
50
+ > **evaluate_decision**
51
+ > - `state`: The context, code diff, error log, or task description
52
+ > - `question`: The targeted question to evaluate
53
+ > - `type`: `"noul"`, `"choice"`, or `"score"`
54
+ > - `criteria`: Criteria map matching the chosen type
55
+
56
+ **Example prompt:**
57
+
58
+ > "Use the evaluate_decision tool to check state 'User deleted their account', question 'Is this high churn risk?', type 'noul', criteria: { true: 'Churn', false: 'Retained' }."
59
+
60
+ **Expected response:**
61
+
62
+ ```json
63
+ {
64
+ "result": { "true": 0.82, "false": 0.18 },
65
+ "telemetry": {
66
+ "latency_ms": 142,
67
+ "output_tokens": 0,
68
+ "cost": "$0.00 output"
69
+ }
70
+ }
71
+ ```
72
+
73
+ ---
74
+
75
+ ## 🛠️ MCP Client Configuration
76
+
77
+ ### Cursor
78
+
79
+ **Settings** → **Features** → **MCP Servers** → **Add New MCP Server**
80
+
81
+ ```json
82
+ {
83
+ "mcpServers": {
84
+ "jev": {
85
+ "command": "node",
86
+ "args": ["/absolute/path/to/jev-mcp/dist/index.js"],
87
+ "env": {
88
+ "OPENROUTER_API_KEY": "sk-or-v1-YOUR-ACTUAL-API-KEY"
89
+ }
90
+ }
91
+ }
92
+ }
93
+ ```
94
+
95
+ ### Claude Desktop
96
+
97
+ Edit `~/Library/Application Support/Claude/claude_desktop_config.json`:
98
+
99
+ ```json
100
+ {
101
+ "mcpServers": {
102
+ "jev": {
103
+ "command": "node",
104
+ "args": ["/absolute/path/to/jev-mcp/dist/index.js"],
105
+ "env": {
106
+ "OPENROUTER_API_KEY": "sk-or-v1-YOUR-ACTUAL-API-KEY"
107
+ }
108
+ }
109
+ }
110
+ }
111
+ ```
112
+
113
+ ### Windsurf
114
+
115
+ Add to your Windsurf MCP configuration:
116
+
117
+ ```json
118
+ {
119
+ "mcpServers": {
120
+ "jev": {
121
+ "command": "node",
122
+ "args": ["/absolute/path/to/jev-mcp/dist/index.js"],
123
+ "env": {
124
+ "OPENROUTER_API_KEY": "sk-or-v1-YOUR-ACTUAL-API-KEY"
125
+ }
126
+ }
127
+ }
128
+ }
129
+ ```
130
+
131
+ ### Claude Code / Other MCP Clients
132
+
133
+ Any MCP-compatible client can use this server with the same configuration pattern above.
134
+
135
+ ---
136
+
137
+ ## 📦 Installation for Developers
138
+
139
+ ### Clone & Run Locally
140
+
141
+ ```bash
142
+ git clone https://github.com/Ravinder82/jev-flash-router.git
143
+ cd jev-flash-router
144
+ npm install
145
+ npm run build
146
+ npm start
147
+ ```
148
+
149
+ ### From npm (no clone)
150
+
151
+ ```bash
152
+ npx -y jev-flash-router
153
+ ```
154
+
155
+ ---
156
+
157
+ ## 🔧 Development
158
+
159
+ ### Project Structure
160
+
161
+ ```
162
+ jev-flash-router/
163
+ ├── src/
164
+ │ └── index.ts # Main server entry (TypeScript)
165
+ ├── dist/
166
+ │ └── index.js # Compiled executable (output)
167
+ ├── package.json
168
+ ├── tsconfig.json
169
+ └── README.md
170
+ ```
171
+
172
+ ### Build
173
+
174
+ ```bash
175
+ npm run build
176
+ ```
177
+
178
+ Compiles TypeScript to executable JavaScript in `./dist/index.js`.
179
+
180
+ ### Start
181
+
182
+ ```bash
183
+ npm start
184
+ ```
185
+
186
+ Runs the compiled MCP server over stdio.
187
+
188
+ ---
189
+
190
+ ## 📋 API Reference
191
+
192
+ ### Tool: `evaluate_decision`
193
+
194
+ Evaluates context and returns calibrated probabilities.
195
+
196
+ | Parameter | Type | Required | Description |
197
+ |-----------|------|----------|-------------|
198
+ | `state` | `string` | ✅ | Context, code diff, error log, or task description |
199
+ | `question` | `string` | ✅ | Targeted question (e.g., "Will this change cause a breaking API error?") |
200
+ | `type` | `string` | ✅ | Decision format: `"noul"`, `"choice"`, or `"score"` |
201
+ | `criteria` | `object` | ✅ | Criteria map matching the type |
202
+
203
+ #### Criteria Examples
204
+
205
+ **`noul`** (binary yes/no):
206
+ ```json
207
+ { "true": "breaks existing callers", "false": "backward compatible" }
208
+ ```
209
+
210
+ **`choice`** (categorical):
211
+ ```json
212
+ { "option1": "use caching", "option2": "recompute", "option3": "defer" }
213
+ ```
214
+
215
+ **`score`** (ordered rubric):
216
+ ```json
217
+ ["critical", "warning", "info"]
218
+ ```
219
+
220
+ ---
221
+
222
+ ## 💰 Cost & Performance
223
+
224
+ | Metric | Value |
225
+ |--------|-------|
226
+ | Latency | ~150ms |
227
+ | Output tokens | 0 |
228
+ | Output cost | $0.00 |
229
+ | Input cost | ~$0.042 / 1M tokens |
230
+ | Model | `~typesafe/jev-latest` |
231
+
232
+ ---
233
+
234
+ ## 🚀 Publish Your Own Copy
235
+
236
+ ### Login to npm
237
+
238
+ ```bash
239
+ npm login
240
+ ```
241
+
242
+ ### Publish
243
+
244
+ ```bash
245
+ npm publish --access public
246
+ ```
247
+
248
+ Then anyone can run `npx -y jev-flash-router` worldwide.
249
+
250
+ ---
251
+
252
+ ## 🤝 Contributing
253
+
254
+ Contributions are welcome! Please open an issue or submit a pull request.
255
+
256
+ 1. Fork the repository
257
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
258
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
259
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
260
+ 5. Open a Pull Request
261
+
262
+ ---
263
+
264
+ ## 📄 License
265
+
266
+ [MIT](LICENSE)
267
+
268
+ ---
269
+
270
+ ## 🔗 Links
271
+
272
+ - **GitHub**: https://github.com/Ravinder82/jev-flash-router
273
+ - **npm**: https://www.npmjs.com/package/jev-flash-router
274
+ - **OpenRouter**: https://openrouter.ai
275
+ - **TypeSafe Jev**: https://typesafe.jev
276
+ - **Model Context Protocol**: https://modelcontextprotocol.io
277
+
278
+ ---
279
+
280
+ ## 🙏 Acknowledgements
281
+
282
+ - [TypeSafe Jev](https://typesafe.jev) — Zero-token decision intelligence
283
+ - [OpenRouter](https://openrouter.ai) — Decisions API infrastructure
284
+ - [Model Context Protocol](https://modelcontextprotocol.io) — Universal MCP standard
package/dist/index.js ADDED
@@ -0,0 +1,145 @@
1
+ #!/usr/bin/env node
2
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
5
+ import dotenv from "dotenv";
6
+ dotenv.config();
7
+ const server = new Server({
8
+ name: "jev-flash-router",
9
+ version: "1.0.0",
10
+ }, {
11
+ capabilities: {
12
+ tools: {},
13
+ },
14
+ });
15
+ // Register the tool
16
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
17
+ return {
18
+ tools: [
19
+ {
20
+ name: "evaluate_decision",
21
+ description: "Zero-token-output decision engine powered by TypeSafe Jev. Evaluates context, code diffs, logs, or planning options and returns calibrated probabilities. Use this BEFORE generating long reasoning plans or multi-file edits to pick optimal paths.",
22
+ inputSchema: {
23
+ type: "object",
24
+ properties: {
25
+ state: {
26
+ type: "string",
27
+ description: "The context, code diff, error log, or task description to evaluate.",
28
+ },
29
+ question: {
30
+ type: "string",
31
+ description: "The targeted question to evaluate (e.g., 'Will this change cause a breaking API error?').",
32
+ },
33
+ type: {
34
+ type: "string",
35
+ enum: ["noul", "choice", "score"],
36
+ description: "Decision format: 'noul' (binary yes/no probability), 'choice' (categorical distribution), or 'score' (ordered rubric).",
37
+ },
38
+ criteria: {
39
+ type: "object",
40
+ description: "Criteria map: for 'noul' provide { true: '...', false: '...' }, for 'choice' provide { option1: '...', option2: '...' }, for 'score' provide an array of strings in order.",
41
+ },
42
+ },
43
+ required: ["state", "question", "type", "criteria"],
44
+ },
45
+ },
46
+ ],
47
+ };
48
+ });
49
+ // Handle tool execution
50
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
51
+ if (request.params.name !== "evaluate_decision") {
52
+ return {
53
+ content: [{ type: "text", text: `Unknown tool: ${request.params.name}` }],
54
+ isError: true,
55
+ };
56
+ }
57
+ const apiKey = process.env.OPENROUTER_API_KEY;
58
+ if (!apiKey) {
59
+ return {
60
+ content: [
61
+ {
62
+ type: "text",
63
+ text: "Missing OPENROUTER_API_KEY. Please provide OPENROUTER_API_KEY in your MCP client environment configuration.",
64
+ },
65
+ ],
66
+ isError: true,
67
+ };
68
+ }
69
+ const { state, question, type, criteria } = request.params.arguments;
70
+ const startTime = Date.now();
71
+ try {
72
+ const payload = {
73
+ model: "~typesafe/jev-latest",
74
+ state,
75
+ questions: {
76
+ eval: {
77
+ type,
78
+ instructions: question,
79
+ criteria,
80
+ },
81
+ },
82
+ };
83
+ const response = await fetch("https://openrouter.ai/api/alpha/decisions", {
84
+ method: "POST",
85
+ headers: {
86
+ Authorization: `Bearer ${apiKey}`,
87
+ "Content-Type": "application/json",
88
+ "HTTP-Referer": "https://github.com/Ravinder82/jev-flash-router",
89
+ "X-OpenRouter-Title": "jev-flash-router",
90
+ },
91
+ body: JSON.stringify(payload),
92
+ });
93
+ if (!response.ok) {
94
+ const errorText = await response.text();
95
+ return {
96
+ content: [
97
+ {
98
+ type: "text",
99
+ text: `OpenRouter Decisions API Error (${response.status}): ${errorText}`,
100
+ },
101
+ ],
102
+ isError: true,
103
+ };
104
+ }
105
+ const data = await response.json();
106
+ const latency = Date.now() - startTime;
107
+ const answer = data.answers?.eval ?? data;
108
+ const result = {
109
+ result: answer,
110
+ telemetry: {
111
+ latency_ms: latency,
112
+ output_tokens: 0,
113
+ cost: "$0.00 output",
114
+ },
115
+ };
116
+ return {
117
+ content: [
118
+ {
119
+ type: "text",
120
+ text: JSON.stringify(result, null, 2),
121
+ },
122
+ ],
123
+ };
124
+ }
125
+ catch (error) {
126
+ return {
127
+ content: [
128
+ {
129
+ type: "text",
130
+ text: `Failed to execute decision: ${error.message || String(error)}`,
131
+ },
132
+ ],
133
+ isError: true,
134
+ };
135
+ }
136
+ });
137
+ // Start the stdio transport
138
+ async function main() {
139
+ const transport = new StdioServerTransport();
140
+ await server.connect(transport);
141
+ }
142
+ main().catch((err) => {
143
+ console.error("Fatal error starting jev-mcp:", err);
144
+ process.exit(1);
145
+ });
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "jev-flash-router",
3
+ "version": "1.0.0",
4
+ "description": "Zero-token-output decision router MCP server powered by TypeSafe Jev",
5
+ "type": "module",
6
+ "bin": {
7
+ "jev-flash-router": "./dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "build": "tsc && chmod +x dist/index.js",
14
+ "start": "node dist/index.js"
15
+ },
16
+ "keywords": ["mcp", "model-context-protocol", "typesafe", "jev", "openrouter", "routing"],
17
+ "author": "",
18
+ "license": "MIT"
19
+ }