mcp-insomnia 0.1.0 → 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Angga Permana
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 CHANGED
@@ -2,31 +2,43 @@
2
2
 
3
3
  MCP-Insomnia is an MCP (Model Context Protocol) server that enables AI agents to create and manage API collections in Insomnia-compatible format. This server provides tools and resources for managing collections, requests, and environments that can be exported to Insomnia.
4
4
 
5
- ## Installation
5
+ ## Installation and Usage
6
6
 
7
7
  ### Prerequisites
8
8
 
9
9
  - Node.js 18+
10
10
  - npm or yarn
11
11
 
12
- ### Install from NPM
12
+ There are three ways to use `mcp-insomnia`.
13
13
 
14
- ```bash
15
- npm install -g mcp-insomnia
14
+ ### 1. Run with NPX (Recommended)
15
+
16
+ You can run `mcp-insomnia` directly using `npx` without a global installation.
17
+
18
+ **Configuration:**
19
+
20
+ ```json
21
+ {
22
+ "mcpServers": {
23
+ "insomnia": {
24
+ "command": "npx",
25
+ "args": ["mcp-insomnia"]
26
+ }
27
+ }
28
+ }
16
29
  ```
17
30
 
18
- ### Install from Source
31
+ ### 2. Install Globally from NPM
32
+
33
+ Install the package globally using npm.
34
+
35
+ **Installation:**
19
36
 
20
37
  ```bash
21
- git clone https://github.com/anggasct/mcp-insomnia.git
22
- cd mcp-insomnia
23
- npm install
24
- npm run build
38
+ npm install -g mcp-insomnia
25
39
  ```
26
40
 
27
- ### Add to MCP Configuration
28
-
29
- Add to your MCP client configuration:
41
+ **Configuration:**
30
42
 
31
43
  ```json
32
44
  {
@@ -38,7 +50,20 @@ Add to your MCP client configuration:
38
50
  }
39
51
  ```
40
52
 
41
- Or if installed from source:
53
+ ### 3. Install from Source
54
+
55
+ Clone the repository and build the project.
56
+
57
+ **Installation:**
58
+
59
+ ```bash
60
+ git clone https://github.com/anggasct/mcp-insomnia.git
61
+ cd mcp-insomnia
62
+ npm install
63
+ npm run build
64
+ ```
65
+
66
+ **Configuration:**
42
67
 
43
68
  ```json
44
69
  {
@@ -70,6 +95,7 @@ Or if installed from source:
70
95
  - `update_request` - Update existing request
71
96
  - `delete_request` - Delete request
72
97
  - `execute_request` - Execute request and view response
98
+ - `generate_code_snippet` - Generate a code snippet for a request in various languages/frameworks
73
99
 
74
100
  ### Environment Management
75
101
 
@@ -116,6 +142,12 @@ Set environment variable "baseUrl" with value "https://api.example.com" for "API
116
142
  Execute "Get Users" request using the configured environment variables
117
143
  ```
118
144
 
145
+ ### Generate Code Snippet
146
+
147
+ ```
148
+ Generate a code snippet for request "Get Users" in "javascript"
149
+ ```
150
+
119
151
  ## Data Storage
120
152
 
121
153
  Data is stored in `~/.mcp-insomnia/collections.json` in JSON format.
package/dist/index.js CHANGED
File without changes
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=run-duplication-test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-duplication-test.d.ts","sourceRoot":"","sources":["../src/run-duplication-test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,58 @@
1
+ import { storage } from './storage.js';
2
+ import { createInsomniaTools } from './tools.js';
3
+ async function runDuplicationTest() {
4
+ console.log('Starting duplication test...');
5
+ const tools = createInsomniaTools();
6
+ const createCollectionTool = tools.find(t => t.name === 'create_collection');
7
+ const createRequestTool = tools.find(t => t.name === 'create_request_in_collection');
8
+ const duplicateRequestTool = tools.find(t => t.name === 'duplicate_request');
9
+ const duplicateCollectionTool = tools.find(t => t.name === 'duplicate_collection');
10
+ if (!createCollectionTool || !createRequestTool || !duplicateRequestTool || !duplicateCollectionTool) {
11
+ throw new Error('One or more required tools are not defined.');
12
+ }
13
+ // 1. Setup
14
+ storage.clearAllCollections();
15
+ const collResult = await createCollectionTool.handler({ params: { arguments: { name: 'Original Collection' } } });
16
+ const collectionId = (collResult.content[0].text.match(/ID: (wrk_[a-zA-Z0-9]+)/) || [])[1];
17
+ const reqResult = await createRequestTool.handler({ params: { arguments: { collectionId, name: 'Original Request', method: 'GET', url: 'http://original.com' } } });
18
+ const requestId = (reqResult.content[0].text.match(/ID: (req_[a-zA-Z0-9]+)/) || [])[1];
19
+ console.log(`Setup complete. Collection: ${collectionId}, Request: ${requestId}`);
20
+ // 2. Test Request Duplication
21
+ console.log('Testing request duplication...');
22
+ const dupReqResult = await duplicateRequestTool.handler({ params: { arguments: { requestId, newName: 'Duplicated Request' } } });
23
+ const newRequestId = (dupReqResult.content[0].text.match(/ID: (req_[a-zA-Z0-9]+)/) || [])[1];
24
+ let collection = storage.getCollection(collectionId);
25
+ if (collection.requests.length !== 2) {
26
+ throw new Error(`❌ FAILED: Expected 2 requests after duplication, found ${collection.requests.length}`);
27
+ }
28
+ const newReq = collection.requests.find(r => r._id === newRequestId);
29
+ if (!newReq || newReq.name !== 'Duplicated Request') {
30
+ throw new Error('❌ FAILED: Duplicated request has incorrect data.');
31
+ }
32
+ console.log('✅ SUCCESS: Request duplication test passed.');
33
+ // 3. Test Collection Duplication
34
+ console.log('Testing collection duplication...');
35
+ const dupCollResult = await duplicateCollectionTool.handler({ params: { arguments: { collectionId, newName: 'Duplicated Collection' } } });
36
+ const newCollectionId = (dupCollResult.content[0].text.match(/ID: (wrk_[a-zA-Z0-9]+)/) || [])[1];
37
+ const newCollection = storage.getCollection(newCollectionId);
38
+ if (!newCollection) {
39
+ throw new Error('❌ FAILED: Duplicated collection not found in storage.');
40
+ }
41
+ if (newCollection.workspace.name !== 'Duplicated Collection') {
42
+ throw new Error('❌ FAILED: Duplicated collection has incorrect name.');
43
+ }
44
+ if (newCollection.requests.length !== 1 || newCollection.requests[0].name !== 'Original Request') {
45
+ throw new Error('❌ FAILED: Requests within duplicated collection are incorrect.');
46
+ }
47
+ if (newCollection.requests[0].parentId === requestId) {
48
+ throw new Error('❌ FAILED: Request parent ID was not updated during collection duplication.');
49
+ }
50
+ console.log('✅ SUCCESS: Collection duplication test passed.');
51
+ console.log('All duplication tests finished successfully.');
52
+ }
53
+ runDuplicationTest().catch(err => {
54
+ console.error('Test failed with an error:');
55
+ console.error(err);
56
+ process.exit(1);
57
+ });
58
+ //# sourceMappingURL=run-duplication-test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-duplication-test.js","sourceRoot":"","sources":["../src/run-duplication-test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,KAAK,UAAU,kBAAkB;IAC/B,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;IAE5C,MAAM,KAAK,GAAG,mBAAmB,EAAE,CAAC;IACpC,MAAM,oBAAoB,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,mBAAmB,CAAC,CAAC;I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",
3
+ "version": "0.2.0",
4
4
  "description": "MCP server for making HTTP requests and managing API collections",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -29,6 +29,7 @@
29
29
  "dependencies": {
30
30
  "@modelcontextprotocol/sdk": "1.13.3",
31
31
  "axios": "^1.6.0",
32
+ "httpsnippet": "^3.0.9",
32
33
  "uuid": "10.0.0"
33
34
  },
34
35
  "devDependencies": {
@@ -41,4 +42,4 @@
41
42
  "mcp-insomnia": "./dist/index.js"
42
43
  },
43
44
  "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
44
- }
45
+ }
@@ -1,9 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(npm --prefix .. run build)",
5
- "Bash(npm:*)"
6
- ],
7
- "deny": []
8
- }
9
- }