@myatkyawthu/mcp-connect 0.2.0 → 0.2.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 CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 myat-kyaw-thu
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
1
+ MIT License
2
+
3
+ Copyright (c) 2024 myat-kyaw-thu
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
21
  SOFTWARE.
package/README.md CHANGED
@@ -1,170 +1,170 @@
1
- # mcp-connect
2
-
3
- > Dead simple MCP (Model Context Protocol) server for exposing your app functions to AI agents
4
-
5
- [![npm version](https://badge.fury.io/js/mcp-connect.svg)](https://www.npmjs.com/package/mcp-connect)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
-
8
- ## 🚀 Claude Desktop Setup (5 Minutes)
9
-
10
- ### Step 1: Install mcp-connect
11
-
12
- ```bash
13
- npm install -g @myatkyawthu/mcp-connect
14
- ```
15
- ### Step 2: Create mcp.config.js
16
-
17
- ### Step 2: Create Your MCP Server
18
-
19
- ```bash
20
- # Navigate to your project directory
21
- cd your-project
22
-
23
- # Generate sample config
24
- mcp-connect init
25
- ```
26
-
27
- This creates `mcp.config.js` with example tools:
28
-
29
- ```javascript
30
- import { defineMCP } from "@myatkyawthu/mcp-connect";
31
-
32
- export default defineMCP({
33
- name: "My MCP App",
34
- version: "1.0.0",
35
- tools: [
36
- ["hello", async ({ name = "World" }) => `Hello ${name}!`],
37
- ["echo", async ({ message }) => `Echo: ${message}`]
38
- ]
39
- });
40
- ```
41
- ### Step 3: Test Locally
42
-
43
- ### Step 3: Configure Claude Desktop
44
-
45
- Open Claude Desktop config file:
46
- - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
47
- - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
48
-
49
- Add your MCP server:
50
-
51
- ```json
52
- {
53
- "mcpServers": {
54
- "my-app": {
55
- "command": "mcp-connect",
56
- "args": ["C:/full/path/to/your/mcp.config.js"]
57
- }
58
- }
59
- }
60
- ```
61
-
62
- **Important**: Use the full absolute path to your `mcp.config.js` file.
63
-
64
- ### Step 4: Start & Test
65
-
66
- 1. **Restart Claude Desktop** completely
67
- 2. **Test connection**: Ask Claude *"What tools do you have available?"*
68
- 3. **Use your tools**: Try *"Hello there!"* or *"Echo this message"*
69
-
70
- ✅ **Done!** Your functions are now available to Claude Desktop.
71
-
72
- ---
73
-
74
- ## 📖 Tool Definition Guide
75
-
76
- ### Simple Format (Recommended)
77
-
78
- ```javascript
79
- // Just name and function
80
- ["toolName", async (args) => "result"]
81
- ```
82
- ## 🔧 CLI Usage
83
-
84
- ### Advanced Format (With Validation)
85
-
86
- ```javascript
87
- {
88
- name: "toolName",
89
- description: "What this tool does",
90
- schema: {
91
- type: "object",
92
- properties: {
93
- param: { type: "string", description: "Parameter description" }
94
- },
95
- required: ["param"]
96
- },
97
- handler: async ({ param }) => `Result: ${param}`
98
- }
99
- ```
100
-
101
- ## 🛠 Development Commands
102
-
103
- ```bash
104
- # Start with auto-reload during development
105
- npm run dev
106
-
107
- # Start server with specific config file
108
- mcp-connect /path/to/your/mcp.config.js
109
-
110
- # Format code
111
- npm run format
112
-
113
- # Lint code
114
- npm run lint
115
- ```
116
-
117
- ## 🔧 Troubleshooting
118
-
119
- ### Config File Not Found
120
- ```bash
121
- # Create sample config
122
- mcp-connect init
123
- ```
124
-
125
- ### Claude Desktop Not Connecting
126
- 1. Check config file path is absolute
127
- 2. Restart Claude Desktop completely
128
- 3. Check Claude Desktop logs for errors
129
-
130
- ### Tool Not Working
131
- 1. Verify tool syntax in `mcp.config.js`
132
- 2. Check server logs for errors
133
- 3. Test with simple tools first
134
-
135
- ## 📋 Examples
136
-
137
- ### File Operations
138
- ```javascript
139
- ["readFile", async ({ path }) => {
140
- const fs = await import('fs/promises');
141
- return await fs.readFile(path, 'utf8');
142
- }]
143
- ```
144
-
145
- ### API Calls
146
- ```javascript
147
- ["getWeather", async ({ city }) => {
148
- const response = await fetch(`https://api.weather.com/${city}`);
149
- return await response.json();
150
- }]
151
- ```
152
-
153
- ### Database Queries
154
- ```javascript
155
- ["getUser", async ({ id }) => {
156
- // Your database logic here
157
- return { id, name: "John Doe", email: "john@example.com" };
158
- }]
159
- ```
160
-
161
- ## 🌐 Other MCP Clients
162
-
163
- Claude Desktop setup is covered above. Tutorials for other MCP clients coming soon:
164
- - VS Code extensions
165
- - Custom applications
166
- - Other AI platforms
167
-
168
- ## 📄 License
169
-
1
+ # mcp-connect
2
+
3
+ > Dead simple MCP (Model Context Protocol) server for exposing your app functions to AI agents
4
+
5
+ [![npm version](https://badge.fury.io/js/mcp-connect.svg)](https://www.npmjs.com/package/mcp-connect)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## 🚀 Claude Desktop Setup (5 Minutes)
9
+
10
+ ### Step 1: Install mcp-connect
11
+
12
+ ```bash
13
+ npm install -g @myatkyawthu/mcp-connect
14
+ ```
15
+ ### Step 2: Create mcp.config.js
16
+
17
+ ### Step 2: Create Your MCP Server
18
+
19
+ ```bash
20
+ # Navigate to your project directory
21
+ cd your-project
22
+
23
+ # Generate sample config
24
+ mcp-connect init
25
+ ```
26
+
27
+ This creates `mcp.config.js` with example tools:
28
+
29
+ ```javascript
30
+ import { defineMCP } from "@myatkyawthu/mcp-connect";
31
+
32
+ export default defineMCP({
33
+ name: "My MCP App",
34
+ version: "1.0.0",
35
+ tools: [
36
+ ["hello", async ({ name = "World" }) => `Hello ${name}!`],
37
+ ["echo", async ({ message }) => `Echo: ${message}`]
38
+ ]
39
+ });
40
+ ```
41
+ ### Step 3: Test Locally
42
+
43
+ ### Step 3: Configure Claude Desktop
44
+
45
+ Open Claude Desktop config file:
46
+ - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
47
+ - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
48
+
49
+ Add your MCP server:
50
+
51
+ ```json
52
+ {
53
+ "mcpServers": {
54
+ "my-app": {
55
+ "command": "mcp-connect",
56
+ "args": ["C:/full/path/to/your/mcp.config.js"]
57
+ }
58
+ }
59
+ }
60
+ ```
61
+
62
+ **Important**: Use the full absolute path to your `mcp.config.js` file.
63
+
64
+ ### Step 4: Start & Test
65
+
66
+ 1. **Restart Claude Desktop** completely
67
+ 2. **Test connection**: Ask Claude *"What tools do you have available?"*
68
+ 3. **Use your tools**: Try *"Hello there!"* or *"Echo this message"*
69
+
70
+ ✅ **Done!** Your functions are now available to Claude Desktop.
71
+
72
+ ---
73
+
74
+ ## 📖 Tool Definition Guide
75
+
76
+ ### Simple Format (Recommended)
77
+
78
+ ```javascript
79
+ // Just name and function
80
+ ["toolName", async (args) => "result"]
81
+ ```
82
+ ## 🔧 CLI Usage
83
+
84
+ ### Advanced Format (With Validation)
85
+
86
+ ```javascript
87
+ {
88
+ name: "toolName",
89
+ description: "What this tool does",
90
+ schema: {
91
+ type: "object",
92
+ properties: {
93
+ param: { type: "string", description: "Parameter description" }
94
+ },
95
+ required: ["param"]
96
+ },
97
+ handler: async ({ param }) => `Result: ${param}`
98
+ }
99
+ ```
100
+
101
+ ## 🛠 Development Commands
102
+
103
+ ```bash
104
+ # Start with auto-reload during development
105
+ npm run dev
106
+
107
+ # Start server with specific config file
108
+ mcp-connect /path/to/your/mcp.config.js
109
+
110
+ # Format code
111
+ npm run format
112
+
113
+ # Lint code
114
+ npm run lint
115
+ ```
116
+
117
+ ## 🔧 Troubleshooting
118
+
119
+ ### Config File Not Found
120
+ ```bash
121
+ # Create sample config
122
+ mcp-connect init
123
+ ```
124
+
125
+ ### Claude Desktop Not Connecting
126
+ 1. Check config file path is absolute
127
+ 2. Restart Claude Desktop completely
128
+ 3. Check Claude Desktop logs for errors
129
+
130
+ ### Tool Not Working
131
+ 1. Verify tool syntax in `mcp.config.js`
132
+ 2. Check server logs for errors
133
+ 3. Test with simple tools first
134
+
135
+ ## 📋 Examples
136
+
137
+ ### File Operations
138
+ ```javascript
139
+ ["readFile", async ({ path }) => {
140
+ const fs = await import('fs/promises');
141
+ return await fs.readFile(path, 'utf8');
142
+ }]
143
+ ```
144
+
145
+ ### API Calls
146
+ ```javascript
147
+ ["getWeather", async ({ city }) => {
148
+ const response = await fetch(`https://api.weather.com/${city}`);
149
+ return await response.json();
150
+ }]
151
+ ```
152
+
153
+ ### Database Queries
154
+ ```javascript
155
+ ["getUser", async ({ id }) => {
156
+ // Your database logic here
157
+ return { id, name: "John Doe", email: "john@example.com" };
158
+ }]
159
+ ```
160
+
161
+ ## 🌐 Other MCP Clients
162
+
163
+ Claude Desktop setup is covered above. Tutorials for other MCP clients coming soon:
164
+ - VS Code extensions
165
+ - Custom applications
166
+ - Other AI platforms
167
+
168
+ ## 📄 License
169
+
170
170
  MIT © [myat-kyaw-thu](https://github.com/myat-kyaw-thu)
package/package.json CHANGED
@@ -1,63 +1,63 @@
1
- {
2
- "name": "@myatkyawthu/mcp-connect",
3
- "version": "0.2.0",
4
- "description": "Dead simple MCP (Model Context Protocol) server for exposing your app functions to AI agents",
5
- "type": "module",
6
- "main": "./src/index.js",
7
- "module": "./src/index.js",
8
- "exports": {
9
- ".": {
10
- "import": "./src/index.js",
11
- "require": "./src/index.js"
12
- }
13
- },
14
- "bin": {
15
- "mcp-connect": "./src/cli.js"
16
- },
17
- "files": [
18
- "src",
19
- "README.md",
20
- "LICENSE"
21
- ],
22
- "scripts": {
23
- "start": "node src/cli.js",
24
- "dev": "nodemon src/cli.js",
25
- "test": "node --test",
26
- "test:unit": "node --test tests/unit",
27
- "test:integration": "node --test tests/integration",
28
- "lint": "eslint src/",
29
- "format": "prettier --write src/"
30
- },
31
- "keywords": [
32
- "mcp",
33
- "model-context-protocol",
34
- "ai",
35
- "agents",
36
- "tools",
37
- "claude",
38
- "gpt",
39
- "javascript",
40
- "nodejs"
41
- ],
42
- "author": "myat-kyaw-thu",
43
- "license": "MIT",
44
- "repository": {
45
- "type": "git",
46
- "url": "https://github.com/myat-kyaw-thu/MCP_Indigration_Package-NPM.git"
47
- },
48
- "bugs": {
49
- "url": "https://github.com/myat-kyaw-thu/MCP_Indigration_Package-NPM/issues"
50
- },
51
- "homepage": "https://github.com/myat-kyaw-thu/MCP_Indigration_Package-NPM#readme",
52
- "engines": {
53
- "node": ">=18.0.0"
54
- },
55
- "dependencies": {
56
- "@modelcontextprotocol/sdk": "^0.5.0"
57
- },
58
- "devDependencies": {
59
- "nodemon": "^3.0.0",
60
- "eslint": "^8.0.0",
61
- "prettier": "^3.0.0"
62
- }
1
+ {
2
+ "name": "@myatkyawthu/mcp-connect",
3
+ "version": "0.2.1",
4
+ "description": "Dead simple MCP (Model Context Protocol) server for exposing your app functions to AI agents",
5
+ "type": "module",
6
+ "main": "./src/index.js",
7
+ "module": "./src/index.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./src/index.js",
11
+ "require": "./src/index.js"
12
+ }
13
+ },
14
+ "bin": {
15
+ "mcp-connect": "src/cli.js"
16
+ },
17
+ "files": [
18
+ "src",
19
+ "README.md",
20
+ "LICENSE"
21
+ ],
22
+ "scripts": {
23
+ "start": "node src/cli.js",
24
+ "dev": "nodemon src/cli.js",
25
+ "test": "node --test",
26
+ "test:unit": "node --test tests/unit",
27
+ "test:integration": "node --test tests/integration",
28
+ "lint": "eslint src/",
29
+ "format": "prettier --write src/"
30
+ },
31
+ "keywords": [
32
+ "mcp",
33
+ "model-context-protocol",
34
+ "ai",
35
+ "agents",
36
+ "tools",
37
+ "claude",
38
+ "gpt",
39
+ "javascript",
40
+ "nodejs"
41
+ ],
42
+ "author": "myat-kyaw-thu",
43
+ "license": "MIT",
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://github.com/myat-kyaw-thu/MCP_Indigration_Package-NPM.git"
47
+ },
48
+ "bugs": {
49
+ "url": "https://github.com/myat-kyaw-thu/MCP_Indigration_Package-NPM/issues"
50
+ },
51
+ "homepage": "https://github.com/myat-kyaw-thu/MCP_Indigration_Package-NPM#readme",
52
+ "engines": {
53
+ "node": ">=18.0.0"
54
+ },
55
+ "dependencies": {
56
+ "@modelcontextprotocol/sdk": "^0.5.0"
57
+ },
58
+ "devDependencies": {
59
+ "nodemon": "^3.0.0",
60
+ "eslint": "^8.0.0",
61
+ "prettier": "^3.0.0"
62
+ }
63
63
  }
package/src/cli.js CHANGED
@@ -5,9 +5,6 @@ import { resolve } from 'path';
5
5
  import { defineMCP } from './defineMCP.js';
6
6
  import { MCPConnectServer } from './server/mcpServer.js';
7
7
 
8
- /**
9
- * Handle init command - create sample config file
10
- */
11
8
  async function handleInitCommand() {
12
9
  const configPath = resolve(process.cwd(), 'mcp.config.js');
13
10
 
@@ -68,13 +65,8 @@ export default defineMCP({
68
65
  }
69
66
  }
70
67
 
71
- /**
72
- * CLI entry point for mcp-connect
73
- * Uses MCP SDK with STDIO transport or Express.js for HTTP transport
74
- */
75
68
  async function main() {
76
69
  try {
77
- // Handle init command
78
70
  if (process.argv[2] === 'init') {
79
71
  await handleInitCommand();
80
72
  return;
@@ -82,13 +74,10 @@ async function main() {
82
74
 
83
75
  console.error('Starting MCP-Connect CLI...');
84
76
 
85
- // Check if config file path is provided as argument
86
77
  const configArg = process.argv[2];
87
- /** @type {string|null} */
88
78
  let configPath = null;
89
79
 
90
80
  if (configArg) {
91
- // Config file path provided as argument
92
81
  const fullPath = resolve(configArg);
93
82
  if (existsSync(fullPath)) {
94
83
  configPath = fullPath;
@@ -97,7 +86,6 @@ async function main() {
97
86
  process.exit(1);
98
87
  }
99
88
  } else {
100
- // Look for config file in current directory (prioritize .js and .mjs)
101
89
  const configPaths = ['mcp.config.js', 'mcp.config.mjs', 'mcp.config.ts'];
102
90
 
103
91
  for (const path of configPaths) {
@@ -134,7 +122,6 @@ export default defineMCP({
134
122
 
135
123
  let configModule;
136
124
  try {
137
- // Handle TypeScript config files
138
125
  if (configPath.endsWith('.ts')) {
139
126
  console.error('TypeScript config detected. For Node.js compatibility:');
140
127
  console.error('1. Rename mcp.config.ts to mcp.config.js and convert to JavaScript');
@@ -157,7 +144,6 @@ export default defineMCP({
157
144
  process.exit(1);
158
145
  }
159
146
 
160
- // Import config file using Node.js ES modules
161
147
  const fileUrl = configPath.startsWith('/')
162
148
  ? `file://${configPath}`
163
149
  : `file:///${configPath.replace(/\\/g, '/')}`;
@@ -190,7 +176,6 @@ export default defineMCP({
190
176
  process.exit(1);
191
177
  }
192
178
 
193
- // Validate config using defineMCP (in case user didn't use it)
194
179
  let validatedConfig;
195
180
  try {
196
181
  validatedConfig = typeof config === 'function' ? config : defineMCP(config);
@@ -199,11 +184,9 @@ export default defineMCP({
199
184
  process.exit(1);
200
185
  }
201
186
 
202
- // Create and start MCP server
203
187
  const server = new MCPConnectServer(validatedConfig);
204
188
  await server.start();
205
189
 
206
- // Handle graceful shutdown
207
190
  process.on('SIGINT', async () => {
208
191
  console.error('Shutting down...');
209
192
  try {
@@ -229,8 +212,6 @@ export default defineMCP({
229
212
  }
230
213
  }
231
214
 
232
- // Run CLI if this file is executed directly
233
- // Multiple checks to ensure main() runs when CLI is executed
234
215
  const isMainModule =
235
216
  process.argv[1] &&
236
217
  (import.meta.url === `file://${process.argv[1]}` ||
package/src/defineMCP.js CHANGED
@@ -1,21 +1,7 @@
1
1
  import { formatValidationErrors, validateConfig } from './utils/configValidation.js';
2
2
  import { logger } from './utils/logger.js';
3
3
 
4
- /**
5
- * Define MCP configuration with tools and server settings
6
- * This is the main user-facing API that converts simple tool definitions
7
- * into MCP-compliant format with comprehensive validation
8
- *
9
- * @param {Object} config - Configuration object
10
- * @param {string} config.name - Server name
11
- * @param {string} config.version - Server version
12
- * @param {string} [config.description] - Server description
13
- * @param {import('./types/mcp.js').ToolDefinition[]} config.tools - Tool definitions
14
- * @returns {import('./types/mcp.js').MCPConfig} MCP configuration object
15
- * @throws {Error} If configuration is invalid
16
- */
17
4
  export function defineMCP(config) {
18
- // Comprehensive configuration validation
19
5
  const validationResult = validateConfig(config);
20
6
 
21
7
  if (!validationResult.isValid) {
@@ -24,7 +10,6 @@ export function defineMCP(config) {
24
10
  throw new Error(`Invalid MCP configuration:\n${errorMessage}`);
25
11
  }
26
12
 
27
- // Log warnings if any
28
13
  if (validationResult.warnings.length > 0) {
29
14
  const warningMessage = formatValidationErrors({
30
15
  isValid: true,
@@ -34,11 +19,8 @@ export function defineMCP(config) {
34
19
  logger.warn('Configuration warnings', warningMessage);
35
20
  }
36
21
 
37
- // Convert validated tool definitions to MCP format
38
- /** @type {import('./types/mcp.js').MCPTool[]} */
39
22
  const mcpTools = config.tools.map((tool) => {
40
23
  if (Array.isArray(tool)) {
41
- // Handle [name, function] format
42
24
  const [name, handler] = tool;
43
25
  return {
44
26
  name: name.trim(),
@@ -51,7 +33,6 @@ export function defineMCP(config) {
51
33
  handler,
52
34
  };
53
35
  } else {
54
- // Handle object format
55
36
  const { name, handler, description, schema } = tool;
56
37
  return {
57
38
  name: name.trim(),
@@ -66,7 +47,6 @@ export function defineMCP(config) {
66
47
  }
67
48
  });
68
49
 
69
- // Return MCP-compliant config
70
50
  return {
71
51
  name: config.name,
72
52
  version: config.version,