@myatkyawthu/mcp-connect 0.1.1 → 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/README.md CHANGED
@@ -5,304 +5,166 @@
5
5
  [![npm version](https://badge.fury.io/js/mcp-connect.svg)](https://www.npmjs.com/package/mcp-connect)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
7
 
8
- ## 🚀 Quick Start
8
+ ## 🚀 Claude Desktop Setup (5 Minutes)
9
9
 
10
- ### Option 1: Global Installation (Recommended)
10
+ ### Step 1: Install mcp-connect
11
11
 
12
12
  ```bash
13
- # Install globally with npm
14
- npm install -g mcp-connect
13
+ npm install -g @myatkyawthu/mcp-connect
15
14
  ```
15
+ ### Step 2: Create mcp.config.js
16
16
 
17
- Create `mcp.config.js` in your project:
18
-
19
- ```javascript
20
- import { defineMCP } from "mcp-connect"
21
-
22
- export default defineMCP({
23
- name: "My App",
24
- version: "1.0.0",
25
- tools: [
26
- ["hello", async ({ name }) => `Hello ${name}!`],
27
- ["getTodos", async () => [{ id: 1, title: "Buy milk" }]],
28
- ]
29
- })
30
- ```
31
-
32
- Start the server from your project directory:
17
+ ### Step 2: Create Your MCP Server
33
18
 
34
19
  ```bash
35
- mcp-connect
36
- ```
37
-
38
- ### Option 2: Local Installation
20
+ # Navigate to your project directory
21
+ cd your-project
39
22
 
40
- ```bash
41
- # Install locally with npm
42
- npm install mcp-connect
23
+ # Generate sample config
24
+ mcp-connect init
43
25
  ```
44
26
 
45
- Start with npx:
46
-
47
- ```bash
48
- npx mcp-connect
49
- ```
50
-
51
- Connect your AI agent via STDIO transport (Claude Desktop)!
52
-
53
- ## 🎯 Features
54
-
55
- - **Zero Config** - Works out of the box with minimal setup
56
- - **MCP Compliant** - Uses official MCP SDK with JSON-RPC 2.0
57
- - **STDIO Transport** - Direct communication with Claude Desktop and other MCP clients
58
- - **Pure JavaScript** - No compilation needed, runs directly on Node.js 18+
59
- - **Production Ready** - Enterprise-grade error handling and logging
60
- - **Performance Monitoring** - Built-in execution timing and debugging
61
- - **Universal** - Works with npm, pnpm, and yarn
62
- - **Claude Desktop Ready** - Works seamlessly with Claude Desktop and other MCP clients
63
- - **Simple API** - Clean, declarative tool definitions with flexible formats
64
-
65
- ## 📖 Documentation
66
-
67
- ### Tool Definition Formats
27
+ This creates `mcp.config.js` with example tools:
68
28
 
69
29
  ```javascript
70
- // Tuple format (simple)
71
- ["toolName", async (args) => result]
72
-
73
- // Object format (with metadata)
74
- {
75
- name: "toolName",
76
- description: "What this tool does",
77
- handler: async (args) => result,
78
- schema: { /* JSON schema for input validation */ }
79
- }
80
- ```
81
-
82
- ### Configuration Options
30
+ import { defineMCP } from "@myatkyawthu/mcp-connect";
83
31
 
84
- ```javascript
85
- defineMCP({
86
- name: "My MCP Server", // Required: Server name
87
- version: "1.0.0", // Required: Server version
88
- description: "My server", // Optional: Description
32
+ export default defineMCP({
33
+ name: "My MCP App",
34
+ version: "1.0.0",
89
35
  tools: [
90
- // Your tool definitions
36
+ ["hello", async ({ name = "World" }) => `Hello ${name}!`],
37
+ ["echo", async ({ message }) => `Echo: ${message}`]
91
38
  ]
92
- })
93
- ```
94
-
95
- ## 🔧 CLI Usage
96
-
97
- ### Global Installation
98
-
99
- ```bash
100
- # Start server (looks for mcp.config.ts in current directory)
101
- mcp-connect
102
-
103
- # With debug logging and performance tracking
104
- MCP_DEBUG=1 mcp-connect
105
-
106
- # Performance tracking only
107
- MCP_PERF=1 mcp-connect
108
-
109
- # Custom log level
110
- MCP_LOG_LEVEL=warn mcp-connect
111
- ```
112
-
113
- ### Local Installation
114
-
115
- ```bash
116
- # Using npx
117
- npx mcp-connect
118
-
119
- # With environment variables
120
- MCP_DEBUG=1 npx mcp-connect
121
- ```
122
-
123
- ## 🔍 Logging & Debugging
124
-
125
- MCP-Connect includes comprehensive logging and debugging features:
126
-
127
- ### Environment Variables
128
-
129
- - `MCP_DEBUG=1` - Enable debug logging with full MCP message tracing
130
- - `MCP_PERF=1` - Enable performance tracking for tool execution times
131
- - `MCP_LOG_LEVEL=level` - Set minimum log level (debug, info, warn, error)
132
-
133
- ### Log Output Examples
134
-
135
- ```
136
- [MCP-INFO] 2024-01-15T10:30:45.123Z MCP server "Todo App" started (stdio, 3 tools)
137
- [MCP-DEBUG] 2024-01-15T10:30:46.456Z Tool execution started: addTodo [req:abc123]
138
- [MCP-INFO] 2024-01-15T10:30:46.478Z Tool execution completed: addTodo (22ms) [req:abc123]
139
- ```
140
-
141
- ## ✅ Configuration Validation
142
-
143
- MCP-Connect provides comprehensive configuration validation with helpful error messages:
144
-
145
- ```
146
- ❌ Configuration Errors:
147
- 1. tools[0].name: Tool name must be a non-empty string
148
- Current value: ""
149
- Suggestion: "myToolName"
150
-
151
- ⚠️ Configuration Warnings:
152
- 1. version: Version doesn't follow semantic versioning
153
- Suggestion: Use format: "1.0.0"
39
+ });
154
40
  ```
41
+ ### Step 3: Test Locally
155
42
 
156
- ## 🛡️ Error Handling
157
-
158
- - **Tool Execution Timeouts** - 30-second default timeout prevents hanging
159
- - **Graceful Shutdown** - Proper cleanup on SIGINT/SIGTERM
160
- - **Sanitized Errors** - Safe error messages without sensitive information
161
- - **MCP-Compliant Errors** - Proper JSON-RPC error format
162
-
163
- ## 🤝 AI Agent Integration
164
-
165
- ### Claude Desktop
43
+ ### Step 3: Configure Claude Desktop
166
44
 
167
- #### Global Installation (Recommended)
45
+ Open Claude Desktop config file:
46
+ - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
47
+ - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
168
48
 
169
- Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
49
+ Add your MCP server:
170
50
 
171
51
  ```json
172
52
  {
173
53
  "mcpServers": {
174
54
  "my-app": {
175
55
  "command": "mcp-connect",
176
- "cwd": "/path/to/your/project"
56
+ "args": ["C:/full/path/to/your/mcp.config.js"]
177
57
  }
178
58
  }
179
59
  }
180
60
  ```
181
61
 
182
- #### Local Installation
62
+ **Important**: Use the full absolute path to your `mcp.config.js` file.
183
63
 
184
- ```json
185
- {
186
- "mcpServers": {
187
- "my-app": {
188
- "command": "npx",
189
- "args": ["mcp-connect"],
190
- "cwd": "/path/to/your/project"
191
- }
192
- }
193
- }
194
- ```
64
+ ### Step 4: Start & Test
195
65
 
196
- #### Alternative: Package Script
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"*
197
69
 
198
- Add to your project's `package.json`:
70
+ **Done!** Your functions are now available to Claude Desktop.
199
71
 
200
- ```json
201
- {
202
- "scripts": {
203
- "mcp": "mcp-connect"
204
- }
205
- }
72
+ ---
73
+
74
+ ## 📖 Tool Definition Guide
75
+
76
+ ### Simple Format (Recommended)
77
+
78
+ ```javascript
79
+ // Just name and function
80
+ ["toolName", async (args) => "result"]
206
81
  ```
82
+ ## 🔧 CLI Usage
207
83
 
208
- Then in Claude Desktop config:
84
+ ### Advanced Format (With Validation)
209
85
 
210
- ```json
86
+ ```javascript
211
87
  {
212
- "mcpServers": {
213
- "my-app": {
214
- "command": "npm",
215
- "args": ["run", "mcp"],
216
- "cwd": "/path/to/your/project"
217
- }
218
- }
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}`
219
98
  }
220
99
  ```
221
100
 
222
- ### Other MCP Clients
223
-
224
- Any MCP-compliant client can connect using the STDIO transport. The server implements the full MCP specification with:
101
+ ## 🛠 Development Commands
225
102
 
226
- - `tools/list` - List available tools
227
- - `tools/call` - Execute tool functions
228
- - Proper JSON-RPC 2.0 messaging
229
- - Standard MCP lifecycle management
103
+ ```bash
104
+ # Start with auto-reload during development
105
+ npm run dev
230
106
 
231
- ## 📁 Examples
107
+ # Start server with specific config file
108
+ mcp-connect /path/to/your/mcp.config.js
232
109
 
233
- ### Todo App Example
110
+ # Format code
111
+ npm run format
234
112
 
235
- ```javascript
236
- import { defineMCP } from "mcp-connect";
113
+ # Lint code
114
+ npm run lint
115
+ ```
237
116
 
238
- const todos = [{ id: 1, title: "Buy milk", completed: false }];
117
+ ## 🔧 Troubleshooting
239
118
 
240
- export default defineMCP({
241
- name: "Todo App",
242
- version: "1.0.0",
243
- description: "Simple todo list management via MCP",
244
- tools: [
245
- // Simple tuple format
246
- ["getTodos", async () => todos],
247
-
248
- // Object format with schema validation
249
- {
250
- name: "addTodo",
251
- description: "Add a new todo item",
252
- schema: {
253
- type: "object",
254
- properties: {
255
- title: { type: "string", description: "Todo title" }
256
- },
257
- required: ["title"]
258
- },
259
- handler: async ({ title }) => {
260
- const newTodo = { id: Date.now(), title, completed: false };
261
- todos.push(newTodo);
262
- return newTodo;
263
- }
264
- }
265
- ]
266
- });
119
+ ### Config File Not Found
120
+ ```bash
121
+ # Create sample config
122
+ mcp-connect init
267
123
  ```
268
124
 
269
- Check out the [examples](./examples) directory for complete working examples.
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
270
129
 
271
- ## 🛠 Development
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
272
134
 
273
- ```bash
274
- # Clone and install
275
- git clone https://github.com/myat-kyaw-thu/MCP_Indigration_Package-NPM.git
276
- cd mcp-connect
277
- npm install
278
-
279
- # Run example with debug logging
280
- cd examples/todo-app
281
- MCP_DEBUG=1 node ../../src/cli.js
135
+ ## 📋 Examples
282
136
 
283
- # Test global installation locally
284
- npm link
285
- cd /path/to/test/project
286
- mcp-connect
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
+ ```
287
144
 
288
- # Run tests
289
- npm test
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
+ ```
290
152
 
291
- # Lint and format code
292
- npm run lint
293
- npm run format
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
+ }]
294
159
  ```
295
160
 
296
- ## 🏗️ Architecture
161
+ ## 🌐 Other MCP Clients
297
162
 
298
- - **Pure JavaScript** with JSDoc type annotations
299
- - **ESM modules** with Node.js 18+ support
300
- - **Express.js** HTTP server integration
301
- - **Official MCP SDK** integration
302
- - **Structured logging** with performance metrics
303
- - **Comprehensive validation** with user-friendly errors
304
- - **Pure MCP implementation** focused on STDIO transport
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
305
167
 
306
168
  ## 📄 License
307
169
 
308
- MIT © [myat-kyaw-thu](https://github.com/myat-kyaw-thu)
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.1.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": "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.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
+ }
63
63
  }