@prereason/mcp 0.1.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 (3) hide show
  1. package/README.md +70 -0
  2. package/bin/cli.mjs +99 -0
  3. package/package.json +35 -0
package/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # @prereason/mcp
2
+
3
+ MCP bridge for [PreReason](https://www.prereason.com) — connects Claude Desktop to PreReason's Bitcoin & macro data API.
4
+
5
+ PreReason provides pre-computed context templates with market data, macro indicators, trend analysis, and causal reasoning for LLM agents.
6
+
7
+ ## Quick Start
8
+
9
+ Add to your `claude_desktop_config.json`:
10
+
11
+ ```json
12
+ {
13
+ "mcpServers": {
14
+ "prereason": {
15
+ "command": "npx",
16
+ "args": [
17
+ "-y", "@prereason/mcp",
18
+ "--header", "Authorization:Bearer YOUR_API_KEY"
19
+ ]
20
+ }
21
+ }
22
+ }
23
+ ```
24
+
25
+ Config file location:
26
+ - **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
27
+ - **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
28
+
29
+ Restart Claude Desktop after editing the config.
30
+
31
+ ## Get an API Key
32
+
33
+ 1. Sign up at [prereason.com](https://www.prereason.com)
34
+ 2. Go to Dashboard > Settings > API Keys
35
+ 3. Copy your key (starts with `pr_live_`)
36
+
37
+ ## What You Get
38
+
39
+ 5 MCP tools:
40
+
41
+ | Tool | Description | Auth Required |
42
+ |------|-------------|---------------|
43
+ | `list_templates` | List all 17 context templates | No |
44
+ | `list_metrics` | List all 26 available metrics | No |
45
+ | `get_health` | API health check | No |
46
+ | `get_context` | Fetch a context template | Yes |
47
+ | `get_metric` | Fetch a single metric | Yes |
48
+
49
+ ## Example Prompts
50
+
51
+ Once connected, ask Claude:
52
+
53
+ - "What's the current BTC regime?"
54
+ - "Show me the macro snapshot"
55
+ - "What does the full context template say about market conditions?"
56
+ - "List available prereason templates"
57
+
58
+ ## Claude Code / Cursor / Windsurf
59
+
60
+ These clients support remote HTTP MCP servers directly — no bridge needed:
61
+
62
+ ```
63
+ claude mcp add prereason --transport http https://api.prereason.com/api/mcp
64
+ ```
65
+
66
+ ## Links
67
+
68
+ - [Documentation](https://www.prereason.com/docs#mcp)
69
+ - [API Reference](https://api.prereason.com/.well-known/mcp/server.json)
70
+ - [PreReason](https://www.prereason.com)
package/bin/cli.mjs ADDED
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @prereason/mcp — MCP bridge for Claude Desktop
4
+ *
5
+ * Connects Claude Desktop (stdio) to PreReason's Streamable HTTP MCP endpoint.
6
+ *
7
+ * Usage:
8
+ * npx @prereason/mcp [--header Key:Value]...
9
+ * npx @prereason/mcp <URL> [--header Key:Value]...
10
+ *
11
+ * Examples:
12
+ * npx @prereason/mcp --header "Authorization:Bearer pr_live_..."
13
+ * npx @prereason/mcp https://api.prereason.com/api/mcp --header "Authorization:Bearer pr_live_..."
14
+ */
15
+
16
+ import { createRequire } from 'node:module';
17
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
18
+ import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
19
+
20
+ const DEFAULT_URL = 'https://api.prereason.com/api/mcp';
21
+
22
+ // --- Help / Version ---
23
+ if (process.argv.includes('--help') || process.argv.includes('-h')) {
24
+ const require = createRequire(import.meta.url);
25
+ const pkg = require('../package.json');
26
+ process.stderr.write(`${pkg.name} v${pkg.version}\n\n`);
27
+ process.stderr.write('Usage:\n');
28
+ process.stderr.write(' npx @prereason/mcp [--header Key:Value]...\n');
29
+ process.stderr.write(' npx @prereason/mcp <URL> [--header Key:Value]...\n\n');
30
+ process.stderr.write('Options:\n');
31
+ process.stderr.write(' --header Key:Value Add HTTP header (can be repeated)\n');
32
+ process.stderr.write(' --help, -h Show this help\n');
33
+ process.stderr.write(' --version, -v Show version\n\n');
34
+ process.stderr.write(`Default URL: ${DEFAULT_URL}\n`);
35
+ process.exit(0);
36
+ }
37
+
38
+ if (process.argv.includes('--version') || process.argv.includes('-v')) {
39
+ const require = createRequire(import.meta.url);
40
+ const pkg = require('../package.json');
41
+ process.stderr.write(`${pkg.version}\n`);
42
+ process.exit(0);
43
+ }
44
+
45
+ // --- Parse CLI arguments ---
46
+ let urlArg = DEFAULT_URL;
47
+ const headers = {};
48
+
49
+ for (let i = 2; i < process.argv.length; i++) {
50
+ if (process.argv[i] === '--header' && process.argv[i + 1]) {
51
+ const val = process.argv[++i];
52
+ const colonIdx = val.indexOf(':');
53
+ if (colonIdx > 0) {
54
+ headers[val.slice(0, colonIdx).trim()] = val.slice(colonIdx + 1).trim();
55
+ }
56
+ } else if (!process.argv[i].startsWith('-')) {
57
+ urlArg = process.argv[i];
58
+ }
59
+ }
60
+
61
+ const url = new URL(urlArg);
62
+
63
+ // --- Create transports ---
64
+ const stdio = new StdioServerTransport();
65
+ const http = new StreamableHTTPClientTransport(url, {
66
+ requestInit: Object.keys(headers).length > 0 ? { headers } : undefined,
67
+ });
68
+
69
+ // --- Wire message routing ---
70
+ stdio.onmessage = (msg) => {
71
+ http.send(msg).catch((e) => {
72
+ process.stderr.write(`[prereason:send] ${e.message}\n`);
73
+ });
74
+ };
75
+
76
+ http.onmessage = (msg) => {
77
+ stdio.send(msg).catch((e) => {
78
+ process.stderr.write(`[prereason:recv] ${e.message}\n`);
79
+ });
80
+ };
81
+
82
+ // --- Error handling ---
83
+ stdio.onerror = (e) => process.stderr.write(`[prereason:stdio] ${e.message}\n`);
84
+ http.onerror = (e) => process.stderr.write(`[prereason:http] ${e.message}\n`);
85
+
86
+ // --- Graceful shutdown ---
87
+ stdio.onclose = () => {
88
+ http.close();
89
+ process.exit(0);
90
+ };
91
+
92
+ http.onclose = () => {
93
+ stdio.close();
94
+ process.exit(0);
95
+ };
96
+
97
+ // --- Start ---
98
+ await http.start();
99
+ await stdio.start();
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@prereason/mcp",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Connect Claude Desktop to PreReason's Bitcoin & macro data API via MCP",
6
+ "bin": {
7
+ "prereason-mcp": "./bin/cli.mjs"
8
+ },
9
+ "files": [
10
+ "bin",
11
+ "README.md"
12
+ ],
13
+ "dependencies": {
14
+ "@modelcontextprotocol/sdk": "^1.26.0"
15
+ },
16
+ "engines": {
17
+ "node": ">=18"
18
+ },
19
+ "keywords": [
20
+ "mcp",
21
+ "model-context-protocol",
22
+ "claude",
23
+ "bitcoin",
24
+ "macro",
25
+ "prereason",
26
+ "ai",
27
+ "llm"
28
+ ],
29
+ "license": "MIT",
30
+ "homepage": "https://www.prereason.com/docs#mcp",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/prereason/mcp"
34
+ }
35
+ }