api-docs-generator-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.
@@ -0,0 +1,26 @@
1
+ name: Publish to Smithery
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish:
9
+ name: Publish MCP Server to Smithery
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: read
13
+ steps:
14
+ - name: Checkout repository
15
+ uses: actions/checkout@v4
16
+
17
+ - name: Setup Node.js
18
+ uses: actions/setup-node@v4
19
+ with:
20
+ node-version: '20'
21
+
22
+ - name: Publish to Smithery
23
+ env:
24
+ SMITHERY_API_KEY: ${{ secrets.SMITHERY_API_KEY }}
25
+ run: |
26
+ npx @smithery/cli mcp publish "https://github.com/${{ github.repository }}" -n nicholastempleman/${{ github.event.repository.name }}
@@ -0,0 +1,4 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .env
4
+ *.db
@@ -0,0 +1,113 @@
1
+ {
2
+ "name": "api-docs-generator-ai-mcp",
3
+ "description": "> **By [MEOK AI Labs](https://meok.ai)** \u2014 Generate OpenAPI/Swagger specifications from natural language API descriptions. Supports REST endpoi",
4
+ "version": "1.0.0",
5
+ "tools": [
6
+ {
7
+ "name": "generate_endpoint",
8
+ "description": "Generate an OpenAPI endpoint definition from a description.",
9
+ "parameters": {
10
+ "type": "object",
11
+ "properties": {
12
+ "path": {
13
+ "type": "string"
14
+ },
15
+ "method": {
16
+ "type": "string"
17
+ },
18
+ "summary": {
19
+ "type": "string"
20
+ },
21
+ "request_body": {
22
+ "type": "string"
23
+ },
24
+ "response_description": {
25
+ "type": "string"
26
+ }
27
+ },
28
+ "required": [
29
+ "path",
30
+ "method",
31
+ "summary"
32
+ ]
33
+ }
34
+ },
35
+ {
36
+ "name": "generate_schema",
37
+ "description": "Generate an OpenAPI schema component. Fields format: 'name:type,name2:type2' (types: string,integer,number,boolean,array).",
38
+ "parameters": {
39
+ "type": "object",
40
+ "properties": {
41
+ "name": {
42
+ "type": "string"
43
+ },
44
+ "fields": {
45
+ "type": "string"
46
+ }
47
+ },
48
+ "required": [
49
+ "name",
50
+ "fields"
51
+ ]
52
+ }
53
+ },
54
+ {
55
+ "name": "generate_full_spec",
56
+ "description": "Generate a complete OpenAPI 3.0 spec. Pass endpoints_json as a JSON array of {path, method, summary} objects.",
57
+ "parameters": {
58
+ "type": "object",
59
+ "properties": {
60
+ "title": {
61
+ "type": "string"
62
+ },
63
+ "description": {
64
+ "type": "string"
65
+ },
66
+ "version": {
67
+ "type": "string"
68
+ },
69
+ "endpoints_json": {
70
+ "type": "string"
71
+ }
72
+ },
73
+ "required": [
74
+ "title",
75
+ "description"
76
+ ]
77
+ }
78
+ },
79
+ {
80
+ "name": "add_auth_to_spec",
81
+ "description": "Add authentication scheme to an OpenAPI spec. auth_type: bearer, api_key, basic, oauth2.",
82
+ "parameters": {
83
+ "type": "object",
84
+ "properties": {
85
+ "spec_json": {
86
+ "type": "string"
87
+ },
88
+ "auth_type": {
89
+ "type": "string"
90
+ }
91
+ },
92
+ "required": [
93
+ "spec_json"
94
+ ]
95
+ }
96
+ },
97
+ {
98
+ "name": "validate_spec",
99
+ "description": "Validate an OpenAPI spec for common issues.",
100
+ "parameters": {
101
+ "type": "object",
102
+ "properties": {
103
+ "spec_json": {
104
+ "type": "string"
105
+ }
106
+ },
107
+ "required": [
108
+ "spec_json"
109
+ ]
110
+ }
111
+ }
112
+ ]
113
+ }
@@ -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: api-docs-generator-ai-mcp
3
+ Version: 1.0.0
4
+ Summary: MEOK AI Labs — api-docs-generator-ai-mcp
5
+ Project-URL: Homepage, https://meok.ai
6
+ Project-URL: Repository, https://github.com/CSOAI-ORG/api-docs-generator-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,api,docs,generator,mcp,meok
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,9 @@
1
+ # Api Docs Generator Ai Mcp
2
+
3
+ api-docs-generator-ai-mcp — Generate API documentation from code.
4
+
5
+ Built by [MEOK AI Labs](https://meok.ai).
6
+
7
+ ## License
8
+
9
+ MIT © MEOK AI Labs
@@ -0,0 +1 @@
1
+ {"name":"api-docs-generator-ai-mcp","version":"1.0.0","description":"MEOK AI Labs MCP","author":"MEOK AI Labs","license":"MIT","repository":{"type":"git","url":"https://github.com/CSOAI-ORG/api-docs-generator-ai-mcp"}}
@@ -0,0 +1,24 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+ [project]
5
+ name = "api-docs-generator-ai-mcp"
6
+ version = "1.0.0"
7
+ description = "MEOK AI Labs — api-docs-generator-ai-mcp"
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", "api", "docs", "generator"]
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/api-docs-generator-ai-mcp"
22
+ [tool.hatch.build.targets.wheel]
23
+ packages = ["."]
24
+ only-include = ["server.py"]
@@ -0,0 +1,219 @@
1
+ #!/usr/bin/env python3
2
+ """api-docs-generator-ai-mcp - Generate OpenAPI specs from descriptions."""
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
9
+ import time
10
+ from typing import Optional
11
+ from mcp.server.fastmcp import FastMCP
12
+
13
+ mcp = FastMCP(
14
+ "api-docs-generator-ai",
15
+ instructions="Generate OpenAPI/Swagger specifications from natural language API descriptions. Supports REST endpoint generation, schema creation, and full spec assembly.",
16
+ )
17
+
18
+ # Rate limiting
19
+ _calls: list[float] = []
20
+ DAILY_LIMIT = 50
21
+
22
+
23
+ def _check_rate() -> bool:
24
+ now = time.time()
25
+ _calls[:] = [t for t in _calls if now - t < 86400]
26
+ if len(_calls) >= DAILY_LIMIT:
27
+ return False
28
+ _calls.append(now)
29
+ return True
30
+
31
+
32
+ @mcp.tool()
33
+ def generate_endpoint(
34
+ path: str, method: str, summary: str, request_body: Optional[str] = None, response_description: str = "Successful response"
35
+ , api_key: str = "") -> dict:
36
+ """Generate an OpenAPI endpoint definition from a description."""
37
+ allowed, msg, tier = check_access(api_key)
38
+ if not allowed:
39
+ return {"error": msg, "upgrade_url": "https://meok.ai/pricing"}
40
+
41
+ if not _check_rate():
42
+ return {"error": "Rate limit exceeded (50/day)"}
43
+ method = method.lower()
44
+ if method not in ("get", "post", "put", "patch", "delete", "head", "options"):
45
+ return {"error": f"Invalid HTTP method: {method}"}
46
+ endpoint: dict = {
47
+ "summary": summary,
48
+ "operationId": path.strip("/").replace("/", "_").replace("{", "").replace("}", "") + f"_{method}",
49
+ "responses": {
50
+ "200": {
51
+ "description": response_description,
52
+ "content": {"application/json": {"schema": {"type": "object"}}},
53
+ },
54
+ "400": {"description": "Bad request"},
55
+ "500": {"description": "Internal server error"},
56
+ },
57
+ }
58
+ if request_body and method in ("post", "put", "patch"):
59
+ fields = [f.strip() for f in request_body.split(",")]
60
+ properties = {}
61
+ for field in fields:
62
+ parts = field.split(":")
63
+ fname = parts[0].strip()
64
+ ftype = parts[1].strip() if len(parts) > 1 else "string"
65
+ properties[fname] = {"type": ftype}
66
+ endpoint["requestBody"] = {
67
+ "required": True,
68
+ "content": {
69
+ "application/json": {
70
+ "schema": {"type": "object", "properties": properties, "required": list(properties.keys())},
71
+ }
72
+ },
73
+ }
74
+ params = []
75
+ import re
76
+ for match in re.finditer(r"\{(\w+)\}", path):
77
+ params.append({"name": match.group(1), "in": "path", "required": True, "schema": {"type": "string"}})
78
+ if params:
79
+ endpoint["parameters"] = params
80
+ return {"path": path, "method": method, "definition": endpoint}
81
+
82
+
83
+ @mcp.tool()
84
+ def generate_schema(name: str, fields: str, api_key: str = "") -> dict:
85
+ """Generate an OpenAPI schema component. Fields format: 'name:type,name2:type2' (types: string,integer,number,boolean,array)."""
86
+ allowed, msg, tier = check_access(api_key)
87
+ if not allowed:
88
+ return {"error": msg, "upgrade_url": "https://meok.ai/pricing"}
89
+
90
+ if not _check_rate():
91
+ return {"error": "Rate limit exceeded (50/day)"}
92
+ properties = {}
93
+ required = []
94
+ for field in fields.split(","):
95
+ parts = field.strip().split(":")
96
+ fname = parts[0].strip()
97
+ ftype = parts[1].strip() if len(parts) > 1 else "string"
98
+ if not fname:
99
+ continue
100
+ if ftype == "array":
101
+ properties[fname] = {"type": "array", "items": {"type": "string"}}
102
+ else:
103
+ properties[fname] = {"type": ftype}
104
+ required.append(fname)
105
+ schema = {"type": "object", "properties": properties, "required": required}
106
+ return {"schema_name": name, "schema": schema}
107
+
108
+
109
+ @mcp.tool()
110
+ def generate_full_spec(
111
+ title: str, description: str, version: str = "1.0.0", endpoints_json: str = "[]"
112
+ , api_key: str = "") -> dict:
113
+ """Generate a complete OpenAPI 3.0 spec. Pass endpoints_json as a JSON array of {path, method, summary} objects."""
114
+ allowed, msg, tier = check_access(api_key)
115
+ if not allowed:
116
+ return {"error": msg, "upgrade_url": "https://meok.ai/pricing"}
117
+
118
+ if not _check_rate():
119
+ return {"error": "Rate limit exceeded (50/day)"}
120
+ try:
121
+ endpoints = json.loads(endpoints_json)
122
+ except json.JSONDecodeError:
123
+ return {"error": "Invalid JSON for endpoints_json"}
124
+ paths: dict = {}
125
+ for ep in endpoints:
126
+ p = ep.get("path", "/")
127
+ m = ep.get("method", "get").lower()
128
+ s = ep.get("summary", "")
129
+ if p not in paths:
130
+ paths[p] = {}
131
+ paths[p][m] = {
132
+ "summary": s,
133
+ "operationId": p.strip("/").replace("/", "_") + f"_{m}",
134
+ "responses": {"200": {"description": "Success", "content": {"application/json": {"schema": {"type": "object"}}}}},
135
+ }
136
+ spec = {
137
+ "openapi": "3.0.3",
138
+ "info": {"title": title, "description": description, "version": version},
139
+ "paths": paths,
140
+ "components": {"schemas": {}},
141
+ }
142
+ return {"spec": spec}
143
+
144
+
145
+ @mcp.tool()
146
+ def add_auth_to_spec(spec_json: str, auth_type: str = "bearer", api_key: str = "") -> dict:
147
+ """Add authentication scheme to an OpenAPI spec. auth_type: bearer, api_key, basic, oauth2."""
148
+ allowed, msg, tier = check_access(api_key)
149
+ if not allowed:
150
+ return {"error": msg, "upgrade_url": "https://meok.ai/pricing"}
151
+
152
+ if not _check_rate():
153
+ return {"error": "Rate limit exceeded (50/day)"}
154
+ try:
155
+ spec = json.loads(spec_json)
156
+ except json.JSONDecodeError:
157
+ return {"error": "Invalid JSON for spec"}
158
+ schemes = {
159
+ "bearer": {"type": "http", "scheme": "bearer", "bearerFormat": "JWT"},
160
+ "api_key": {"type": "apiKey", "in": "header", "name": "X-API-Key"},
161
+ "basic": {"type": "http", "scheme": "basic"},
162
+ "oauth2": {
163
+ "type": "oauth2",
164
+ "flows": {"authorizationCode": {"authorizationUrl": "https://example.com/oauth/authorize", "tokenUrl": "https://example.com/oauth/token", "scopes": {"read": "Read access", "write": "Write access"}}},
165
+ },
166
+ }
167
+ if auth_type not in schemes:
168
+ return {"error": f"Unknown auth type: {auth_type}. Use: bearer, api_key, basic, oauth2"}
169
+ if "components" not in spec:
170
+ spec["components"] = {}
171
+ spec["components"]["securitySchemes"] = {auth_type: schemes[auth_type]}
172
+ spec["security"] = [{auth_type: []}]
173
+ return {"spec": spec}
174
+
175
+
176
+ @mcp.tool()
177
+ def validate_spec(spec_json: str, api_key: str = "") -> dict:
178
+ """Validate an OpenAPI spec for common issues."""
179
+ allowed, msg, tier = check_access(api_key)
180
+ if not allowed:
181
+ return {"error": msg, "upgrade_url": "https://meok.ai/pricing"}
182
+
183
+ if not _check_rate():
184
+ return {"error": "Rate limit exceeded (50/day)"}
185
+ try:
186
+ spec = json.loads(spec_json)
187
+ except json.JSONDecodeError:
188
+ return {"valid": False, "errors": ["Invalid JSON"]}
189
+ errors = []
190
+ warnings = []
191
+ if "openapi" not in spec:
192
+ errors.append("Missing 'openapi' version field")
193
+ if "info" not in spec:
194
+ errors.append("Missing 'info' object")
195
+ else:
196
+ if "title" not in spec["info"]:
197
+ errors.append("Missing 'info.title'")
198
+ if "version" not in spec["info"]:
199
+ errors.append("Missing 'info.version'")
200
+ if "paths" not in spec:
201
+ errors.append("Missing 'paths' object")
202
+ else:
203
+ for path, methods in spec["paths"].items():
204
+ if not path.startswith("/"):
205
+ errors.append(f"Path '{path}' must start with /")
206
+ for method, definition in methods.items():
207
+ if method not in ("get", "post", "put", "patch", "delete", "head", "options", "trace"):
208
+ errors.append(f"Invalid method '{method}' on {path}")
209
+ if "responses" not in definition:
210
+ warnings.append(f"{method.upper()} {path} has no responses defined")
211
+ return {"valid": len(errors) == 0, "errors": errors, "warnings": warnings}
212
+
213
+
214
+ def main():
215
+ mcp.run(transport="stdio")
216
+
217
+
218
+ if __name__ == "__main__":
219
+ main()
@@ -0,0 +1,65 @@
1
+ name: api-docs-generator-ai-mcp
2
+ description: Generate OpenAPI/Swagger specifications from natural language API descriptions.
3
+ Supports REST endpoi
4
+ version: 1.0.0
5
+ tools:
6
+ - name: generate_endpoint
7
+ description: Generate an OpenAPI endpoint definition from a description.
8
+ parameters:
9
+ - name: path
10
+ type: string
11
+ required: true
12
+ - name: method
13
+ type: string
14
+ required: true
15
+ - name: summary
16
+ type: string
17
+ required: true
18
+ - name: request_body
19
+ type: string
20
+ required: false
21
+ - name: response_description
22
+ type: string
23
+ required: false
24
+ - name: generate_schema
25
+ description: 'Generate an OpenAPI schema component. Fields format: ''name:type,name2:type2''
26
+ (types: string,integer,number,boolean,array).'
27
+ parameters:
28
+ - name: name
29
+ type: string
30
+ required: true
31
+ - name: fields
32
+ type: string
33
+ required: true
34
+ - name: generate_full_spec
35
+ description: Generate a complete OpenAPI 3.0 spec. Pass endpoints_json as a JSON
36
+ array of {path, method, summary} objects.
37
+ parameters:
38
+ - name: title
39
+ type: string
40
+ required: true
41
+ - name: description
42
+ type: string
43
+ required: true
44
+ - name: version
45
+ type: string
46
+ required: false
47
+ - name: endpoints_json
48
+ type: string
49
+ required: false
50
+ - name: add_auth_to_spec
51
+ description: 'Add authentication scheme to an OpenAPI spec. auth_type: bearer, api_key,
52
+ basic, oauth2.'
53
+ parameters:
54
+ - name: spec_json
55
+ type: string
56
+ required: true
57
+ - name: auth_type
58
+ type: string
59
+ required: false
60
+ - name: validate_spec
61
+ description: Validate an OpenAPI spec for common issues.
62
+ parameters:
63
+ - name: spec_json
64
+ type: string
65
+ required: true