@apexmcp/cli 0.1.1

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) 2024 ApexMCP
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,302 @@
1
+ # @apexmcp/cli
2
+
3
+ [![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=flat&logo=typescript)](https://www.typescriptlang.org/)
4
+ [![Node.js](https://img.shields.io/badge/Node.js-339933?style=flat&logo=node.js)](https://nodejs.org/)
5
+
6
+ CLI tool for deploying MCP servers to ApexMCP.
7
+
8
+ ## โœจ Features
9
+
10
+ - **Simple Deployment**: Deploy MCP servers with a single command
11
+ - **Flexible Configuration**: Support for environment files, custom domains, and URL strategies
12
+ - **Deployment Management**: View, update, and delete deployments from the CLI
13
+ - **Authentication Management**: Login/logout with persistent token storage
14
+ - **MCP Server Management**: Enable/disable and configure MCP servers from the catalog
15
+ - **Plugin & Secret Management**: Manage secrets and configurations for MCP servers
16
+ - **MCP Interactions**: List and call tools, read resources directly from the CLI
17
+ - **Configuration Management**: Persistent CLI settings and preferences
18
+ - **Cross-platform**: Works on any platform with Node.js
19
+
20
+ ## ๐Ÿš€ Installation
21
+
22
+ ### Global Installation (Recommended)
23
+
24
+ ```bash
25
+ npm install -g @apexmcp/cli
26
+ # or
27
+ yarn global add @apexmcp/cli
28
+ # or
29
+ pnpm add -g @apexmcp/cli
30
+ ```
31
+
32
+ ### npx (One-time usage)
33
+
34
+ ```bash
35
+ npx @apexmcp/cli deploy ./my-mcp-server
36
+ ```
37
+
38
+ ### Local Development
39
+
40
+ ```bash
41
+ git clone <repo>
42
+ cd deploy-cli
43
+ bun install
44
+ bun run build
45
+ bun run cli --help
46
+ ```
47
+
48
+ ## ๐Ÿงช Usage
49
+
50
+ ### Deploy an MCP Server
51
+
52
+ ```bash
53
+ # Basic deployment
54
+ apexmcp deploy ./my-mcp-server
55
+
56
+ # With custom project name
57
+ apexmcp deploy ./my-mcp-server --project-name "My Custom MCP"
58
+
59
+ # With environment variables
60
+ apexmcp deploy ./my-mcp-server --env-file .env.production
61
+
62
+ # With custom domain and authentication
63
+ apexmcp deploy ./my-mcp-server --domain my-custom-domain.com --token your-auth-token
64
+
65
+ # Full example
66
+ apexmcp deploy ./my-mcp-server \
67
+ --project-name "My MCP Server" \
68
+ --env-file .env \
69
+ --url-strategy readable \
70
+ --endpoint https://deploy.apexmcp.dev \
71
+ --token eyJhbGciOiJIUzI1NiIs...
72
+ ```
73
+
74
+ ### Deployment Command Options
75
+
76
+ | Option | Description | Default |
77
+ | --------------------------- | --------------------------------------------------------------------------- | --------------------------- |
78
+ | `--project-name <name>` | Display name for the deployment | Derived from directory name |
79
+ | `--env-file <file>` | Environment variables file | None |
80
+ | `--domain <domain>` | Custom domain for deployment | None |
81
+ | `--url-strategy <strategy>` | URL generation strategy (`readable`, `obscure`, `timestamp-only`, `random`) | `readable` |
82
+ | `--endpoint <url>` | Deploy service endpoint | Configured endpoint |
83
+ | `--token <token>` | Authentication token | Configured token |
84
+
85
+ ### Authentication Commands
86
+
87
+ ```bash
88
+ # Login with token
89
+ apexmcp login --token your-jwt-token
90
+
91
+ # Login with email/password (if supported)
92
+ apexmcp login --email user@example.com --password yourpassword
93
+
94
+ # Logout and clear credentials
95
+ apexmcp logout
96
+
97
+ # Show current authentication status
98
+ apexmcp whoami
99
+ ```
100
+
101
+ ### MCP Server Management
102
+
103
+ ```bash
104
+ # List all available MCP servers
105
+ apexmcp servers
106
+
107
+ # List enabled MCP servers for your organization
108
+ apexmcp servers:enabled
109
+
110
+ # Enable an MCP server
111
+ apexmcp servers:enable <catalog-id>
112
+
113
+ # Disable an MCP server
114
+ apexmcp servers:disable <catalog-id>
115
+
116
+ # Get detailed info about an MCP server
117
+ apexmcp servers:info <catalog-id>
118
+ ```
119
+
120
+ ### Deployment Management
121
+
122
+ ```bash
123
+ # List all deployments
124
+ apexmcp list
125
+
126
+ # Get detailed status of a specific deployment
127
+ apexmcp status <deployment-name>
128
+
129
+ # Update deployment properties
130
+ apexmcp update <deployment-name> --name "New Name"
131
+ apexmcp update <deployment-name> --domain "new-domain.com"
132
+ apexmcp update <deployment-name> --env-file .env.production
133
+
134
+ # Delete a deployment (with confirmation)
135
+ apexmcp delete <deployment-name>
136
+
137
+ # Force delete without confirmation
138
+ apexmcp delete <deployment-name> --force
139
+ ```
140
+
141
+ #### Deletion Process
142
+
143
+ When you delete a deployment, ApexMCP will:
144
+
145
+ 1. **Mark as deleted** in the ApexMCP database (status = 'deleted')
146
+ 2. **Delete the Deno deployment** from Deno Deploy
147
+ 3. **Remove DNS records** from Cloudflare
148
+ 4. **Clear external references** (project_id, URLs)
149
+
150
+ The CLI simply calls the `/api/deployments/:name` DELETE endpoint, and the API handles all cleanup operations.
151
+
152
+ ### Plugin & Secret Management
153
+
154
+ ```bash
155
+ # List secrets for an MCP server
156
+ apexmcp secrets <catalog-id>
157
+
158
+ # Set a secret for an MCP server
159
+ apexmcp secrets:set <catalog-id> <secret-key> <secret-value>
160
+
161
+ # Delete a secret for an MCP server
162
+ apexmcp secrets:delete <catalog-id> <secret-key>
163
+
164
+ # Delete entire plugin configuration
165
+ apexmcp plugins:delete <catalog-id>
166
+ ```
167
+
168
+ ### MCP Interactions
169
+
170
+ ```bash
171
+ # List available tools
172
+ apexmcp tools
173
+
174
+ # Call a tool with parameters
175
+ apexmcp tools:call <tool-name> '{"param1": "value1", "param2": "value2"}'
176
+
177
+ # List available resources
178
+ apexmcp resources
179
+
180
+ # Read a specific resource
181
+ apexmcp resources:read <resource-uri>
182
+
183
+ # List resource templates
184
+ apexmcp resources:templates
185
+ ```
186
+
187
+ ### Configuration Management
188
+
189
+ ```bash
190
+ # Show current configuration
191
+ apexmcp config get
192
+
193
+ # Set configuration values
194
+ apexmcp config set endpoints.core https://api.apexmcp.dev
195
+ apexmcp config set endpoints.deploy https://deploy.apexmcp.dev
196
+ apexmcp config set preferences.json true
197
+
198
+ # Reset configuration to defaults
199
+ apexmcp config reset
200
+ ```
201
+
202
+ ### URL Strategies
203
+
204
+ - **`readable`** (default): Project name + date + random suffix (e.g., `my-project-241219ab.org-123.apexmcp.dev`)
205
+ - **`obscure`**: Date + random characters only (e.g., `241219abcd.org-123.apexmcp.dev`)
206
+ - **`timestamp-only`**: Clean date/time format (e.g., `2412191435.org-123.apexmcp.dev`)
207
+ - **`random`**: Pure random characters (e.g., `a8b3c9d2ef.org-123.apexmcp.dev`)
208
+
209
+ ## ๐Ÿ“ Project Structure
210
+
211
+ Your MCP server project should have an entry point file. Configuration files are optional but recommended.
212
+
213
+ ### Minimal Project Structure
214
+
215
+ ```
216
+ my-mcp-server/
217
+ โ”œโ”€โ”€ main.ts # Entry point (or index.ts, server.ts, app.ts)
218
+ โ””โ”€โ”€ [other files...] # Additional source files
219
+ ```
220
+
221
+ ### Recommended Project Structure
222
+
223
+ ```
224
+ my-mcp-server/
225
+ โ”œโ”€โ”€ deno.json # Optional: Deno configuration
226
+ โ”œโ”€โ”€ package.json # Optional: Node.js configuration
227
+ โ”œโ”€โ”€ main.ts # Entry point
228
+ โ”œโ”€โ”€ README.md # Documentation
229
+ โ””โ”€โ”€ [other files...] # Additional source files
230
+ ```
231
+
232
+ ### Entry Point Detection
233
+
234
+ The CLI automatically detects entry points in this order:
235
+
236
+ 1. **Configuration files** (if present):
237
+ - `deno.json` / `deno.jsonc`: `main` or `entryPoint` field
238
+ - `package.json`: `main`, `module`, or `exports["."]` field
239
+
240
+ 2. **Common filenames** (fallback):
241
+ - `main.ts`, `main.js`
242
+ - `index.ts`, `index.js`
243
+ - `server.ts`, `server.js`
244
+ - `app.ts`, `app.js`
245
+
246
+ ### Configuration Examples
247
+
248
+ **deno.json:**
249
+ ```json
250
+ {
251
+ "main": "main.ts",
252
+ "name": "my-mcp-server",
253
+ "version": "1.0.0"
254
+ }
255
+ ```
256
+
257
+ **package.json:**
258
+ ```json
259
+ {
260
+ "name": "my-mcp-server",
261
+ "version": "1.0.0",
262
+ "main": "server.js"
263
+ }
264
+ ```
265
+
266
+ **deno.jsonc:**
267
+ ```jsonc
268
+ {
269
+ "main": "main.ts",
270
+ "name": "my-mcp-server"
271
+ }
272
+ ```
273
+
274
+ ### Supported Files
275
+
276
+ The CLI includes **all project files** in deployments, letting the deploy service decide what's acceptable. This includes:
277
+
278
+ - **Source files**: `.ts`, `.js`, `.mjs`, `.cjs`, HTML, CSS, etc.
279
+ - **Configuration files**: `deno.json`, `package.json`, `tsconfig.json`, etc.
280
+ - **Documentation**: `README.md`, `LICENSE`, `CHANGELOG.md`
281
+ - **Package files**: Lock files, manifest files, etc.
282
+ - **Assets**: Images, fonts, and other web assets
283
+ - **Build outputs**: Generated files from build processes
284
+
285
+ **Excluded files:** Temporary files, OS-specific files (`.DS_Store`, `Thumbs.db`), and development artifacts.
286
+
287
+ **Note:** The deploy service validates all files and may reject certain types or enforce size limits with clear error messages.
288
+
289
+ ## ๐Ÿ” Authentication
290
+
291
+ Get your authentication token from the ApexMCP dashboard or your deployment service administrator.
292
+
293
+ ## ๐Ÿ“ Scripts
294
+
295
+ - `bun run build` - Build the CLI with tsup
296
+ - `bun run cli` - Run the CLI locally
297
+ - `bun run dev` - Build with watch mode
298
+ - `bun test` - Run tests
299
+
300
+ ---
301
+
302
+ Built with Commander.js. MIT License.
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/utils/load-env-file.ts
4
+ import { readFileSync } from "fs";
5
+ async function loadEnvFile(envFile) {
6
+ try {
7
+ const content = readFileSync(envFile, "utf-8");
8
+ const envVars = {};
9
+ for (const line of content.split("\n")) {
10
+ const trimmed = line.trim();
11
+ if (trimmed && !trimmed.startsWith("#")) {
12
+ const [key, ...valueParts] = trimmed.split("=");
13
+ if (key && valueParts.length > 0) {
14
+ envVars[key.trim()] = valueParts.join("=").trim();
15
+ }
16
+ }
17
+ }
18
+ return envVars;
19
+ } catch (error) {
20
+ throw new Error(
21
+ `Failed to load env file ${envFile}: ${error instanceof Error ? error.message : String(error)}`
22
+ );
23
+ }
24
+ }
25
+
26
+ export {
27
+ loadEnvFile
28
+ };
29
+ //# sourceMappingURL=chunk-BWPU5TUK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/load-env-file.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\n\nexport async function loadEnvFile(\n envFile: string\n): Promise<Record<string, string>> {\n try {\n const content = readFileSync(envFile, 'utf-8');\n const envVars: Record<string, string> = {};\n\n for (const line of content.split('\\n')) {\n const trimmed = line.trim();\n if (trimmed && !trimmed.startsWith('#')) {\n const [key, ...valueParts] = trimmed.split('=');\n if (key && valueParts.length > 0) {\n envVars[key.trim()] = valueParts.join('=').trim();\n }\n }\n }\n\n return envVars;\n } catch (error) {\n throw new Error(\n `Failed to load env file ${envFile}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n}\n"],"mappings":";;;AAAA,SAAS,oBAAoB;AAE7B,eAAsB,YACpB,SACiC;AACjC,MAAI;AACF,UAAM,UAAU,aAAa,SAAS,OAAO;AAC7C,UAAM,UAAkC,CAAC;AAEzC,eAAW,QAAQ,QAAQ,MAAM,IAAI,GAAG;AACtC,YAAM,UAAU,KAAK,KAAK;AAC1B,UAAI,WAAW,CAAC,QAAQ,WAAW,GAAG,GAAG;AACvC,cAAM,CAAC,KAAK,GAAG,UAAU,IAAI,QAAQ,MAAM,GAAG;AAC9C,YAAI,OAAO,WAAW,SAAS,GAAG;AAChC,kBAAQ,IAAI,KAAK,CAAC,IAAI,WAAW,KAAK,GAAG,EAAE,KAAK;AAAA,QAClD;AAAA,MACF;AAAA,IACF;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,UAAM,IAAI;AAAA,MACR,2BAA2B,OAAO,KAAK,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,IAC/F;AAAA,EACF;AACF;","names":[]}