nvipin63 commited on
Commit
ac2f0de
·
verified ·
1 Parent(s): e781b34

Create mcp_server.py

Browse files
Files changed (1) hide show
  1. mcp_server.py +734 -0
mcp_server.py ADDED
@@ -0,0 +1,734 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ MCP Server for Second Opinion AI Agent
3
+ Provides tools for analyzing ideas, detecting biases, and generating alternatives
4
+ """
5
+
6
+ from mcp.server.fastmcp import FastMCP
7
+ from pydantic import BaseModel, Field
8
+ from typing import List, Dict, Optional, Literal
9
+ import json
10
+ from datetime import datetime
11
+
12
+ # Initialize FastMCP server
13
+ mcp = FastMCP("second-opinion-tools")
14
+
15
+ class IdeaAnalysis(BaseModel):
16
+ """Model for idea analysis input"""
17
+ idea: str = Field(..., description="The idea or decision to analyze")
18
+ context: Optional[str] = Field(None, description="Additional context or background")
19
+ goals: Optional[List[str]] = Field(None, description="Stated goals or objectives")
20
+
21
+ class BiasDetection(BaseModel):
22
+ """Model for bias detection results"""
23
+ bias_type: str
24
+ description: str
25
+ evidence: str
26
+ severity: Literal["low", "medium", "high"]
27
+
28
+ class Alternative(BaseModel):
29
+ """Model for alternative solutions"""
30
+ title: str
31
+ description: str
32
+ pros: List[str]
33
+ cons: List[str]
34
+ feasibility: Literal["low", "medium", "high"]
35
+
36
+ @mcp.tool()
37
+ def analyze_assumptions(idea: str, context: str = "") -> str:
38
+ """
39
+ Analyzes an idea to identify hidden assumptions and unstated premises.
40
+
41
+ Args:
42
+ idea: The idea or decision to analyze
43
+ context: Additional context or background information
44
+
45
+ Returns:
46
+ JSON string containing identified assumptions, their implications, and questions to verify them
47
+ """
48
+
49
+ analysis = {
50
+ "timestamp": datetime.now().isoformat(),
51
+ "idea_summary": idea[:200] + "..." if len(idea) > 200 else idea,
52
+ "analysis": {
53
+ "explicit_assumptions": [
54
+ "Assumptions that are stated directly in the idea"
55
+ ],
56
+ "implicit_assumptions": [
57
+ "Assumptions that are implied but not stated",
58
+ "Hidden premises that need to be examined"
59
+ ],
60
+ "foundational_beliefs": [
61
+ "Core beliefs this idea rests upon",
62
+ "Worldview assumptions"
63
+ ],
64
+ "contextual_assumptions": [
65
+ "Assumptions about the environment",
66
+ "Assumptions about timing and conditions"
67
+ ]
68
+ },
69
+ "verification_questions": [
70
+ "What evidence supports this assumption?",
71
+ "What if this assumption is wrong?",
72
+ "Under what conditions would this assumption fail?"
73
+ ],
74
+ "recommendations": [
75
+ "Test key assumptions before proceeding",
76
+ "Identify which assumptions are most critical",
77
+ "Create contingency plans for false assumptions"
78
+ ]
79
+ }
80
+
81
+ return json.dumps(analysis, indent=2)
82
+
83
+ @mcp.tool()
84
+ def detect_cognitive_biases(idea: str, reasoning: str = "") -> str:
85
+ """
86
+ Detects potential cognitive biases in reasoning and decision-making.
87
+
88
+ Args:
89
+ idea: The idea or decision being proposed
90
+ reasoning: The reasoning or justification provided
91
+
92
+ Returns:
93
+ JSON string containing detected biases, their descriptions, and mitigation strategies
94
+ """
95
+
96
+ common_biases = {
97
+ "confirmation_bias": {
98
+ "name": "Confirmation Bias",
99
+ "description": "Tendency to search for or interpret information that confirms existing beliefs",
100
+ "indicators": ["cherry-picking data", "ignoring contradictory evidence"],
101
+ "severity": "high"
102
+ },
103
+ "anchoring_bias": {
104
+ "name": "Anchoring Bias",
105
+ "description": "Over-reliance on the first piece of information encountered",
106
+ "indicators": ["fixating on initial numbers", "difficulty adjusting from first impression"],
107
+ "severity": "medium"
108
+ },
109
+ "sunk_cost_fallacy": {
110
+ "name": "Sunk Cost Fallacy",
111
+ "description": "Continuing a course of action due to previously invested resources",
112
+ "indicators": ["'we've come too far to turn back'", "justifying based on past investment"],
113
+ "severity": "high"
114
+ },
115
+ "availability_bias": {
116
+ "name": "Availability Bias",
117
+ "description": "Overestimating likelihood of events based on recent or memorable examples",
118
+ "indicators": ["relying on anecdotes", "recent events driving decisions"],
119
+ "severity": "medium"
120
+ },
121
+ "optimism_bias": {
122
+ "name": "Optimism Bias",
123
+ "description": "Overestimating positive outcomes and underestimating risks",
124
+ "indicators": ["'it won't happen to us'", "underestimating complexity"],
125
+ "severity": "high"
126
+ },
127
+ "groupthink": {
128
+ "name": "Groupthink",
129
+ "description": "Desire for harmony leads to poor decision-making",
130
+ "indicators": ["suppressing dissent", "illusion of unanimity"],
131
+ "severity": "high"
132
+ }
133
+ }
134
+
135
+ analysis = {
136
+ "timestamp": datetime.now().isoformat(),
137
+ "detected_biases": list(common_biases.values()),
138
+ "mitigation_strategies": [
139
+ "Actively seek disconfirming evidence",
140
+ "Consult diverse perspectives",
141
+ "Use pre-mortem analysis (imagine failure)",
142
+ "Set decision criteria before gathering information",
143
+ "Assign someone to play devil's advocate"
144
+ ],
145
+ "debiasing_questions": [
146
+ "What evidence would change my mind?",
147
+ "Am I being overconfident?",
148
+ "What am I not seeing?",
149
+ "Would I make this decision if starting fresh today?"
150
+ ]
151
+ }
152
+
153
+ return json.dumps(analysis, indent=2)
154
+
155
+ @mcp.tool()
156
+ def generate_alternatives(
157
+ idea: str,
158
+ constraints: str = "",
159
+ num_alternatives: int = 5
160
+ ) -> str:
161
+ """
162
+ Generates alternative approaches and solutions to consider.
163
+
164
+ Args:
165
+ idea: The original idea or approach
166
+ constraints: Known constraints or requirements
167
+ num_alternatives: Number of alternatives to generate (1-10)
168
+
169
+ Returns:
170
+ JSON string containing diverse alternative approaches with pros/cons analysis
171
+ """
172
+
173
+ alternatives = {
174
+ "original_idea": idea[:200] + "..." if len(idea) > 200 else idea,
175
+ "constraints": constraints,
176
+ "alternatives": [
177
+ {
178
+ "id": 1,
179
+ "title": "Incremental Approach",
180
+ "description": "Break down the idea into smaller, testable steps",
181
+ "pros": [
182
+ "Lower risk",
183
+ "Learn as you go",
184
+ "Can pivot based on feedback"
185
+ ],
186
+ "cons": [
187
+ "Slower to full implementation",
188
+ "May lose momentum",
189
+ "Partial solutions might not prove value"
190
+ ],
191
+ "feasibility": "high"
192
+ },
193
+ {
194
+ "id": 2,
195
+ "title": "Opposite Approach",
196
+ "description": "Consider doing the exact opposite of the proposed idea",
197
+ "pros": [
198
+ "Reveals hidden assumptions",
199
+ "May uncover better path",
200
+ "Challenges conventional thinking"
201
+ ],
202
+ "cons": [
203
+ "May seem counterintuitive",
204
+ "Requires reframing problem",
205
+ "Not always applicable"
206
+ ],
207
+ "feasibility": "medium"
208
+ },
209
+ {
210
+ "id": 3,
211
+ "title": "Hybrid Solution",
212
+ "description": "Combine elements from multiple approaches",
213
+ "pros": [
214
+ "Balances trade-offs",
215
+ "Leverages strengths of each",
216
+ "More flexible"
217
+ ],
218
+ "cons": [
219
+ "Can be complex",
220
+ "May lack clear focus",
221
+ "Harder to execute"
222
+ ],
223
+ "feasibility": "medium"
224
+ },
225
+ {
226
+ "id": 4,
227
+ "title": "Wait and Learn",
228
+ "description": "Delay decision while gathering more information",
229
+ "pros": [
230
+ "Reduces uncertainty",
231
+ "Market may validate/invalidate",
232
+ "More data for better decision"
233
+ ],
234
+ "cons": [
235
+ "Opportunity cost",
236
+ "Competitive disadvantage",
237
+ "Analysis paralysis risk"
238
+ ],
239
+ "feasibility": "high"
240
+ },
241
+ {
242
+ "id": 5,
243
+ "title": "Minimum Viable Approach",
244
+ "description": "Find the simplest possible version that tests key assumptions",
245
+ "pros": [
246
+ "Fast to implement",
247
+ "Low resource commitment",
248
+ "Quick validation"
249
+ ],
250
+ "cons": [
251
+ "May not fully represent vision",
252
+ "Limited scope",
253
+ "Could underestimate true potential"
254
+ ],
255
+ "feasibility": "high"
256
+ }
257
+ ][:num_alternatives],
258
+ "evaluation_framework": {
259
+ "criteria": [
260
+ "Alignment with goals",
261
+ "Risk level",
262
+ "Resource requirements",
263
+ "Time to value",
264
+ "Reversibility",
265
+ "Learning potential"
266
+ ],
267
+ "process": "Score each alternative 1-10 on each criterion, then compare"
268
+ }
269
+ }
270
+
271
+ return json.dumps(alternatives, indent=2)
272
+
273
+ @mcp.tool()
274
+ def perform_premortem_analysis(idea: str, timeframe: str = "1 year") -> str:
275
+ """
276
+ Performs a pre-mortem analysis: imagine the idea failed and identify why.
277
+
278
+ Args:
279
+ idea: The idea or project to analyze
280
+ timeframe: When in the future to imagine the failure (e.g., "6 months", "1 year")
281
+
282
+ Returns:
283
+ JSON string containing potential failure modes, warning signs, and preventive measures
284
+ """
285
+
286
+ premortem = {
287
+ "timestamp": datetime.now().isoformat(),
288
+ "scenario": f"Imagine it's {timeframe} from now, and this idea has failed completely",
289
+ "failure_modes": [
290
+ {
291
+ "category": "Execution Failures",
292
+ "scenarios": [
293
+ "Team lacked necessary skills",
294
+ "Underestimated complexity and timeline",
295
+ "Poor communication led to misalignment",
296
+ "Key person left at critical moment"
297
+ ]
298
+ },
299
+ {
300
+ "category": "Market/External Failures",
301
+ "scenarios": [
302
+ "Market conditions changed unexpectedly",
303
+ "Competitor launched better solution first",
304
+ "Customer needs were misunderstood",
305
+ "Regulatory changes blocked approach"
306
+ ]
307
+ },
308
+ {
309
+ "category": "Strategic Failures",
310
+ "scenarios": [
311
+ "Solving the wrong problem",
312
+ "Solution didn't address root cause",
313
+ "Opportunity cost was too high",
314
+ "Failed to achieve minimum viable scale"
315
+ ]
316
+ },
317
+ {
318
+ "category": "Resource Failures",
319
+ "scenarios": [
320
+ "Ran out of budget before completion",
321
+ "Couldn't secure necessary partnerships",
322
+ "Technical infrastructure couldn't scale",
323
+ "Dependencies failed or were delayed"
324
+ ]
325
+ }
326
+ ],
327
+ "early_warning_signs": [
328
+ "Metrics trending wrong direction",
329
+ "Increasing resistance or skepticism",
330
+ "Scope creep and deadline slips",
331
+ "Key assumptions proving false",
332
+ "Team morale declining"
333
+ ],
334
+ "preventive_measures": [
335
+ "Define clear success metrics upfront",
336
+ "Build in checkpoints for go/no-go decisions",
337
+ "Create contingency plans for top 3 risks",
338
+ "Establish kill criteria before starting",
339
+ "Schedule regular assumption testing"
340
+ ],
341
+ "questions_to_answer": [
342
+ "What would need to be true for this to succeed?",
343
+ "What's our plan if X fails?",
344
+ "How will we know if we're on the wrong path?",
345
+ "What's our exit strategy?"
346
+ ]
347
+ }
348
+
349
+ return json.dumps(premortem, indent=2)
350
+
351
+ @mcp.tool()
352
+ def identify_stakeholders_and_impacts(
353
+ idea: str,
354
+ organization_context: str = ""
355
+ ) -> str:
356
+ """
357
+ Identifies all stakeholders and analyzes potential impacts on each group.
358
+
359
+ Args:
360
+ idea: The idea or decision to analyze
361
+ organization_context: Context about the organization or situation
362
+
363
+ Returns:
364
+ JSON string containing stakeholder analysis with impacts, concerns, and engagement strategies
365
+ """
366
+
367
+ analysis = {
368
+ "timestamp": datetime.now().isoformat(),
369
+ "stakeholder_groups": [
370
+ {
371
+ "group": "Direct Users/Customers",
372
+ "impact_level": "high",
373
+ "potential_impacts": [
374
+ "Changed user experience or workflow",
375
+ "New learning curve required",
376
+ "Value proposition shift"
377
+ ],
378
+ "likely_concerns": [
379
+ "Will this make things better or worse?",
380
+ "How much effort to adapt?",
381
+ "What if I don't like it?"
382
+ ],
383
+ "engagement_strategy": "Early involvement, clear communication, feedback loops"
384
+ },
385
+ {
386
+ "group": "Implementation Team",
387
+ "impact_level": "high",
388
+ "potential_impacts": [
389
+ "Additional workload",
390
+ "New skills required",
391
+ "Changed priorities"
392
+ ],
393
+ "likely_concerns": [
394
+ "Do we have capacity?",
395
+ "What gets deprioritized?",
396
+ "Is timeline realistic?"
397
+ ],
398
+ "engagement_strategy": "Involve in planning, realistic scoping, adequate resources"
399
+ },
400
+ {
401
+ "group": "Leadership/Decision Makers",
402
+ "impact_level": "medium",
403
+ "potential_impacts": [
404
+ "Resource allocation decisions",
405
+ "Strategic direction implications",
406
+ "Risk exposure"
407
+ ],
408
+ "likely_concerns": [
409
+ "What's the ROI?",
410
+ "What are the risks?",
411
+ "How does this fit strategy?"
412
+ ],
413
+ "engagement_strategy": "Business case, risk mitigation plan, metrics"
414
+ },
415
+ {
416
+ "group": "Adjacent Teams/Partners",
417
+ "impact_level": "medium",
418
+ "potential_impacts": [
419
+ "Workflow dependencies",
420
+ "Integration requirements",
421
+ "Coordination overhead"
422
+ ],
423
+ "likely_concerns": [
424
+ "How does this affect our work?",
425
+ "What do we need to change?",
426
+ "Were we consulted?"
427
+ ],
428
+ "engagement_strategy": "Early coordination, clear interfaces, collaborative planning"
429
+ },
430
+ {
431
+ "group": "Competitors/Market",
432
+ "impact_level": "low",
433
+ "potential_impacts": [
434
+ "Competitive dynamics shift",
435
+ "Market expectations change",
436
+ "Industry standards affected"
437
+ ],
438
+ "likely_concerns": [
439
+ "How to respond?",
440
+ "Is this a threat or opportunity?"
441
+ ],
442
+ "engagement_strategy": "Market monitoring, strategic positioning"
443
+ }
444
+ ],
445
+ "overlooked_stakeholders": [
446
+ "Consider: Who maintains this long-term?",
447
+ "Consider: Who pays for this?",
448
+ "Consider: Who gets blamed if it fails?",
449
+ "Consider: Whose job becomes harder/easier?"
450
+ ],
451
+ "conflict_analysis": {
452
+ "potential_conflicts": [
453
+ "Short-term costs vs long-term benefits",
454
+ "Individual convenience vs collective good",
455
+ "Innovation speed vs risk management"
456
+ ],
457
+ "resolution_approaches": [
458
+ "Transparent trade-off discussions",
459
+ "Pilot programs to demonstrate value",
460
+ "Phased rollout to manage change"
461
+ ]
462
+ }
463
+ }
464
+
465
+ return json.dumps(analysis, indent=2)
466
+
467
+ @mcp.tool()
468
+ def second_order_thinking(idea: str, time_horizon: str = "2-5 years") -> str:
469
+ """
470
+ Analyzes second and third-order consequences of an idea or decision.
471
+
472
+ Args:
473
+ idea: The idea or decision to analyze
474
+ time_horizon: Time period to consider for consequences
475
+
476
+ Returns:
477
+ JSON string containing cascade of consequences and system-level effects
478
+ """
479
+
480
+ analysis = {
481
+ "timestamp": datetime.now().isoformat(),
482
+ "time_horizon": time_horizon,
483
+ "consequence_cascade": {
484
+ "first_order": {
485
+ "description": "Immediate, direct effects",
486
+ "examples": [
487
+ "Direct impact on users/customers",
488
+ "Immediate resource requirements",
489
+ "Initial results or outcomes"
490
+ ]
491
+ },
492
+ "second_order": {
493
+ "description": "Effects of the first-order effects",
494
+ "examples": [
495
+ "How do people adapt to the change?",
496
+ "What new behaviors emerge?",
497
+ "What dependencies are created?",
498
+ "What gets easier/harder as a result?"
499
+ ]
500
+ },
501
+ "third_order": {
502
+ "description": "Systemic shifts and long-term transformations",
503
+ "examples": [
504
+ "How does culture or mindset shift?",
505
+ "What new equilibrium is reached?",
506
+ "What irreversible changes occur?",
507
+ "What becomes possible/impossible?"
508
+ ]
509
+ }
510
+ },
511
+ "unintended_consequences": {
512
+ "positive": [
513
+ "Unexpected benefits that may emerge",
514
+ "Side effects that create value elsewhere",
515
+ "Learning and capability building"
516
+ ],
517
+ "negative": [
518
+ "Perverse incentives created",
519
+ "Workarounds that undermine intent",
520
+ "Dependencies that create fragility",
521
+ "Race conditions or competitive dynamics"
522
+ ]
523
+ },
524
+ "feedback_loops": {
525
+ "reinforcing": [
526
+ "What positive feedback loops could accelerate this?",
527
+ "What could spiral out of control?"
528
+ ],
529
+ "balancing": [
530
+ "What natural limits exist?",
531
+ "What forces will push back?"
532
+ ]
533
+ },
534
+ "questions_to_explore": [
535
+ "If this succeeds, then what?",
536
+ "What happens when everyone does this?",
537
+ "What does this make inevitable?",
538
+ "What does this make obsolete?",
539
+ "What new problems does this create?"
540
+ ]
541
+ }
542
+
543
+ return json.dumps(analysis, indent=2)
544
+
545
+ @mcp.tool()
546
+ def opportunity_cost_analysis(
547
+ idea: str,
548
+ resources: str = "",
549
+ alternatives: str = ""
550
+ ) -> str:
551
+ """
552
+ Analyzes opportunity costs: what you give up by choosing this path.
553
+
554
+ Args:
555
+ idea: The idea or decision being considered
556
+ resources: Available resources (time, money, people, etc.)
557
+ alternatives: Other options being considered
558
+
559
+ Returns:
560
+ JSON string containing opportunity cost analysis and trade-off framework
561
+ """
562
+
563
+ analysis = {
564
+ "timestamp": datetime.now().isoformat(),
565
+ "core_concept": "Opportunity cost is what you give up when you choose one option over another",
566
+ "resource_commitments": {
567
+ "time": {
568
+ "direct_time": "Time spent implementing this idea",
569
+ "opportunity_cost": "What else could be done with that time?",
570
+ "questions": [
571
+ "Is this the highest-value use of our time?",
572
+ "What are we NOT doing by doing this?"
573
+ ]
574
+ },
575
+ "money": {
576
+ "direct_cost": "Financial investment required",
577
+ "opportunity_cost": "Alternative investments or savings",
578
+ "questions": [
579
+ "What else could this money fund?",
580
+ "What's the expected return compared to alternatives?"
581
+ ]
582
+ },
583
+ "attention": {
584
+ "direct_cost": "Mental energy and focus required",
585
+ "opportunity_cost": "Other priorities that get less attention",
586
+ "questions": [
587
+ "What falls through the cracks?",
588
+ "Where should attention be focused?"
589
+ ]
590
+ },
591
+ "reputation": {
592
+ "direct_cost": "Credibility and social capital at stake",
593
+ "opportunity_cost": "Political capital spent, trust consumed",
594
+ "questions": [
595
+ "What if this fails publicly?",
596
+ "Is this worth spending reputation on?"
597
+ ]
598
+ }
599
+ },
600
+ "trade_off_framework": {
601
+ "explicit_trade_offs": [
602
+ "What are we openly choosing to sacrifice?",
603
+ "What constraints are we accepting?"
604
+ ],
605
+ "implicit_trade_offs": [
606
+ "What are we giving up without realizing it?",
607
+ "What doors close by choosing this path?"
608
+ ],
609
+ "reversibility": [
610
+ "Can we undo this decision later?",
611
+ "What becomes locked in?",
612
+ "What optionality do we lose?"
613
+ ]
614
+ },
615
+ "better_alternatives_test": {
616
+ "questions": [
617
+ "If we had unlimited time/money, would we still choose this?",
618
+ "What would we do if this option didn't exist?",
619
+ "Is there a 10x better option we're not seeing?",
620
+ "Are we settling for local maximum?"
621
+ ]
622
+ },
623
+ "recommendations": [
624
+ "List out what you're explicitly NOT doing",
625
+ "Quantify opportunity costs where possible",
626
+ "Consider: is this a reversible decision?",
627
+ "Ask: what keeps us from doing this AND something else?"
628
+ ]
629
+ }
630
+
631
+ return json.dumps(analysis, indent=2)
632
+
633
+ @mcp.tool()
634
+ def red_team_analysis(idea: str, attack_surface: str = "") -> str:
635
+ """
636
+ Performs red team analysis: actively tries to break or exploit the idea.
637
+
638
+ Args:
639
+ idea: The idea, system, or plan to attack
640
+ attack_surface: Known vulnerabilities or areas of concern
641
+
642
+ Returns:
643
+ JSON string containing attack vectors, vulnerabilities, and defensive measures
644
+ """
645
+
646
+ analysis = {
647
+ "timestamp": datetime.now().isoformat(),
648
+ "red_team_mindset": "Assume adversarial intent. How can this be broken, gamed, or exploited?",
649
+ "attack_vectors": [
650
+ {
651
+ "category": "Incentive Manipulation",
652
+ "attacks": [
653
+ "How can users game the system?",
654
+ "What perverse incentives does this create?",
655
+ "How could metrics be manipulated?",
656
+ "What loopholes exist?"
657
+ ]
658
+ },
659
+ {
660
+ "category": "Technical Vulnerabilities",
661
+ "attacks": [
662
+ "What breaks at scale?",
663
+ "Where are single points of failure?",
664
+ "What assumptions break under stress?",
665
+ "What's the weakest link?"
666
+ ]
667
+ },
668
+ {
669
+ "category": "Economic Attacks",
670
+ "attacks": [
671
+ "How could competitors undermine this?",
672
+ "What's the economic incentive to break it?",
673
+ "How can value be extracted unfairly?",
674
+ "What arbitrage opportunities exist?"
675
+ ]
676
+ },
677
+ {
678
+ "category": "Social Engineering",
679
+ "attacks": [
680
+ "How can trust be exploited?",
681
+ "What social dynamics undermine intent?",
682
+ "How can this be weaponized?",
683
+ "What could go viral in bad ways?"
684
+ ]
685
+ },
686
+ {
687
+ "category": "Edge Cases",
688
+ "attacks": [
689
+ "What happens at extremes?",
690
+ "What if 1000x more users?",
691
+ "What if all users do X at once?",
692
+ "What breaks the model?"
693
+ ]
694
+ }
695
+ ],
696
+ "defensive_measures": {
697
+ "prevention": [
698
+ "Design out vulnerabilities",
699
+ "Limit attack surface",
700
+ "Build in circuit breakers",
701
+ "Rate limiting and quotas"
702
+ ],
703
+ "detection": [
704
+ "Monitor for anomalies",
705
+ "Set up alerts for abuse patterns",
706
+ "Track leading indicators",
707
+ "Regular security audits"
708
+ ],
709
+ "response": [
710
+ "Incident response plan",
711
+ "Ability to roll back quickly",
712
+ "Clear escalation paths",
713
+ "Communication strategy"
714
+ ]
715
+ },
716
+ "worst_case_scenarios": [
717
+ "What's the absolute worst that could happen?",
718
+ "How bad could this get before we notice?",
719
+ "What if our assumptions are completely wrong?",
720
+ "What if malicious actors target this?"
721
+ ],
722
+ "stress_test_questions": [
723
+ "What breaks first under pressure?",
724
+ "Where is there no redundancy?",
725
+ "What do we trust that we shouldn't?",
726
+ "What could cascade into catastrophic failure?"
727
+ ]
728
+ }
729
+
730
+ return json.dumps(analysis, indent=2)
731
+
732
+ # Run the server
733
+ if __name__ == "__main__":
734
+ mcp.run()