@emcy/openapi-to-mcp 0.2.0 → 0.4.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/README.md +180 -127
- package/dist/__tests__/cli-config.test.d.ts +2 -0
- package/dist/__tests__/cli-config.test.d.ts.map +1 -0
- package/dist/__tests__/cli-config.test.js +95 -0
- package/dist/__tests__/cli-config.test.js.map +1 -0
- package/dist/__tests__/generator.test.d.ts +1 -1
- package/dist/__tests__/generator.test.js +178 -200
- package/dist/__tests__/generator.test.js.map +1 -1
- package/dist/__tests__/integration.test.js +11 -11
- package/dist/__tests__/integration.test.js.map +1 -1
- package/dist/__tests__/mapper.test.js +30 -6
- package/dist/__tests__/mapper.test.js.map +1 -1
- package/dist/__tests__/parser.test.js +2 -0
- package/dist/__tests__/parser.test.js.map +1 -1
- package/dist/__tests__/tool-identity.test.d.ts +2 -0
- package/dist/__tests__/tool-identity.test.d.ts.map +1 -0
- package/dist/__tests__/tool-identity.test.js +15 -0
- package/dist/__tests__/tool-identity.test.js.map +1 -0
- package/dist/cli-config.d.ts +31 -0
- package/dist/cli-config.d.ts.map +1 -0
- package/dist/cli-config.js +148 -0
- package/dist/cli-config.js.map +1 -0
- package/dist/cli.js +66 -4
- package/dist/cli.js.map +1 -1
- package/dist/generator.d.ts +8 -3
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js +711 -327
- package/dist/generator.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mapper.d.ts.map +1 -1
- package/dist/mapper.js +6 -2
- package/dist/mapper.js.map +1 -1
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +18 -5
- package/dist/parser.js.map +1 -1
- package/dist/tool-identity.d.ts +6 -0
- package/dist/tool-identity.d.ts.map +1 -0
- package/dist/tool-identity.js +67 -0
- package/dist/tool-identity.js.map +1 -0
- package/dist/types.d.ts +119 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,35 +1,69 @@
|
|
|
1
1
|
# @emcy/openapi-to-mcp
|
|
2
2
|
|
|
3
|
-
Convert OpenAPI specifications
|
|
3
|
+
Convert OpenAPI specifications into MCP servers.
|
|
4
|
+
|
|
5
|
+
Use this package when you want a quick way to turn an OpenAPI spec into a TypeScript MCP server.
|
|
6
|
+
If you want Emcy Gateway in front of that server, add `--use-emcy-gateway`.
|
|
4
7
|
|
|
5
8
|
[](https://www.npmjs.com/package/@emcy/openapi-to-mcp)
|
|
6
9
|
[](https://opensource.org/licenses/MIT)
|
|
7
10
|
|
|
8
|
-
## What
|
|
11
|
+
## What it generates
|
|
12
|
+
|
|
13
|
+
This package generates TypeScript MCP servers.
|
|
14
|
+
|
|
15
|
+
Most users only need two shapes:
|
|
16
|
+
|
|
17
|
+
1. `standalone_no_auth`
|
|
18
|
+
- Public MCP server
|
|
19
|
+
- No built-in upstream auth logic
|
|
20
|
+
- Good for public or already-open APIs
|
|
21
|
+
|
|
22
|
+
2. `standalone_headers`
|
|
23
|
+
- Public MCP server
|
|
24
|
+
- Injects static/custom headers into every upstream API request
|
|
25
|
+
- Good for API keys, static bearer tokens, tenant headers, and similar patterns
|
|
26
|
+
|
|
27
|
+
If you want Emcy Gateway in front of the generated server, opt into the Gateway integration:
|
|
28
|
+
|
|
29
|
+
- the generated server stays a TypeScript MCP server
|
|
30
|
+
- Emcy Gateway owns the public MCP and OAuth edge
|
|
31
|
+
- Emcy Host can run the server for you if you want managed hosting
|
|
9
32
|
|
|
10
|
-
|
|
33
|
+
FastMCP and other MCP runtimes can use Emcy Gateway too. This package is only for OpenAPI generation.
|
|
11
34
|
|
|
12
|
-
|
|
13
|
-
- Let AI assistants (Claude, Cursor, etc.) interact with your REST APIs
|
|
14
|
-
- Create MCP servers without writing code
|
|
15
|
-
- Add observability to AI tool usage with Emcy telemetry
|
|
35
|
+
The generator no longer produces standalone public OAuth resource servers and no longer supports bearer-token passthrough.
|
|
16
36
|
|
|
17
37
|
## Quick Start
|
|
18
38
|
|
|
19
39
|
```bash
|
|
20
|
-
#
|
|
21
|
-
npx @emcy/openapi-to-mcp generate
|
|
40
|
+
# Standalone MCP server for a public API
|
|
41
|
+
npx @emcy/openapi-to-mcp generate \
|
|
42
|
+
--url https://petstore.swagger.io/v2/swagger.json \
|
|
43
|
+
--mode standalone-no-auth
|
|
22
44
|
|
|
23
|
-
#
|
|
24
|
-
npx @emcy/openapi-to-mcp generate
|
|
45
|
+
# Standalone MCP server that injects an API key header upstream
|
|
46
|
+
npx @emcy/openapi-to-mcp generate \
|
|
47
|
+
--url ./openapi.yaml \
|
|
48
|
+
--name my-api \
|
|
49
|
+
--mode standalone-headers \
|
|
50
|
+
--header X-API-Key=UPSTREAM_API_KEY
|
|
25
51
|
|
|
26
|
-
# Generate
|
|
27
|
-
npx @emcy/openapi-to-mcp generate
|
|
52
|
+
# Generate a server and configure it for Emcy Gateway on an OAuth-protected app
|
|
53
|
+
npx @emcy/openapi-to-mcp generate \
|
|
54
|
+
--url ./openapi.yaml \
|
|
55
|
+
--name my-app \
|
|
56
|
+
--use-emcy-gateway \
|
|
57
|
+
--gateway-provider sqlos \
|
|
58
|
+
--gateway-auth-server-url https://auth.example.com/sqlos/auth \
|
|
59
|
+
--gateway-client-id todo-mcp-local \
|
|
60
|
+
--gateway-resource https://api.example.com/todos \
|
|
61
|
+
--gateway-scopes "openid profile email offline_access todos.read todos.write"
|
|
28
62
|
```
|
|
29
63
|
|
|
30
64
|
## Installation
|
|
31
65
|
|
|
32
|
-
|
|
66
|
+
Use it directly with `npx` or install globally:
|
|
33
67
|
|
|
34
68
|
```bash
|
|
35
69
|
npm install -g @emcy/openapi-to-mcp
|
|
@@ -39,169 +73,188 @@ npm install -g @emcy/openapi-to-mcp
|
|
|
39
73
|
|
|
40
74
|
### `generate`
|
|
41
75
|
|
|
42
|
-
Generate an MCP server from an OpenAPI specification.
|
|
43
|
-
|
|
44
76
|
```bash
|
|
45
77
|
npx @emcy/openapi-to-mcp generate [options]
|
|
46
78
|
```
|
|
47
79
|
|
|
48
|
-
**Options:**
|
|
49
|
-
|
|
50
80
|
| Option | Short | Description |
|
|
51
|
-
|
|
52
|
-
| `--url` | `-u` | URL or file path to OpenAPI
|
|
53
|
-
| `--name` | `-n` | Name for the generated
|
|
54
|
-
| `--output` | `-o` | Output directory
|
|
55
|
-
| `--
|
|
56
|
-
| `--
|
|
57
|
-
| `--
|
|
58
|
-
| `--
|
|
81
|
+
| --- | --- | --- |
|
|
82
|
+
| `--url` | `-u` | URL or file path to OpenAPI spec |
|
|
83
|
+
| `--name` | `-n` | Name for the generated server |
|
|
84
|
+
| `--output` | `-o` | Output directory |
|
|
85
|
+
| `--base-url` | `-b` | Override the upstream API base URL |
|
|
86
|
+
| `--version` | | Runtime version string |
|
|
87
|
+
| `--emcy` | `-e` | Include `@emcy/sdk` telemetry |
|
|
88
|
+
| `--local-sdk` | | Use a local `@emcy/sdk` path |
|
|
89
|
+
| `--prompts-json` | | JSON array of MCP prompt definitions |
|
|
90
|
+
| `--tool-instructions-json` | | JSON object keyed by tool key for tool-specific AI guidance |
|
|
91
|
+
| `--mode` | | Low-level runtime mode. Most users should only pass `standalone-no-auth` or `standalone-headers` directly |
|
|
92
|
+
| `--use-emcy-gateway` | | Generate a server preconfigured to use Emcy Gateway as the public MCP/OAuth edge |
|
|
93
|
+
| `--header` | | Repeatable `Header-Name=ENV_VAR` mapping for upstream requests |
|
|
94
|
+
| `--gateway-provider` | | Emcy Gateway OAuth provider recipe label |
|
|
95
|
+
| `--gateway-auth-server-url` | | Downstream authorization server issuer or metadata base URL |
|
|
96
|
+
| `--gateway-client-id` | | Downstream client ID Emcy should use |
|
|
97
|
+
| `--gateway-resource` | | Downstream API resource / audience |
|
|
98
|
+
| `--gateway-scopes` | | Comma or space separated downstream scopes |
|
|
99
|
+
| `--force` | `-f` | Overwrite the output directory |
|
|
59
100
|
|
|
60
101
|
### `validate`
|
|
61
102
|
|
|
62
|
-
Validate an OpenAPI specification.
|
|
63
|
-
|
|
64
103
|
```bash
|
|
65
104
|
npx @emcy/openapi-to-mcp validate --url https://api.example.com/openapi.json
|
|
66
105
|
```
|
|
67
106
|
|
|
68
|
-
##
|
|
107
|
+
## Server Modes
|
|
69
108
|
|
|
70
|
-
|
|
109
|
+
### `standalone_no_auth`
|
|
71
110
|
|
|
72
|
-
|
|
73
|
-
- **HTTP transport** - For Cursor and web-based clients
|
|
74
|
-
- **Stdio transport** - For Claude Desktop
|
|
75
|
-
- **Security support** - API keys, Bearer tokens, OAuth2
|
|
76
|
-
- **Environment-based config** - `.env.example` with all settings
|
|
77
|
-
- **README** - Usage instructions
|
|
78
|
-
|
|
79
|
-
### Running the Generated Server
|
|
111
|
+
Use this when the upstream API is public or already reachable without adding credentials from the MCP runtime.
|
|
80
112
|
|
|
81
113
|
```bash
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
# For Cursor/HTTP clients
|
|
87
|
-
npm run start:http
|
|
88
|
-
|
|
89
|
-
# For Claude Desktop/stdio
|
|
90
|
-
npm start
|
|
114
|
+
npx @emcy/openapi-to-mcp generate \
|
|
115
|
+
--url ./openapi.json \
|
|
116
|
+
--mode standalone-no-auth
|
|
91
117
|
```
|
|
92
118
|
|
|
93
|
-
###
|
|
119
|
+
### `standalone_headers`
|
|
94
120
|
|
|
95
|
-
|
|
121
|
+
Use this when every upstream request needs static headers.
|
|
96
122
|
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
}
|
|
123
|
+
```bash
|
|
124
|
+
npx @emcy/openapi-to-mcp generate \
|
|
125
|
+
--url ./openapi.json \
|
|
126
|
+
--mode standalone-headers \
|
|
127
|
+
--header X-API-Key=UPSTREAM_API_KEY \
|
|
128
|
+
--header X-Tenant-Id=UPSTREAM_TENANT_ID
|
|
105
129
|
```
|
|
106
130
|
|
|
107
|
-
|
|
131
|
+
If your upstream API needs `Authorization: Bearer ...`, either:
|
|
108
132
|
|
|
109
|
-
|
|
133
|
+
- model it as a bearer security scheme in the OpenAPI document, or
|
|
134
|
+
- pass the full header value through an env var:
|
|
110
135
|
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
"args": ["/path/to/my-api-mcp-server/build/index.js"]
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
136
|
+
```bash
|
|
137
|
+
npx @emcy/openapi-to-mcp generate \
|
|
138
|
+
--url ./openapi.json \
|
|
139
|
+
--mode standalone-headers \
|
|
140
|
+
--header Authorization=UPSTREAM_AUTHORIZATION
|
|
120
141
|
```
|
|
121
142
|
|
|
122
|
-
|
|
143
|
+
Then set:
|
|
123
144
|
|
|
124
|
-
|
|
145
|
+
```bash
|
|
146
|
+
UPSTREAM_AUTHORIZATION=Bearer eyJ...
|
|
147
|
+
```
|
|
125
148
|
|
|
126
|
-
|
|
127
|
-
- **Error monitoring** - Failures are captured with context
|
|
128
|
-
- **Performance metrics** - Latency and success rates
|
|
129
|
-
- **Dashboard** - View analytics at [emcy.ai](https://emcy.ai)
|
|
149
|
+
## Using Emcy Gateway
|
|
130
150
|
|
|
131
|
-
|
|
151
|
+
Use this when the upstream API is protected by OAuth and you want Emcy Gateway to own the public MCP URL, OAuth flow, and client-facing discovery.
|
|
132
152
|
|
|
133
153
|
```bash
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
154
|
+
npx @emcy/openapi-to-mcp generate \
|
|
155
|
+
--url ./openapi.json \
|
|
156
|
+
--use-emcy-gateway \
|
|
157
|
+
--gateway-provider sqlos \
|
|
158
|
+
--gateway-auth-server-url https://auth.example.com/sqlos/auth \
|
|
159
|
+
--gateway-client-id todo-mcp-local \
|
|
160
|
+
--gateway-resource https://api.example.com/todos \
|
|
161
|
+
--gateway-scopes "openid profile email offline_access todos.read todos.write"
|
|
137
162
|
```
|
|
138
163
|
|
|
139
|
-
|
|
164
|
+
This is the right mode for apps protected by systems like:
|
|
140
165
|
|
|
141
|
-
|
|
166
|
+
- Auth0
|
|
167
|
+
- WorkOS AuthKit
|
|
168
|
+
- SqlOS AuthServer/AuthPage
|
|
169
|
+
- Entra
|
|
170
|
+
- generic OAuth/OIDC authorization servers
|
|
142
171
|
|
|
143
|
-
|
|
144
|
-
import { parseOpenAPI, mapToMcpTools, generateMcpServer } from '@emcy/openapi-to-mcp';
|
|
172
|
+
Legacy compatibility:
|
|
145
173
|
|
|
146
|
-
|
|
147
|
-
const parsed = await parseOpenAPI('https://api.example.com/openapi.json');
|
|
174
|
+
- older `--mode emcy-gateway-worker` invocations still parse, but `--use-emcy-gateway` is the supported interface
|
|
148
175
|
|
|
149
|
-
|
|
150
|
-
const tools = mapToMcpTools(parsed.endpoints);
|
|
176
|
+
Typical usage:
|
|
151
177
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
name: 'my-api',
|
|
155
|
-
version: '1.0.0',
|
|
156
|
-
baseUrl: 'https://api.example.com',
|
|
157
|
-
emcyEnabled: true,
|
|
158
|
-
}, parsed.securitySchemes);
|
|
178
|
+
1. generate a normal MCP server
|
|
179
|
+
2. add `--use-emcy-gateway` when you want Emcy Gateway to become the public edge for that server
|
|
159
180
|
|
|
160
|
-
|
|
161
|
-
```
|
|
181
|
+
## Generated Server
|
|
162
182
|
|
|
163
|
-
|
|
183
|
+
Every generated server includes:
|
|
164
184
|
|
|
165
|
-
-
|
|
166
|
-
-
|
|
167
|
-
-
|
|
168
|
-
-
|
|
169
|
-
-
|
|
170
|
-
- ✅ OAuth2 (client credentials)
|
|
171
|
-
- ✅ Multiple security schemes
|
|
172
|
-
- ⏳ File uploads (coming soon)
|
|
173
|
-
- ⏳ Webhooks (coming soon)
|
|
185
|
+
- TypeScript source
|
|
186
|
+
- MCP tool bindings for the selected OpenAPI operations
|
|
187
|
+
- Streamable HTTP transport
|
|
188
|
+
- `.env.example`
|
|
189
|
+
- generated README
|
|
174
190
|
|
|
175
|
-
|
|
191
|
+
Standalone modes also support stdio for desktop clients.
|
|
176
192
|
|
|
177
|
-
|
|
193
|
+
## Programmatic Usage
|
|
178
194
|
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
--url https://petstore.swagger.io/v2/swagger.json \
|
|
182
|
-
--name petstore
|
|
183
|
-
```
|
|
195
|
+
```ts
|
|
196
|
+
import { parseOpenAPI, mapToMcpTools, generateMcpServer } from "@emcy/openapi-to-mcp";
|
|
184
197
|
|
|
185
|
-
|
|
198
|
+
const parsed = await parseOpenAPI("https://api.example.com/openapi.json");
|
|
199
|
+
const tools = mapToMcpTools(parsed.endpoints);
|
|
186
200
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
201
|
+
const files = generateMcpServer(
|
|
202
|
+
tools,
|
|
203
|
+
{
|
|
204
|
+
name: "my-api",
|
|
205
|
+
version: "1.0.0",
|
|
206
|
+
baseUrl: "https://api.example.com",
|
|
207
|
+
runtimeMode: "standalone_headers",
|
|
208
|
+
upstreamHeaders: [
|
|
209
|
+
{ name: "X-API-Key", envVar: "UPSTREAM_API_KEY" },
|
|
210
|
+
],
|
|
211
|
+
},
|
|
212
|
+
parsed.securitySchemes
|
|
213
|
+
);
|
|
192
214
|
```
|
|
193
215
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
216
|
+
Gateway-backed generation:
|
|
217
|
+
|
|
218
|
+
```ts
|
|
219
|
+
const files = generateMcpServer(
|
|
220
|
+
tools,
|
|
221
|
+
{
|
|
222
|
+
name: "my-api",
|
|
223
|
+
version: "1.0.0",
|
|
224
|
+
baseUrl: "https://api.example.com",
|
|
225
|
+
gatewayIntegration: {
|
|
226
|
+
provider: "emcy",
|
|
227
|
+
oauth: {
|
|
228
|
+
provider: "sqlos",
|
|
229
|
+
authorizationServerUrl: "https://auth.example.com/sqlos/auth",
|
|
230
|
+
clientId: "todo-mcp-local",
|
|
231
|
+
resource: "https://api.example.com/todos",
|
|
232
|
+
scopes: ["openid", "profile", "todos.read", "todos.write"],
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
parsed.securitySchemes
|
|
237
|
+
);
|
|
202
238
|
```
|
|
203
239
|
|
|
240
|
+
## What this package does not do
|
|
241
|
+
|
|
242
|
+
- It does not host a public OAuth authorization server for MCP clients.
|
|
243
|
+
- It does not support forwarding end-user bearer tokens from the MCP client to the upstream API.
|
|
244
|
+
- It does not try to replace Emcy Host or Emcy Gateway for OAuth-protected apps.
|
|
245
|
+
|
|
246
|
+
## Emcy
|
|
247
|
+
|
|
248
|
+
Use Emcy when you want to turn an OAuth-protected API into:
|
|
249
|
+
|
|
250
|
+
- a hosted runtime behind Emcy Host
|
|
251
|
+
- a gateway-managed public MCP/OAuth surface
|
|
252
|
+
- an embedded agent
|
|
253
|
+
- a workspace integration
|
|
254
|
+
- an external client surface for tools like VS Code or Claude
|
|
255
|
+
|
|
256
|
+
The open-source generator handles the runtime. Emcy Host runs it. Emcy Gateway handles the public auth and orchestration layer.
|
|
257
|
+
|
|
204
258
|
## License
|
|
205
259
|
|
|
206
260
|
MIT © [Emcy](https://emcy.ai)
|
|
207
|
-
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-config.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/cli-config.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { normalizeRuntimeMode, parseEmcyGatewayIntegration, parseGatewayOauthConfig, parseGeneratorCliConfig, parseToolInstructions, } from "../cli-config.js";
|
|
3
|
+
describe("cli-config", () => {
|
|
4
|
+
it("normalizes supported runtime modes", () => {
|
|
5
|
+
expect(normalizeRuntimeMode("standalone-no-auth")).toBe("standalone_no_auth");
|
|
6
|
+
expect(normalizeRuntimeMode("standalone_headers")).toBe("standalone_headers");
|
|
7
|
+
expect(normalizeRuntimeMode("emcy-gateway-worker")).toBe("emcy_gateway_worker");
|
|
8
|
+
});
|
|
9
|
+
it("parses gateway oauth config from explicit flags", () => {
|
|
10
|
+
const config = parseGatewayOauthConfig({
|
|
11
|
+
"gateway-provider": "auth0",
|
|
12
|
+
"gateway-auth-server-url": "https://auth.example.com",
|
|
13
|
+
"gateway-client-id": "client_123",
|
|
14
|
+
"gateway-resource": "https://api.example.com",
|
|
15
|
+
"gateway-scopes": "openid profile email offline_access todos.read",
|
|
16
|
+
});
|
|
17
|
+
expect(config).toEqual({
|
|
18
|
+
provider: "auth0",
|
|
19
|
+
authorizationServerUrl: "https://auth.example.com",
|
|
20
|
+
clientId: "client_123",
|
|
21
|
+
resource: "https://api.example.com",
|
|
22
|
+
scopes: ["openid", "profile", "email", "offline_access", "todos.read"],
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
it("parses tool instructions json objects", () => {
|
|
26
|
+
expect(parseToolInstructions(JSON.stringify({
|
|
27
|
+
get_api_todos: {
|
|
28
|
+
customInstructions: "Use this for current todos only.",
|
|
29
|
+
},
|
|
30
|
+
}))).toEqual({
|
|
31
|
+
get_api_todos: {
|
|
32
|
+
customInstructions: "Use this for current todos only.",
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
it("builds generator CLI config for gateway workers", () => {
|
|
37
|
+
const parsed = parseGeneratorCliConfig({
|
|
38
|
+
"use-emcy-gateway": true,
|
|
39
|
+
"prompts-json": JSON.stringify([
|
|
40
|
+
{
|
|
41
|
+
name: "todo-summary",
|
|
42
|
+
description: "Summarize todos",
|
|
43
|
+
content: "Summarize {{topic}}",
|
|
44
|
+
},
|
|
45
|
+
]),
|
|
46
|
+
"tool-instructions-json": JSON.stringify({
|
|
47
|
+
get_api_todos: {
|
|
48
|
+
whenToUse: "When the user asks to list todos.",
|
|
49
|
+
},
|
|
50
|
+
}),
|
|
51
|
+
"gateway-provider": "sqlos",
|
|
52
|
+
"gateway-auth-server-url": "https://auth.example.com/sqlos/auth",
|
|
53
|
+
"gateway-client-id": "todo-mcp-local",
|
|
54
|
+
"gateway-resource": "https://api.example.com/todos",
|
|
55
|
+
"gateway-scopes": "openid profile todos.read todos.write",
|
|
56
|
+
});
|
|
57
|
+
expect(parsed.runtimeMode).toBe("emcy_gateway_worker");
|
|
58
|
+
expect(parsed.prompts).toHaveLength(1);
|
|
59
|
+
expect(parsed.toolInstructions).toEqual({
|
|
60
|
+
get_api_todos: {
|
|
61
|
+
whenToUse: "When the user asks to list todos.",
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
expect(parsed.gatewayOauthConfig).toEqual({
|
|
65
|
+
provider: "sqlos",
|
|
66
|
+
authorizationServerUrl: "https://auth.example.com/sqlos/auth",
|
|
67
|
+
clientId: "todo-mcp-local",
|
|
68
|
+
resource: "https://api.example.com/todos",
|
|
69
|
+
scopes: ["openid", "profile", "todos.read", "todos.write"],
|
|
70
|
+
});
|
|
71
|
+
expect(parsed.gatewayIntegration).toEqual({
|
|
72
|
+
provider: "emcy",
|
|
73
|
+
oauth: {
|
|
74
|
+
provider: "sqlos",
|
|
75
|
+
authorizationServerUrl: "https://auth.example.com/sqlos/auth",
|
|
76
|
+
clientId: "todo-mcp-local",
|
|
77
|
+
resource: "https://api.example.com/todos",
|
|
78
|
+
scopes: ["openid", "profile", "todos.read", "todos.write"],
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
it("parses emcy gateway integration from legacy runtime mode", () => {
|
|
83
|
+
const integration = parseEmcyGatewayIntegration({
|
|
84
|
+
mode: "emcy-gateway-worker",
|
|
85
|
+
"gateway-auth-server-url": "https://auth.example.com",
|
|
86
|
+
});
|
|
87
|
+
expect(integration).toEqual({
|
|
88
|
+
provider: "emcy",
|
|
89
|
+
oauth: {
|
|
90
|
+
authorizationServerUrl: "https://auth.example.com",
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
//# sourceMappingURL=cli-config.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-config.test.js","sourceRoot":"","sources":["../../src/__tests__/cli-config.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,oBAAoB,EACpB,2BAA2B,EAC3B,uBAAuB,EACvB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAE1B,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,CAAC,oBAAoB,CAAC,oBAAoB,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAC9E,MAAM,CAAC,oBAAoB,CAAC,oBAAoB,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAC9E,MAAM,CAAC,oBAAoB,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAClF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,MAAM,GAAG,uBAAuB,CAAC;YACrC,kBAAkB,EAAE,OAAO;YAC3B,yBAAyB,EAAE,0BAA0B;YACrD,mBAAmB,EAAE,YAAY;YACjC,kBAAkB,EAAE,yBAAyB;YAC7C,gBAAgB,EAAE,gDAAgD;SACnE,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,QAAQ,EAAE,OAAO;YACjB,sBAAsB,EAAE,0BAA0B;YAClD,QAAQ,EAAE,YAAY;YACtB,QAAQ,EAAE,yBAAyB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