@myatkyawthu/mcp-connect 0.1.1 → 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,308 +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
- ## 🚀 Quick Start
9
-
10
- ### Option 1: Global Installation (Recommended)
11
-
12
- ```bash
13
- # Install globally with npm
14
- npm install -g mcp-connect
15
- ```
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:
33
-
34
- ```bash
35
- mcp-connect
36
- ```
37
-
38
- ### Option 2: Local Installation
39
-
40
- ```bash
41
- # Install locally with npm
42
- npm install mcp-connect
43
- ```
44
-
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
68
-
69
- ```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
83
-
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
89
- tools: [
90
- // Your tool definitions
91
- ]
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"
154
- ```
155
-
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
166
-
167
- #### Global Installation (Recommended)
168
-
169
- Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
170
-
171
- ```json
172
- {
173
- "mcpServers": {
174
- "my-app": {
175
- "command": "mcp-connect",
176
- "cwd": "/path/to/your/project"
177
- }
178
- }
179
- }
180
- ```
181
-
182
- #### Local Installation
183
-
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
- ```
195
-
196
- #### Alternative: Package Script
197
-
198
- Add to your project's `package.json`:
199
-
200
- ```json
201
- {
202
- "scripts": {
203
- "mcp": "mcp-connect"
204
- }
205
- }
206
- ```
207
-
208
- Then in Claude Desktop config:
209
-
210
- ```json
211
- {
212
- "mcpServers": {
213
- "my-app": {
214
- "command": "npm",
215
- "args": ["run", "mcp"],
216
- "cwd": "/path/to/your/project"
217
- }
218
- }
219
- }
220
- ```
221
-
222
- ### Other MCP Clients
223
-
224
- Any MCP-compliant client can connect using the STDIO transport. The server implements the full MCP specification with:
225
-
226
- - `tools/list` - List available tools
227
- - `tools/call` - Execute tool functions
228
- - Proper JSON-RPC 2.0 messaging
229
- - Standard MCP lifecycle management
230
-
231
- ## 📁 Examples
232
-
233
- ### Todo App Example
234
-
235
- ```javascript
236
- import { defineMCP } from "mcp-connect";
237
-
238
- const todos = [{ id: 1, title: "Buy milk", completed: false }];
239
-
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
- });
267
- ```
268
-
269
- Check out the [examples](./examples) directory for complete working examples.
270
-
271
- ## 🛠 Development
272
-
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
282
-
283
- # Test global installation locally
284
- npm link
285
- cd /path/to/test/project
286
- mcp-connect
287
-
288
- # Run tests
289
- npm test
290
-
291
- # Lint and format code
292
- npm run lint
293
- npm run format
294
- ```
295
-
296
- ## 🏗️ Architecture
297
-
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
305
-
306
- ## 📄 License
307
-
308
- MIT © [myat-kyaw-thu](https://github.com/myat-kyaw-thu)
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
+ MIT © [myat-kyaw-thu](https://github.com/myat-kyaw-thu)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myatkyawthu/mcp-connect",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
4
4
  "description": "Dead simple MCP (Model Context Protocol) server for exposing your app functions to AI agents",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -12,7 +12,7 @@
12
12
  }
13
13
  },
14
14
  "bin": {
15
- "mcp-connect": "./src/cli.js"
15
+ "mcp-connect": "src/cli.js"
16
16
  },
17
17
  "files": [
18
18
  "src",
@@ -43,7 +43,7 @@
43
43
  "license": "MIT",
44
44
  "repository": {
45
45
  "type": "git",
46
- "url": "https://github.com/myat-kyaw-thu/MCP_Indigration_Package-NPM.git"
46
+ "url": "git+https://github.com/myat-kyaw-thu/MCP_Indigration_Package-NPM.git"
47
47
  },
48
48
  "bugs": {
49
49
  "url": "https://github.com/myat-kyaw-thu/MCP_Indigration_Package-NPM/issues"