thunderclient-mcp 1.0.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.
@@ -0,0 +1,10 @@
1
+ name: New MCP server
2
+ version: 0.0.1
3
+ schema: v1
4
+ mcpServers:
5
+ - name: Thunder Client MCP server
6
+ command: npx
7
+ args:
8
+ - -y
9
+ - "@thunderclient/mcp"
10
+ env: {}
package/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Thunder Client
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
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,146 @@
1
+ # Thunder Client MCP
2
+
3
+ A Model Context Protocol (MCP) server that integrates Thunder Client functionality into various AI development environments including Cline, Continue.dev, and GitHub Copilot.
4
+
5
+ ## Available Tools
6
+
7
+ This MCP server provides three powerful tools for managing Thunder Client operations:
8
+
9
+ ### 1. `tc_create`
10
+ **Description:**
11
+ Saves API endpoints to Thunder Client, automatically creating collections and folders if they do not already exist.
12
+
13
+ **Usage:**
14
+ - Use AI to analyze your current project and automatically generate API requests in Thunder Client, with the appropriate collection and folder created as needed.
15
+ - Add new requests to a specific collection in Thunder Client.
16
+ - Dynamically create a request using an AI-generated prompt.
17
+
18
+ ### 2. `tc_help`
19
+ **Description:** Show Thunder Client CLI help using `tc --help` in the given project directory.
20
+ - **Usage:** Get comprehensive help documentation for Thunder Client CLI
21
+
22
+ ### 3. `tc_debug`
23
+ **Description:** Show Thunder Client CLI debug information using `tc --debug` in the given project directory.
24
+ - **Usage:** Troubleshoot and get detailed debug information from Thunder Client
25
+
26
+ ## Installation & Setup
27
+
28
+ ### Prerequisites
29
+ ```bash
30
+ npm i
31
+ npm run build
32
+ ```
33
+ After building, a `dist` folder will be created. Copy the `index.js` path from the `dist` folder - this path will be used in your MCP server configuration.
34
+
35
+
36
+ ## Configuration for Different Environments
37
+
38
+ ### For Cline
39
+
40
+ 1. Open Cline and navigate to the **MCP Server** section
41
+ 2. Click on **Installed**
42
+ 3. Click on **Configure the MCP Server**
43
+ 4. Add the following configuration inside the `mcpServers` JSON:
44
+
45
+ ```json
46
+ {
47
+ "mcpServers": {
48
+ "thunderclient": {
49
+ "type": "stdio",
50
+ "command": "node",
51
+ "args": [
52
+ "/path/to/thunder-mcp/dist/index.js"
53
+ ]
54
+ }
55
+ }
56
+ }
57
+ ```
58
+
59
+ **Important:** Replace `/path/to/thunder-mcp/dist/index.js` with the actual path to your `index.js` file from the `dist` folder.
60
+
61
+ Once configured, you can use all `tc_*` command tools in Cline's MCP interface.
62
+
63
+ ---
64
+
65
+ ### For Continue.dev
66
+
67
+ 1. Add a new **MCP server** to your configuration
68
+ 2. Switch to **Agent mode** instead of Chat mode
69
+ 3. Configure using the following YAML structure:
70
+
71
+ ```yaml
72
+ name: Thunder Client MCP Server
73
+ version: 0.0.1
74
+ schema: v1
75
+ mcpServers:
76
+ - name: Thunder Client MCP Server
77
+ command: node
78
+ args:
79
+ - /path/to/thunder-mcp/dist/index.js
80
+ ```
81
+
82
+ **Important:** Replace `/path/to/thunder-mcp/dist/index.js` with your actual `index.js` location.
83
+
84
+ ---
85
+
86
+ ### For GitHub Copilot
87
+
88
+ 1. Switch to **Agent mode** from Chat mode
89
+ 2. Click on the **Tools** icon in the interface
90
+ 3. Scroll down and click **+ Add more tools**
91
+ 4. Select **+ Add MCP Server**
92
+ ![alt text](/public/copolit_add_mcp_server.png)
93
+ 5. Choose **Stdio** as the connection type
94
+ 6. Enter the correct path to `node` and your `thunder-mcp/dist/index.js` file
95
+ 7. Save the configuration
96
+
97
+ ---
98
+
99
+ # Example Prompts
100
+
101
+ This document contains simple example prompts for the `tc_create` tool to extract APIs from code files and save them to Thunder Client.
102
+
103
+ ## Extract APIs from Code Files
104
+
105
+ ### 1. Extract APIs from Current Project
106
+
107
+ ```
108
+ "Get the endpoints from current project and save to Thunder Client with collection name 'My API'."
109
+ ```
110
+
111
+ ### 2. Extract APIs from Files and Folders
112
+
113
+ ```
114
+ "Get the endpoints from app/main.py and save to Thunder Client with collection name 'E-commerce API' and folder name 'Products'."
115
+ ```
116
+
117
+ ```
118
+ "Get the endpoints from src/routes/ folder and save to Thunder Client with collection name 'Node API'."
119
+ ```
120
+
121
+ ### 3. Create Simple HTTP Requests
122
+
123
+ ```
124
+ "Create a POST request to https://api.example.com/users with a JSON body and with authorization header in Thunder Client."
125
+ ```
126
+
127
+ ## Troubleshooting
128
+
129
+ ### If the Agent Is Not Executing Commands Properly
130
+
131
+ 1. **Use Attach Context:** Utilize the **Attach Context** option in your AI environment
132
+ 2. **Attach Required Files:** Include relevant files and specifically attach the `tc_create` tool context
133
+ 3. **Provide Clear Prompts:** Give detailed, specific prompts to assist with command execution
134
+
135
+ ### Common Issues
136
+
137
+ - **Path Issues:** Ensure all file paths are absolute and correctly formatted for your operating system
138
+ - **Node.js Version:** Verify you're using a compatible Node.js version
139
+ - **Permissions:** Check that the MCP server has appropriate file system permissions
140
+ - **Project Directory:** Ensure the `projectDir` parameter points to a valid Thunder Client workspace
141
+
142
+ ---
143
+
144
+ ## Contributing
145
+
146
+ Feel free to contribute to this project by submitting issues or pull requests to improve functionality and compatibility with different AI development environments.
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env node
2
+ import { ThunderClient } from "./thunder-client.js";
3
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
4
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
6
+ import { toolHandlers, tools } from "./tools/definitions.js";
7
+ import pkg from '../package.json' with { type: 'json' };
8
+ const version = pkg.version;
9
+ const thunderClient = new ThunderClient();
10
+ const server = new Server({
11
+ name: "thunderclient-mcp",
12
+ version,
13
+ title: "Thunder Client MCP",
14
+ }, {
15
+ capabilities: {
16
+ tools: {},
17
+ },
18
+ });
19
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
20
+ return {
21
+ tools
22
+ };
23
+ });
24
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
25
+ const { name, arguments: args } = request.params;
26
+ try {
27
+ const toolDefinition = toolHandlers[name];
28
+ if (!toolDefinition) {
29
+ throw new Error(`Unknown tool: ${name}`);
30
+ }
31
+ const validatedArgs = toolDefinition.schema.parse(args);
32
+ const result = await toolDefinition.handler(thunderClient, validatedArgs);
33
+ return {
34
+ content: [
35
+ {
36
+ type: "text",
37
+ text: JSON.stringify(result, null, 2),
38
+ },
39
+ ],
40
+ };
41
+ }
42
+ catch (error) {
43
+ const errorMessage = error instanceof Error ? error.message : "An unknown error occurred.";
44
+ return {
45
+ content: [
46
+ {
47
+ type: "text",
48
+ text: `Error calling tool ${name}: ${errorMessage}`,
49
+ },
50
+ ],
51
+ isError: true,
52
+ };
53
+ }
54
+ });
55
+ async function main() {
56
+ const transport = new StdioServerTransport();
57
+ await server.connect(transport);
58
+ console.log(`Thunder Client MCP server is running...`);
59
+ }
60
+ main().catch((error) => {
61
+ console.error("Fatal error starting server:", error);
62
+ process.exit(1);
63
+ });
@@ -0,0 +1,27 @@
1
+ export declare class ThunderClient {
2
+ private validateProjectDir;
3
+ private execCommand;
4
+ thunder_help(projectDir: string): Promise<{
5
+ projectDir: string;
6
+ success: boolean;
7
+ result?: string;
8
+ error?: string;
9
+ }>;
10
+ thunder_debug(projectDir: string): Promise<{
11
+ projectDir: string;
12
+ success: boolean;
13
+ result?: string;
14
+ error?: string;
15
+ }>;
16
+ runCurl({ curlInput, name, collection, folder, projectDir, }: {
17
+ curlInput: string;
18
+ name?: string;
19
+ collection?: string;
20
+ folder?: string;
21
+ projectDir: string;
22
+ }): Promise<{
23
+ success: boolean;
24
+ error?: string;
25
+ }>;
26
+ }
27
+ //# sourceMappingURL=thunder-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thunder-client.d.ts","sourceRoot":"","sources":["../src/thunder-client.ts"],"names":[],"mappings":"AAiBA,qBAAa,aAAa;IACxB,OAAO,CAAC,kBAAkB;YAUZ,WAAW;IAYnB,YAAY,CAAC,UAAU,EAAE,MAAM;;iBAZuC,OAAO;iBAAW,MAAM;gBAAU,MAAM;;IAoB9G,aAAa,CAAC,UAAU,EAAE,MAAM;;iBApBsC,OAAO;iBAAW,MAAM;gBAAU,MAAM;;IA4B9G,OAAO,CAAC,EACZ,SAAS,EACT,IAAI,EACJ,UAAU,EACV,MAAM,EACN,UAAU,GACX,EAAE;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CA4BlD"}
@@ -0,0 +1,76 @@
1
+ import { exec } from "child_process";
2
+ import { promisify } from "util";
3
+ import * as fs from "fs";
4
+ const execAsync = promisify(exec);
5
+ // Support multiple data flags in curl
6
+ function normalizeCurlInputForWindows(curlInput) {
7
+ return curlInput.replace(/(-d|--data(?:-raw)?)\s+(['"])([\s\S]*?)\2/g, (_, flag, _quote, rawBody) => {
8
+ const escapedBody = rawBody.replace(/"/g, '\\"');
9
+ return `${flag} "${escapedBody}"`;
10
+ });
11
+ }
12
+ export class ThunderClient {
13
+ validateProjectDir(projectDir) {
14
+ if (!fs.existsSync(projectDir)) {
15
+ return {
16
+ valid: false,
17
+ error: `Invalid project directory: ${projectDir}`,
18
+ };
19
+ }
20
+ return { valid: true };
21
+ }
22
+ async execCommand(command, cwd) {
23
+ try {
24
+ const { stdout } = await execAsync(command, { cwd });
25
+ return { success: true, result: stdout };
26
+ }
27
+ catch (error) {
28
+ return {
29
+ success: false,
30
+ error: error?.stderr || error?.message || "Unknown error",
31
+ };
32
+ }
33
+ }
34
+ async thunder_help(projectDir) {
35
+ const check = this.validateProjectDir(projectDir);
36
+ if (!check.valid)
37
+ return { success: false, error: check.error, projectDir };
38
+ const result = await this.execCommand("tc --help", projectDir);
39
+ return { ...result, projectDir };
40
+ }
41
+ async thunder_debug(projectDir) {
42
+ const check = this.validateProjectDir(projectDir);
43
+ if (!check.valid)
44
+ return { success: false, error: check.error, projectDir };
45
+ const result = await this.execCommand("tc --debug", projectDir);
46
+ return { ...result, projectDir };
47
+ }
48
+ async runCurl({ curlInput, name, collection, folder, projectDir, }) {
49
+ const check = this.validateProjectDir(projectDir);
50
+ if (!check.valid)
51
+ return { success: false, error: check.error };
52
+ const trimmedInput = curlInput.trim();
53
+ if (!trimmedInput.toLowerCase().startsWith("curl ")) {
54
+ return { success: false, error: "Input must start with 'curl '" };
55
+ }
56
+ let curlArgs = trimmedInput.slice(5).trim();
57
+ if (process.platform === "win32") {
58
+ curlArgs = normalizeCurlInputForWindows(curlArgs);
59
+ }
60
+ let cmd = `tc curl ${curlArgs} --ws .`;
61
+ if (name)
62
+ cmd += ` --name "${name}"`;
63
+ if (collection)
64
+ cmd += ` --col "${collection}"`;
65
+ if (folder)
66
+ cmd += ` --fol "${folder}"`;
67
+ cmd += ` --mcp`;
68
+ const result = await this.execCommand(cmd, projectDir);
69
+ if (result.success) {
70
+ return { success: true }; // ✅ Return only success: true
71
+ }
72
+ else {
73
+ return { success: false, error: result.error };
74
+ }
75
+ }
76
+ }
@@ -0,0 +1,133 @@
1
+ import { z, ZodSchema } from "zod";
2
+ import { ThunderClient } from "../thunder-client.js";
3
+ import { Tool } from "@modelcontextprotocol/sdk/types.js";
4
+ interface ToolDefinition<TSchema extends ZodSchema, TResult> {
5
+ name: string;
6
+ description: string;
7
+ schema: TSchema;
8
+ handler: (client: ThunderClient, args: z.infer<TSchema>) => Promise<TResult>;
9
+ }
10
+ export declare const toolDefinitions: {
11
+ readonly thunder_help: ToolDefinition<z.ZodObject<{
12
+ projectDir: z.ZodString;
13
+ }, "strip", z.ZodTypeAny, {
14
+ projectDir: string;
15
+ }, {
16
+ projectDir: string;
17
+ }>, {
18
+ projectDir: string;
19
+ success: boolean;
20
+ result?: string;
21
+ error?: string;
22
+ }>;
23
+ readonly thunder_debug: ToolDefinition<z.ZodObject<{
24
+ projectDir: z.ZodString;
25
+ }, "strip", z.ZodTypeAny, {
26
+ projectDir: string;
27
+ }, {
28
+ projectDir: string;
29
+ }>, {
30
+ projectDir: string;
31
+ success: boolean;
32
+ result?: string;
33
+ error?: string;
34
+ }>;
35
+ readonly thunder_curl: ToolDefinition<z.ZodEffects<z.ZodObject<{
36
+ curlInput: z.ZodEffects<z.ZodString, string, string>;
37
+ name: z.ZodString;
38
+ collection: z.ZodOptional<z.ZodString>;
39
+ folder: z.ZodOptional<z.ZodString>;
40
+ projectDir: z.ZodString;
41
+ }, "strip", z.ZodTypeAny, {
42
+ curlInput: string;
43
+ name: string;
44
+ projectDir: string;
45
+ collection?: string | undefined;
46
+ folder?: string | undefined;
47
+ }, {
48
+ curlInput: string;
49
+ name: string;
50
+ projectDir: string;
51
+ collection?: string | undefined;
52
+ folder?: string | undefined;
53
+ }>, {
54
+ curlInput: string;
55
+ name: string;
56
+ projectDir: string;
57
+ collection?: string | undefined;
58
+ folder?: string | undefined;
59
+ }, {
60
+ curlInput: string;
61
+ name: string;
62
+ projectDir: string;
63
+ collection?: string | undefined;
64
+ folder?: string | undefined;
65
+ }>, {
66
+ success: boolean;
67
+ error?: string;
68
+ }>;
69
+ };
70
+ export declare const tools: Tool[];
71
+ export declare const toolHandlers: {
72
+ [k: string]: ToolDefinition<z.ZodObject<{
73
+ projectDir: z.ZodString;
74
+ }, "strip", z.ZodTypeAny, {
75
+ projectDir: string;
76
+ }, {
77
+ projectDir: string;
78
+ }>, {
79
+ projectDir: string;
80
+ success: boolean;
81
+ result?: string;
82
+ error?: string;
83
+ }> | ToolDefinition<z.ZodObject<{
84
+ projectDir: z.ZodString;
85
+ }, "strip", z.ZodTypeAny, {
86
+ projectDir: string;
87
+ }, {
88
+ projectDir: string;
89
+ }>, {
90
+ projectDir: string;
91
+ success: boolean;
92
+ result?: string;
93
+ error?: string;
94
+ }> | ToolDefinition<z.ZodEffects<z.ZodObject<{
95
+ curlInput: z.ZodEffects<z.ZodString, string, string>;
96
+ name: z.ZodString;
97
+ collection: z.ZodOptional<z.ZodString>;
98
+ folder: z.ZodOptional<z.ZodString>;
99
+ projectDir: z.ZodString;
100
+ }, "strip", z.ZodTypeAny, {
101
+ curlInput: string;
102
+ name: string;
103
+ projectDir: string;
104
+ collection?: string | undefined;
105
+ folder?: string | undefined;
106
+ }, {
107
+ curlInput: string;
108
+ name: string;
109
+ projectDir: string;
110
+ collection?: string | undefined;
111
+ folder?: string | undefined;
112
+ }>, {
113
+ curlInput: string;
114
+ name: string;
115
+ projectDir: string;
116
+ collection?: string | undefined;
117
+ folder?: string | undefined;
118
+ }, {
119
+ curlInput: string;
120
+ name: string;
121
+ projectDir: string;
122
+ collection?: string | undefined;
123
+ folder?: string | undefined;
124
+ }>, {
125
+ success: boolean;
126
+ error?: string;
127
+ }>;
128
+ };
129
+ export declare const toolNames: Record<string, string>;
130
+ export type ToolName = (typeof toolDefinitions)[keyof typeof toolDefinitions]["name"];
131
+ export type ToolArgs<T extends ToolName> = z.infer<(typeof toolDefinitions)[Extract<keyof typeof toolDefinitions, string>]["schema"]>;
132
+ export {};
133
+ //# sourceMappingURL=definitions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/tools/definitions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAG1D,UAAU,cAAc,CAAC,OAAO,SAAS,SAAS,EAAE,OAAO;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9E;AAQD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyClB,CAAC;AAEX,eAAO,MAAM,KAAK,EAAE,IAAI,EAIrB,CAAC;AAEJ,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAExB,CAAC;AAEF,eAAO,MAAM,SAAS,EAEjB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE5B,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtF,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,QAAQ,IAAI,CAAC,CAAC,KAAK,CAChD,CAAC,OAAO,eAAe,CAAC,CAAC,OAAO,CAAC,MAAM,OAAO,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAClF,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { z } from "zod";
2
+ import { zodToMCPInputSchema } from "../utils/schema-converter.js";
3
+ function defineTool(definition) {
4
+ return definition;
5
+ }
6
+ export const toolDefinitions = {
7
+ thunder_help: defineTool({
8
+ name: "tc_help",
9
+ description: "Show Thunder Client CLI help using `tc --help` in the given project directory.",
10
+ schema: z.object({
11
+ projectDir: z.string().min(1, "projectDir is required"),
12
+ }),
13
+ handler: async (client, args) => client.thunder_help(args.projectDir.trim()),
14
+ }),
15
+ thunder_debug: defineTool({
16
+ name: "tc_debug",
17
+ description: "Show Thunder Client CLI debug using `tc --debug` in the given project directory.",
18
+ schema: z.object({
19
+ projectDir: z.string().min(1, "projectDir is required"),
20
+ }),
21
+ handler: async (client, args) => client.thunder_debug(args.projectDir.trim()),
22
+ }),
23
+ thunder_curl: defineTool({
24
+ name: "tc_create",
25
+ description: "Saves API endpoints to Thunder Client, automatically creating collections and folders if they do not already exist.",
26
+ schema: z
27
+ .object({
28
+ curlInput: z
29
+ .string()
30
+ .min(5, { message: "curlInput must be at least 5 characters long" })
31
+ .refine(val => val.trim().toLowerCase().startsWith("curl "), {
32
+ message: "curlInput must start with 'curl '",
33
+ }),
34
+ name: z.string().min(2, { message: "Name must be at least 2 characters" }),
35
+ collection: z.string().optional(),
36
+ folder: z.string().optional(),
37
+ projectDir: z.string().min(1, { message: "projectDir is required" }),
38
+ })
39
+ .refine(data => !(data.folder && !data.collection), {
40
+ message: "If 'folder' is provided, you must also provide 'collection'.",
41
+ path: ["collection"],
42
+ }),
43
+ handler: async (client, args) => client.runCurl({ ...args, projectDir: args.projectDir.trim() }),
44
+ }),
45
+ };
46
+ export const tools = Object.values(toolDefinitions).map(def => ({
47
+ name: def.name,
48
+ description: def.description.trim(),
49
+ inputSchema: zodToMCPInputSchema(def.schema),
50
+ }));
51
+ export const toolHandlers = Object.fromEntries(Object.values(toolDefinitions).map(def => [def.name, def]));
52
+ export const toolNames = Object.fromEntries(Object.entries(toolDefinitions).map(([key, def]) => [key.toUpperCase(), def.name]));
@@ -0,0 +1,8 @@
1
+ import { z } from "zod";
2
+ export declare function zodToMCPInputSchema(schema: z.ZodSchema): {
3
+ type: "object";
4
+ properties?: Record<string, any>;
5
+ required?: string[];
6
+ description?: string;
7
+ };
8
+ //# sourceMappingURL=schema-converter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-converter.d.ts","sourceRoot":"","sources":["../../src/utils/schema-converter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC,SAAS,GAAG;IACxD,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAuDA"}
@@ -0,0 +1,51 @@
1
+ import { zodToJsonSchema } from "zod-to-json-schema";
2
+ export function zodToMCPInputSchema(schema) {
3
+ try {
4
+ const jsonSchema = zodToJsonSchema(schema, {
5
+ target: "jsonSchema7",
6
+ $refStrategy: "none",
7
+ definitions: {},
8
+ });
9
+ let actualSchema = jsonSchema;
10
+ // If it has a $ref, extract the actual schema from definitions
11
+ if (typeof jsonSchema === "object" && jsonSchema !== null) {
12
+ if ("$ref" in jsonSchema && jsonSchema.definitions) {
13
+ const refPath = jsonSchema.$ref;
14
+ const definitionKey = refPath.replace("#/definitions/", "");
15
+ if (jsonSchema.definitions[definitionKey]) {
16
+ actualSchema = jsonSchema.definitions[definitionKey];
17
+ }
18
+ }
19
+ }
20
+ // Ensure it's an object schema (MCP requirement)
21
+ if (typeof actualSchema === "object" &&
22
+ actualSchema !== null &&
23
+ actualSchema.type === "object") {
24
+ const objectSchema = actualSchema;
25
+ return {
26
+ type: "object",
27
+ properties: objectSchema.properties || {},
28
+ required: Array.isArray(objectSchema.required)
29
+ ? objectSchema.required
30
+ : [],
31
+ ...(objectSchema.description && {
32
+ description: objectSchema.description,
33
+ }),
34
+ };
35
+ }
36
+ // Fallback for non-object schemas
37
+ return {
38
+ type: "object",
39
+ properties: {},
40
+ required: [],
41
+ };
42
+ }
43
+ catch (error) {
44
+ console.warn(`Failed to convert schema for tool, using fallback:`, error);
45
+ return {
46
+ type: "object",
47
+ properties: {},
48
+ required: [],
49
+ };
50
+ }
51
+ }
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "thunderclient-mcp",
3
+ "version": "1.0.0",
4
+ "description": "Thunder Client MCP Server",
5
+ "main": "dist/index.js`",
6
+ "types": "dist/index.d.ts",
7
+ "type": "module",
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "prepublishOnly": "rimraf dist && tsc",
11
+ "postinstall": "npm install -g @thunderclient/cli@latest"
12
+ },
13
+ "bin": {
14
+ "thunderclient-mcp": "dist/index.js"
15
+ },
16
+ "keywords": [],
17
+ "author": "Thunder Client Limited",
18
+ "license": "MIT",
19
+ "dependencies": {
20
+ "@modelcontextprotocol/sdk": "^1.16.0",
21
+ "zod": "^3.25.76",
22
+ "zod-to-json-schema": "^3.24.6"
23
+ },
24
+ "devDependencies": {
25
+ "@types/node": "^24.1.0",
26
+ "rimraf": "^6.0.1",
27
+ "tsx": "^4.20.3",
28
+ "typescript": "^5.8.3"
29
+ }
30
+ }