@hellocrossman/mcp-sdk 0.1.2 → 0.3.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.
Files changed (76) hide show
  1. package/README.md +99 -28
  2. package/dist/cjs/cli.d.ts +3 -0
  3. package/dist/cjs/cli.d.ts.map +1 -0
  4. package/dist/cjs/cli.js +610 -0
  5. package/dist/cjs/cli.js.map +1 -0
  6. package/dist/cjs/db-executor.d.ts +4 -0
  7. package/dist/cjs/db-executor.d.ts.map +1 -0
  8. package/dist/cjs/db-executor.js +152 -0
  9. package/dist/cjs/db-executor.js.map +1 -0
  10. package/dist/cjs/db-introspect.d.ts +18 -0
  11. package/dist/cjs/db-introspect.d.ts.map +1 -0
  12. package/dist/cjs/db-introspect.js +145 -0
  13. package/dist/cjs/db-introspect.js.map +1 -0
  14. package/dist/cjs/db-tool-generator.d.ts +9 -0
  15. package/dist/cjs/db-tool-generator.d.ts.map +1 -0
  16. package/dist/cjs/db-tool-generator.js +167 -0
  17. package/dist/cjs/db-tool-generator.js.map +1 -0
  18. package/dist/cjs/enrichment.d.ts +13 -0
  19. package/dist/cjs/enrichment.d.ts.map +1 -0
  20. package/dist/cjs/enrichment.js +36 -0
  21. package/dist/cjs/enrichment.js.map +1 -0
  22. package/dist/cjs/index.d.ts +2 -0
  23. package/dist/cjs/index.d.ts.map +1 -1
  24. package/dist/cjs/index.js +4 -1
  25. package/dist/cjs/index.js.map +1 -1
  26. package/dist/cjs/introspect.d.ts.map +1 -1
  27. package/dist/cjs/introspect.js +10 -4
  28. package/dist/cjs/introspect.js.map +1 -1
  29. package/dist/cjs/route-scan.d.ts +9 -0
  30. package/dist/cjs/route-scan.d.ts.map +1 -0
  31. package/dist/cjs/route-scan.js +140 -0
  32. package/dist/cjs/route-scan.js.map +1 -0
  33. package/dist/cjs/server.d.ts +1 -0
  34. package/dist/cjs/server.d.ts.map +1 -1
  35. package/dist/cjs/server.js +113 -15
  36. package/dist/cjs/server.js.map +1 -1
  37. package/dist/cjs/types.d.ts +6 -0
  38. package/dist/cjs/types.d.ts.map +1 -1
  39. package/dist/cli.d.ts +3 -0
  40. package/dist/cli.d.ts.map +1 -0
  41. package/dist/cli.js +582 -0
  42. package/dist/cli.js.map +1 -0
  43. package/dist/db-executor.d.ts +4 -0
  44. package/dist/db-executor.d.ts.map +1 -0
  45. package/dist/db-executor.js +125 -0
  46. package/dist/db-executor.js.map +1 -0
  47. package/dist/db-introspect.d.ts +18 -0
  48. package/dist/db-introspect.d.ts.map +1 -0
  49. package/dist/db-introspect.js +118 -0
  50. package/dist/db-introspect.js.map +1 -0
  51. package/dist/db-tool-generator.d.ts +9 -0
  52. package/dist/db-tool-generator.d.ts.map +1 -0
  53. package/dist/db-tool-generator.js +163 -0
  54. package/dist/db-tool-generator.js.map +1 -0
  55. package/dist/enrichment.d.ts +13 -0
  56. package/dist/enrichment.d.ts.map +1 -0
  57. package/dist/enrichment.js +33 -0
  58. package/dist/enrichment.js.map +1 -0
  59. package/dist/index.d.ts +2 -0
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +1 -0
  62. package/dist/index.js.map +1 -1
  63. package/dist/introspect.d.ts.map +1 -1
  64. package/dist/introspect.js +10 -4
  65. package/dist/introspect.js.map +1 -1
  66. package/dist/route-scan.d.ts +9 -0
  67. package/dist/route-scan.d.ts.map +1 -0
  68. package/dist/route-scan.js +133 -0
  69. package/dist/route-scan.js.map +1 -0
  70. package/dist/server.d.ts +1 -0
  71. package/dist/server.d.ts.map +1 -1
  72. package/dist/server.js +113 -15
  73. package/dist/server.js.map +1 -1
  74. package/dist/types.d.ts +6 -0
  75. package/dist/types.d.ts.map +1 -1
  76. package/package.json +13 -3
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @hellocrossman/mcp-sdk
2
2
 
3
- Turn your Express API into an MCP server with two lines of code.
3
+ Turn your Express API into an MCP server with zero configuration.
4
4
 
5
- Your customers can access your business data and logic through AI assistants (Claude, ChatGPT, Cursor) instead of traditional UIs.
5
+ Auto-discovers your routes, database tables, and generates AI-enhanced tools so your customers can access your business data through AI assistants (Claude, ChatGPT, Cursor).
6
6
 
7
7
  ## Install
8
8
 
@@ -10,7 +10,15 @@ Your customers can access your business data and logic through AI assistants (Cl
10
10
  npm install @hellocrossman/mcp-sdk
11
11
  ```
12
12
 
13
- ## Quick Start
13
+ ## Zero-Config Setup
14
+
15
+ ```bash
16
+ npx @hellocrossman/mcp-sdk init
17
+ ```
18
+
19
+ This automatically finds your Express app file, adds the MCP setup, and you're done. Restart your app and visit `/mcp` to see your tools.
20
+
21
+ ## Manual Setup
14
22
 
15
23
  ```typescript
16
24
  import express from 'express';
@@ -21,7 +29,6 @@ const app = express();
21
29
  // Your existing routes
22
30
  app.get('/api/customers', (req, res) => { /* ... */ });
23
31
  app.post('/api/orders', (req, res) => { /* ... */ });
24
- app.get('/api/orders/:id', (req, res) => { /* ... */ });
25
32
 
26
33
  // Add MCP in one line
27
34
  createMcpServer({ app });
@@ -29,14 +36,55 @@ createMcpServer({ app });
29
36
  app.listen(3000);
30
37
  ```
31
38
 
32
- That's it. Visit `localhost:3000/mcp` to see your auto-discovered tools.
39
+ ## What Gets Discovered
40
+
41
+ The SDK automatically finds and exposes:
42
+
43
+ ### Express Routes
44
+ Every API route becomes a callable tool:
45
+
46
+ | HTTP Method | Tool Name Example | Description |
47
+ |---|---|---|
48
+ | GET | `get_customers_by_id` | Fetches a record by ID |
49
+ | POST | `create_orders` | Creates a new record |
50
+ | PUT/PATCH | `update_orders_by_id` | Updates a record |
51
+ | DELETE | `delete_orders_by_id` | Deletes a record |
33
52
 
34
- ## How It Works
53
+ ### Database Tables
54
+ If `DATABASE_URL` is in your environment (PostgreSQL), the SDK auto-discovers every table and generates tools:
35
55
 
36
- 1. **Auto-discovers your routes** -- Reads your Express router and finds all registered API routes
37
- 2. **Generates MCP tools** -- Each route becomes a tool with a name, description, and input schema
38
- 3. **Serves the MCP protocol** -- Creates a `/mcp` endpoint that speaks Streamable HTTP transport
39
- 4. **Calls your actual routes** -- When a tool is invoked, it makes an internal HTTP request to your real endpoint, so all your auth, validation, and middleware still runs
56
+ - **`list_<table>`** -- Query all records with filtering and pagination
57
+ - **`get_<table>_by_id`** -- Fetch a single record by primary key
58
+
59
+ No extra configuration needed. The SDK detects the database connection from your environment variables automatically.
60
+
61
+ ### Smart Security
62
+ Sensitive tables are **auto-hidden** by default:
63
+ - `users`, `accounts`, `sessions`, `tokens`, `passwords`, `api_keys`, `migrations`
64
+
65
+ Sensitive columns are redacted in query results:
66
+ - `password`, `password_hash`, `secret`, `api_key`, `access_token`, `credit_card`
67
+
68
+ ### AI-Enhanced Descriptions
69
+ Tool names and descriptions are automatically enriched by AI to be clear and business-oriented. Instead of `list_scans`, you get `browse_scan_history` with a description like "Retrieve all scan records to review analysis results and status."
70
+
71
+ ## Discovery Report
72
+
73
+ On startup, you'll see a clean summary in your console:
74
+
75
+ ```
76
+ [mcp-sdk] ---- Discovery Report ----
77
+ [mcp-sdk] Express routes: 4 found, 4 tools generated
78
+ [mcp-sdk] + create_scans (POST /api/scans)
79
+ [mcp-sdk] + get_scan_details (GET /api/scans/:id)
80
+ [mcp-sdk] Database: 8 tables found, 12 tools generated
81
+ [mcp-sdk] + list_roadmap_items (DB_QUERY)
82
+ [mcp-sdk] + get_feature_details (DB_QUERY)
83
+ [mcp-sdk] Auto-hidden (sensitive): users, sessions
84
+ [mcp-sdk] AI enrichment: applied
85
+ [mcp-sdk] Total tools: 16
86
+ [mcp-sdk] ----------------------------
87
+ ```
40
88
 
41
89
  ## Options
42
90
 
@@ -44,35 +92,57 @@ That's it. Visit `localhost:3000/mcp` to see your auto-discovered tools.
44
92
  createMcpServer({
45
93
  app, // Your Express app (required)
46
94
  path: '/mcp', // MCP endpoint path (default: '/mcp')
47
- name: 'my-app', // Server name shown to AI clients (default: 'mcp-server')
48
- version: '1.0.0', // Server version (default: '1.0.0')
95
+ name: 'my-app', // Server name shown to AI clients
96
+ version: '1.0.0', // Server version
49
97
  description: 'My MCP server', // Server description
50
- routePrefix: '/api', // Only expose routes starting with this (default: '/api')
51
- excludeRoutes: ['/api/admin/*'], // Hide specific routes (supports * wildcards)
98
+ routePrefix: '/api', // Only expose routes starting with this
99
+ excludeRoutes: ['/api/admin/*'], // Hide specific routes (supports wildcards)
100
+
101
+ // Database options
102
+ database: true, // Auto-detect database (default: true)
103
+ excludeTables: ['internal_logs'], // Hide specific tables
104
+ includeTables: ['products'], // Only expose these tables (overrides exclude)
105
+ includeWrites: false, // Generate create tools for tables (default: false)
106
+
107
+ // AI enrichment
108
+ enrichment: true, // Auto-enrich tool descriptions (default: true)
52
109
  });
53
110
  ```
54
111
 
55
- ## What Gets Exposed
112
+ ## Controlling What's Exposed
113
+
114
+ **Hide specific tables:**
115
+ ```typescript
116
+ createMcpServer({ app, excludeTables: ['internal_logs', 'analytics'] });
117
+ ```
118
+
119
+ **Only expose specific tables:**
120
+ ```typescript
121
+ createMcpServer({ app, includeTables: ['products', 'orders'] });
122
+ ```
123
+
124
+ **Enable write operations:**
125
+ ```typescript
126
+ createMcpServer({ app, includeWrites: true });
127
+ ```
56
128
 
57
- | HTTP Method | Tool Prefix | Example Route | Tool Name |
58
- |---|---|---|---|
59
- | GET | `get_` | `/api/customers/:id` | `get_customers_by_id` |
60
- | POST | `create_` | `/api/orders` | `create_orders` |
61
- | PUT/PATCH | `update_` | `/api/orders/:id` | `update_orders_by_id` |
62
- | DELETE | `delete_` | `/api/orders/:id` | `delete_orders_by_id` |
129
+ **Disable database discovery:**
130
+ ```typescript
131
+ createMcpServer({ app, database: false });
132
+ ```
63
133
 
64
134
  ## Security
65
135
 
66
136
  - Only routes matching `routePrefix` are exposed (default: `/api`)
67
- - Use `excludeRoutes` to hide admin or internal endpoints
68
- - Tool execution goes through your existing Express middleware stack -- auth, rate limiting, validation all still apply
69
- - No direct database access -- the SDK only calls your routes
137
+ - Sensitive tables are auto-hidden (users, sessions, tokens, migrations, etc.)
138
+ - Sensitive columns are redacted in all query results
139
+ - Database tools are read-only by default (opt-in for writes)
140
+ - Route-based tools go through your existing Express middleware (auth, rate limiting, validation)
141
+ - Use `excludeRoutes` and `excludeTables` for additional control
70
142
 
71
143
  ## Connecting AI Clients
72
144
 
73
- Once your MCP server is running, AI assistants can connect to it:
74
-
75
- **Claude Desktop** -- Add to your MCP settings:
145
+ **Claude Desktop:**
76
146
  ```json
77
147
  {
78
148
  "mcpServers": {
@@ -83,13 +153,14 @@ Once your MCP server is running, AI assistants can connect to it:
83
153
  }
84
154
  ```
85
155
 
86
- **Cursor** -- Add the MCP server URL in Cursor settings under MCP Servers.
156
+ **Cursor:** Add the MCP server URL in Cursor settings under MCP Servers.
87
157
 
88
158
  ## Requirements
89
159
 
90
160
  - Node.js >= 18
91
161
  - Express >= 4
92
162
  - Zod >= 3
163
+ - pg >= 8 (optional, for database discovery)
93
164
 
94
165
  ## License
95
166
 
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":""}