Skip to content

Commit 2cab8ae

Browse files
committed
style: format the code with the prettier config
1 parent ea89e04 commit 2cab8ae

31 files changed

Lines changed: 8684 additions & 7460 deletions

.eslintrc.json

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
{
2-
"parser": "@typescript-eslint/parser",
3-
"extends": [
4-
"eslint:recommended",
5-
"plugin:@typescript-eslint/recommended"
6-
],
7-
"plugins": ["@typescript-eslint"],
8-
"env": {
9-
"node": true,
10-
"es2022": true
11-
},
12-
"rules": {
13-
"no-console": "off",
14-
"@typescript-eslint/explicit-function-return-type": "off",
15-
"@typescript-eslint/no-explicit-any": "off",
16-
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }]
17-
}
18-
}
2+
"parser": "@typescript-eslint/parser",
3+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
4+
"plugins": ["@typescript-eslint"],
5+
"env": {
6+
"node": true,
7+
"es2022": true
8+
},
9+
"rules": {
10+
"no-console": "off",
11+
"@typescript-eslint/explicit-function-return-type": "off",
12+
"@typescript-eslint/no-explicit-any": "off",
13+
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }]
14+
}
15+
}

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ about: Create a report to help us improve
44
title: ''
55
labels: ''
66
assignees: ''
7-
87
---
98

109
**Describe the bug**
1110
A clear and concise description of what the bug is.
1211

1312
**To Reproduce**
1413
Steps to reproduce the behavior:
14+
1515
1. Go to '...'
1616
2. Click on '....'
1717
3. Scroll down to '....'
@@ -24,15 +24,17 @@ A clear and concise description of what you expected to happen.
2424
If applicable, add screenshots to help explain your problem.
2525

2626
**Desktop (please complete the following information):**
27-
- OS: [e.g. iOS]
28-
- Browser [e.g. chrome, safari]
29-
- Version [e.g. 22]
27+
28+
- OS: [e.g. iOS]
29+
- Browser [e.g. chrome, safari]
30+
- Version [e.g. 22]
3031

3132
**Smartphone (please complete the following information):**
32-
- Device: [e.g. iPhone6]
33-
- OS: [e.g. iOS8.1]
34-
- Browser [e.g. stock browser, safari]
35-
- Version [e.g. 22]
33+
34+
- Device: [e.g. iPhone6]
35+
- OS: [e.g. iOS8.1]
36+
- Browser [e.g. stock browser, safari]
37+
- Version [e.g. 22]
3638

3739
**Additional context**
3840
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/custom.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,4 @@ about: Describe this issue template's purpose here.
44
title: ''
55
labels: ''
66
assignees: ''
7-
87
---
9-
10-

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ about: Suggest an idea for this project
44
title: ''
55
labels: ''
66
assignees: ''
7-
87
---
98

109
**Is your feature request related to a problem? Please describe.**

.github/workflows/npm-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
with:
2424
node-version: '20'
2525
registry-url: 'https://registry.npmjs.org'
26-
cache: 'npm' # Enables npm dependency caching
26+
cache: 'npm' # Enables npm dependency caching
2727
cache-dependency-path: '**/package-lock.json' # Cache key based on lockfile
2828

2929
- name: Install dependencies

.prettierrc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"semi": true,
3-
"trailingComma": "es5",
4-
"singleQuote": true,
5-
"printWidth": 100,
6-
"tabWidth": 2
7-
}
2+
"semi": true,
3+
"trailingComma": "es5",
4+
"singleQuote": true,
5+
"printWidth": 100,
6+
"tabWidth": 2
7+
}

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,59 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [3.1.2] - 2025-06-08
99

1010
### Fixed
11+
1112
- Prevent stack overflow (RangeError: Maximum call stack size exceeded) when processing recursive or cyclic OpenAPI schemas (e.g., self-referencing objects).
1213
- Added cycle detection to schema mapping, ensuring robust handling of recursive structures.
1314

1415
## [3.1.1] - 2025-05-26
1516

1617
### Added
18+
1719
- Introduced a new executable command-line script for easier usage in Unix-like environments.
1820

1921
### Changed
22+
2023
- Use new CLI entry point to use the new `bin/openapi-mcp-generator.js` file.
2124
- Updated build script to ensure the new CLI file has the correct permissions.
2225
- Refactored `index.ts` to streamline argument parsing and error handling.
2326

24-
2527
## [3.1.0] - 2025-05-18
2628

2729
### Added
30+
2831
- Programmatic API to extract MCP tool definitions from OpenAPI specs
2932
- New exportable `getToolsFromOpenApi` function for direct integration in code
3033
- Advanced filtering capabilities for programmatic tool extraction
3134
- Comprehensive documentation in PROGRAMMATIC_API.md
3235
- Updated README with programmatic API usage examples
3336

3437
### Changed
38+
3539
- Improved module structure with better exports
3640
- Enhanced detection of module execution context
3741

3842
## [3.0.0] - 2025-04-26
3943

4044
### Added
45+
4146
- Streamable HTTP support for OpenAPI MCP generator, enabling efficient handling of large payloads and real-time data transfer.
4247
- Major architectural refactor to support streaming responses and requests.
4348

4449
### Fixed
50+
4551
- Multiple bugs related to HTTP/HTTPS connection handling, stream closure, and error propagation in streaming scenarios.
4652
- Fixed resource leak issues on server aborts and client disconnects during streaming.
4753

4854
### Changed
55+
4956
- Major version bump due to breaking changes in API and internal structures to support streaming.
5057
- Updated documentation to reflect new streaming capabilities and usage instructions.
5158
- Enhanced performance and robustness of HTTP/HTTPS transport layers.
5259

5360
## [2.0.0] - 2025-04-12
5461

5562
### Added
63+
5664
- Runtime argument validation using Zod
5765
- JSON Schema to Zod schema conversion
5866
- Improved error handling and formatting
@@ -63,6 +71,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6371
- Support for multiple content types
6472

6573
### Changed
74+
6675
- Simplified transport layer to only support stdio transport
6776
- Removed support for WebSocket and HTTP transports
6877
- Updated to use @modelcontextprotocol/sdk v1.9.0
@@ -72,6 +81,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7281
- More robust OpenAPI schema processing
7382

7483
### Fixed
84+
7585
- Path parameter resolution in URLs
7686
- Content-Type header handling
7787
- Response processing for different content types
@@ -81,6 +91,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8191
## [1.0.0] - Initial Release
8292

8393
### Added
94+
8495
- Basic OpenAPI to MCP server generation
8596
- Support for GET, POST, PUT, DELETE methods
8697
- Basic error handling

PROGRAMMATIC_API.md

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ import { getToolsFromOpenApi } from 'openapi-mcp-generator';
2121
This function extracts an array of tools from an OpenAPI specification.
2222

2323
**Parameters:**
24+
2425
- `specPathOrUrl`: Path to a local OpenAPI spec file or URL to a remote spec
2526
- `options`: (Optional) Configuration options
2627

2728
**Options:**
29+
2830
- `baseUrl`: Override the base URL in the OpenAPI spec
2931
- `dereference`: Whether to resolve $refs (default: false)
3032
- `excludeOperationIds`: Array of operation IDs to exclude from the results
3133
- `filterFn`: Custom function to filter tools (receives tool, returns boolean)
3234

3335
**Returns:**
36+
3437
- Promise that resolves to an array of McpToolDefinition objects
3538

3639
**Example:**
@@ -42,12 +45,15 @@ import { getToolsFromOpenApi } from 'openapi-mcp-generator';
4245
const tools = await getToolsFromOpenApi('./petstore.json');
4346

4447
// With options
45-
const filteredTools = await getToolsFromOpenApi('https://petstore3.swagger.io/api/v3/openapi.json', {
46-
baseUrl: 'https://petstore3.swagger.io/api/v3',
47-
dereference: true,
48-
excludeOperationIds: ['addPet', 'updatePet'],
49-
filterFn: (tool) => tool.method.toLowerCase() === 'get'
50-
});
48+
const filteredTools = await getToolsFromOpenApi(
49+
'https://petstore3.swagger.io/api/v3/openapi.json',
50+
{
51+
baseUrl: 'https://petstore3.swagger.io/api/v3',
52+
dereference: true,
53+
excludeOperationIds: ['addPet', 'updatePet'],
54+
filterFn: (tool) => tool.method.toLowerCase() === 'get',
55+
}
56+
);
5157

5258
// Process the results
5359
for (const tool of filteredTools) {
@@ -66,34 +72,34 @@ Each tool definition (`McpToolDefinition`) has the following properties:
6672
interface McpToolDefinition {
6773
/** Name of the tool, must be unique */
6874
name: string;
69-
75+
7076
/** Human-readable description of the tool */
7177
description: string;
72-
78+
7379
/** JSON Schema that defines the input parameters */
7480
inputSchema: JSONSchema7 | boolean;
75-
81+
7682
/** HTTP method for the operation (get, post, etc.) */
7783
method: string;
78-
84+
7985
/** URL path template with parameter placeholders */
8086
pathTemplate: string;
81-
87+
8288
/** OpenAPI parameter objects for this operation */
8389
parameters: OpenAPIV3.ParameterObject[];
84-
90+
8591
/** Parameter names and locations for execution */
8692
executionParameters: { name: string; in: string }[];
87-
93+
8894
/** Content type for request body, if applicable */
8995
requestBodyContentType?: string;
90-
96+
9197
/** Security requirements for this operation */
9298
securityRequirements: OpenAPIV3.SecurityRequirementObject[];
93-
99+
94100
/** Original operation ID from the OpenAPI spec */
95101
operationId: string;
96-
102+
97103
/** Base URL for the API (if available) */
98104
baseUrl?: string;
99105
}
@@ -105,23 +111,23 @@ interface McpToolDefinition {
105111

106112
```typescript
107113
const getTools = await getToolsFromOpenApi(specUrl, {
108-
filterFn: (tool) => tool.method.toLowerCase() === 'get'
114+
filterFn: (tool) => tool.method.toLowerCase() === 'get',
109115
});
110116
```
111117

112118
### Filter by Security Requirements
113119

114120
```typescript
115121
const secureTools = await getToolsFromOpenApi(specUrl, {
116-
filterFn: (tool) => tool.securityRequirements.length > 0
122+
filterFn: (tool) => tool.securityRequirements.length > 0,
117123
});
118124
```
119125

120126
### Filter by Path Pattern
121127

122128
```typescript
123129
const userTools = await getToolsFromOpenApi(specUrl, {
124-
filterFn: (tool) => tool.pathTemplate.includes('/user')
130+
filterFn: (tool) => tool.pathTemplate.includes('/user'),
125131
});
126132
```
127133

@@ -130,8 +136,6 @@ const userTools = await getToolsFromOpenApi(specUrl, {
130136
```typescript
131137
const safeUserTools = await getToolsFromOpenApi(specUrl, {
132138
excludeOperationIds: ['deleteUser', 'updateUser'],
133-
filterFn: (tool) =>
134-
tool.pathTemplate.includes('/user') &&
135-
tool.method.toLowerCase() === 'get'
139+
filterFn: (tool) => tool.pathTemplate.includes('/user') && tool.method.toLowerCase() === 'get',
136140
});
137-
```
141+
```

bin/openapi-mcp-generator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
import { program } from '../dist/index.js';
44

55
// Parse CLI arguments and run the program
6-
program.parse(process.argv);
6+
program.parse(process.argv);
Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
{
22
"parser": "@typescript-eslint/parser",
3-
"extends": [
4-
"eslint:recommended",
5-
"plugin:@typescript-eslint/recommended"
6-
],
7-
"plugins": [
8-
"@typescript-eslint"
9-
],
3+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
4+
"plugins": ["@typescript-eslint"],
105
"env": {
116
"node": true,
127
"es2022": true
@@ -15,10 +10,7 @@
1510
"no-console": [
1611
"error",
1712
{
18-
"allow": [
19-
"error",
20-
"warn"
21-
]
13+
"allow": ["error", "warn"]
2214
}
2315
],
2416
"@typescript-eslint/explicit-function-return-type": "off",
@@ -30,4 +22,4 @@
3022
}
3123
]
3224
}
33-
}
25+
}

0 commit comments

Comments
 (0)