schema-validator-ai-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.
- schema_validator_ai_mcp-1.0.0/.github/workflows/mcp-smithery-publish.yml +40 -0
- schema_validator_ai_mcp-1.0.0/.gitignore +4 -0
- schema_validator_ai_mcp-1.0.0/.mcp.json +81 -0
- schema_validator_ai_mcp-1.0.0/CODE_OF_CONDUCT.md +18 -0
- schema_validator_ai_mcp-1.0.0/CONTRIBUTING.md +21 -0
- schema_validator_ai_mcp-1.0.0/Dockerfile.glama +20 -0
- schema_validator_ai_mcp-1.0.0/LICENSE +13 -0
- schema_validator_ai_mcp-1.0.0/PKG-INFO +28 -0
- schema_validator_ai_mcp-1.0.0/README.md +24 -0
- schema_validator_ai_mcp-1.0.0/SECURITY.md +16 -0
- schema_validator_ai_mcp-1.0.0/glama.json +10 -0
- schema_validator_ai_mcp-1.0.0/mcp-wrapper.py +85 -0
- schema_validator_ai_mcp-1.0.0/package.json +30 -0
- schema_validator_ai_mcp-1.0.0/pyproject.toml +27 -0
- schema_validator_ai_mcp-1.0.0/pytest.ini +3 -0
- schema_validator_ai_mcp-1.0.0/server.py +230 -0
- schema_validator_ai_mcp-1.0.0/smithery.yaml +41 -0
- schema_validator_ai_mcp-1.0.0/tests/test_server.py +55 -0
|
@@ -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,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "schema-validator-ai-mcp",
|
|
3
|
+
"description": "Schema Validator Ai automation via MCP. Includes validate json schema, generate schema, convert openapi. By MEOK AI Labs.",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"tools": [
|
|
6
|
+
{
|
|
7
|
+
"name": "validate_json_schema",
|
|
8
|
+
"description": "Validate JSON data against a JSON Schema.",
|
|
9
|
+
"parameters": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"properties": {
|
|
12
|
+
"data_json": {
|
|
13
|
+
"type": "string"
|
|
14
|
+
},
|
|
15
|
+
"schema_json": {
|
|
16
|
+
"type": "string"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"required": [
|
|
20
|
+
"data_json",
|
|
21
|
+
"schema_json"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "generate_schema",
|
|
27
|
+
"description": "Generate a JSON Schema from example JSON data.",
|
|
28
|
+
"parameters": {
|
|
29
|
+
"type": "object",
|
|
30
|
+
"properties": {
|
|
31
|
+
"data_json": {
|
|
32
|
+
"type": "string"
|
|
33
|
+
},
|
|
34
|
+
"title": {
|
|
35
|
+
"type": "string"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"required": [
|
|
39
|
+
"data_json"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "convert_openapi",
|
|
45
|
+
"description": "Extract and convert schemas from an OpenAPI specification.",
|
|
46
|
+
"parameters": {
|
|
47
|
+
"type": "object",
|
|
48
|
+
"properties": {
|
|
49
|
+
"openapi_json": {
|
|
50
|
+
"type": "string"
|
|
51
|
+
},
|
|
52
|
+
"extract_schemas": {
|
|
53
|
+
"type": "boolean"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"required": [
|
|
57
|
+
"openapi_json"
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"name": "validate_types",
|
|
63
|
+
"description": "Validate that JSON data fields match expected types.",
|
|
64
|
+
"parameters": {
|
|
65
|
+
"type": "object",
|
|
66
|
+
"properties": {
|
|
67
|
+
"data_json": {
|
|
68
|
+
"type": "string"
|
|
69
|
+
},
|
|
70
|
+
"type_spec": {
|
|
71
|
+
"type": "object"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"required": [
|
|
75
|
+
"data_json",
|
|
76
|
+
"type_spec"
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
}
|
|
@@ -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,13 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MEOK AI Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: schema-validator-ai-mcp
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Schema Validator Ai automation via MCP. Includes validate json schema, generate schema, convert openapi. By MEOK AI Labs.
|
|
5
|
+
Project-URL: Homepage, https://meok.ai
|
|
6
|
+
Project-URL: Repository, https://github.com/CSOAI-ORG/schema-validator-ai-mcp
|
|
7
|
+
Author-email: MEOK AI Labs <nicholas@meok.ai>
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2026 MEOK AI Labs
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Keywords: ai,mcp,meok,schema,validator
|
|
23
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
24
|
+
Classifier: Operating System :: OS Independent
|
|
25
|
+
Classifier: Programming Language :: Python :: 3
|
|
26
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
27
|
+
Requires-Python: >=3.10
|
|
28
|
+
Requires-Dist: mcp>=1.0.0
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Schema Validator AI MCP Server
|
|
2
|
+
|
|
3
|
+
JSON Schema validation, schema generation, OpenAPI extraction, and type checking.
|
|
4
|
+
|
|
5
|
+
## Tools
|
|
6
|
+
|
|
7
|
+
- **validate_json_schema**
|
|
8
|
+
- **generate_schema**
|
|
9
|
+
- **convert_openapi**
|
|
10
|
+
- **validate_types**
|
|
11
|
+
|
|
12
|
+
## Quick Start
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install mcp
|
|
16
|
+
python server.py
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Rate Limits
|
|
20
|
+
|
|
21
|
+
- Free tier: 50 calls/day per tool
|
|
22
|
+
- Upgrade: https://meok.ai/pricing
|
|
23
|
+
|
|
24
|
+
Built by [MEOK AI Labs](https://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": "schema-validator-ai-mcp",
|
|
3
|
+
"description": "MEOK AI Labs \u2014 schema-validator-ai-mcp",
|
|
4
|
+
"vendor": "MEOK AI Labs",
|
|
5
|
+
"homepage": "https://meok.ai",
|
|
6
|
+
"repository": "https://github.com/CSOAI-ORG/schema-validator-ai-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,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "schema-validator-ai-mcp",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Schema Validator Ai automation via MCP. Includes validate json schema, generate schema, convert openapi. By MEOK AI Labs.",
|
|
5
|
+
"main": "server.py",
|
|
6
|
+
"mcp": {
|
|
7
|
+
"name": "schema validator",
|
|
8
|
+
"vendor": "MEOK AI Labs",
|
|
9
|
+
"homepage": "https://meok.ai",
|
|
10
|
+
"repository": "https://github.com/CSOAI-ORG/schema-validator-ai-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/schema-validator-ai-mcp"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
[project]
|
|
5
|
+
name = "schema-validator-ai-mcp"
|
|
6
|
+
version = "1.0.0"
|
|
7
|
+
description = "Schema Validator Ai automation via MCP. Includes validate json schema, generate schema, convert openapi. By MEOK AI Labs."
|
|
8
|
+
license = {file = "LICENSE"}
|
|
9
|
+
requires-python = ">=3.10"
|
|
10
|
+
authors = [{name = "MEOK AI Labs", email = "nicholas@meok.ai"}]
|
|
11
|
+
dependencies = ["mcp>=1.0.0"]
|
|
12
|
+
keywords = ["mcp", "ai", "meok", "schema", "validator"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"License :: OSI Approved :: MIT License",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
"Topic :: Software Development :: Libraries",
|
|
18
|
+
]
|
|
19
|
+
[project.urls]
|
|
20
|
+
Homepage = "https://meok.ai"
|
|
21
|
+
Repository = "https://github.com/CSOAI-ORG/schema-validator-ai-mcp"
|
|
22
|
+
[tool.hatch.build.targets.wheel]
|
|
23
|
+
packages = ["."]
|
|
24
|
+
only-include = ["server.py"]
|
|
25
|
+
|
|
26
|
+
[project.scripts]
|
|
27
|
+
schema_validator_ai_mcp = "server:main"
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Schema Validator AI MCP Server
|
|
3
|
+
JSON Schema validation and generation tools powered by MEOK AI Labs.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
import sys, os
|
|
8
|
+
sys.path.insert(0, os.path.expanduser('~/clawd/meok-labs-engine/shared'))
|
|
9
|
+
from auth_middleware import check_access
|
|
10
|
+
|
|
11
|
+
import json
|
|
12
|
+
import time
|
|
13
|
+
from collections import defaultdict
|
|
14
|
+
from mcp.server.fastmcp import FastMCP
|
|
15
|
+
|
|
16
|
+
mcp = FastMCP("schema-validator-ai", instructions="MEOK AI Labs MCP Server")
|
|
17
|
+
|
|
18
|
+
_call_counts: dict[str, list[float]] = defaultdict(list)
|
|
19
|
+
FREE_TIER_LIMIT = 50
|
|
20
|
+
WINDOW = 86400
|
|
21
|
+
|
|
22
|
+
TYPE_MAP = {str: "string", int: "integer", float: "number", bool: "boolean", list: "array", dict: "object", type(None): "null"}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _check_rate_limit(tool_name: str) -> None:
|
|
26
|
+
now = time.time()
|
|
27
|
+
_call_counts[tool_name] = [t for t in _call_counts[tool_name] if now - t < WINDOW]
|
|
28
|
+
if len(_call_counts[tool_name]) >= FREE_TIER_LIMIT:
|
|
29
|
+
raise ValueError(f"Rate limit exceeded for {tool_name}. Free tier: {FREE_TIER_LIMIT}/day. Upgrade at https://meok.ai/pricing")
|
|
30
|
+
_call_counts[tool_name].append(now)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _infer_type(value) -> dict:
|
|
34
|
+
"""Infer JSON Schema type from a Python value."""
|
|
35
|
+
if value is None:
|
|
36
|
+
return {"type": "null"}
|
|
37
|
+
if isinstance(value, bool):
|
|
38
|
+
return {"type": "boolean"}
|
|
39
|
+
if isinstance(value, int):
|
|
40
|
+
return {"type": "integer"}
|
|
41
|
+
if isinstance(value, float):
|
|
42
|
+
return {"type": "number"}
|
|
43
|
+
if isinstance(value, str):
|
|
44
|
+
schema = {"type": "string"}
|
|
45
|
+
if "@" in value and "." in value:
|
|
46
|
+
schema["format"] = "email"
|
|
47
|
+
elif value.startswith("http"):
|
|
48
|
+
schema["format"] = "uri"
|
|
49
|
+
elif len(value) == 10 and value[4:5] == "-":
|
|
50
|
+
schema["format"] = "date"
|
|
51
|
+
return schema
|
|
52
|
+
if isinstance(value, list):
|
|
53
|
+
if value:
|
|
54
|
+
item_types = [_infer_type(v) for v in value[:5]]
|
|
55
|
+
if all(t == item_types[0] for t in item_types):
|
|
56
|
+
return {"type": "array", "items": item_types[0]}
|
|
57
|
+
return {"type": "array", "items": {"anyOf": list({json.dumps(t, sort_keys=True): t for t in item_types}.values())}}
|
|
58
|
+
return {"type": "array"}
|
|
59
|
+
if isinstance(value, dict):
|
|
60
|
+
props = {}
|
|
61
|
+
for k, v in value.items():
|
|
62
|
+
props[k] = _infer_type(v)
|
|
63
|
+
return {"type": "object", "properties": props, "required": list(value.keys())}
|
|
64
|
+
return {}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _validate_against_schema(data, schema, path="$") -> list:
|
|
68
|
+
"""Basic JSON Schema validation without external libs."""
|
|
69
|
+
errors = []
|
|
70
|
+
schema_type = schema.get("type")
|
|
71
|
+
if schema_type:
|
|
72
|
+
actual = TYPE_MAP.get(type(data))
|
|
73
|
+
if isinstance(data, bool) and schema_type != "boolean":
|
|
74
|
+
errors.append({"path": path, "error": f"Expected {schema_type}, got boolean"})
|
|
75
|
+
elif schema_type == "number" and actual in ("integer", "number"):
|
|
76
|
+
pass
|
|
77
|
+
elif actual != schema_type and data is not None:
|
|
78
|
+
errors.append({"path": path, "error": f"Expected {schema_type}, got {actual or type(data).__name__}"})
|
|
79
|
+
if schema_type == "object" and isinstance(data, dict):
|
|
80
|
+
for req in schema.get("required", []):
|
|
81
|
+
if req not in data:
|
|
82
|
+
errors.append({"path": f"{path}.{req}", "error": f"Required property '{req}' missing"})
|
|
83
|
+
for prop, prop_schema in schema.get("properties", {}).items():
|
|
84
|
+
if prop in data:
|
|
85
|
+
errors.extend(_validate_against_schema(data[prop], prop_schema, f"{path}.{prop}"))
|
|
86
|
+
if schema_type == "array" and isinstance(data, list):
|
|
87
|
+
items_schema = schema.get("items", {})
|
|
88
|
+
if items_schema:
|
|
89
|
+
for i, item in enumerate(data):
|
|
90
|
+
errors.extend(_validate_against_schema(item, items_schema, f"{path}[{i}]"))
|
|
91
|
+
if "minItems" in schema and len(data) < schema["minItems"]:
|
|
92
|
+
errors.append({"path": path, "error": f"Array has {len(data)} items, minimum {schema['minItems']}"})
|
|
93
|
+
if "maxItems" in schema and len(data) > schema["maxItems"]:
|
|
94
|
+
errors.append({"path": path, "error": f"Array has {len(data)} items, maximum {schema['maxItems']}"})
|
|
95
|
+
if schema_type == "string" and isinstance(data, str):
|
|
96
|
+
if "minLength" in schema and len(data) < schema["minLength"]:
|
|
97
|
+
errors.append({"path": path, "error": f"String too short: {len(data)} < {schema['minLength']}"})
|
|
98
|
+
if "maxLength" in schema and len(data) > schema["maxLength"]:
|
|
99
|
+
errors.append({"path": path, "error": f"String too long: {len(data)} > {schema['maxLength']}"})
|
|
100
|
+
if "enum" in schema and data not in schema["enum"]:
|
|
101
|
+
errors.append({"path": path, "error": f"Value not in enum: {schema['enum']}"})
|
|
102
|
+
if schema_type in ("integer", "number") and isinstance(data, (int, float)):
|
|
103
|
+
if "minimum" in schema and data < schema["minimum"]:
|
|
104
|
+
errors.append({"path": path, "error": f"Value {data} below minimum {schema['minimum']}"})
|
|
105
|
+
if "maximum" in schema and data > schema["maximum"]:
|
|
106
|
+
errors.append({"path": path, "error": f"Value {data} above maximum {schema['maximum']}"})
|
|
107
|
+
return errors
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
@mcp.tool()
|
|
111
|
+
def validate_json_schema(data_json: str, schema_json: str, api_key: str = "") -> dict:
|
|
112
|
+
"""Validate JSON data against a JSON Schema.
|
|
113
|
+
|
|
114
|
+
Args:
|
|
115
|
+
data_json: JSON string of the data to validate
|
|
116
|
+
schema_json: JSON string of the schema to validate against
|
|
117
|
+
"""
|
|
118
|
+
allowed, msg, tier = check_access(api_key)
|
|
119
|
+
if not allowed:
|
|
120
|
+
return {"error": msg, "upgrade_url": "https://meok.ai/pricing"}
|
|
121
|
+
|
|
122
|
+
_check_rate_limit("validate_json_schema")
|
|
123
|
+
try:
|
|
124
|
+
data = json.loads(data_json)
|
|
125
|
+
schema = json.loads(schema_json)
|
|
126
|
+
except json.JSONDecodeError as e:
|
|
127
|
+
return {"valid": False, "error": f"JSON parse error: {e}"}
|
|
128
|
+
errors = _validate_against_schema(data, schema)
|
|
129
|
+
return {"valid": len(errors) == 0, "errors": errors, "error_count": len(errors)}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
@mcp.tool()
|
|
133
|
+
def generate_schema(data_json: str, title: str = "", api_key: str = "") -> dict:
|
|
134
|
+
"""Generate a JSON Schema from example JSON data.
|
|
135
|
+
|
|
136
|
+
Args:
|
|
137
|
+
data_json: Example JSON data string
|
|
138
|
+
title: Optional schema title
|
|
139
|
+
"""
|
|
140
|
+
allowed, msg, tier = check_access(api_key)
|
|
141
|
+
if not allowed:
|
|
142
|
+
return {"error": msg, "upgrade_url": "https://meok.ai/pricing"}
|
|
143
|
+
|
|
144
|
+
_check_rate_limit("generate_schema")
|
|
145
|
+
try:
|
|
146
|
+
data = json.loads(data_json)
|
|
147
|
+
except json.JSONDecodeError as e:
|
|
148
|
+
return {"error": f"Invalid JSON: {e}"}
|
|
149
|
+
schema = {"$schema": "https://json-schema.org/draft/2020-12/schema"}
|
|
150
|
+
if title:
|
|
151
|
+
schema["title"] = title
|
|
152
|
+
schema.update(_infer_type(data))
|
|
153
|
+
return {"schema": json.dumps(schema, indent=2), "schema_object": schema}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
@mcp.tool()
|
|
157
|
+
def convert_openapi(openapi_json: str, extract_schemas: bool = True, api_key: str = "") -> dict:
|
|
158
|
+
"""Extract and convert schemas from an OpenAPI specification.
|
|
159
|
+
|
|
160
|
+
Args:
|
|
161
|
+
openapi_json: OpenAPI spec as JSON string
|
|
162
|
+
extract_schemas: Whether to extract component schemas (default True)
|
|
163
|
+
"""
|
|
164
|
+
allowed, msg, tier = check_access(api_key)
|
|
165
|
+
if not allowed:
|
|
166
|
+
return {"error": msg, "upgrade_url": "https://meok.ai/pricing"}
|
|
167
|
+
|
|
168
|
+
_check_rate_limit("convert_openapi")
|
|
169
|
+
try:
|
|
170
|
+
spec = json.loads(openapi_json)
|
|
171
|
+
except json.JSONDecodeError as e:
|
|
172
|
+
return {"error": f"Invalid JSON: {e}"}
|
|
173
|
+
info = spec.get("info", {})
|
|
174
|
+
paths = spec.get("paths", {})
|
|
175
|
+
endpoints = []
|
|
176
|
+
for path, methods in paths.items():
|
|
177
|
+
for method, details in methods.items():
|
|
178
|
+
if method in ("get", "post", "put", "delete", "patch"):
|
|
179
|
+
endpoints.append({"path": path, "method": method.upper(),
|
|
180
|
+
"summary": details.get("summary", ""), "operationId": details.get("operationId", "")})
|
|
181
|
+
schemas = {}
|
|
182
|
+
if extract_schemas:
|
|
183
|
+
components = spec.get("components", {}).get("schemas", {})
|
|
184
|
+
for name, schema in components.items():
|
|
185
|
+
schemas[name] = schema
|
|
186
|
+
return {"title": info.get("title", ""), "version": info.get("version", ""),
|
|
187
|
+
"endpoints": endpoints, "endpoint_count": len(endpoints),
|
|
188
|
+
"schemas": schemas, "schema_count": len(schemas)}
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
@mcp.tool()
|
|
192
|
+
def validate_types(data_json: str, type_spec: dict, api_key: str = "") -> dict:
|
|
193
|
+
"""Validate that JSON data fields match expected types.
|
|
194
|
+
|
|
195
|
+
Args:
|
|
196
|
+
data_json: JSON string to validate
|
|
197
|
+
type_spec: Dict mapping field paths to expected types (e.g., {"name": "string", "age": "integer"})
|
|
198
|
+
"""
|
|
199
|
+
allowed, msg, tier = check_access(api_key)
|
|
200
|
+
if not allowed:
|
|
201
|
+
return {"error": msg, "upgrade_url": "https://meok.ai/pricing"}
|
|
202
|
+
|
|
203
|
+
_check_rate_limit("validate_types")
|
|
204
|
+
try:
|
|
205
|
+
data = json.loads(data_json)
|
|
206
|
+
except json.JSONDecodeError as e:
|
|
207
|
+
return {"valid": False, "error": f"Invalid JSON: {e}"}
|
|
208
|
+
errors = []
|
|
209
|
+
for field, expected_type in type_spec.items():
|
|
210
|
+
parts = field.split('.')
|
|
211
|
+
value = data
|
|
212
|
+
found = True
|
|
213
|
+
for part in parts:
|
|
214
|
+
if isinstance(value, dict) and part in value:
|
|
215
|
+
value = value[part]
|
|
216
|
+
else:
|
|
217
|
+
errors.append({"field": field, "error": "Field not found"})
|
|
218
|
+
found = False
|
|
219
|
+
break
|
|
220
|
+
if found:
|
|
221
|
+
actual = TYPE_MAP.get(type(value), type(value).__name__)
|
|
222
|
+
if expected_type == "number" and actual in ("integer", "number"):
|
|
223
|
+
continue
|
|
224
|
+
if actual != expected_type:
|
|
225
|
+
errors.append({"field": field, "expected": expected_type, "actual": actual})
|
|
226
|
+
return {"valid": len(errors) == 0, "errors": errors, "fields_checked": len(type_spec)}
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
if __name__ == "__main__":
|
|
230
|
+
mcp.run()
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
name: schema-validator-ai-mcp
|
|
2
|
+
description: Schema Validator Ai automation via MCP. Includes validate json schema,
|
|
3
|
+
generate schema, convert openapi. By MEOK AI Labs.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
tools:
|
|
6
|
+
- name: validate_json_schema
|
|
7
|
+
description: Validate JSON data against a JSON Schema.
|
|
8
|
+
parameters:
|
|
9
|
+
- name: data_json
|
|
10
|
+
type: string
|
|
11
|
+
required: true
|
|
12
|
+
- name: schema_json
|
|
13
|
+
type: string
|
|
14
|
+
required: true
|
|
15
|
+
- name: generate_schema
|
|
16
|
+
description: Generate a JSON Schema from example JSON data.
|
|
17
|
+
parameters:
|
|
18
|
+
- name: data_json
|
|
19
|
+
type: string
|
|
20
|
+
required: true
|
|
21
|
+
- name: title
|
|
22
|
+
type: string
|
|
23
|
+
required: false
|
|
24
|
+
- name: convert_openapi
|
|
25
|
+
description: Extract and convert schemas from an OpenAPI specification.
|
|
26
|
+
parameters:
|
|
27
|
+
- name: openapi_json
|
|
28
|
+
type: string
|
|
29
|
+
required: true
|
|
30
|
+
- name: extract_schemas
|
|
31
|
+
type: boolean
|
|
32
|
+
required: false
|
|
33
|
+
- name: validate_types
|
|
34
|
+
description: Validate that JSON data fields match expected types.
|
|
35
|
+
parameters:
|
|
36
|
+
- name: data_json
|
|
37
|
+
type: string
|
|
38
|
+
required: true
|
|
39
|
+
- name: type_spec
|
|
40
|
+
type: object
|
|
41
|
+
required: true
|
|
@@ -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()
|