microcms-mcp-server 0.3.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 (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +368 -0
  3. package/bin/microcms-mcp-server.js +9 -0
  4. package/dist/cli.d.ts +4 -0
  5. package/dist/cli.d.ts.map +1 -0
  6. package/dist/cli.js +105 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/client.d.ts +42 -0
  9. package/dist/client.d.ts.map +1 -0
  10. package/dist/client.js +58 -0
  11. package/dist/client.js.map +1 -0
  12. package/dist/config.d.ts +6 -0
  13. package/dist/config.d.ts.map +1 -0
  14. package/dist/config.js +27 -0
  15. package/dist/config.js.map +1 -0
  16. package/dist/index.d.ts +3 -0
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js +118 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/tools/create-content.d.ts +7 -0
  21. package/dist/tools/create-content.d.ts.map +1 -0
  22. package/dist/tools/create-content.js +40 -0
  23. package/dist/tools/create-content.js.map +1 -0
  24. package/dist/tools/delete-content.d.ts +7 -0
  25. package/dist/tools/delete-content.d.ts.map +1 -0
  26. package/dist/tools/delete-content.js +28 -0
  27. package/dist/tools/delete-content.js.map +1 -0
  28. package/dist/tools/get-content.d.ts +5 -0
  29. package/dist/tools/get-content.d.ts.map +1 -0
  30. package/dist/tools/get-content.js +48 -0
  31. package/dist/tools/get-content.js.map +1 -0
  32. package/dist/tools/get-list.d.ts +5 -0
  33. package/dist/tools/get-list.d.ts.map +1 -0
  34. package/dist/tools/get-list.js +80 -0
  35. package/dist/tools/get-list.js.map +1 -0
  36. package/dist/tools/get-media.d.ts +5 -0
  37. package/dist/tools/get-media.d.ts.map +1 -0
  38. package/dist/tools/get-media.js +51 -0
  39. package/dist/tools/get-media.js.map +1 -0
  40. package/dist/tools/patch-content.d.ts +7 -0
  41. package/dist/tools/patch-content.d.ts.map +1 -0
  42. package/dist/tools/patch-content.js +41 -0
  43. package/dist/tools/patch-content.js.map +1 -0
  44. package/dist/tools/update-content.d.ts +7 -0
  45. package/dist/tools/update-content.d.ts.map +1 -0
  46. package/dist/tools/update-content.js +41 -0
  47. package/dist/tools/update-content.js.map +1 -0
  48. package/dist/tools/upload-media.d.ts +7 -0
  49. package/dist/tools/upload-media.d.ts.map +1 -0
  50. package/dist/tools/upload-media.js +70 -0
  51. package/dist/tools/upload-media.js.map +1 -0
  52. package/dist/types.d.ts +74 -0
  53. package/dist/types.d.ts.map +1 -0
  54. package/dist/types.js +2 -0
  55. package/dist/types.js.map +1 -0
  56. package/mcp-config-sample.json +13 -0
  57. package/package.json +68 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 microCMS MCP Server
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,368 @@
1
+ # microCMS MCP Server
2
+
3
+ A Model Context Protocol (MCP) server for microCMS API integration. This server enables AI assistants like Claude to interact with microCMS content management system.
4
+
5
+ ## Features
6
+
7
+ - **Content Management**: Full CRUD operations for microCMS list-type APIs
8
+ - **Eight Core Tools**:
9
+ - `microcms_get_list` - Retrieve content lists with filtering and pagination
10
+ - `microcms_get_content` - Get individual content items
11
+ - `microcms_create_content` - Create new content
12
+ - `microcms_update_content` - Update content (PUT)
13
+ - `microcms_patch_content` - Partially update content (PATCH)
14
+ - `microcms_delete_content` - Delete content
15
+ - `microcms_get_media` - Retrieve media files (Management API)
16
+ - `microcms_upload_media` - Upload media files (Management API)
17
+ - **Full API Support**: Supports all microCMS query parameters including drafts, filters, pagination, and depth expansion
18
+
19
+ ## Requirements
20
+
21
+ - Node.js 18.0.0 or higher
22
+ - microCMS account and API key
23
+
24
+ ## Installation
25
+
26
+ ### Method 1: Using npx (Recommended)
27
+
28
+ No installation required! Use directly with npx:
29
+
30
+ ```bash
31
+ npx microcms-mcp-server --service-id your-service-id --api-key your-api-key
32
+ ```
33
+
34
+ ### Method 2: Global Installation
35
+
36
+ ```bash
37
+ npm install -g microcms-mcp-server
38
+ microcms-mcp-server --service-id your-service-id --api-key your-api-key
39
+ ```
40
+
41
+ ### Method 3: Development Setup
42
+
43
+ 1. Clone this repository
44
+ 2. Install dependencies:
45
+ ```bash
46
+ npm install
47
+ ```
48
+
49
+ 3. Build the project:
50
+ ```bash
51
+ npm run build
52
+ ```
53
+
54
+ ## Configuration
55
+
56
+ You can configure microCMS credentials in two ways:
57
+
58
+ ### Method 1: Environment Variables
59
+
60
+ 1. Copy the environment template:
61
+ ```bash
62
+ cp .env.example .env
63
+ ```
64
+
65
+ 2. Configure your microCMS credentials in `.env`:
66
+ ```bash
67
+ MICROCMS_SERVICE_ID=your-service-id
68
+ MICROCMS_API_KEY=your-api-key
69
+ ```
70
+
71
+ ### Method 2: Command Line Arguments
72
+
73
+ Pass credentials directly as command line arguments:
74
+ ```bash
75
+ node dist/index.js --service-id your-service-id --api-key your-api-key
76
+ ```
77
+
78
+ **Note**: Command line arguments take precedence over environment variables.
79
+
80
+ ## Usage
81
+
82
+ ### Running the Server
83
+
84
+ Using environment variables:
85
+ ```bash
86
+ npm start
87
+ ```
88
+
89
+ Using command line arguments:
90
+ ```bash
91
+ npm run start:args
92
+ # or directly:
93
+ node dist/index.js --service-id your-service-id --api-key your-api-key
94
+ ```
95
+
96
+ ### Using with Claude Desktop
97
+
98
+ Add the following to your Claude Desktop MCP configuration file:
99
+
100
+ **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
101
+ **Windows**: `%APPDATA%/Claude/claude_desktop_config.json`
102
+
103
+ #### Option 1: Using npx (Recommended)
104
+ ```json
105
+ {
106
+ "mcpServers": {
107
+ "microcms": {
108
+ "command": "npx",
109
+ "args": [
110
+ "microcms-mcp-server",
111
+ "--service-id", "your-service-id",
112
+ "--api-key", "your-api-key"
113
+ ]
114
+ }
115
+ }
116
+ }
117
+ ```
118
+
119
+ #### Option 2: Using global installation
120
+ ```json
121
+ {
122
+ "mcpServers": {
123
+ "microcms": {
124
+ "command": "microcms-mcp-server",
125
+ "args": [
126
+ "--service-id", "your-service-id",
127
+ "--api-key", "your-api-key"
128
+ ]
129
+ }
130
+ }
131
+ }
132
+ ```
133
+
134
+ #### Option 3: Using local development setup
135
+ ```json
136
+ {
137
+ "mcpServers": {
138
+ "microcms": {
139
+ "command": "node",
140
+ "args": [
141
+ "/path/to/microcms-mcp-server/dist/index.js",
142
+ "--service-id", "your-service-id",
143
+ "--api-key", "your-api-key"
144
+ ]
145
+ }
146
+ }
147
+ }
148
+ ```
149
+
150
+ Replace:
151
+ - `your-service-id` with your microCMS service ID
152
+ - `your-api-key` with your microCMS API key
153
+ - `/path/to/microcms-mcp-server/` with the actual path (Option 3 only)
154
+
155
+ Restart Claude Desktop after updating the configuration.
156
+
157
+ ### Development Mode
158
+
159
+ ```bash
160
+ npm run dev
161
+ ```
162
+
163
+ ### Available Scripts
164
+
165
+ - `npm run build` - Build TypeScript to JavaScript
166
+ - `npm start` - Run the compiled server
167
+ - `npm run dev` - Development mode with auto-reload
168
+ - `npm run lint` - Run ESLint
169
+ - `npm run format` - Format code with Prettier
170
+
171
+ ## Tool Examples
172
+
173
+ ### Get Content List
174
+ ```json
175
+ {
176
+ "name": "microcms_get_list",
177
+ "arguments": {
178
+ "endpoint": "blogs",
179
+ "limit": 10,
180
+ "orders": "-publishedAt"
181
+ }
182
+ }
183
+ ```
184
+
185
+ ### Get Individual Content
186
+ ```json
187
+ {
188
+ "name": "microcms_get_content",
189
+ "arguments": {
190
+ "endpoint": "blogs",
191
+ "contentId": "article-1"
192
+ }
193
+ }
194
+ ```
195
+
196
+ ### Create New Content
197
+ ```json
198
+ {
199
+ "name": "microcms_create_content",
200
+ "arguments": {
201
+ "endpoint": "blogs",
202
+ "content": {
203
+ "title": "My Blog Post",
204
+ "body": "Content here...",
205
+ "category": "tech",
206
+ "thumbnail": "https://example.com/image.jpg"
207
+ }
208
+ }
209
+ }
210
+ ```
211
+
212
+ ### Update Content with Image
213
+ ```json
214
+ {
215
+ "name": "microcms_update_content",
216
+ "arguments": {
217
+ "endpoint": "blogs",
218
+ "contentId": "article-1",
219
+ "content": {
220
+ "title": "Updated Title",
221
+ "image": "https://example.com/new-image.jpg"
222
+ }
223
+ }
224
+ }
225
+ ```
226
+
227
+ ### Get Media Files
228
+ ```json
229
+ {
230
+ "name": "microcms_get_media",
231
+ "arguments": {
232
+ "limit": 20,
233
+ "imageOnly": true,
234
+ "fileName": "sample"
235
+ }
236
+ }
237
+ ```
238
+
239
+ ### Upload Media File (Base64)
240
+ ```json
241
+ {
242
+ "name": "microcms_upload_media",
243
+ "arguments": {
244
+ "fileData": "base64-encoded-file-data",
245
+ "fileName": "image.jpg",
246
+ "mimeType": "image/jpeg"
247
+ }
248
+ }
249
+ ```
250
+
251
+ ### Upload Media File (External URL)
252
+ ```json
253
+ {
254
+ "name": "microcms_upload_media",
255
+ "arguments": {
256
+ "externalUrl": "https://example.com/image.jpg"
257
+ }
258
+ }
259
+ ```
260
+
261
+ ## Field Type Specifications
262
+
263
+ When creating or updating content, different field types require specific formats:
264
+
265
+ ### Text Fields
266
+ ```json
267
+ "title": "Article Title"
268
+ ```
269
+
270
+ ### Rich Editor Fields
271
+ ```json
272
+ "body": "<h1>見出し</h1><p>このようにHTMLで入稿できます</p>"
273
+ ```
274
+
275
+ ### Image Fields
276
+ Must use URLs from the same microCMS service:
277
+ ```json
278
+ "thumbnail": "https://images.microcms-assets.io/assets/xxxxxxxx/yyyyyyyy/sample.png"
279
+ ```
280
+
281
+ ### Multiple Image Fields
282
+ ```json
283
+ "gallery": [
284
+ "https://images.microcms-assets.io/assets/xxxxxxxx/yyyyyyyy/sample1.png",
285
+ "https://images.microcms-assets.io/assets/xxxxxxxx/yyyyyyyy/sample2.png"
286
+ ]
287
+ ```
288
+
289
+ ### Date Fields
290
+ Use ISO 8601 format:
291
+ ```json
292
+ "publishedAt": "2020-04-23T14:32:38.163Z"
293
+ ```
294
+
295
+ ### Select Fields
296
+ ```json
297
+ "categories": ["カテゴリ1", "カテゴリ2"]
298
+ ```
299
+
300
+ ### Content Reference Fields
301
+ Single reference:
302
+ ```json
303
+ "relatedArticle": "article-id-123"
304
+ ```
305
+
306
+ Multiple references:
307
+ ```json
308
+ "relatedArticles": ["article-id-123", "article-id-456"]
309
+ ```
310
+
311
+ ### Complete Example
312
+ ```json
313
+ {
314
+ "name": "microcms_create_content",
315
+ "arguments": {
316
+ "endpoint": "blogs",
317
+ "content": {
318
+ "title": "My Blog Post",
319
+ "body": "<h2>Introduction</h2><p>This is a paragraph with <strong>bold text</strong>.</p>",
320
+ "thumbnail": "https://images.microcms-assets.io/assets/xxx/yyy/image.png",
321
+ "publishedAt": "2024-01-15T10:30:00.000Z",
322
+ "categories": ["tech", "tutorial"],
323
+ "relatedArticles": ["article-1", "article-2"]
324
+ }
325
+ }
326
+ }
327
+ ```
328
+
329
+ ## Media Management
330
+
331
+ ### Media Retrieval (`microcms_get_media`)
332
+ - **API Type**: Management API v2 (direct fetch)
333
+ - **Permissions**: Requires "media retrieval" permissions
334
+ - **Features**:
335
+ - Pagination with tokens (15-second validity)
336
+ - Filter by filename
337
+ - Image-only filtering
338
+ - Returns URLs, dimensions, and metadata
339
+
340
+ ### Media Upload (`microcms_upload_media`)
341
+ - **API Type**: Management API v1 (via JS SDK)
342
+ - **Permissions**: Requires "media upload" permissions
343
+ - **Upload Methods**:
344
+ 1. **File Data Upload**: Base64 encoded file data with filename and mimeType
345
+ 2. **External URL Upload**: Direct upload from external URL
346
+ - **Limitations**:
347
+ - File size: 5MB maximum
348
+ - One file per request
349
+ - Available on Team, Business, Advanced, Enterprise plans
350
+ - **Returns**: microCMS asset URLs
351
+ - Images: `https://images.microcms-assets.io/...`
352
+ - Files: `https://files.microcms-assets.io/...`
353
+
354
+ ## API Reference
355
+
356
+ All tools support the full range of microCMS API parameters. Content tools use the [Content API](https://document.microcms.io/content-api), while media tools use the [Management API](https://document.microcms.io/management-api).
357
+
358
+ ## Error Handling
359
+
360
+ The server provides detailed error messages for:
361
+ - Missing required environment variables
362
+ - Invalid API requests
363
+ - microCMS API errors
364
+ - Malformed tool parameters
365
+
366
+ ## License
367
+
368
+ MIT
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+
3
+ // CLI entry point for the package
4
+ import('../dist/cli.js').then(module => {
5
+ module.runCli();
6
+ }).catch(error => {
7
+ console.error('Failed to start microCMS MCP Server:', error.message);
8
+ process.exit(1);
9
+ });
package/dist/cli.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ export declare function showHelp(): void;
3
+ export declare function runCli(): Promise<void>;
4
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAMA,wBAAgB,QAAQ,SAyCvB;AAED,wBAAsB,MAAM,kBA0D3B"}
package/dist/cli.js ADDED
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env node
2
+ import { parseArgs } from 'node:util';
3
+ export function showHelp() {
4
+ console.log(`
5
+ microCMS MCP Server
6
+
7
+ A Model Context Protocol server for microCMS API integration.
8
+
9
+ Usage:
10
+ npx microcms-mcp-server [options]
11
+
12
+ Options:
13
+ --service-id <service-id> microCMS service ID (required)
14
+ --api-key <key> microCMS API key (required)
15
+ --help Show this help message
16
+ --version Show version information
17
+
18
+ Environment Variables:
19
+ MICROCMS_SERVICE_ID Service ID (fallback)
20
+ MICROCMS_API_KEY API key (fallback)
21
+
22
+ Examples:
23
+ npx microcms-mcp-server --service-id my-blog --api-key your-key
24
+
25
+ # Using environment variables
26
+ export MICROCMS_SERVICE_ID=my-blog
27
+ export MICROCMS_API_KEY=your-key
28
+ npx microcms-mcp-server
29
+
30
+ Claude Desktop Configuration:
31
+ {
32
+ "mcpServers": {
33
+ "microcms": {
34
+ "command": "npx",
35
+ "args": [
36
+ "microcms-mcp-server",
37
+ "--service-id", "your-service-id",
38
+ "--api-key", "your-api-key"
39
+ ]
40
+ }
41
+ }
42
+ }
43
+ `);
44
+ }
45
+ export async function runCli() {
46
+ try {
47
+ const { values, positionals } = parseArgs({
48
+ args: process.argv.slice(2),
49
+ options: {
50
+ 'service-id': {
51
+ type: 'string',
52
+ short: 's',
53
+ },
54
+ 'api-key': {
55
+ type: 'string',
56
+ short: 'k',
57
+ },
58
+ 'help': {
59
+ type: 'boolean',
60
+ short: 'h',
61
+ }
62
+ },
63
+ allowPositionals: true,
64
+ });
65
+ if (values.help) {
66
+ showHelp();
67
+ process.exit(0);
68
+ }
69
+ // 設定を環境変数に設定(既存のサーバーコードが使用するため)
70
+ if (values['service-id']) {
71
+ process.env.MICROCMS_SERVICE_ID = values['service-id'];
72
+ }
73
+ if (values['api-key']) {
74
+ process.env.MICROCMS_API_KEY = values['api-key'];
75
+ }
76
+ // 設定の検証
77
+ if (!process.env.MICROCMS_SERVICE_ID || !process.env.MICROCMS_API_KEY) {
78
+ console.error('Error: microCMS credentials are required.');
79
+ console.error('');
80
+ console.error('Provide them via:');
81
+ console.error(' --service-id <service-id> --api-key <key>');
82
+ console.error(' or environment variables MICROCMS_SERVICE_ID and MICROCMS_API_KEY');
83
+ console.error('');
84
+ console.error('Run with --help for more information.');
85
+ process.exit(1);
86
+ }
87
+ // サーバーを起動(既存のロジックを使用)
88
+ const { startServer } = await import('./index.js');
89
+ await startServer();
90
+ }
91
+ catch (error) {
92
+ if (error instanceof Error) {
93
+ console.error('Error:', error.message);
94
+ }
95
+ else {
96
+ console.error('Unknown error occurred');
97
+ }
98
+ process.exit(1);
99
+ }
100
+ }
101
+ // 直接実行された場合
102
+ if (import.meta.url === `file://${process.argv[1]}`) {
103
+ runCli();
104
+ }
105
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAItC,MAAM,UAAU,QAAQ;IACtB,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCb,CAAC,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,MAAM;IAC1B,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,SAAS,CAAC;YACxC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YAC3B,OAAO,EAAE;gBACP,YAAY,EAAE;oBACZ,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,GAAG;iBACX;gBACD,SAAS,EAAE;oBACT,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,GAAG;iBACX;gBACD,MAAM,EAAE;oBACN,IAAI,EAAE,SAAS;oBACf,KAAK,EAAE,GAAG;iBACX;aACF;YACD,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAA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CAAC;YACN,OAAO,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,YAAY;AACZ,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,UAAU,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACpD,MAAM,EAAE,CAAC;AACX,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { MicroCMSQueries } from 'microcms-js-sdk';
2
+ import type { MicroCMSContent, MicroCMSListResponse } from './types.js';
3
+ export declare const microCMSClient: {
4
+ get: <T = any>({ endpoint, contentId, queries, customRequestInit, }: import("microcms-js-sdk").GetRequest) => Promise<T>;
5
+ getList: <T_1 = any>({ endpoint, queries, customRequestInit, }: import("microcms-js-sdk").GetListRequest) => Promise<import("microcms-js-sdk").MicroCMSListResponse<T_1>>;
6
+ getListDetail: <T_2 = any>({ endpoint, contentId, queries, customRequestInit, }: import("microcms-js-sdk").GetListDetailRequest) => Promise<T_2 & import("microcms-js-sdk").MicroCMSContentId & import("microcms-js-sdk").MicroCMSDate>;
7
+ getObject: <T_3 = any>({ endpoint, queries, customRequestInit, }: import("microcms-js-sdk").GetObjectRequest) => Promise<T_3 & import("microcms-js-sdk").MicroCMSDate>;
8
+ getAllContentIds: ({ endpoint, alternateField, draftKey, filters, orders, customRequestInit, }: import("microcms-js-sdk").GetAllContentIdsRequest) => Promise<string[]>;
9
+ getAllContents: <T_4 = any>({ endpoint, queries, customRequestInit, }: import("microcms-js-sdk").GetAllContentRequest) => Promise<(T_4 & import("microcms-js-sdk").MicroCMSContentId & import("microcms-js-sdk").MicroCMSDate)[]>;
10
+ create: <T_5 extends Record<string | number, any>>({ endpoint, contentId, content, isDraft, customRequestInit, }: import("microcms-js-sdk").CreateRequest<T_5>) => Promise<import("microcms-js-sdk").WriteApiRequestResult>;
11
+ update: <T_6 extends Record<string | number, any>>({ endpoint, contentId, content, customRequestInit, }: import("microcms-js-sdk").UpdateRequest<T_6>) => Promise<import("microcms-js-sdk").WriteApiRequestResult>;
12
+ delete: ({ endpoint, contentId, customRequestInit, }: import("microcms-js-sdk").DeleteRequest) => Promise<void>;
13
+ };
14
+ export declare const microCMSManagementClient: {
15
+ uploadMedia: ({ data, name, type, customRequestHeaders, }: import("microcms-js-sdk").UploadMediaRequest) => Promise<{
16
+ url: string;
17
+ }>;
18
+ };
19
+ export declare const microCMSConfig: {
20
+ serviceDomain: string;
21
+ apiKey: string;
22
+ };
23
+ export declare function getList<T = MicroCMSContent>(endpoint: string, queries?: MicroCMSQueries): Promise<MicroCMSListResponse<T>>;
24
+ export declare function getListDetail<T = MicroCMSContent>(endpoint: string, contentId: string, queries?: MicroCMSQueries): Promise<T>;
25
+ export declare function create<T = MicroCMSContent>(endpoint: string, content: Omit<T, 'id' | 'createdAt' | 'updatedAt' | 'publishedAt' | 'revisedAt'>, options?: {
26
+ isDraft?: boolean;
27
+ contentId?: string;
28
+ }): Promise<{
29
+ id: string;
30
+ }>;
31
+ export declare function update<T = MicroCMSContent>(endpoint: string, contentId: string, content: Omit<T, 'id' | 'createdAt' | 'updatedAt' | 'publishedAt' | 'revisedAt'>, options?: {
32
+ isDraft?: boolean;
33
+ }): Promise<{
34
+ id: string;
35
+ }>;
36
+ export declare function patch<T = MicroCMSContent>(endpoint: string, contentId: string, content: Partial<Omit<T, 'id' | 'createdAt' | 'updatedAt' | 'publishedAt' | 'revisedAt'>>, options?: {
37
+ isDraft?: boolean;
38
+ }): Promise<{
39
+ id: string;
40
+ }>;
41
+ export declare function deleteContent(endpoint: string, contentId: string): Promise<void>;
42
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACxF,OAAO,KAAK,EAAE,eAAe,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EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,WAAW,GAAG,WAAW,GAAG,aAAa,GAAG,WAAW,CAAC,CAAC,EACzF,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9B,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAOzB;AAED,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAKf"}
package/dist/client.js ADDED
@@ -0,0 +1,58 @@
1
+ import { createClient, createManagementClient } from 'microcms-js-sdk';
2
+ import { parseConfig } from './config.js';
3
+ const config = parseConfig();
4
+ export const microCMSClient = createClient({
5
+ serviceDomain: config.serviceDomain,
6
+ apiKey: config.apiKey,
7
+ });
8
+ export const microCMSManagementClient = createManagementClient({
9
+ serviceDomain: config.serviceDomain,
10
+ apiKey: config.apiKey,
11
+ });
12
+ export const microCMSConfig = {
13
+ serviceDomain: config.serviceDomain,
14
+ apiKey: config.apiKey,
15
+ };
16
+ export async function getList(endpoint, queries) {
17
+ return await microCMSClient.getList({
18
+ endpoint,
19
+ queries,
20
+ });
21
+ }
22
+ export async function getListDetail(endpoint, contentId, queries) {
23
+ return await microCMSClient.getListDetail({
24
+ endpoint,
25
+ contentId,
26
+ queries,
27
+ });
28
+ }
29
+ export async function create(endpoint, content, options) {
30
+ return await microCMSClient.create({
31
+ endpoint,
32
+ content,
33
+ ...options,
34
+ });
35
+ }
36
+ export async function update(endpoint, contentId, content, options) {
37
+ return await microCMSClient.update({
38
+ endpoint,
39
+ contentId,
40
+ content,
41
+ ...options,
42
+ });
43
+ }
44
+ export async function patch(endpoint, contentId, content, options) {
45
+ return await microCMSClient.update({
46
+ endpoint,
47
+ contentId,
48
+ content,
49
+ ...options,
50
+ });
51
+ }
52
+ export async function deleteContent(endpoint, contentId) {
53
+ return await microCMSClient.delete({
54
+ endpoint,
55
+ contentId,
56
+ });
57
+ }
58
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAmB,MAAM,iBAAiB,CAAC;AAExF,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;AAE7B,MAAM,CAAC,MAAM,cAAc,GAAG,YAAY,CAAC;IACzC,aAAa,EAAE,MAAM,CAAC,aAAa;IACnC,MAAM,EAAE,MAAM,CAAC,MAAM;CACtB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;IAC7D,aAAa,EAAE,MAAM,CAAC,aAAa;IACnC,MAAM,EAAE,MAAM,CAAC,MAAM;CACtB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,aAAa,EAAE,MAAM,CAAC,aAAa;IACnC,MAAM,EAAE,MAAM,CAAC,MAAM;CACtB,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,QAAgB,EAChB,OAAyB;IAEzB,OAAO,MAAM,cAAc,CAAC,OAAO,CAAI;QACrC,QAAQ;QACR,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,QAAgB,EAChB,SAAiB,EACjB,OAAyB;IAEzB,OAAO,MAAM,cAAc,CAAC,aAAa,CAAI;QAC3C,QAAQ;QACR,SAAS;QACT,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,QAAgB,EAChB,OAAgF,EAChF,OAAmD;IAEnD,OAAO,MAAM,cAAc,CAAC,MAAM,CAAC;QACjC,QAAQ;QACR,OAAO;QACP,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,QAAgB,EAChB,SAAiB,EACjB,OAAgF,EAChF,OAA+B;IAE/B,OAAO,MAAM,cAAc,CAAC,MAAM,CAAC;QACjC,QAAQ;QACR,SAAS;QACT,OAAO;QACP,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,QAAgB,EAChB,SAAiB,EACjB,OAAyF,EACzF,OAA+B;IAE/B,OAAO,MAAM,cAAc,CAAC,MAAM,CAAC;QACjC,QAAQ;QACR,SAAS;QACT,OAAO;QACP,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,QAAgB,EAChB,SAAiB;IAEjB,OAAO,MAAM,cAAc,CAAC,MAAM,CAAC;QACjC,QAAQ;QACR,SAAS;KACV,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,6 @@
1
+ export interface Config {
2
+ serviceDomain: string;
3
+ apiKey: string;
4
+ }
5
+ export declare function parseConfig(): Config;
6
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,WAAW,IAAI,MAAM,CAiCpC"}
package/dist/config.js ADDED
@@ -0,0 +1,27 @@
1
+ export function parseConfig() {
2
+ const args = process.argv.slice(2);
3
+ // Parse command line arguments
4
+ let serviceDomain;
5
+ let apiKey;
6
+ const serviceIdIndex = args.indexOf('--service-id');
7
+ if (serviceIdIndex !== -1 && serviceIdIndex + 1 < args.length) {
8
+ serviceDomain = args[serviceIdIndex + 1];
9
+ }
10
+ const apiKeyIndex = args.indexOf('--api-key');
11
+ if (apiKeyIndex !== -1 && apiKeyIndex + 1 < args.length) {
12
+ apiKey = args[apiKeyIndex + 1];
13
+ }
14
+ // Fallback to environment variables if not provided via command line
15
+ serviceDomain = serviceDomain || process.env.MICROCMS_SERVICE_ID;
16
+ apiKey = apiKey || process.env.MICROCMS_API_KEY;
17
+ if (!serviceDomain || !apiKey) {
18
+ throw new Error('microCMS credentials are required. Provide them via:\n' +
19
+ ' Command line: --service-id <service-id> --api-key <key>\n' +
20
+ ' Environment variables: MICROCMS_SERVICE_ID and MICROCMS_API_KEY');
21
+ }
22
+ return {
23
+ serviceDomain,
24
+ apiKey,
25
+ };
26
+ }
27
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,WAAW;IACzB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEnC,+BAA+B;IAC/B,IAAI,aAAiC,CAAC;IACtC,IAAI,MAA0B,CAAC;IAE/B,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IACpD,IAAI,cAAc,KAAK,CAAC,CAAC,IAAI,cAAc,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAC9D,aAAa,GAAG,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC9C,IAAI,WAAW,KAAK,CAAC,CAAC,IAAI,WAAW,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QACxD,MAAM,GAAG,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;IACjC,CAAC;IAED,qEAAqE;IACrE,aAAa,GAAG,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IACjE,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;IAEhD,IAAI,CAAC,aAAa,IAAI,CAAC,MAAM,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACb,wDAAwD;YACxD,6DAA6D;YAC7D,mEAAmE,CACpE,CAAC;IACJ,CAAC;IAED,OAAO;QACL,aAAa;QACb,MAAM;KACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export declare function startServer(): Promise<void>;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AA0GA,wBAAsB,WAAW,kBAgBhC"}