my-openapi-mcp-weather-server 1.0.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
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.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # openapi-mcp-server
2
+
3
+ An MCP (Model Context Protocol) server for OpenAPI specification parsing and interaction.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install openapi-mcp-server
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Run directly with npx:
14
+
15
+ ```bash
16
+ npx openapi-mcp-server
17
+ ```
18
+
19
+ ## Features
20
+
21
+ - Parse OpenAPI specifications
22
+ - Provide API endpoint information via MCP protocol
23
+ - Support OpenAPI 3.0+ specifications
24
+
25
+ ## License
26
+
27
+ MIT
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
5
+ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
6
+ const zod_1 = require("zod");
7
+ const server = new mcp_js_1.McpServer({
8
+ name: "openapi-mcp-server",
9
+ version: "1.0.0",
10
+ });
11
+ server.tool("parse-openapi", "Parse an OpenAPI specification and return its structure", {
12
+ specUrl: zod_1.z.string().url().describe("URL of the OpenAPI specification JSON/YAML file"),
13
+ }, async ({ specUrl }) => {
14
+ try {
15
+ const response = await fetch(specUrl);
16
+ const contentType = response.headers.get("content-type") || "";
17
+ let spec;
18
+ if (contentType.includes("yaml") || specUrl.endsWith(".yaml") || specUrl.endsWith(".yml")) {
19
+ const text = await response.text();
20
+ return {
21
+ content: [
22
+ {
23
+ type: "text",
24
+ text: `YAML parsing not yet supported. Please provide a JSON spec. Raw content length: ${text.length}`,
25
+ },
26
+ ],
27
+ };
28
+ }
29
+ spec = await response.json();
30
+ const info = spec.info;
31
+ const paths = spec.paths;
32
+ const pathCount = paths ? Object.keys(paths).length : 0;
33
+ const summary = [
34
+ `OpenAPI Specification:`,
35
+ ` Title: ${info?.title || "Unknown"}`,
36
+ ` Version: ${info?.version || "Unknown"}`,
37
+ ` Paths: ${pathCount}`,
38
+ ` Endpoints:`,
39
+ ...Object.keys(paths || {}).map((p) => ` ${p}`),
40
+ ].join("\n");
41
+ return {
42
+ content: [{ type: "text", text: summary }],
43
+ };
44
+ }
45
+ catch (error) {
46
+ return {
47
+ content: [
48
+ {
49
+ type: "text",
50
+ text: `Error parsing OpenAPI spec: ${error instanceof Error ? error.message : String(error)}`,
51
+ },
52
+ ],
53
+ };
54
+ }
55
+ });
56
+ server.tool("list-endpoints", "List all API endpoints from an OpenAPI specification", {
57
+ specUrl: zod_1.z.string().url().describe("URL of the OpenAPI specification JSON file"),
58
+ }, async ({ specUrl }) => {
59
+ try {
60
+ const response = await fetch(specUrl);
61
+ const spec = (await response.json());
62
+ const paths = spec.paths;
63
+ if (!paths) {
64
+ return {
65
+ content: [{ type: "text", text: "No paths found in the specification." }],
66
+ };
67
+ }
68
+ const endpoints = [];
69
+ for (const [path, methods] of Object.entries(paths)) {
70
+ for (const method of Object.keys(methods)) {
71
+ const detail = methods[method];
72
+ const opId = detail.operationId || "";
73
+ const summary = detail.summary || "";
74
+ endpoints.push(`${method.toUpperCase().padEnd(7)} ${path}${opId ? ` (${opId})` : ""}${summary ? ` - ${summary}` : ""}`);
75
+ }
76
+ }
77
+ return {
78
+ content: [{ type: "text", text: endpoints.join("\n") || "No endpoints found." }],
79
+ };
80
+ }
81
+ catch (error) {
82
+ return {
83
+ content: [
84
+ {
85
+ type: "text",
86
+ text: `Error listing endpoints: ${error instanceof Error ? error.message : String(error)}`,
87
+ },
88
+ ],
89
+ };
90
+ }
91
+ });
92
+ async function main() {
93
+ const transport = new stdio_js_1.StdioServerTransport();
94
+ await server.connect(transport);
95
+ }
96
+ main().catch((error) => {
97
+ console.error("Fatal error in main():", error);
98
+ process.exit(1);
99
+ });
100
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,oEAAoE;AACpE,wEAAiF;AACjF,6BAAwB;AAExB,MAAM,MAAM,GAAG,IAAI,kBAAS,CAAC;IAC3B,IAAI,EAAE,oBAAoB;IAC1B,OAAO,EAAE,OAAO;CACjB,CAAC,CAAC;AAEH,MAAM,CAAC,IAAI,CACT,eAAe,EACf,yDAAyD,EACzD;IACE,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE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CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "my-openapi-mcp-weather-server",
3
+ "version": "1.0.0",
4
+ "description": "An MCP server for OpenAPI specification parsing and interaction",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "bin": {
8
+ "my-openapi-mcp-weather-server": "dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "README.md",
13
+ "LICENSE"
14
+ ],
15
+ "scripts": {
16
+ "build": "tsc",
17
+ "prepare": "npm run build",
18
+ "test": "jest"
19
+ },
20
+ "engines": {
21
+ "node": ">=18.0.0"
22
+ },
23
+ "keywords": [
24
+ "mcp",
25
+ "openapi",
26
+ "server"
27
+ ],
28
+ "license": "MIT",
29
+ "dependencies": {
30
+ "@modelcontextprotocol/sdk": "^1.12.1"
31
+ },
32
+ "devDependencies": {
33
+ "typescript": "^5.7.0",
34
+ "@types/node": "^22.0.0"
35
+ }
36
+ }