code-executor-mcp 1.0.0__tar.gz → 1.0.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: code-executor-mcp
3
- Version: 1.0.0
3
+ Version: 1.0.1
4
4
  Summary: MCP server for code executor. Features execute code, run command, run tests. From MEOK AI Labs.
5
5
  Project-URL: Homepage, https://meok.ai
6
6
  Project-URL: Repository, https://github.com/CSOAI-ORG/code-executor-mcp
@@ -34,3 +34,46 @@ Classifier: Programming Language :: Python :: 3
34
34
  Classifier: Topic :: Software Development :: Libraries
35
35
  Requires-Python: >=3.10
36
36
  Requires-Dist: mcp>=1.0.0
37
+ Description-Content-Type: text/markdown
38
+
39
+ [![code-executor-mcp MCP server](https://glama.ai/mcp/servers/CSOAI-ORG/code-executor-mcp/badges/card.svg)](https://glama.ai/mcp/servers/CSOAI-ORG/code-executor-mcp)
40
+
41
+ <div align="center">
42
+
43
+ [![GitHub stars](https://img.shields.io/github/stars/CSOAI-ORG/code-executor-mcp)](https://github.com/CSOAI-ORG/code-executor-mcp/stargazers)
44
+
45
+ # ucodeU executorU mcp
46
+
47
+ ****
48
+
49
+ [![npm version](https://img.shields.io/npm/v/@meok-ai/code-executor-mcp)](https://www.npmjs.com/package/@meok-ai/code-executor-mcp)
50
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
51
+ [![MEOK AI Labs](https://img.shields.io/badge/MEOK_AI_Labs-255+_servers-purple)](https://meok.ai)
52
+
53
+ [Installation](#installation) · [Docs](https://csoai.org) · [Report Bug](https://github.com/CSOAI-ORG/code-executor-mcp/issues)
54
+
55
+ </div>
56
+
57
+ ---
58
+
59
+ ## Installation
60
+
61
+ ```bash
62
+ pip install code-executor-mcp
63
+ # or
64
+ npm install -g @meok-ai/code-executor-mcp
65
+ ```
66
+
67
+ ## Quick Start
68
+
69
+ See the project repository for full documentation and examples.
70
+
71
+ ## Enterprise Support
72
+
73
+ - 📧 nicholas@csoai.org
74
+ - 🌐 [CSOAI.org](https://csoai.org)
75
+
76
+ ## License
77
+
78
+ MIT © [CSOAI](https://csoai.org)
79
+ <!-- mcp-name: io.github.CSOAI-ORG/code-executor-mcp -->
@@ -0,0 +1,41 @@
1
+ [![code-executor-mcp MCP server](https://glama.ai/mcp/servers/CSOAI-ORG/code-executor-mcp/badges/card.svg)](https://glama.ai/mcp/servers/CSOAI-ORG/code-executor-mcp)
2
+
3
+ <div align="center">
4
+
5
+ [![GitHub stars](https://img.shields.io/github/stars/CSOAI-ORG/code-executor-mcp)](https://github.com/CSOAI-ORG/code-executor-mcp/stargazers)
6
+
7
+ # ucodeU executorU mcp
8
+
9
+ ****
10
+
11
+ [![npm version](https://img.shields.io/npm/v/@meok-ai/code-executor-mcp)](https://www.npmjs.com/package/@meok-ai/code-executor-mcp)
12
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
13
+ [![MEOK AI Labs](https://img.shields.io/badge/MEOK_AI_Labs-255+_servers-purple)](https://meok.ai)
14
+
15
+ [Installation](#installation) · [Docs](https://csoai.org) · [Report Bug](https://github.com/CSOAI-ORG/code-executor-mcp/issues)
16
+
17
+ </div>
18
+
19
+ ---
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ pip install code-executor-mcp
25
+ # or
26
+ npm install -g @meok-ai/code-executor-mcp
27
+ ```
28
+
29
+ ## Quick Start
30
+
31
+ See the project repository for full documentation and examples.
32
+
33
+ ## Enterprise Support
34
+
35
+ - 📧 nicholas@csoai.org
36
+ - 🌐 [CSOAI.org](https://csoai.org)
37
+
38
+ ## License
39
+
40
+ MIT © [CSOAI](https://csoai.org)
41
+ <!-- mcp-name: io.github.CSOAI-ORG/code-executor-mcp -->
@@ -3,8 +3,9 @@ requires = ["hatchling"]
3
3
  build-backend = "hatchling.build"
4
4
  [project]
5
5
  name = "code-executor-mcp"
6
- version = "1.0.0"
6
+ version = "1.0.1"
7
7
  description = "MCP server for code executor. Features execute code, run command, run tests. From MEOK AI Labs."
8
+ readme = "README.md"
8
9
  license = {file = "LICENSE"}
9
10
  requires-python = ">=3.10"
10
11
  authors = [{name = "MEOK AI Labs", email = "nicholas@meok.ai"}]
@@ -1,40 +0,0 @@
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
@@ -1,31 +0,0 @@
1
- name: Test MCP Server
2
-
3
- on:
4
- push:
5
- branches: [main]
6
- pull_request:
7
- branches: [main]
8
-
9
- jobs:
10
- test:
11
- runs-on: ubuntu-latest
12
- strategy:
13
- matrix:
14
- python-version: ["3.10", "3.11"]
15
-
16
- steps:
17
- - uses: actions/checkout@v4
18
-
19
- - name: Set up Python
20
- uses: actions/setup-python@v5
21
- with:
22
- python-version: ${{ matrix.python-version }}
23
-
24
- - name: Install dependencies
25
- run: pip install mcp>=1.0.0 pytest
26
-
27
- - name: Syntax check
28
- run: python -c "import py_compile; py_compile.compile('server.py', doraise=True)"
29
-
30
- - name: Run tests
31
- run: pytest tests/ -v --tb=short 2>/dev/null || echo "No tests found"
@@ -1,10 +0,0 @@
1
- __pycache__/
2
- *.pyc
3
- *.pyo
4
- .env
5
- .venv/
6
- dist/
7
- build/
8
- *.egg-info/
9
- .pytest_cache/
10
- *.db
@@ -1,122 +0,0 @@
1
- {
2
- "name": "code-executor-mcp",
3
- "description": "MCP server for code executor. Features execute code, run command, run tests. From MEOK AI Labs.",
4
- "version": "1.0.0",
5
- "tools": [
6
- {
7
- "name": "execute_code",
8
- "description": "Execute code in a sandboxed environment with safety checks.",
9
- "parameters": {
10
- "type": "object",
11
- "properties": {
12
- "code": {
13
- "type": "string"
14
- },
15
- "language": {
16
- "type": "string"
17
- },
18
- "timeout": {
19
- "type": "integer"
20
- }
21
- },
22
- "required": [
23
- "code"
24
- ]
25
- }
26
- },
27
- {
28
- "name": "run_command",
29
- "description": "Execute a shell command and return stdout/stderr/exit_code.",
30
- "parameters": {
31
- "type": "object",
32
- "properties": {
33
- "command": {
34
- "type": "string"
35
- },
36
- "timeout": {
37
- "type": "integer"
38
- }
39
- },
40
- "required": [
41
- "command"
42
- ]
43
- }
44
- },
45
- {
46
- "name": "run_tests",
47
- "description": "Run a test suite and return results. Default: pytest.",
48
- "parameters": {
49
- "type": "object",
50
- "properties": {
51
- "test_command": {
52
- "type": "string"
53
- },
54
- "working_dir": {
55
- "type": "string"
56
- },
57
- "timeout": {
58
- "type": "integer"
59
- }
60
- },
61
- "required": []
62
- }
63
- },
64
- {
65
- "name": "read_file",
66
- "description": "Read contents of a file (restricted to allowed directories: Desktop,",
67
- "parameters": {
68
- "type": "object",
69
- "properties": {
70
- "path": {
71
- "type": "string"
72
- },
73
- "limit": {
74
- "type": "integer"
75
- }
76
- },
77
- "required": [
78
- "path"
79
- ]
80
- }
81
- },
82
- {
83
- "name": "list_sandbox_files",
84
- "description": "List files in the sandbox working directory. All code execution",
85
- "parameters": {
86
- "type": "object",
87
- "properties": {},
88
- "required": []
89
- }
90
- },
91
- {
92
- "name": "get_safety_rules",
93
- "description": "Get the current safety rules and blocked patterns for code execution.",
94
- "parameters": {
95
- "type": "object",
96
- "properties": {},
97
- "required": []
98
- }
99
- },
100
- {
101
- "name": "execute_code_docker",
102
- "description": "Execute code inside a temporary Docker container for isolation.",
103
- "parameters": {
104
- "type": "object",
105
- "properties": {
106
- "code": {
107
- "type": "string"
108
- },
109
- "language": {
110
- "type": "string"
111
- },
112
- "timeout_sec": {
113
- "type": "integer"
114
- }
115
- },
116
- "required": [
117
- "code"
118
- ]
119
- }
120
- }
121
- ]
122
- }
@@ -1,64 +0,0 @@
1
- {
2
- "name": "Code Executor MCP",
3
- "description": "Sandboxed code execution: Python, JavaScript, and shell commands with safety guards, output capture, and timeout protection.",
4
- "version": "1.0.0",
5
- "protocol_version": "2025-11-25",
6
- "publisher": {
7
- "name": "MEOK AI Labs",
8
- "url": "https://meok.ai",
9
- "email": "nicholas@meok.ai"
10
- },
11
- "repository": "https://github.com/CSOAI-ORG/code-executor-mcp",
12
- "license": "MIT",
13
- "transport": [
14
- "stdio",
15
- "streamable-http"
16
- ],
17
- "authentication": {
18
- "type": "api-key",
19
- "free_tier": true,
20
- "free_limit": "15 calls/day"
21
- },
22
- "tools": [
23
- {
24
- "name": "execute_code",
25
- "description": "Execute code in a sandboxed environment with safety checks."
26
- },
27
- {
28
- "name": "run_command",
29
- "description": "Execute a shell command and return stdout/stderr/exit_code."
30
- },
31
- {
32
- "name": "run_tests",
33
- "description": "Run a test suite and return results. Default: pytest."
34
- },
35
- {
36
- "name": "read_file",
37
- "description": "Read contents of a file (restricted to allowed directories: Desktop,"
38
- },
39
- {
40
- "name": "list_sandbox_files",
41
- "description": "List files in the sandbox working directory. All code execution"
42
- },
43
- {
44
- "name": "get_safety_rules",
45
- "description": "Get the current safety rules and blocked patterns for code execution."
46
- },
47
- {
48
- "name": "execute_code_docker",
49
- "description": "Execute code inside a temporary Docker container for isolation."
50
- }
51
- ],
52
- "categories": [
53
- "Developer Tools"
54
- ],
55
- "pricing": {
56
- "free": {
57
- "calls_per_day": 15
58
- },
59
- "pro": {
60
- "price": "$29/month",
61
- "url": "https://meok.ai/pricing"
62
- }
63
- }
64
- }
@@ -1,18 +0,0 @@
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.
@@ -1,21 +0,0 @@
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.
@@ -1,20 +0,0 @@
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"]
@@ -1,69 +0,0 @@
1
- # Code Executor MCP Server
2
-
3
- > By [MEOK AI Labs](https://meok.ai) — Sandboxed code execution for Python, JavaScript, and shell commands with safety guards
4
-
5
- ## Installation
6
-
7
- ```bash
8
- pip install code-executor-mcp
9
- ```
10
-
11
- ## Usage
12
-
13
- ```bash
14
- python server.py
15
- ```
16
-
17
- ## Tools
18
-
19
- ### `execute_code`
20
- Execute code in a sandboxed environment with safety checks. Dangerous patterns (os.system, eval, exec) are blocked.
21
-
22
- **Parameters:**
23
- - `code` (str): Code to execute
24
- - `language` (str): Language — 'python' or 'javascript' (default 'python')
25
- - `timeout` (int): Timeout in seconds (max 60, default 30)
26
-
27
- ### `run_command`
28
- Execute a shell command with safety filters. Destructive commands are blocked.
29
-
30
- **Parameters:**
31
- - `command` (str): Shell command
32
- - `timeout` (int): Timeout in seconds (max 60)
33
-
34
- ### `run_tests`
35
- Run a test suite and return results with pass/fail summary.
36
-
37
- **Parameters:**
38
- - `test_command` (str): Test command (default 'python -m pytest')
39
- - `working_dir` (str): Working directory
40
- - `timeout` (int): Timeout in seconds (default 60)
41
-
42
- ### `read_file`
43
- Read file contents from allowed directories (Desktop, Documents, Downloads, /tmp, sandbox).
44
-
45
- **Parameters:**
46
- - `path` (str): File path
47
- - `limit` (int): Max lines to read (default 200)
48
-
49
- ### `list_sandbox_files`
50
- List files in the sandbox working directory.
51
-
52
- ### `get_safety_rules`
53
- Get current safety rules and blocked patterns.
54
-
55
- ### `execute_code_docker`
56
- Execute code inside a temporary Docker container for full isolation.
57
-
58
- **Parameters:**
59
- - `code` (str): Code to execute
60
- - `language` (str): Language — 'python', 'node', 'bash'
61
- - `timeout_sec` (int): Timeout in seconds (default 30)
62
-
63
- ## Authentication
64
-
65
- Free tier: 50 calls/day. Upgrade at [meok.ai/pricing](https://meok.ai/pricing) for unlimited access.
66
-
67
- ## License
68
-
69
- MIT — MEOK AI Labs
@@ -1,16 +0,0 @@
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.
@@ -1,10 +0,0 @@
1
- {
2
- "name": "code-executor-mcp",
3
- "description": "MEOK AI Labs \u2014 code-executor-mcp",
4
- "vendor": "MEOK AI Labs",
5
- "homepage": "https://meok.ai",
6
- "repository": "https://github.com/CSOAI-ORG/code-executor-mcp",
7
- "license": "MIT",
8
- "runtime": "python",
9
- "entryPoint": "mcp-wrapper.py"
10
- }
@@ -1,85 +0,0 @@
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")
@@ -1,30 +0,0 @@
1
- {
2
- "name": "code-executor-mcp",
3
- "version": "1.0.0",
4
- "description": "MCP server for code executor. Features execute code, run command, run tests. From MEOK AI Labs.",
5
- "main": "server.py",
6
- "mcp": {
7
- "name": "code executor",
8
- "vendor": "MEOK AI Labs",
9
- "homepage": "https://meok.ai",
10
- "repository": "https://github.com/CSOAI-ORG/code-executor-mcp",
11
- "runtime": "python",
12
- "tags": [
13
- "mcp",
14
- "mcp-server",
15
- "meok-ai-labs",
16
- "ai-tools"
17
- ]
18
- },
19
- "keywords": [
20
- "mcp",
21
- "mcp-server",
22
- "meok-ai-labs"
23
- ],
24
- "author": "MEOK AI Labs <nicholas@meok.ai>",
25
- "license": "MIT",
26
- "repository": {
27
- "type": "git",
28
- "url": "https://github.com/CSOAI-ORG/code-executor-mcp"
29
- }
30
- }
@@ -1,3 +0,0 @@
1
- [pytest]
2
- testpaths = tests
3
- python_files = test_*.py
@@ -1,65 +0,0 @@
1
- name: code-executor-mcp
2
- description: MCP server for code executor. Features execute code, run command, run
3
- tests. From MEOK AI Labs.
4
- version: 1.0.0
5
- tools:
6
- - name: execute_code
7
- description: Execute code in a sandboxed environment with safety checks.
8
- parameters:
9
- - name: code
10
- type: string
11
- required: true
12
- - name: language
13
- type: string
14
- required: false
15
- - name: timeout
16
- type: integer
17
- required: false
18
- - name: run_command
19
- description: Execute a shell command and return stdout/stderr/exit_code.
20
- parameters:
21
- - name: command
22
- type: string
23
- required: true
24
- - name: timeout
25
- type: integer
26
- required: false
27
- - name: run_tests
28
- description: 'Run a test suite and return results. Default: pytest.'
29
- parameters:
30
- - name: test_command
31
- type: string
32
- required: false
33
- - name: working_dir
34
- type: string
35
- required: false
36
- - name: timeout
37
- type: integer
38
- required: false
39
- - name: read_file
40
- description: 'Read contents of a file (restricted to allowed directories: Desktop,'
41
- parameters:
42
- - name: path
43
- type: string
44
- required: true
45
- - name: limit
46
- type: integer
47
- required: false
48
- - name: list_sandbox_files
49
- description: List files in the sandbox working directory. All code execution
50
- parameters: []
51
- - name: get_safety_rules
52
- description: Get the current safety rules and blocked patterns for code execution.
53
- parameters: []
54
- - name: execute_code_docker
55
- description: Execute code inside a temporary Docker container for isolation.
56
- parameters:
57
- - name: code
58
- type: string
59
- required: true
60
- - name: language
61
- type: string
62
- required: false
63
- - name: timeout_sec
64
- type: integer
65
- required: false
@@ -1,55 +0,0 @@
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()