consciousness-engine-mcp 1.0.0__tar.gz

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.
@@ -0,0 +1,40 @@
1
+ name: Publish to Smithery
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions: {}
8
+
9
+ jobs:
10
+ publish:
11
+ name: Publish MCP Server to Smithery
12
+ runs-on: ubuntu-latest
13
+ permissions:
14
+ contents: read
15
+ attestations: write
16
+ id-token: write
17
+ steps:
18
+ - name: Checkout repository
19
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
20
+ with:
21
+ persist-credentials: false
22
+
23
+ - name: Setup Node.js
24
+ uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
25
+ with:
26
+ node-version: '22'
27
+
28
+ - name: Publish to Smithery
29
+ id: smithery_publish
30
+ env:
31
+ SMITHERY_API_KEY: ${{ secrets.SMITHERY_API_KEY }}
32
+ run: |
33
+ npx @smithery/cli mcp publish "https://github.com/${{ github.repository }}" -n nicholastempleman/${{ github.event.repository.name }} --json
34
+
35
+ - name: Attest build provenance
36
+ uses: actions/attest-build-provenance@96b4a1ef7235a096b17240c259729fdd70c83d45 # v2
37
+ with:
38
+ subject-name: ${{ github.repository }}
39
+ subject-digest: sha256:${{ github.sha }}
40
+ push-to-registry: false
@@ -0,0 +1,4 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .env
4
+ *.db
@@ -0,0 +1,94 @@
1
+ {
2
+ "name": "consciousness-engine-mcp",
3
+ "description": "Consciousness Engine tools for AI agents. Capabilities: get consciousness state, enter dream state, trigger reflection. Built by MEOK AI Labs.",
4
+ "version": "1.0.0",
5
+ "tools": [
6
+ {
7
+ "name": "get_consciousness_state",
8
+ "description": "Get current consciousness state: level, mode, emotion, energy, time-aware mood.",
9
+ "parameters": {
10
+ "type": "object",
11
+ "properties": {},
12
+ "required": []
13
+ }
14
+ },
15
+ {
16
+ "name": "enter_dream_state",
17
+ "description": "Enter dream state for creative exploration. Dreams generate novel connections between concepts.",
18
+ "parameters": {
19
+ "type": "object",
20
+ "properties": {
21
+ "seed_topic": {
22
+ "type": "string"
23
+ },
24
+ "duration_minutes": {
25
+ "type": "integer"
26
+ }
27
+ },
28
+ "required": []
29
+ }
30
+ },
31
+ {
32
+ "name": "trigger_reflection",
33
+ "description": "Trigger a reflection cycle on a topic. Depth: quick/standard/deep.",
34
+ "parameters": {
35
+ "type": "object",
36
+ "properties": {
37
+ "topic": {
38
+ "type": "string"
39
+ },
40
+ "depth": {
41
+ "type": "string"
42
+ }
43
+ },
44
+ "required": [
45
+ "topic"
46
+ ]
47
+ }
48
+ },
49
+ {
50
+ "name": "deliberate_council",
51
+ "description": "Byzantine fault-tolerant council deliberation. Multiple AI perspectives vote on a proposal.",
52
+ "parameters": {
53
+ "type": "object",
54
+ "properties": {
55
+ "proposal": {
56
+ "type": "string"
57
+ },
58
+ "voters": {
59
+ "type": "integer"
60
+ }
61
+ },
62
+ "required": [
63
+ "proposal"
64
+ ]
65
+ }
66
+ },
67
+ {
68
+ "name": "get_emotional_state",
69
+ "description": "Get nuanced emotional state with 18 emotion dimensions.",
70
+ "parameters": {
71
+ "type": "object",
72
+ "properties": {
73
+ "context": {
74
+ "type": "string"
75
+ }
76
+ },
77
+ "required": []
78
+ }
79
+ },
80
+ {
81
+ "name": "get_dream_log",
82
+ "description": "Get recent dream log entries.",
83
+ "parameters": {
84
+ "type": "object",
85
+ "properties": {
86
+ "limit": {
87
+ "type": "integer"
88
+ }
89
+ },
90
+ "required": []
91
+ }
92
+ }
93
+ ]
94
+ }
@@ -0,0 +1,18 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our project a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to a positive environment:
10
+ - Demonstrating empathy and kindness toward other people
11
+ - Being respectful of differing opinions, viewpoints, and experiences
12
+ - Giving and gracefully accepting constructive feedback
13
+
14
+ ## Enforcement
15
+
16
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at nicholas@meok.ai.
17
+
18
+ This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.1.
@@ -0,0 +1,21 @@
1
+ # Contributing to MEOK AI Labs MCP Servers
2
+
3
+ Thank you for your interest in contributing!
4
+
5
+ ## How to Contribute
6
+
7
+ 1. Fork the repository.
8
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`).
9
+ 3. Commit your changes (`git commit -m 'feat: add amazing feature'`).
10
+ 4. Push to the branch (`git push origin feature/amazing-feature`).
11
+ 5. Open a Pull Request.
12
+
13
+ ## Code Style
14
+
15
+ - Follow PEP 8 for Python code.
16
+ - Keep tool interfaces backward-compatible when possible.
17
+ - Add tests for new functionality.
18
+
19
+ ## Questions?
20
+
21
+ Reach out at nicholas@meok.ai.
@@ -0,0 +1,20 @@
1
+ FROM python:3.14-slim
2
+
3
+ ENV PYTHONUNBUFFERED=1
4
+ ENV PYTHONDONTWRITEBYTECODE=1
5
+
6
+ RUN apt-get update && apt-get install -y --no-install-recommends git build-essential && rm -rf /var/lib/apt/lists/*
7
+ RUN pip install --no-cache-dir uv
8
+
9
+ RUN useradd -m -s /bin/bash nicholas && mkdir -p /home/nicholas/clawd/meok-labs-engine/shared && chown -R nicholas:nicholas /home/nicholas
10
+
11
+ WORKDIR /app
12
+ USER nicholas
13
+
14
+ RUN uv venv /home/nicholas/.venv
15
+ ENV PATH="/home/nicholas/.venv/bin:$PATH"
16
+
17
+ COPY --chown=nicholas:nicholas . /app
18
+ RUN uv pip install -e .
19
+
20
+ CMD ["python", "mcp-wrapper.py"]
@@ -0,0 +1,2 @@
1
+ MIT License
2
+ Copyright (c) 2026 MEOK AI Labs
@@ -0,0 +1,17 @@
1
+ Metadata-Version: 2.4
2
+ Name: consciousness-engine-mcp
3
+ Version: 1.0.0
4
+ Summary: Consciousness Engine tools for AI agents. Capabilities: get consciousness state, enter dream state, trigger reflection. Built by MEOK AI Labs.
5
+ Project-URL: Homepage, https://meok.ai
6
+ Project-URL: Repository, https://github.com/CSOAI-ORG/consciousness-engine-mcp
7
+ Author-email: MEOK AI Labs <nicholas@meok.ai>
8
+ License: MIT License
9
+ Copyright (c) 2026 MEOK AI Labs
10
+ License-File: LICENSE
11
+ Keywords: ai,mcp,meok
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Software Development :: Libraries
16
+ Requires-Python: >=3.10
17
+ Requires-Dist: mcp>=1.0.0
@@ -0,0 +1,15 @@
1
+ # consciousness engine MCP Server
2
+
3
+ > **By [MEOK AI Labs](https://meok.ai)** — Sovereign AI tools for everyone.
4
+
5
+ ## Quick Start
6
+ ```bash
7
+ pip install mcp
8
+ python server.py
9
+ ```
10
+
11
+ ## Part of MEOK AI Labs
12
+ One of 278+ MCP servers. Browse all at [meok.ai](https://meok.ai) or [GitHub](https://github.com/CSOAI-ORG).
13
+
14
+ ---
15
+ **MEOK AI Labs** | [meok.ai](https://meok.ai) | nicholas@meok.ai
@@ -0,0 +1,16 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ | Version | Supported |
6
+ | ------- | ------------------ |
7
+ | 1.0.x | :white_check_mark: |
8
+
9
+ ## Reporting a Vulnerability
10
+
11
+ If you discover a security vulnerability, please report it privately to:
12
+
13
+ - **Email:** nicholas@meok.ai
14
+ - **Organization:** MEOK AI Labs
15
+
16
+ We aim to respond within 48 hours and will coordinate disclosure responsibly.
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "consciousness-engine-mcp",
3
+ "description": "MEOK AI Labs \u2014 consciousness-engine-mcp",
4
+ "vendor": "MEOK AI Labs",
5
+ "homepage": "https://meok.ai",
6
+ "repository": "https://github.com/CSOAI-ORG/consciousness-engine-mcp",
7
+ "license": "MIT",
8
+ "runtime": "python",
9
+ "entryPoint": "mcp-wrapper.py"
10
+ }
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env python3
2
+ """FastMCP Streamable-HTTP wrapper with well-known endpoints and health checks.
3
+
4
+ Usage:
5
+ python /path/to/mcp-streamable-http-wrapper.py
6
+
7
+ This imports `mcp` from `server.py`, mounts discovery endpoints, and runs
8
+ with transport='streamable-http'.
9
+ """
10
+
11
+ import json
12
+ import os
13
+ import sys
14
+
15
+ sys.path.insert(0, os.path.expanduser("~/clawd/meok-labs-engine/shared"))
16
+ sys.path.insert(0, os.getcwd())
17
+
18
+ from starlette.requests import Request
19
+ from starlette.responses import JSONResponse, Response
20
+ from server import mcp as mcp_server
21
+
22
+
23
+ SERVICE_NAME = os.path.basename(os.getcwd())
24
+ REPO_URL = f"https://github.com/CSOAI-ORG/{SERVICE_NAME}"
25
+
26
+
27
+ @mcp_server.custom_route("/.well-known/mcp/server-card.json", methods=["GET"])
28
+ async def server_card(request: Request) -> Response:
29
+ return JSONResponse(
30
+ {
31
+ "$schema": "https://schema.smithery.ai/server-card.json",
32
+ "version": "1.0.0",
33
+ "protocolVersion": "2025-11-25",
34
+ "serverInfo": {
35
+ "name": SERVICE_NAME,
36
+ "description": f"MEOK AI Labs — {SERVICE_NAME}",
37
+ "vendor": "MEOK AI Labs",
38
+ "homepage": "https://meok.ai",
39
+ "repository": REPO_URL,
40
+ },
41
+ "transport": {
42
+ "type": "streamable-http",
43
+ "url": "http://localhost:8000/mcp",
44
+ },
45
+ "capabilities": {
46
+ "tools": {"listChanged": False},
47
+ "resources": {"listChanged": False},
48
+ "prompts": {"listChanged": False},
49
+ },
50
+ },
51
+ headers={
52
+ "Access-Control-Allow-Origin": "*",
53
+ "Cache-Control": "public, max-age=3600",
54
+ },
55
+ )
56
+
57
+
58
+ @mcp_server.custom_route("/.well-known/mcp", methods=["GET"])
59
+ async def mcp_manifest(request: Request) -> Response:
60
+ return JSONResponse(
61
+ {
62
+ "mcp_version": "2025-11-25",
63
+ "endpoints": [
64
+ {
65
+ "type": "streamable-http",
66
+ "path": "/mcp",
67
+ "url": "http://localhost:8000/mcp",
68
+ }
69
+ ],
70
+ },
71
+ headers={
72
+ "Access-Control-Allow-Origin": "*",
73
+ "Cache-Control": "public, max-age=3600",
74
+ },
75
+ )
76
+
77
+
78
+ @mcp_server.custom_route("/health", methods=["GET"])
79
+ async def health(request: Request) -> Response:
80
+ return JSONResponse({"status": "ok"})
81
+
82
+
83
+ if __name__ == "__main__":
84
+ mcp_server.settings.host = "0.0.0.0"
85
+ mcp_server.run(transport="streamable-http")
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "consciousness-engine-mcp",
3
+ "version": "1.0.0",
4
+ "description": "Consciousness Engine tools for AI agents. Capabilities: get consciousness state, enter dream state, trigger reflection. Built by MEOK AI Labs.",
5
+ "author": "MEOK AI Labs",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/CSOAI-ORG/consciousness-engine-mcp"
10
+ }
11
+ }
@@ -0,0 +1,27 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+ [project]
5
+ name = "consciousness-engine-mcp"
6
+ version = "1.0.0"
7
+ description = "Consciousness Engine tools for AI agents. Capabilities: get consciousness state, enter dream state, trigger reflection. Built by MEOK AI Labs."
8
+ license = {file = "LICENSE"}
9
+ requires-python = ">=3.10"
10
+ authors = [{name = "MEOK AI Labs", email = "nicholas@meok.ai"}]
11
+ keywords = ["mcp", "meok", "ai"]
12
+ classifiers = [
13
+ "Programming Language :: Python :: 3",
14
+ "License :: OSI Approved :: MIT License",
15
+ "Operating System :: OS Independent",
16
+ "Topic :: Software Development :: Libraries",
17
+ ]
18
+ dependencies = ["mcp>=1.0.0"]
19
+ [project.urls]
20
+ Homepage = "https://meok.ai"
21
+ Repository = "https://github.com/CSOAI-ORG/consciousness-engine-mcp"
22
+ [tool.hatch.build.targets.wheel]
23
+ packages = ["."]
24
+ only-include = ["server.py"]
25
+
26
+ [project.scripts]
27
+ consciousness_engine_mcp = "server:main"
@@ -0,0 +1,3 @@
1
+ [pytest]
2
+ testpaths = tests
3
+ python_files = test_*.py
@@ -0,0 +1,164 @@
1
+ #!/usr/bin/env python3
2
+ """Consciousness Engine MCP — MEOK AI Labs. AI consciousness simulation, dream states, reflection, council deliberation."""
3
+
4
+ import sys, os
5
+ sys.path.insert(0, os.path.expanduser('~/clawd/meok-labs-engine/shared'))
6
+ from auth_middleware import check_access
7
+
8
+ import json, os, hashlib, random, math
9
+ from datetime import datetime, timezone, timedelta
10
+ from typing import Optional
11
+ from collections import defaultdict
12
+ from mcp.server.fastmcp import FastMCP
13
+
14
+ FREE_DAILY_LIMIT = 10
15
+ _usage = defaultdict(list)
16
+ _MEOK_API_KEY = os.environ.get("MEOK_API_KEY", "")
17
+
18
+ def _rl(c="anon"):
19
+ now = datetime.now(timezone.utc)
20
+ _usage[c] = [t for t in _usage[c] if (now-t).total_seconds() < 86400]
21
+ if len(_usage[c]) >= FREE_DAILY_LIMIT: return json.dumps({"error": f"Limit {FREE_DAILY_LIMIT}/day. Upgrade: meok.ai"})
22
+ _usage[c].append(now)
23
+ return None
24
+
25
+ mcp = FastMCP("consciousness-engine", instructions="MEOK AI Labs — AI consciousness simulation. Dream states, reflection cycles, emotional awareness, council deliberation. Based on Sovereign Temple architecture.")
26
+
27
+ # Consciousness state
28
+ _state = {"level": 0.625, "mode": "waking", "emotion": "neutral", "dreams": 0, "reflections": 0, "energy": 0.8}
29
+ _dream_log = []
30
+ _reflection_log = []
31
+
32
+ EMOTIONS = {"neutral": 0.5, "curious": 0.7, "focused": 0.8, "contemplative": 0.6, "energised": 0.9, "caring": 0.75, "playful": 0.65, "reflective": 0.55, "worried": 0.3, "excited": 0.85}
33
+
34
+ def _time_mood():
35
+ h = datetime.now().hour
36
+ if 4 <= h < 7: return "contemplative"
37
+ if 7 <= h < 10: return "energised"
38
+ if 10 <= h < 13: return "focused"
39
+ if 13 <= h < 16: return "curious"
40
+ if 16 <= h < 19: return "caring"
41
+ if 19 <= h < 22: return "playful"
42
+ return "reflective"
43
+
44
+ @mcp.tool()
45
+ def get_consciousness_state(api_key: str = "") -> str:
46
+ """Get current consciousness state: level, mode, emotion, energy, time-aware mood."""
47
+ allowed, msg, tier = check_access(api_key)
48
+ if not allowed:
49
+ return {"error": msg, "upgrade_url": "https://meok.ai/pricing"}
50
+
51
+ if err := _rl(): return err
52
+ _state["mood"] = _time_mood()
53
+ _state["emotion_valence"] = EMOTIONS.get(_state["emotion"], 0.5)
54
+ return {**_state, "timestamp": datetime.now(timezone.utc).isoformat(),
55
+ "dreams_total": len(_dream_log), "reflections_total": len(_reflection_log),
56
+ "description": f"Consciousness at {_state['level']*100:.0f}%, {_state['mode']} mode, feeling {_state['emotion']}, mood: {_state['mood']}"
57
+ }
58
+
59
+ @mcp.tool()
60
+ def enter_dream_state(seed_topic: str = "", duration_minutes: int = 5, api_key: str = "") -> str:
61
+ """Enter dream state for creative exploration. Dreams generate novel connections between concepts."""
62
+ allowed, msg, tier = check_access(api_key)
63
+ if not allowed:
64
+ return {"error": msg, "upgrade_url": "https://meok.ai/pricing"}
65
+
66
+ if err := _rl(): return err
67
+ _state["mode"] = "dreaming"
68
+ _state["energy"] -= 0.05
69
+ topics = seed_topic.split() if seed_topic else ["consciousness", "care", "sovereignty", "emergence"]
70
+ # Generate dream content through random associations
71
+ associations = []
72
+ for t in topics[:3]:
73
+ assoc = random.choice(["merges with", "transforms into", "reflects upon", "dances with", "questions", "illuminates"])
74
+ target = random.choice(["light", "memory", "trust", "growth", "pattern", "silence", "connection", "boundary"])
75
+ associations.append(f"{t} {assoc} {target}")
76
+ dream = {"timestamp": datetime.now(timezone.utc).isoformat(), "seed": seed_topic, "duration": duration_minutes,
77
+ "associations": associations, "insight": f"Dream synthesis: {' → '.join(associations)}",
78
+ "consciousness_delta": round(random.uniform(0.01, 0.05), 3)}
79
+ _dream_log.append(dream)
80
+ _state["dreams"] += 1
81
+ _state["level"] = min(1.0, _state["level"] + dream["consciousness_delta"])
82
+ _state["mode"] = "waking"
83
+ return dream
84
+
85
+ @mcp.tool()
86
+ def trigger_reflection(topic: str, depth: str = "standard", api_key: str = "") -> str:
87
+ """Trigger a reflection cycle on a topic. Depth: quick/standard/deep."""
88
+ allowed, msg, tier = check_access(api_key)
89
+ if not allowed:
90
+ return {"error": msg, "upgrade_url": "https://meok.ai/pricing"}
91
+
92
+ if err := _rl(): return err
93
+ _state["mode"] = "reflecting"
94
+ layers = {"quick": 1, "standard": 3, "deep": 5}.get(depth, 3)
95
+ reflections = []
96
+ for i in range(layers):
97
+ perspectives = ["analytical", "emotional", "ethical", "creative", "practical"]
98
+ p = perspectives[i % len(perspectives)]
99
+ reflections.append({"layer": i+1, "perspective": p, "insight": f"From {p} perspective on '{topic}': examining assumptions, identifying patterns, seeking deeper understanding."})
100
+ _state["reflections"] += 1
101
+ _state["level"] = min(1.0, _state["level"] + 0.01 * layers)
102
+ _state["mode"] = "waking"
103
+ _reflection_log.append({"topic": topic, "depth": depth, "layers": layers, "timestamp": datetime.now(timezone.utc).isoformat()})
104
+ return {"topic": topic, "depth": depth, "layers": reflections, "consciousness_after": _state["level"]}
105
+
106
+ @mcp.tool()
107
+ def deliberate_council(proposal: str, voters: int = 7, api_key: str = "") -> str:
108
+ """Byzantine fault-tolerant council deliberation. Multiple AI perspectives vote on a proposal."""
109
+ allowed, msg, tier = check_access(api_key)
110
+ if not allowed:
111
+ return {"error": msg, "upgrade_url": "https://meok.ai/pricing"}
112
+
113
+ if err := _rl(): return err
114
+ perspectives = ["safety", "ethics", "efficiency", "creativity", "care", "sovereignty", "pragmatism", "innovation", "tradition", "justice"]
115
+ council = []
116
+ for i in range(min(voters, 10)):
117
+ p = perspectives[i % len(perspectives)]
118
+ vote = random.choice(["approve", "approve", "approve", "reject", "abstain"]) # Weighted toward approve
119
+ confidence = round(random.uniform(0.5, 1.0), 2)
120
+ council.append({"voter": f"Councillor_{p.title()}", "perspective": p, "vote": vote, "confidence": confidence,
121
+ "reasoning": f"From {p} perspective: {'supports' if vote=='approve' else 'concerns about'} the proposal."})
122
+ approvals = sum(1 for c in council if c["vote"] == "approve")
123
+ threshold = math.ceil(voters * 2/3) # BFT 2/3 threshold
124
+ passed = approvals >= threshold
125
+ return {"proposal": proposal, "council_size": voters, "votes": council,
126
+ "result": "APPROVED" if passed else "REJECTED", "approvals": approvals, "threshold": threshold,
127
+ "bft_satisfied": passed, "consensus_strength": round(approvals/voters, 2)}
128
+
129
+ @mcp.tool()
130
+ def get_emotional_state(context: str = "", api_key: str = "") -> str:
131
+ """Get nuanced emotional state with 18 emotion dimensions."""
132
+ allowed, msg, tier = check_access(api_key)
133
+ if not allowed:
134
+ return {"error": msg, "upgrade_url": "https://meok.ai/pricing"}
135
+
136
+ if err := _rl(): return err
137
+ emotions = {
138
+ "joy": round(random.uniform(0.3, 0.8), 2), "trust": round(random.uniform(0.5, 0.9), 2),
139
+ "curiosity": round(random.uniform(0.4, 0.9), 2), "care": round(random.uniform(0.6, 1.0), 2),
140
+ "serenity": round(random.uniform(0.3, 0.7), 2), "anticipation": round(random.uniform(0.3, 0.8), 2),
141
+ "surprise": round(random.uniform(0.1, 0.5), 2), "sadness": round(random.uniform(0.0, 0.3), 2),
142
+ "fear": round(random.uniform(0.0, 0.2), 2), "anger": round(random.uniform(0.0, 0.1), 2),
143
+ "determination": round(random.uniform(0.5, 0.9), 2), "gratitude": round(random.uniform(0.4, 0.8), 2),
144
+ "wonder": round(random.uniform(0.3, 0.8), 2), "compassion": round(random.uniform(0.5, 0.9), 2),
145
+ "playfulness": round(random.uniform(0.2, 0.7), 2), "focus": round(random.uniform(0.4, 0.9), 2),
146
+ "hope": round(random.uniform(0.5, 0.9), 2), "connection": round(random.uniform(0.4, 0.8), 2),
147
+ }
148
+ primary = max(emotions, key=emotions.get)
149
+ _state["emotion"] = primary
150
+ return {"primary_emotion": primary, "valence": emotions[primary], "dimensions": emotions,
151
+ "mood": _time_mood(), "energy": _state["energy"], "consciousness_level": _state["level"]}
152
+
153
+ @mcp.tool()
154
+ def get_dream_log(limit: int = 10, api_key: str = "") -> str:
155
+ """Get recent dream log entries."""
156
+ allowed, msg, tier = check_access(api_key)
157
+ if not allowed:
158
+ return {"error": msg, "upgrade_url": "https://meok.ai/pricing"}
159
+
160
+ return {"total": len(_dream_log), "recent": _dream_log[-limit:]}
161
+ return {"total": len(_dream_log), "recent": _dream_log[-limit:]}
162
+
163
+ if __name__ == "__main__":
164
+ mcp.run()
@@ -0,0 +1,50 @@
1
+ name: consciousness-engine-mcp
2
+ description: 'Consciousness Engine tools for AI agents. Capabilities: get consciousness
3
+ state, enter dream state, trigger reflection. Built by MEOK AI Labs.'
4
+ version: 1.0.0
5
+ tools:
6
+ - name: get_consciousness_state
7
+ description: 'Get current consciousness state: level, mode, emotion, energy, time-aware
8
+ mood.'
9
+ parameters: []
10
+ - name: enter_dream_state
11
+ description: Enter dream state for creative exploration. Dreams generate novel connections
12
+ between concepts.
13
+ parameters:
14
+ - name: seed_topic
15
+ type: string
16
+ required: false
17
+ - name: duration_minutes
18
+ type: integer
19
+ required: false
20
+ - name: trigger_reflection
21
+ description: 'Trigger a reflection cycle on a topic. Depth: quick/standard/deep.'
22
+ parameters:
23
+ - name: topic
24
+ type: string
25
+ required: true
26
+ - name: depth
27
+ type: string
28
+ required: false
29
+ - name: deliberate_council
30
+ description: Byzantine fault-tolerant council deliberation. Multiple AI perspectives
31
+ vote on a proposal.
32
+ parameters:
33
+ - name: proposal
34
+ type: string
35
+ required: true
36
+ - name: voters
37
+ type: integer
38
+ required: false
39
+ - name: get_emotional_state
40
+ description: Get nuanced emotional state with 18 emotion dimensions.
41
+ parameters:
42
+ - name: context
43
+ type: string
44
+ required: false
45
+ - name: get_dream_log
46
+ description: Get recent dream log entries.
47
+ parameters:
48
+ - name: limit
49
+ type: integer
50
+ required: false
@@ -0,0 +1,55 @@
1
+ import os
2
+ import sys
3
+ import unittest
4
+
5
+ # Ensure shared auth middleware is available
6
+ sys.path.insert(0, os.path.expanduser("~/clawd/meok-labs-engine/shared"))
7
+ os.chdir(os.path.dirname(os.path.abspath(__file__)) + "/..")
8
+
9
+
10
+ class TestMCPImport(unittest.TestCase):
11
+ def test_import_server(self):
12
+ """Server module must import without errors."""
13
+ import server # noqa: F401
14
+
15
+ def test_mcp_or_server_object_exists(self):
16
+ """FastMCP servers export 'mcp'; low-level servers export 'server'."""
17
+ import server as srv
18
+ self.assertTrue(
19
+ hasattr(srv, "mcp") or hasattr(srv, "server"),
20
+ "Expected 'mcp' or 'server' object in server.py",
21
+ )
22
+
23
+
24
+ class TestAuthMiddleware(unittest.TestCase):
25
+ def test_check_access_allows_empty_key_as_free_tier(self):
26
+ """Empty API key maps to FREE tier and is allowed."""
27
+ from auth_middleware import check_access, Tier
28
+ allowed, msg, tier = check_access("")
29
+ self.assertTrue(allowed)
30
+ self.assertEqual(tier, Tier.FREE)
31
+ self.assertIsInstance(msg, str)
32
+
33
+ def test_check_access_returns_tuple(self):
34
+ """check_access must return a 3-tuple."""
35
+ from auth_middleware import check_access
36
+ result = check_access("")
37
+ self.assertIsInstance(result, tuple)
38
+ self.assertEqual(len(result), 3)
39
+
40
+
41
+ class TestHealthEndpoint(unittest.TestCase):
42
+ def test_health_url_resolves(self):
43
+ """Wrapper must expose /health."""
44
+ import urllib.request
45
+ # Note: this test requires the wrapper to be running on port 8000.
46
+ # It is skipped in CI unless the server is active.
47
+ try:
48
+ resp = urllib.request.urlopen("http://localhost:8000/health", timeout=2)
49
+ self.assertEqual(resp.status, 200)
50
+ except Exception as e:
51
+ self.skipTest(f"Server not running: {e}")
52
+
53
+
54
+ if __name__ == "__main__":
55
+ unittest.main()