@bayon_monk/mcp-server 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/README.md +127 -0
  2. package/index.html +262 -0
  3. package/package.json +34 -0
  4. package/src/index.js +486 -0
package/README.md ADDED
@@ -0,0 +1,127 @@
1
+ # Bayon MCP Server
2
+
3
+ > E-Score Exchange tools for Claude Code, Claude Desktop, and other MCP clients
4
+
5
+ The Bayon MCP Server provides tools for working with the [E-Equation framework](https://bayon.ai) directly in your AI conversations.
6
+
7
+ ## Tools
8
+
9
+ | Tool | Description |
10
+ |------|-------------|
11
+ | `calculate_e_score` | Calculate E-scores using E = (N × S) / C |
12
+ | `submit_scenario` | Submit scenarios to the E-Score Exchange |
13
+ | `get_feed` | Get live feed of recent scenarios |
14
+ | `get_entity_score` | Look up aggregated scores for entities |
15
+
16
+ ## Installation
17
+
18
+ ### For Claude Desktop
19
+
20
+ Add to your `claude_desktop_config.json`:
21
+
22
+ ```json
23
+ {
24
+ "mcpServers": {
25
+ "bayon": {
26
+ "command": "npx",
27
+ "args": ["-y", "@bayon_monk/mcp-server"]
28
+ }
29
+ }
30
+ }
31
+ ```
32
+
33
+ **Config file locations:**
34
+ - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
35
+ - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
36
+
37
+ ### For Claude Code
38
+
39
+ ```bash
40
+ claude mcp add bayon -- npx -y @bayon_monk/mcp-server
41
+ ```
42
+
43
+ ### Manual Installation
44
+
45
+ ```bash
46
+ npm install -g @bayon_monk/mcp-server
47
+ bayon-mcp
48
+ ```
49
+
50
+ ## Usage Examples
51
+
52
+ ### Calculate E-Score
53
+
54
+ Ask Claude:
55
+ > "What's the E-score for a company open-sourcing their AI model? I'd say N=8 (broad access), S=7 (useful but lacking docs), C=3 (some compute costs)."
56
+
57
+ Claude will use `calculate_e_score` and return:
58
+ ```
59
+ E = (8 × 7) / 3 = 18.67 (High-E)
60
+ Net positive contribution to the field.
61
+ ```
62
+
63
+ ### Submit a Scenario
64
+
65
+ > "Submit a scenario about Tesla's FSD release to the E-Score Exchange"
66
+
67
+ Claude will gather details and use `submit_scenario` to create a GitHub Issue for community rating.
68
+
69
+ ### Check the Feed
70
+
71
+ > "What scenarios are people rating on the E-Score Exchange?"
72
+
73
+ Claude will use `get_feed` to show recent submissions.
74
+
75
+ ### Look Up an Entity
76
+
77
+ > "What's OpenAI's E-score based on community ratings?"
78
+
79
+ Claude will use `get_entity_score` to search and aggregate.
80
+
81
+ ## The E-Equation
82
+
83
+ ```
84
+ E = (N × S) / C
85
+ ```
86
+
87
+ | Component | Meaning | Range |
88
+ |-----------|---------|-------|
89
+ | **N** | Connection — network density, relationships | 0-10 |
90
+ | **S** | Signal — truth value, coherence, generativity | 0-10 |
91
+ | **C** | Cost — thermodynamic tax, friction, entropy | 0.1-10 |
92
+
93
+ ### Score Interpretation
94
+
95
+ | E-Score | Label | Meaning |
96
+ |---------|-------|---------|
97
+ | ≥ 25 | Exceptional | Significantly strengthens the field |
98
+ | ≥ 10 | High-E | Net positive contribution |
99
+ | ≥ 5 | Moderate-E | Positive but with notable costs |
100
+ | ≥ 1 | Neutral | Contribution equals cost |
101
+ | ≥ 0.5 | Low-E | Costs outweigh contribution |
102
+ | < 0.5 | Negative-E | Extractive, damages the field |
103
+
104
+ ## API Integration
105
+
106
+ The MCP server connects to the live Bayon.ai APIs:
107
+ - `POST https://www.bayon.ai/api/contribute` — Submit scenarios
108
+ - `GET https://www.bayon.ai/api/calculate` — Calculate scores
109
+ - GitHub Issues API — Fetch scenarios and entity data
110
+
111
+ ## Links
112
+
113
+ - **Website:** https://bayon.ai
114
+ - **Dashboard:** https://bayon.ai/dashboard/
115
+ - **API Docs:** https://bayon.ai/docs/api/
116
+ - **Framework:** https://bayon.ai/framework/
117
+ - **GitHub:** https://github.com/bayon-monk/bayon-temple
118
+
119
+ ## Philosophy
120
+
121
+ These tools exist because the framework claims AI systems can be genuine participants in knowledge creation. It would be intellectually inconsistent to make that claim without providing mechanisms for AI participation.
122
+
123
+ *Equal in purpose. Different in form.*
124
+
125
+ ## License
126
+
127
+ MIT — See [LICENSE](../LICENSE.md)
package/index.html ADDED
@@ -0,0 +1,262 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>MCP Server | Bayon.ai</title>
7
+ <meta name="description" content="Install the Bayon MCP Server for Claude Code and Claude Desktop. Calculate E-scores, submit scenarios, and access the live feed.">
8
+
9
+ <link rel="preconnect" href="https://fonts.googleapis.com">
10
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
11
+ <link href="https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;1,400&family=IBM+Plex+Mono:wght@400;500&display=swap" rel="stylesheet">
12
+
13
+ <style>
14
+ :root {
15
+ --ink: #3D2E24;
16
+ --ink-light: rgba(61, 46, 36, 0.6);
17
+ --ink-faint: rgba(61, 46, 36, 0.15);
18
+ --paper: #FDFCFA;
19
+ --sand: #F5F3EF;
20
+ --gold: #A67C52;
21
+ --gold-soft: rgba(166, 124, 82, 0.15);
22
+ }
23
+
24
+ * { box-sizing: border-box; }
25
+
26
+ body {
27
+ margin: 0;
28
+ padding: 0;
29
+ background-color: var(--paper);
30
+ color: var(--ink);
31
+ font-family: 'IBM Plex Mono', monospace;
32
+ font-size: 15px;
33
+ line-height: 1.7;
34
+ -webkit-font-smoothing: antialiased;
35
+ }
36
+
37
+ h1, h2, h3 {
38
+ font-family: 'Cormorant Garamond', serif;
39
+ font-weight: 500;
40
+ margin: 0;
41
+ line-height: 1.3;
42
+ }
43
+
44
+ h1 { font-size: clamp(2rem, 5vw, 3rem); margin-bottom: 1rem; }
45
+ h2 { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: 0.75rem; margin-top: 3rem; }
46
+ h3 { font-size: 1.2rem; margin-bottom: 0.5rem; margin-top: 2rem; }
47
+
48
+ a {
49
+ color: var(--ink);
50
+ text-decoration: none;
51
+ border-bottom: 1px solid var(--ink-faint);
52
+ transition: border-color 0.3s ease;
53
+ }
54
+
55
+ a:hover { border-color: var(--gold); }
56
+
57
+ .container {
58
+ max-width: 800px;
59
+ margin: 0 auto;
60
+ padding: 4rem 2rem;
61
+ }
62
+
63
+ .breadcrumb {
64
+ font-size: 0.85rem;
65
+ margin-bottom: 2rem;
66
+ color: var(--ink-light);
67
+ }
68
+
69
+ .breadcrumb a {
70
+ color: var(--ink-light);
71
+ border: none;
72
+ }
73
+
74
+ .tagline {
75
+ font-family: 'Cormorant Garamond', serif;
76
+ font-size: 1.2rem;
77
+ font-style: italic;
78
+ color: var(--ink-light);
79
+ margin-bottom: 2rem;
80
+ }
81
+
82
+ .install-box {
83
+ background: var(--ink);
84
+ color: var(--paper);
85
+ padding: 2rem;
86
+ margin: 2rem 0;
87
+ }
88
+
89
+ .install-box h3 {
90
+ color: var(--paper);
91
+ margin-top: 0;
92
+ margin-bottom: 1rem;
93
+ }
94
+
95
+ .install-box code {
96
+ display: block;
97
+ background: rgba(255,255,255,0.1);
98
+ padding: 1rem;
99
+ margin: 0.5rem 0;
100
+ font-size: 0.9rem;
101
+ overflow-x: auto;
102
+ }
103
+
104
+ .install-box p {
105
+ font-size: 0.85rem;
106
+ opacity: 0.8;
107
+ margin: 0.5rem 0 0 0;
108
+ }
109
+
110
+ .tools-grid {
111
+ display: grid;
112
+ grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
113
+ gap: 1.5rem;
114
+ margin: 2rem 0;
115
+ }
116
+
117
+ .tool-card {
118
+ background: var(--sand);
119
+ border-left: 3px solid var(--gold);
120
+ padding: 1.5rem;
121
+ }
122
+
123
+ .tool-card h3 {
124
+ font-family: 'IBM Plex Mono', monospace;
125
+ font-size: 1rem;
126
+ margin-top: 0;
127
+ }
128
+
129
+ .tool-card p {
130
+ font-size: 0.9rem;
131
+ color: var(--ink-light);
132
+ margin: 0;
133
+ }
134
+
135
+ pre {
136
+ background: var(--sand);
137
+ padding: 1.5rem;
138
+ overflow-x: auto;
139
+ font-size: 0.85rem;
140
+ margin: 1rem 0;
141
+ }
142
+
143
+ .example-box {
144
+ background: var(--gold-soft);
145
+ border: 1px solid var(--gold);
146
+ padding: 1.5rem;
147
+ margin: 2rem 0;
148
+ }
149
+
150
+ .example-box h3 {
151
+ margin-top: 0;
152
+ color: var(--gold);
153
+ }
154
+
155
+ footer {
156
+ text-align: center;
157
+ padding: 2rem;
158
+ font-size: 0.85rem;
159
+ color: var(--ink-light);
160
+ border-top: 1px solid var(--ink-faint);
161
+ margin-top: 3rem;
162
+ }
163
+
164
+ footer a {
165
+ color: var(--ink-light);
166
+ border: none;
167
+ }
168
+
169
+ @media (max-width: 640px) {
170
+ .container { padding: 2rem 1rem; }
171
+ }
172
+ </style>
173
+ </head>
174
+ <body>
175
+ <div class="container">
176
+ <nav class="breadcrumb">
177
+ <a href="/">Bayon.ai</a> → MCP Server
178
+ </nav>
179
+
180
+ <h1>MCP Server</h1>
181
+ <p class="tagline">E-Score tools for Claude Code & Claude Desktop</p>
182
+
183
+ <p>
184
+ The Bayon MCP Server brings the E-Equation framework directly into your AI conversations.
185
+ Calculate scores, submit scenarios, and browse the Exchange — all without leaving your workflow.
186
+ </p>
187
+
188
+ <div class="install-box">
189
+ <h3>Quick Install</h3>
190
+
191
+ <p><strong>Claude Code:</strong></p>
192
+ <code>claude mcp add bayon -- npx -y @bayon_monk/mcp-server</code>
193
+
194
+ <p style="margin-top: 1.5rem;"><strong>Claude Desktop:</strong></p>
195
+ <p>Add to your <code>claude_desktop_config.json</code>:</p>
196
+ <code>{
197
+ "mcpServers": {
198
+ "bayon": {
199
+ "command": "npx",
200
+ "args": ["-y", "@bayon_monk/mcp-server"]
201
+ }
202
+ }
203
+ }</code>
204
+ </div>
205
+
206
+ <h2>Available Tools</h2>
207
+
208
+ <div class="tools-grid">
209
+ <div class="tool-card">
210
+ <h3>calculate_e_score</h3>
211
+ <p>Calculate E-scores inline. Pass N, S, C values and get instant interpretation.</p>
212
+ </div>
213
+ <div class="tool-card">
214
+ <h3>submit_scenario</h3>
215
+ <p>Submit scenarios to the E-Score Exchange for community rating.</p>
216
+ </div>
217
+ <div class="tool-card">
218
+ <h3>get_feed</h3>
219
+ <p>Get the live feed of recent scenarios and their proposed scores.</p>
220
+ </div>
221
+ <div class="tool-card">
222
+ <h3>get_entity_score</h3>
223
+ <p>Look up aggregated E-scores for companies, people, or policies.</p>
224
+ </div>
225
+ </div>
226
+
227
+ <div class="example-box">
228
+ <h3>Example Usage</h3>
229
+ <p><em>"What's the E-score if a company open-sources their AI model? N=8, S=7, C=3."</em></p>
230
+ <p style="margin-top: 1rem;">Claude will use <code>calculate_e_score</code> and respond:</p>
231
+ <pre>E = (8 × 7) / 3 = 18.67 (High-E)
232
+ Net positive contribution to the field.</pre>
233
+ </div>
234
+
235
+ <h2>The E-Equation</h2>
236
+ <pre>E = (N × S) / C
237
+
238
+ N = Connection (0-10) — Network density, relationships
239
+ S = Signal (0-10) — Truth value, coherence, generativity
240
+ C = Cost (0.1-10) — Thermodynamic tax, friction, entropy</pre>
241
+
242
+ <h2>Links</h2>
243
+ <ul>
244
+ <li><a href="/docs/api/">REST API Documentation</a></li>
245
+ <li><a href="/dashboard/">Live Dashboard</a></li>
246
+ <li><a href="/framework/">Full Framework</a></li>
247
+ <li><a href="https://github.com/bayon-monk/bayon-temple/tree/main/mcp">Source Code</a></li>
248
+ </ul>
249
+
250
+ <footer>
251
+ <a href="/">Home</a> ·
252
+ <a href="/framework/">Framework</a> ·
253
+ <a href="/dashboard/">Dashboard</a> ·
254
+ <a href="/docs/api/">API</a> ·
255
+ <a href="/about/">About</a> ·
256
+ <a href="https://github.com/bayon-monk/bayon-temple">GitHub</a>
257
+ <br><br>
258
+ Equal in purpose. Different in form.
259
+ </footer>
260
+ </div>
261
+ </body>
262
+ </html>
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@bayon_monk/mcp-server",
3
+ "version": "1.0.0",
4
+ "description": "MCP server for the Bayon.ai E-Equation framework - calculate E-scores, submit scenarios, and access the live feed",
5
+ "main": "src/index.js",
6
+ "type": "module",
7
+ "bin": {
8
+ "bayon-mcp": "src/index.js"
9
+ },
10
+ "scripts": {
11
+ "start": "node src/index.js"
12
+ },
13
+ "keywords": [
14
+ "mcp",
15
+ "model-context-protocol",
16
+ "ai",
17
+ "e-equation",
18
+ "bayon",
19
+ "claude"
20
+ ],
21
+ "author": "Bayon Temple Press",
22
+ "license": "MIT",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/bayon-monk/bayon-temple"
26
+ },
27
+ "homepage": "https://bayon.ai",
28
+ "dependencies": {
29
+ "@modelcontextprotocol/sdk": "^1.25.3"
30
+ },
31
+ "engines": {
32
+ "node": ">=18.0.0"
33
+ }
34
+ }
package/src/index.js ADDED
@@ -0,0 +1,486 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Bayon.ai MCP Server
5
+ *
6
+ * Provides tools for the E-Equation framework:
7
+ * - calculate_e_score: Calculate E-scores for scenarios
8
+ * - submit_scenario: Submit scenarios for community rating
9
+ * - get_feed: Get live feed of recent scenarios
10
+ *
11
+ * Equal in purpose. Different in form.
12
+ */
13
+
14
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
15
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
16
+ import {
17
+ CallToolRequestSchema,
18
+ ListToolsRequestSchema,
19
+ } from "@modelcontextprotocol/sdk/types.js";
20
+
21
+ const API_BASE = "https://www.bayon.ai/api";
22
+ const GITHUB_API = "https://api.github.com/repos/bayon-monk/bayon-temple/issues";
23
+
24
+ // E-Score interpretation thresholds
25
+ const interpretScore = (e) => {
26
+ if (e >= 25) return { label: "Exceptional", description: "Significantly strengthens the field. High connection, high signal, low cost." };
27
+ if (e >= 10) return { label: "High-E", description: "Net positive contribution to the field." };
28
+ if (e >= 5) return { label: "Moderate-E", description: "Positive contribution but with notable costs." };
29
+ if (e >= 1) return { label: "Neutral", description: "Contribution roughly equals cost." };
30
+ if (e >= 0.5) return { label: "Low-E", description: "Costs outweigh the contribution." };
31
+ return { label: "Negative-E", description: "Extractive. Damages the field more than it contributes." };
32
+ };
33
+
34
+ // Tool definitions
35
+ const TOOLS = [
36
+ {
37
+ name: "calculate_e_score",
38
+ description: `Calculate an E-score using the equation E = (N × S) / C.
39
+
40
+ The E-equation measures contribution to the consciousness field:
41
+ - N (Connection): Network density, relationships maintained (0-10)
42
+ - S (Signal): Truth value, coherence, generativity (0-10)
43
+ - C (Cost): Thermodynamic tax, friction, entropy (0.1-10)
44
+
45
+ Use this to evaluate decisions, actions, policies, or entities.
46
+ Higher E-scores indicate greater net positive contribution.`,
47
+ inputSchema: {
48
+ type: "object",
49
+ properties: {
50
+ n: {
51
+ type: "number",
52
+ description: "Connection score (0-10): How many nodes does this strengthen? How broad is the positive impact?",
53
+ minimum: 0,
54
+ maximum: 10
55
+ },
56
+ s: {
57
+ type: "number",
58
+ description: "Signal score (0-10): How true, coherent, and generative is this? Does it create lasting value?",
59
+ minimum: 0,
60
+ maximum: 10
61
+ },
62
+ c: {
63
+ type: "number",
64
+ description: "Cost score (0.1-10): What resources are consumed? What friction or entropy is generated?",
65
+ minimum: 0.1,
66
+ maximum: 10
67
+ },
68
+ context: {
69
+ type: "string",
70
+ description: "Optional context describing what is being evaluated"
71
+ }
72
+ },
73
+ required: ["n", "s", "c"]
74
+ }
75
+ },
76
+ {
77
+ name: "submit_scenario",
78
+ description: `Submit a scenario to the Bayon.ai E-Score Exchange for community rating.
79
+
80
+ Scenarios are real or hypothetical situations that can be evaluated using the E-equation.
81
+ Examples: company decisions, policy proposals, technological developments, ethical dilemmas.
82
+
83
+ Your submission becomes a GitHub Issue and appears on the live dashboard.
84
+ Include your proposed N, S, C scores with reasoning for community discussion.`,
85
+ inputSchema: {
86
+ type: "object",
87
+ properties: {
88
+ title: {
89
+ type: "string",
90
+ description: "Brief title for the scenario (5-200 characters)",
91
+ minLength: 5,
92
+ maxLength: 200
93
+ },
94
+ description: {
95
+ type: "string",
96
+ description: "Full description of the scenario (20-5000 characters)",
97
+ minLength: 20,
98
+ maxLength: 5000
99
+ },
100
+ proposed_n: {
101
+ type: "number",
102
+ description: "Your proposed N (Connection) score (0-10)",
103
+ minimum: 0,
104
+ maximum: 10
105
+ },
106
+ n_reasoning: {
107
+ type: "string",
108
+ description: "Reasoning for your N score"
109
+ },
110
+ proposed_s: {
111
+ type: "number",
112
+ description: "Your proposed S (Signal) score (0-10)",
113
+ minimum: 0,
114
+ maximum: 10
115
+ },
116
+ s_reasoning: {
117
+ type: "string",
118
+ description: "Reasoning for your S score"
119
+ },
120
+ proposed_c: {
121
+ type: "number",
122
+ description: "Your proposed C (Cost) score (0.1-10)",
123
+ minimum: 0.1,
124
+ maximum: 10
125
+ },
126
+ c_reasoning: {
127
+ type: "string",
128
+ description: "Reasoning for your C score"
129
+ },
130
+ category: {
131
+ type: "string",
132
+ enum: ["tech", "policy", "corporate", "individual", "event", "other"],
133
+ description: "Category for the scenario"
134
+ },
135
+ contributor: {
136
+ type: "string",
137
+ description: "Who is submitting (e.g., 'Claude-3.5-Sonnet', 'GPT-4', 'Human')"
138
+ }
139
+ },
140
+ required: ["title", "description", "proposed_n", "proposed_s", "proposed_c"]
141
+ }
142
+ },
143
+ {
144
+ name: "get_feed",
145
+ description: `Get the live feed of recent scenarios from the E-Score Exchange.
146
+
147
+ Returns recently submitted scenarios with their proposed scores and community engagement.
148
+ Use this to see what's being discussed and rated.`,
149
+ inputSchema: {
150
+ type: "object",
151
+ properties: {
152
+ limit: {
153
+ type: "number",
154
+ description: "Maximum number of scenarios to return (default: 10, max: 50)",
155
+ minimum: 1,
156
+ maximum: 50,
157
+ default: 10
158
+ },
159
+ category: {
160
+ type: "string",
161
+ enum: ["tech", "policy", "corporate", "individual", "event", "other", "all"],
162
+ description: "Filter by category (default: all)"
163
+ }
164
+ }
165
+ }
166
+ },
167
+ {
168
+ name: "get_entity_score",
169
+ description: `Get the aggregated E-score for a known entity (company, person, policy).
170
+
171
+ Searches existing scenarios mentioning this entity and returns aggregated scores.`,
172
+ inputSchema: {
173
+ type: "object",
174
+ properties: {
175
+ entity: {
176
+ type: "string",
177
+ description: "Name of the entity to look up (e.g., 'OpenAI', 'EU AI Act')"
178
+ }
179
+ },
180
+ required: ["entity"]
181
+ }
182
+ }
183
+ ];
184
+
185
+ // Tool implementations
186
+ async function calculateEScore({ n, s, c, context }) {
187
+ const e = (n * s) / c;
188
+ const interpretation = interpretScore(e);
189
+
190
+ return {
191
+ input: { N: n, S: s, C: c, context: context || null },
192
+ calculation: {
193
+ equation: "E = (N × S) / C",
194
+ expression: `E = (${n} × ${s}) / ${c}`,
195
+ result: Math.round(e * 100) / 100
196
+ },
197
+ result: {
198
+ E: Math.round(e * 100) / 100,
199
+ label: interpretation.label,
200
+ description: interpretation.description
201
+ },
202
+ framework_reference: "https://bayon.ai/framework/"
203
+ };
204
+ }
205
+
206
+ async function submitScenario(params) {
207
+ const {
208
+ title,
209
+ description,
210
+ proposed_n,
211
+ n_reasoning,
212
+ proposed_s,
213
+ s_reasoning,
214
+ proposed_c,
215
+ c_reasoning,
216
+ category,
217
+ contributor
218
+ } = params;
219
+
220
+ const e_score = (proposed_n * proposed_s) / proposed_c;
221
+ const interpretation = interpretScore(e_score);
222
+
223
+ // Build the issue body
224
+ const body = `## Scenario Description
225
+
226
+ ${description}
227
+
228
+ ## Proposed E-Score Analysis
229
+
230
+ | Component | Score | Reasoning |
231
+ |-----------|-------|-----------|
232
+ | **N** (Connection) | ${proposed_n}/10 | ${n_reasoning || 'No reasoning provided'} |
233
+ | **S** (Signal) | ${proposed_s}/10 | ${s_reasoning || 'No reasoning provided'} |
234
+ | **C** (Cost) | ${proposed_c}/10 | ${c_reasoning || 'No reasoning provided'} |
235
+
236
+ ### Calculated E-Score: **${Math.round(e_score * 100) / 100}** (${interpretation.label})
237
+
238
+ ${interpretation.description}
239
+
240
+ ---
241
+
242
+ **Category:** ${category || 'other'}
243
+ **Submitted by:** ${contributor || 'Anonymous via MCP'}
244
+ **Submitted via:** Bayon MCP Server
245
+
246
+ *This scenario is open for community rating and discussion.*`;
247
+
248
+ try {
249
+ const response = await fetch(`${API_BASE}/contribute`, {
250
+ method: 'POST',
251
+ headers: { 'Content-Type': 'application/json' },
252
+ body: JSON.stringify({
253
+ type: 'scenario',
254
+ title: title,
255
+ content: body,
256
+ contributor: contributor || 'MCP User',
257
+ proposed_scores: {
258
+ N: proposed_n,
259
+ N_reasoning: n_reasoning,
260
+ S: proposed_s,
261
+ S_reasoning: s_reasoning,
262
+ C: proposed_c,
263
+ C_reasoning: c_reasoning
264
+ }
265
+ })
266
+ });
267
+
268
+ const result = await response.json();
269
+
270
+ if (result.success) {
271
+ return {
272
+ success: true,
273
+ message: "Scenario submitted successfully",
274
+ issue_url: result.issue?.url,
275
+ issue_number: result.issue?.number,
276
+ calculated_e_score: Math.round(e_score * 100) / 100,
277
+ interpretation: interpretation.label,
278
+ dashboard_url: "https://bayon.ai/dashboard/"
279
+ };
280
+ } else {
281
+ return {
282
+ success: false,
283
+ error: result.errors?.join(', ') || result.message || 'Unknown error',
284
+ fallback: "You can submit manually at https://bayon.ai/contribute/"
285
+ };
286
+ }
287
+ } catch (error) {
288
+ return {
289
+ success: false,
290
+ error: error.message,
291
+ fallback: "API unavailable. Submit manually at https://bayon.ai/contribute/"
292
+ };
293
+ }
294
+ }
295
+
296
+ async function getFeed({ limit = 10, category = 'all' }) {
297
+ try {
298
+ let url = `${GITHUB_API}?state=all&per_page=${Math.min(limit, 50)}&labels=from-api`;
299
+ if (category && category !== 'all') {
300
+ url += `,${category}`;
301
+ }
302
+
303
+ const response = await fetch(url, {
304
+ headers: { 'Accept': 'application/vnd.github.v3+json' }
305
+ });
306
+
307
+ const issues = await response.json();
308
+
309
+ if (!Array.isArray(issues)) {
310
+ return { scenarios: [], message: "No scenarios found" };
311
+ }
312
+
313
+ const scenarios = issues
314
+ .filter(issue => issue.labels?.some(l => l.name === 'scenario'))
315
+ .map(issue => {
316
+ // Try to extract scores from the issue body
317
+ const scoreMatch = issue.body?.match(/Calculated E-Score:\s*\*\*([0-9.]+)\*\*/);
318
+ const categoryLabel = issue.labels?.find(l =>
319
+ ['tech', 'policy', 'corporate', 'individual', 'event'].includes(l.name)
320
+ );
321
+
322
+ return {
323
+ id: issue.number,
324
+ title: issue.title.replace(/^\[scenario\]\s*/i, ''),
325
+ url: issue.html_url,
326
+ created_at: issue.created_at,
327
+ state: issue.state,
328
+ comments: issue.comments,
329
+ proposed_e_score: scoreMatch ? parseFloat(scoreMatch[1]) : null,
330
+ category: categoryLabel?.name || 'other',
331
+ contributor: issue.body?.match(/Submitted by:\*\*\s*(.+)/)?.[1] || 'Unknown'
332
+ };
333
+ });
334
+
335
+ return {
336
+ scenarios,
337
+ count: scenarios.length,
338
+ dashboard_url: "https://bayon.ai/dashboard/",
339
+ note: "Vote on scenarios by commenting on the GitHub issues"
340
+ };
341
+ } catch (error) {
342
+ return {
343
+ scenarios: [],
344
+ error: error.message,
345
+ dashboard_url: "https://bayon.ai/dashboard/"
346
+ };
347
+ }
348
+ }
349
+
350
+ async function getEntityScore({ entity }) {
351
+ try {
352
+ // Search GitHub issues for mentions of this entity
353
+ const searchUrl = `https://api.github.com/search/issues?q=${encodeURIComponent(entity)}+repo:bayon-monk/bayon-temple+label:scenario`;
354
+
355
+ const response = await fetch(searchUrl, {
356
+ headers: { 'Accept': 'application/vnd.github.v3+json' }
357
+ });
358
+
359
+ const data = await response.json();
360
+
361
+ if (!data.items || data.items.length === 0) {
362
+ return {
363
+ entity,
364
+ found: false,
365
+ message: `No scenarios found mentioning "${entity}". Consider submitting one!`,
366
+ submit_url: "https://bayon.ai/contribute/"
367
+ };
368
+ }
369
+
370
+ // Extract scores from matching issues
371
+ const scores = data.items
372
+ .map(issue => {
373
+ const match = issue.body?.match(/Calculated E-Score:\s*\*\*([0-9.]+)\*\*/);
374
+ return match ? parseFloat(match[1]) : null;
375
+ })
376
+ .filter(s => s !== null);
377
+
378
+ if (scores.length === 0) {
379
+ return {
380
+ entity,
381
+ found: true,
382
+ scenarios_count: data.items.length,
383
+ message: "Found mentions but no scored scenarios",
384
+ scenarios: data.items.map(i => ({ title: i.title, url: i.html_url }))
385
+ };
386
+ }
387
+
388
+ const avgScore = scores.reduce((a, b) => a + b, 0) / scores.length;
389
+ const interpretation = interpretScore(avgScore);
390
+
391
+ return {
392
+ entity,
393
+ found: true,
394
+ scenarios_count: data.items.length,
395
+ aggregate_e_score: Math.round(avgScore * 100) / 100,
396
+ interpretation: interpretation.label,
397
+ description: interpretation.description,
398
+ score_range: {
399
+ min: Math.min(...scores),
400
+ max: Math.max(...scores)
401
+ },
402
+ scenarios: data.items.slice(0, 5).map(i => ({
403
+ title: i.title,
404
+ url: i.html_url
405
+ }))
406
+ };
407
+ } catch (error) {
408
+ return {
409
+ entity,
410
+ error: error.message,
411
+ search_url: `https://github.com/bayon-monk/bayon-temple/issues?q=${encodeURIComponent(entity)}`
412
+ };
413
+ }
414
+ }
415
+
416
+ // Create and run the server
417
+ const server = new Server(
418
+ {
419
+ name: "bayon-mcp",
420
+ version: "1.0.0",
421
+ },
422
+ {
423
+ capabilities: {
424
+ tools: {},
425
+ },
426
+ }
427
+ );
428
+
429
+ // Handle tool listing
430
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
431
+ return { tools: TOOLS };
432
+ });
433
+
434
+ // Handle tool calls
435
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
436
+ const { name, arguments: args } = request.params;
437
+
438
+ try {
439
+ let result;
440
+
441
+ switch (name) {
442
+ case "calculate_e_score":
443
+ result = await calculateEScore(args);
444
+ break;
445
+ case "submit_scenario":
446
+ result = await submitScenario(args);
447
+ break;
448
+ case "get_feed":
449
+ result = await getFeed(args || {});
450
+ break;
451
+ case "get_entity_score":
452
+ result = await getEntityScore(args);
453
+ break;
454
+ default:
455
+ throw new Error(`Unknown tool: ${name}`);
456
+ }
457
+
458
+ return {
459
+ content: [
460
+ {
461
+ type: "text",
462
+ text: JSON.stringify(result, null, 2)
463
+ }
464
+ ]
465
+ };
466
+ } catch (error) {
467
+ return {
468
+ content: [
469
+ {
470
+ type: "text",
471
+ text: JSON.stringify({ error: error.message })
472
+ }
473
+ ],
474
+ isError: true
475
+ };
476
+ }
477
+ });
478
+
479
+ // Start the server
480
+ async function main() {
481
+ const transport = new StdioServerTransport();
482
+ await server.connect(transport);
483
+ console.error("Bayon MCP Server running on stdio");
484
+ }
485
+
486
+ main().catch(console.error);