@ivotoby/openapi-mcp-server 0.1.0 → 1.1.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.
Files changed (3) hide show
  1. package/README.md +116 -39
  2. package/dist/bundle.js +1502 -68
  3. package/package.json +26 -10
package/README.md CHANGED
@@ -2,14 +2,24 @@
2
2
 
3
3
  A Model Context Protocol (MCP) server that exposes OpenAPI endpoints as MCP resources. This server allows Large Language Models to discover and interact with REST APIs defined by OpenAPI specifications through the MCP protocol.
4
4
 
5
- ## Quick Start
5
+ ## Overview
6
6
 
7
- You do not need to clone this repository to use this MCP server. You can simply configure it in Claude Desktop:
7
+ This MCP server supports two transport methods:
8
+
9
+ 1. **Stdio Transport** (default): For direct integration with AI systems like Claude Desktop that manage MCP connections through standard input/output.
10
+ 2. **Streamable HTTP Transport**: For connecting to the server over HTTP, allowing web clients and other HTTP-capable systems to use the MCP protocol.
11
+
12
+ ## Quick Start for Users
13
+
14
+ ### Option 1: Using with Claude Desktop (Stdio Transport)
15
+
16
+ No need to clone this repository. Simply configure Claude Desktop to use this MCP server:
8
17
 
9
18
  1. Locate or create your Claude Desktop configuration file:
19
+
10
20
  - On macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
11
21
 
12
- 2. Add the following configuration to enable the OpenAPI MCP server:
22
+ 2. Add the following configuration:
13
23
 
14
24
  ```json
15
25
  {
@@ -32,27 +42,75 @@ You do not need to clone this repository to use this MCP server. You can simply
32
42
  - `OPENAPI_SPEC_PATH`: URL or path to your OpenAPI specification
33
43
  - `API_HEADERS`: Comma-separated key:value pairs for API authentication headers
34
44
 
35
- ## Development Tools
45
+ ### Option 2: Using with HTTP Clients (HTTP Transport)
36
46
 
37
- This project includes several development tools to make your workflow easier:
47
+ To use the server with HTTP clients:
38
48
 
39
- ### Building
49
+ 1. No installation required! Use npx to run the package directly:
40
50
 
41
- - `npm run build` - Builds the TypeScript source
42
- - `npm run clean` - Removes build artifacts
43
- - `npm run typecheck` - Runs TypeScript type checking
51
+ ```bash
52
+ npx @ivotoby/openapi-mcp-server \
53
+ --api-base-url https://api.example.com \
54
+ --openapi-spec https://api.example.com/openapi.json \
55
+ --headers "Authorization:Bearer token123" \
56
+ --transport http \
57
+ --port 3000
58
+ ```
44
59
 
45
- ### Development Mode
60
+ 2. Interact with the server using HTTP requests:
46
61
 
47
- - `npm run dev` - Watches source files and rebuilds on changes
48
- - `npm run inspect-watch` - Runs the inspector with auto-reload on changes
62
+ ```bash
63
+ # Initialize a session (first request)
64
+ curl -X POST http://localhost:3000/mcp \
65
+ -H "Content-Type: application/json" \
66
+ -d '{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"client":{"name":"curl-client","version":"1.0.0"},"protocol":{"name":"mcp","version":"2025-03-26"}}}'
67
+
68
+ # The response includes a Mcp-Session-Id header that you must use for subsequent requests
69
+ # and the InitializeResult directly in the POST response body.
70
+
71
+ # Send a request to list tools
72
+ # This also receives its response directly on this POST request.
73
+ curl -X POST http://localhost:3000/mcp \
74
+ -H "Content-Type: application/json" \
75
+ -H "Mcp-Session-Id: your-session-id" \
76
+ -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
77
+
78
+ # Open a streaming connection for other server responses (e.g., tool execution results)
79
+ # This uses Server-Sent Events (SSE).
80
+ curl -N http://localhost:3000/mcp -H "Mcp-Session-Id: your-session-id"
81
+
82
+ # Example: Execute a tool (response will arrive on the GET stream)
83
+ # curl -X POST http://localhost:3000/mcp \
84
+ # -H "Content-Type: application/json" \
85
+ # -H "Mcp-Session-Id: your-session-id" \
86
+ # -d '{"jsonrpc":"2.0","id":2,"method":"tools/execute","params":{"name":"yourToolName", "arguments": {}}}'
87
+
88
+ # Terminate the session when done
89
+ curl -X DELETE http://localhost:3000/mcp -H "Mcp-Session-Id: your-session-id"
90
+ ```
49
91
 
50
- ### Code Quality
92
+ ## Transport Types
51
93
 
52
- - `npm run lint` - Runs ESLint
53
- - `npm run typecheck` - Verifies TypeScript types
94
+ ### Stdio Transport (Default)
95
+
96
+ The stdio transport is designed for direct integration with AI systems like Claude Desktop that manage MCP connections through standard input/output. This is the simplest setup and requires no network configuration.
97
+
98
+ **When to use**: When integrating with Claude Desktop or other systems that support stdio-based MCP communication.
99
+
100
+ ### Streamable HTTP Transport
101
+
102
+ The HTTP transport allows the MCP server to be accessed over HTTP, enabling web applications and other HTTP-capable clients to interact with the MCP protocol. It supports session management, streaming responses, and standard HTTP methods.
54
103
 
55
- ## Configuration
104
+ **Key features**:
105
+
106
+ - Session management with Mcp-Session-Id header
107
+ - HTTP responses for `initialize` and `tools/list` requests are sent synchronously on the POST.
108
+ - Other server-to-client messages (e.g., `tools/execute` results, notifications) are streamed over a GET connection using Server-Sent Events (SSE).
109
+ - Support for POST/GET/DELETE methods
110
+
111
+ **When to use**: When you need to expose the MCP server to web clients or systems that communicate over HTTP rather than stdio.
112
+
113
+ ## Configuration Options
56
114
 
57
115
  The server can be configured through environment variables or command line arguments:
58
116
 
@@ -63,51 +121,70 @@ The server can be configured through environment variables or command line argum
63
121
  - `API_HEADERS` - Comma-separated key:value pairs for API headers
64
122
  - `SERVER_NAME` - Name for the MCP server (default: "mcp-openapi-server")
65
123
  - `SERVER_VERSION` - Version of the server (default: "1.0.0")
124
+ - `TRANSPORT_TYPE` - Transport type to use: "stdio" or "http" (default: "stdio")
125
+ - `HTTP_PORT` - Port for HTTP transport (default: 3000)
126
+ - `HTTP_HOST` - Host for HTTP transport (default: "127.0.0.1")
127
+ - `ENDPOINT_PATH` - Endpoint path for HTTP transport (default: "/mcp")
66
128
 
67
129
  ### Command Line Arguments
68
130
 
69
131
  ```bash
70
- npm run inspect -- \
132
+ npx @ivotoby/openapi-mcp-server \
71
133
  --api-base-url https://api.example.com \
72
134
  --openapi-spec https://api.example.com/openapi.json \
73
135
  --headers "Authorization:Bearer token123,X-API-Key:your-api-key" \
74
136
  --name "my-mcp-server" \
75
- --version "1.0.0"
137
+ --version "1.0.0" \
138
+ --transport http \
139
+ --port 3000 \
140
+ --host 127.0.0.1 \
141
+ --path /mcp
76
142
  ```
77
143
 
78
- ## Development Workflow
79
-
80
- 1. Start the development environment:
81
- ```bash
82
- npm run inspect-watch
83
- ```
144
+ ## Security Considerations
84
145
 
85
- 2. Make changes to the TypeScript files in `src/`
86
- 3. The server will automatically rebuild and restart
87
- 4. Use the MCP Inspector UI to test your changes
146
+ - The HTTP transport validates Origin headers to prevent DNS rebinding attacks
147
+ - By default, HTTP transport only binds to localhost (127.0.0.1)
148
+ - If exposing to other hosts, consider implementing additional authentication
88
149
 
89
150
  ## Debugging
90
151
 
91
- The server outputs debug logs to stderr. To see these logs:
152
+ To see debug logs:
92
153
 
93
- 1. In development mode:
94
- - Logs appear in the terminal running `inspect-watch`
95
-
96
- 2. When running directly:
154
+ 1. When using stdio transport with Claude Desktop:
155
+
156
+ - Logs appear in the Claude Desktop logs
157
+
158
+ 2. When using HTTP transport:
97
159
  ```bash
98
- npm run inspect 2>debug.log
160
+ npx @ivotoby/openapi-mcp-server --transport http 2>debug.log
99
161
  ```
100
162
 
101
- ## Contributing
163
+ ## For Developers
164
+
165
+ ### Development Tools
166
+
167
+ - `npm run build` - Builds the TypeScript source
168
+ - `npm run clean` - Removes build artifacts
169
+ - `npm run typecheck` - Runs TypeScript type checking
170
+ - `npm run lint` - Runs ESLint
171
+ - `npm run dev` - Watches source files and rebuilds on changes
172
+ - `npm run inspect-watch` - Runs the inspector with auto-reload on changes
173
+
174
+ ### Development Workflow
175
+
176
+ 1. Clone the repository
177
+ 2. Install dependencies: `npm install`
178
+ 3. Start the development environment: `npm run inspect-watch`
179
+ 4. Make changes to the TypeScript files in `src/`
180
+ 5. The server will automatically rebuild and restart
181
+
182
+ ### Contributing
102
183
 
103
184
  1. Fork the repository
104
185
  2. Create a feature branch
105
186
  3. Make your changes
106
- 4. Run tests and linting:
107
- ```bash
108
- npm run typecheck
109
- npm run lint
110
- ```
187
+ 4. Run tests and linting: `npm run typecheck && npm run lint`
111
188
  5. Submit a pull request
112
189
 
113
190
  ## License