@mcp-use/inspector 0.3.2 → 0.3.5
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 +457 -129
- package/dist/cli/inspect.cjs +19 -129
- package/dist/client/assets/index-CObt6NY0.css +1 -0
- package/dist/client/assets/index-D8xpCgi7.js +1681 -0
- package/dist/client/index.html +2 -2
- package/dist/server/chunk-2CGL7VW4.js +75 -0
- package/dist/server/chunk-KT6SE3BW.js +125 -0
- package/dist/server/chunk-LLCPK3RJ.js +124 -0
- package/dist/server/chunk-PKBMQBKP.js +7 -0
- package/dist/server/index.js +8 -7
- package/dist/server/mcp-inspector.js +7 -132
- package/dist/server/middleware.d.ts.map +1 -1
- package/dist/server/middleware.js +8 -145
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +254 -233
- package/dist/server/shared-utils.d.ts +28 -0
- package/dist/server/shared-utils.d.ts.map +1 -0
- package/dist/server/shared-utils.js +13 -0
- package/package.json +36 -28
- package/dist/cli/inspect.js +0 -265
- package/dist/client/assets/index-BOon65c9.css +0 -1
- package/dist/client/assets/index-sdbH0tuu.js +0 -1656
- package/dist/index.js +0 -107
- package/dist/server/favicon-proxy.d.ts +0 -4
- package/dist/server/favicon-proxy.d.ts.map +0 -1
- package/dist/server/favicon-proxy.js +0 -123
- package/dist/server/standalone.d.ts +0 -9
- package/dist/server/standalone.d.ts.map +0 -1
- package/dist/server/standalone.js +0 -228
- package/dist/server/unified.d.ts +0 -9
- package/dist/server/unified.d.ts.map +0 -1
- package/dist/server/unified.js +0 -294
package/README.md
CHANGED
|
@@ -1,49 +1,85 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
<div align="center" style="margin: 0 auto; max-width: 80%;">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mcp-use/mcp-use-ts/main/packages/mcp-use/static/logo_white.svg">
|
|
4
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/mcp-use/mcp-use-ts/main/packages/mcp-use/static/logo_black.svg">
|
|
5
|
+
<img alt="mcp use logo" src="https://raw.githubusercontent.com/mcp-use/mcp-use-ts/main/packages/mcp-use/static/logo_white.svg" width="80%" style="margin: 20px auto;">
|
|
6
|
+
</picture>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
<h1 align="center">MCP Inspector</h1>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/@mcp-use/inspector" alt="NPM Downloads">
|
|
13
|
+
<img src="https://img.shields.io/npm/dw/@mcp-use/inspector.svg"/></a>
|
|
14
|
+
<a href="https://www.npmjs.com/package/@mcp-use/inspector" alt="NPM Version">
|
|
15
|
+
<img src="https://img.shields.io/npm/v/@mcp-use/inspector.svg"/></a>
|
|
16
|
+
<a href="https://github.com/mcp-use/mcp-use-ts/blob/main/LICENSE" alt="License">
|
|
17
|
+
<img src="https://img.shields.io/github/license/mcp-use/mcp-use-ts" /></a>
|
|
18
|
+
<a href="https://github.com/mcp-use/mcp-use-ts/stargazers" alt="GitHub stars">
|
|
19
|
+
<img src="https://img.shields.io/github/stars/mcp-use/mcp-use-ts?style=social" /></a>
|
|
20
|
+
<a href="https://discord.gg/XkNkSkMz3V" alt="Discord">
|
|
21
|
+
<img src="https://dcbadge.limes.pink/api/server/XkNkSkMz3V?style=flat" /></a>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
🔍 **MCP Inspector** is a powerful web-based debugging and inspection tool for MCP (Model Context Protocol) servers. It provides a beautiful, intuitive interface for testing tools, exploring resources, managing prompts, and monitoring server connections - all from your browser. Think of it as Swagger UI for MCP servers, but better!
|
|
25
|
+
|
|
26
|
+
## 📦 Related Packages
|
|
27
|
+
|
|
28
|
+
| Package | Description | Version |
|
|
29
|
+
|---------|-------------|---------|
|
|
30
|
+
| [mcp-use](https://github.com/mcp-use/mcp-use-ts/tree/main/packages/mcp-use) | Core MCP framework | [](https://www.npmjs.com/package/mcp-use) |
|
|
31
|
+
| [@mcp-use/cli](https://github.com/mcp-use/mcp-use-ts/tree/main/packages/cli) | Build tool for MCP apps | [](https://www.npmjs.com/package/@mcp-use/cli) |
|
|
32
|
+
| [create-mcp-use-app](https://github.com/mcp-use/mcp-use-ts/tree/main/packages/create-mcp-use-app) | Create MCP apps | [](https://www.npmjs.com/package/create-mcp-use-app) |
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## ✨ Key Features
|
|
37
|
+
|
|
38
|
+
| Feature | Description |
|
|
39
|
+
|---------|-------------|
|
|
40
|
+
| **🚀 Auto-Mount** | Automatically available at `/inspector` for all MCP-Use servers |
|
|
41
|
+
| **🔌 Multi-Connection** | Connect to and manage multiple MCP servers simultaneously |
|
|
42
|
+
| **🎯 Interactive Testing** | Test tools with live execution and real-time results |
|
|
43
|
+
| **📊 Real-time Status** | Monitor connection states, errors, and server health |
|
|
44
|
+
| **🔐 OAuth Support** | Built-in OAuth flow handling with popup authentication |
|
|
45
|
+
| **💾 Persistent Sessions** | Connections saved to localStorage and auto-reconnect |
|
|
46
|
+
| **🎨 Beautiful UI** | Modern, responsive interface built with React and Tailwind |
|
|
47
|
+
| **🔍 Tool Explorer** | Browse and execute all available tools with schema validation |
|
|
48
|
+
| **📁 Resource Browser** | View and copy resource URIs with syntax highlighting |
|
|
49
|
+
| **💬 Prompt Manager** | Test and manage prompts with argument templates |
|
|
50
|
+
| **🌐 Universal Support** | Works with HTTP/SSE and WebSocket connections |
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## 🚀 Quick Start
|
|
55
|
+
|
|
56
|
+
### Method 1: Automatic with MCP-Use Server (Recommended)
|
|
57
|
+
|
|
58
|
+
When you create an MCP server with `mcp-use`, the inspector is automatically available:
|
|
22
59
|
|
|
23
60
|
```typescript
|
|
24
|
-
import { createMCPServer } from 'mcp-use'
|
|
61
|
+
import { createMCPServer } from 'mcp-use/server'
|
|
25
62
|
|
|
26
63
|
const server = createMCPServer('my-server', {
|
|
27
|
-
version: '1.0.0'
|
|
28
|
-
description: 'My awesome MCP server'
|
|
64
|
+
version: '1.0.0'
|
|
29
65
|
})
|
|
30
66
|
|
|
31
|
-
//
|
|
67
|
+
// Add your tools, resources, prompts...
|
|
32
68
|
|
|
33
69
|
server.listen(3000)
|
|
34
|
-
// Inspector
|
|
35
|
-
// Auto-connects to http://localhost:3000/mcp
|
|
70
|
+
// 🎉 Inspector automatically available at http://localhost:3000/inspector
|
|
71
|
+
// 🚀 Auto-connects to your local server at http://localhost:3000/mcp
|
|
36
72
|
```
|
|
37
73
|
|
|
38
|
-
That's it
|
|
39
|
-
|
|
74
|
+
**That's it!** No additional configuration needed. The inspector:
|
|
40
75
|
- Automatically mounts at `/inspector`
|
|
41
76
|
- Auto-connects to your local MCP server
|
|
42
|
-
- Provides
|
|
77
|
+
- Provides instant debugging capabilities
|
|
78
|
+
- Opens automatically in dev mode with `@mcp-use/cli`
|
|
43
79
|
|
|
44
|
-
###
|
|
80
|
+
### Method 2: Standalone CLI Tool
|
|
45
81
|
|
|
46
|
-
|
|
82
|
+
Use the inspector with any MCP server (local or remote):
|
|
47
83
|
|
|
48
84
|
```bash
|
|
49
85
|
# Inspect a remote server
|
|
@@ -52,158 +88,450 @@ npx mcp-inspect --url https://mcp.linear.app/sse
|
|
|
52
88
|
# Custom port
|
|
53
89
|
npx mcp-inspect --url http://localhost:3000/mcp --port 8080
|
|
54
90
|
|
|
55
|
-
#
|
|
91
|
+
# Open inspector without auto-connect
|
|
56
92
|
npx mcp-inspect
|
|
57
93
|
```
|
|
58
94
|
|
|
59
|
-
|
|
95
|
+
### Method 3: Custom Integration
|
|
60
96
|
|
|
61
|
-
|
|
97
|
+
Mount the inspector in your Express app at a custom path:
|
|
62
98
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
- **Server URL**: The URL to connect to (e.g., `https://mcp.linear.app/sse`)
|
|
67
|
-
3. Click "Connect" to add the server
|
|
68
|
-
4. The server will automatically attempt to connect
|
|
99
|
+
```typescript
|
|
100
|
+
import { mountInspector } from '@mcp-use/inspector'
|
|
101
|
+
import express from 'express'
|
|
69
102
|
|
|
70
|
-
|
|
103
|
+
const app = express()
|
|
71
104
|
|
|
72
|
-
|
|
105
|
+
// Mount at custom path
|
|
106
|
+
mountInspector(app, '/debug/inspector')
|
|
73
107
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
- **loading**: Loading tools, resources, and prompts
|
|
78
|
-
- **ready**: Connected and ready to use
|
|
79
|
-
- **failed**: Connection failed (with retry option)
|
|
80
|
-
- **pending_auth**: Waiting for OAuth authentication
|
|
108
|
+
app.listen(3000)
|
|
109
|
+
// Inspector available at http://localhost:3000/debug/inspector
|
|
110
|
+
```
|
|
81
111
|
|
|
82
|
-
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## 📖 Usage Guide
|
|
115
|
+
|
|
116
|
+
### Dashboard Overview
|
|
117
|
+
|
|
118
|
+
The main dashboard shows:
|
|
119
|
+
- **Connection Overview**: Total servers, active connections, available tools
|
|
120
|
+
- **Server List**: All configured servers with their current status
|
|
121
|
+
- **Quick Actions**: Add new server, refresh all, clear sessions
|
|
122
|
+
|
|
123
|
+
### Adding Servers
|
|
124
|
+
|
|
125
|
+
Click "Add New MCP Server" and provide:
|
|
126
|
+
- **Server Name** (optional): Friendly name for identification
|
|
127
|
+
- **Server URL**: The MCP endpoint URL
|
|
128
|
+
|
|
129
|
+
Example URLs:
|
|
130
|
+
- Local: `http://localhost:3000/mcp`
|
|
131
|
+
- Linear: `https://mcp.linear.app/sse`
|
|
132
|
+
- WebSocket: `ws://localhost:8080`
|
|
133
|
+
|
|
134
|
+
### Connection States
|
|
135
|
+
|
|
136
|
+
The inspector displays real-time connection states:
|
|
137
|
+
|
|
138
|
+
| State | Description | Action |
|
|
139
|
+
|-------|-------------|---------|
|
|
140
|
+
| 🔍 **discovering** | Finding the server | Wait |
|
|
141
|
+
| 🔄 **connecting** | Establishing connection | Wait |
|
|
142
|
+
| 🔐 **authenticating** | OAuth flow in progress | Complete auth |
|
|
143
|
+
| 📥 **loading** | Loading tools & resources | Wait |
|
|
144
|
+
| ✅ **ready** | Connected and operational | Use tools |
|
|
145
|
+
| ❌ **failed** | Connection failed | Retry |
|
|
146
|
+
| ⏳ **pending_auth** | Waiting for authentication | Click Authenticate |
|
|
147
|
+
|
|
148
|
+
### Testing Tools
|
|
149
|
+
|
|
150
|
+
1. Click **"Inspect"** on a connected server
|
|
151
|
+
2. Navigate to the **Tools** tab
|
|
152
|
+
3. Select a tool to view its schema
|
|
153
|
+
4. Click **"Execute"** to open the test panel
|
|
154
|
+
5. Enter JSON parameters
|
|
155
|
+
6. Click **"Run"** to execute
|
|
156
|
+
7. View results in real-time
|
|
157
|
+
|
|
158
|
+
Example tool execution:
|
|
159
|
+
|
|
160
|
+
```json
|
|
161
|
+
// Input for 'search_database' tool
|
|
162
|
+
{
|
|
163
|
+
"query": "user analytics",
|
|
164
|
+
"limit": 10,
|
|
165
|
+
"sortBy": "date"
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Result
|
|
169
|
+
{
|
|
170
|
+
"results": [...],
|
|
171
|
+
"total": 42,
|
|
172
|
+
"executionTime": "23ms"
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### OAuth Authentication
|
|
83
177
|
|
|
84
178
|
For servers requiring OAuth (like Linear):
|
|
85
179
|
|
|
86
|
-
1.
|
|
87
|
-
2.
|
|
88
|
-
3.
|
|
89
|
-
4.
|
|
180
|
+
1. Connection shows "pending_auth" status
|
|
181
|
+
2. Click **"Authenticate"** button
|
|
182
|
+
3. Complete OAuth in the popup window
|
|
183
|
+
4. Connection automatically completes
|
|
184
|
+
|
|
185
|
+
If popup is blocked:
|
|
186
|
+
- Click "open auth page" link
|
|
187
|
+
- Complete authentication manually
|
|
188
|
+
- Return to inspector
|
|
189
|
+
|
|
190
|
+
### Resource Management
|
|
191
|
+
|
|
192
|
+
Browse available resources:
|
|
193
|
+
- View resource descriptions
|
|
194
|
+
- Copy resource URIs
|
|
195
|
+
- Check MIME types
|
|
196
|
+
- Preview resource metadata
|
|
197
|
+
|
|
198
|
+
### Prompt Testing
|
|
199
|
+
|
|
200
|
+
Test prompts with the inspector:
|
|
201
|
+
1. Navigate to **Prompts** tab
|
|
202
|
+
2. Select a prompt
|
|
203
|
+
3. Fill in required arguments
|
|
204
|
+
4. Click **"Render"** to see output
|
|
205
|
+
5. Copy rendered prompt for use
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## 🎨 UI Components
|
|
210
|
+
|
|
211
|
+
### Server Card
|
|
212
|
+
|
|
213
|
+
Each server displays:
|
|
214
|
+
- Connection status indicator
|
|
215
|
+
- Server name and URL
|
|
216
|
+
- Available tools count
|
|
217
|
+
- Last connection time
|
|
218
|
+
- Action buttons (Connect/Disconnect/Inspect/Remove)
|
|
219
|
+
|
|
220
|
+
### Tool Explorer
|
|
221
|
+
|
|
222
|
+
The tool explorer shows:
|
|
223
|
+
- Tool name and description
|
|
224
|
+
- Input schema with types
|
|
225
|
+
- Output schema
|
|
226
|
+
- Execution panel
|
|
227
|
+
- Response viewer with syntax highlighting
|
|
90
228
|
|
|
91
|
-
###
|
|
229
|
+
### Chat Interface
|
|
92
230
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
231
|
+
Interactive chat for testing conversational flows:
|
|
232
|
+
- Send messages to test prompts
|
|
233
|
+
- View tool calls in real-time
|
|
234
|
+
- See formatted responses
|
|
235
|
+
- Copy conversation history
|
|
98
236
|
|
|
99
|
-
|
|
237
|
+
---
|
|
100
238
|
|
|
101
|
-
|
|
239
|
+
## 🔧 Advanced Features
|
|
102
240
|
|
|
103
|
-
|
|
241
|
+
### Bulk Operations
|
|
104
242
|
|
|
105
|
-
|
|
106
|
-
- **Server URL**: `https://mcp.linear.app/sse`
|
|
243
|
+
Manage multiple servers efficiently:
|
|
107
244
|
|
|
108
|
-
|
|
245
|
+
```javascript
|
|
246
|
+
// Select multiple servers
|
|
247
|
+
// Click "Bulk Actions"
|
|
248
|
+
// Choose: Connect All, Disconnect All, Remove Selected
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Session Management
|
|
252
|
+
|
|
253
|
+
Sessions are automatically saved to localStorage:
|
|
254
|
+
- Preserves server configurations
|
|
255
|
+
- Maintains connection preferences
|
|
256
|
+
- Restores on page reload
|
|
257
|
+
- Clear with "Clear All Sessions"
|
|
258
|
+
|
|
259
|
+
### Custom Themes
|
|
260
|
+
|
|
261
|
+
The inspector respects system theme preferences:
|
|
262
|
+
- Light mode for better readability
|
|
263
|
+
- Dark mode for reduced eye strain
|
|
264
|
+
- Automatic switching based on OS settings
|
|
265
|
+
|
|
266
|
+
### Keyboard Shortcuts
|
|
267
|
+
|
|
268
|
+
| Shortcut | Action |
|
|
269
|
+
|----------|--------|
|
|
270
|
+
| `Cmd/Ctrl + K` | Quick server search |
|
|
271
|
+
| `Cmd/Ctrl + N` | Add new server |
|
|
272
|
+
| `Cmd/Ctrl + R` | Refresh all connections |
|
|
273
|
+
| `Esc` | Close modals |
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## 🛠️ Configuration Examples
|
|
109
278
|
|
|
110
279
|
### Local Development Server
|
|
111
280
|
|
|
112
|
-
|
|
281
|
+
```javascript
|
|
282
|
+
// Your MCP server
|
|
283
|
+
import { createMCPServer } from 'mcp-use/server'
|
|
113
284
|
|
|
114
|
-
|
|
115
|
-
|
|
285
|
+
const server = createMCPServer('dev-server', {
|
|
286
|
+
version: '1.0.0',
|
|
287
|
+
description: 'Development MCP Server'
|
|
288
|
+
})
|
|
116
289
|
|
|
117
|
-
|
|
290
|
+
server.tool('debug_tool', {
|
|
291
|
+
description: 'Debug tool for testing',
|
|
292
|
+
parameters: z.object({
|
|
293
|
+
message: z.string()
|
|
294
|
+
}),
|
|
295
|
+
execute: async ({ message }) => {
|
|
296
|
+
console.log('Debug:', message)
|
|
297
|
+
return { received: message, timestamp: Date.now() }
|
|
298
|
+
}
|
|
299
|
+
})
|
|
118
300
|
|
|
119
|
-
|
|
301
|
+
server.listen(3000)
|
|
302
|
+
// Inspector at http://localhost:3000/inspector
|
|
303
|
+
```
|
|
120
304
|
|
|
121
|
-
|
|
122
|
-
- **Server URL**: `ws://localhost:8080`
|
|
305
|
+
### Production Server with Auth
|
|
123
306
|
|
|
124
|
-
|
|
307
|
+
```javascript
|
|
308
|
+
const server = createMCPServer('production-server', {
|
|
309
|
+
version: '1.0.0',
|
|
310
|
+
oauth: {
|
|
311
|
+
clientId: process.env.OAUTH_CLIENT_ID,
|
|
312
|
+
clientSecret: process.env.OAUTH_CLIENT_SECRET,
|
|
313
|
+
authorizationUrl: 'https://api.example.com/oauth/authorize',
|
|
314
|
+
tokenUrl: 'https://api.example.com/oauth/token'
|
|
315
|
+
}
|
|
316
|
+
})
|
|
125
317
|
|
|
126
|
-
|
|
318
|
+
// Inspector handles OAuth flow automatically
|
|
319
|
+
```
|
|
127
320
|
|
|
128
|
-
|
|
129
|
-
- **useMcp Hook**: From `mcp-use/react` for managing MCP connections
|
|
130
|
-
- **React Router**: For navigation between dashboard and server detail views
|
|
131
|
-
- **Tailwind CSS**: For styling
|
|
132
|
-
- **shadcn/ui**: UI component library
|
|
321
|
+
### Multiple Server Management
|
|
133
322
|
|
|
134
|
-
|
|
323
|
+
In the inspector, manage multiple servers:
|
|
135
324
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
325
|
+
```javascript
|
|
326
|
+
// Add servers via UI
|
|
327
|
+
// Server 1: Local Development
|
|
328
|
+
URL: http://localhost:3000/mcp
|
|
140
329
|
|
|
141
|
-
|
|
330
|
+
// Server 2: Staging
|
|
331
|
+
URL: https://staging.example.com/mcp
|
|
142
332
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
- Error handling and retry logic
|
|
147
|
-
- Session persistence via localStorage
|
|
333
|
+
// Server 3: Production
|
|
334
|
+
URL: https://api.example.com/mcp
|
|
335
|
+
```
|
|
148
336
|
|
|
149
|
-
|
|
337
|
+
---
|
|
150
338
|
|
|
151
|
-
|
|
339
|
+
## 🏗️ Architecture
|
|
152
340
|
|
|
153
|
-
|
|
154
|
-
import { mountInspector } from '@mcp-use/inspector'
|
|
155
|
-
import express from 'express'
|
|
341
|
+
The inspector is built with modern web technologies:
|
|
156
342
|
|
|
157
|
-
|
|
343
|
+
### Frontend Stack
|
|
344
|
+
- **React 19**: UI framework
|
|
345
|
+
- **React Router**: Navigation
|
|
346
|
+
- **Tailwind CSS**: Styling
|
|
347
|
+
- **shadcn/ui**: Component library
|
|
348
|
+
- **Framer Motion**: Animations
|
|
349
|
+
- **React Syntax Highlighter**: Code display
|
|
158
350
|
|
|
159
|
-
|
|
160
|
-
mountInspector(app, '/my-custom-inspector-path')
|
|
351
|
+
### Core Components
|
|
161
352
|
|
|
162
|
-
app.listen(3000)
|
|
163
353
|
```
|
|
354
|
+
src/client/
|
|
355
|
+
├── components/
|
|
356
|
+
│ ├── InspectorDashboard.tsx # Main dashboard view
|
|
357
|
+
│ ├── ServerList.tsx # Server management
|
|
358
|
+
│ ├── ServerDetail.tsx # Individual server view
|
|
359
|
+
│ ├── ToolExecutor.tsx # Tool testing interface
|
|
360
|
+
│ ├── ResourceBrowser.tsx # Resource explorer
|
|
361
|
+
│ └── ChatInterface.tsx # Interactive chat
|
|
362
|
+
├── context/
|
|
363
|
+
│ └── McpContext.tsx # Connection state management
|
|
364
|
+
└── hooks/
|
|
365
|
+
└── useMcp.ts # MCP connection hook
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### Connection Management
|
|
164
369
|
|
|
165
|
-
|
|
370
|
+
The `useMcp` hook handles:
|
|
371
|
+
- WebSocket/SSE connections
|
|
372
|
+
- Automatic reconnection
|
|
373
|
+
- OAuth flow management
|
|
374
|
+
- Error recovery
|
|
375
|
+
- State synchronization
|
|
166
376
|
|
|
167
|
-
|
|
377
|
+
---
|
|
168
378
|
|
|
379
|
+
## 🐛 Troubleshooting
|
|
380
|
+
|
|
381
|
+
### Common Issues and Solutions
|
|
382
|
+
|
|
383
|
+
**Inspector not loading:**
|
|
169
384
|
```bash
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
385
|
+
# Check server is running
|
|
386
|
+
curl http://localhost:3000/inspector
|
|
387
|
+
|
|
388
|
+
# Verify no conflicting routes
|
|
389
|
+
# Ensure inspector is mounted correctly
|
|
173
390
|
```
|
|
174
391
|
|
|
175
|
-
|
|
392
|
+
**Connection fails immediately:**
|
|
393
|
+
- Check CORS configuration
|
|
394
|
+
- Verify server URL is correct
|
|
395
|
+
- Ensure server supports SSE/WebSocket
|
|
396
|
+
- Check network/firewall settings
|
|
176
397
|
|
|
177
|
-
|
|
178
|
-
|
|
398
|
+
**OAuth popup blocked:**
|
|
399
|
+
- Allow popups for the inspector domain
|
|
400
|
+
- Use the manual auth link provided
|
|
401
|
+
- Check browser console for errors
|
|
402
|
+
|
|
403
|
+
**Tools not executing:**
|
|
404
|
+
- Verify tool schemas are valid
|
|
405
|
+
- Check server logs for errors
|
|
406
|
+
- Ensure proper authentication
|
|
407
|
+
- Validate input parameters
|
|
408
|
+
|
|
409
|
+
**Session not persisting:**
|
|
410
|
+
- Check localStorage is enabled
|
|
411
|
+
- Clear browser cache
|
|
412
|
+
- Try incognito/private mode
|
|
413
|
+
- Check for browser extensions blocking storage
|
|
414
|
+
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
## 🚀 Performance Tips
|
|
418
|
+
|
|
419
|
+
### Optimize for Large Tool Sets
|
|
420
|
+
|
|
421
|
+
```javascript
|
|
422
|
+
// Use pagination for many tools
|
|
423
|
+
server.configurePagination({
|
|
424
|
+
toolsPerPage: 50,
|
|
425
|
+
enableSearch: true
|
|
426
|
+
})
|
|
179
427
|
```
|
|
180
428
|
|
|
181
|
-
|
|
429
|
+
### Reduce Connection Overhead
|
|
430
|
+
|
|
431
|
+
```javascript
|
|
432
|
+
// Configure connection pooling
|
|
433
|
+
const inspector = {
|
|
434
|
+
maxConnections: 5,
|
|
435
|
+
connectionTimeout: 30000,
|
|
436
|
+
keepAlive: true
|
|
437
|
+
}
|
|
438
|
+
```
|
|
182
439
|
|
|
183
|
-
###
|
|
440
|
+
### Enable Caching
|
|
184
441
|
|
|
442
|
+
```javascript
|
|
443
|
+
// Cache tool results
|
|
444
|
+
server.enableCache({
|
|
445
|
+
ttl: 300, // 5 minutes
|
|
446
|
+
maxSize: 100 // MB
|
|
447
|
+
})
|
|
185
448
|
```
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
449
|
+
|
|
450
|
+
---
|
|
451
|
+
|
|
452
|
+
## 🔒 Security Considerations
|
|
453
|
+
|
|
454
|
+
### CORS Configuration
|
|
455
|
+
|
|
456
|
+
```javascript
|
|
457
|
+
// Configure CORS for inspector access
|
|
458
|
+
server.configureCORS({
|
|
459
|
+
origin: ['http://localhost:3000'],
|
|
460
|
+
credentials: true
|
|
461
|
+
})
|
|
199
462
|
```
|
|
200
463
|
|
|
201
|
-
|
|
464
|
+
### Authentication
|
|
202
465
|
|
|
203
|
-
|
|
466
|
+
```javascript
|
|
467
|
+
// Add authentication middleware
|
|
468
|
+
server.use(authMiddleware)
|
|
469
|
+
```
|
|
204
470
|
|
|
205
|
-
|
|
206
|
-
|
|
471
|
+
### Rate Limiting
|
|
472
|
+
|
|
473
|
+
```javascript
|
|
474
|
+
// Prevent abuse
|
|
475
|
+
server.configureRateLimit({
|
|
476
|
+
windowMs: 60000, // 1 minute
|
|
477
|
+
max: 100 // requests
|
|
478
|
+
})
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
---
|
|
482
|
+
|
|
483
|
+
## 📚 API Reference
|
|
484
|
+
|
|
485
|
+
### Inspector Methods
|
|
486
|
+
|
|
487
|
+
```typescript
|
|
488
|
+
// Mount inspector
|
|
489
|
+
mountInspector(app: Express, path?: string): void
|
|
490
|
+
|
|
491
|
+
// Standalone server
|
|
492
|
+
startInspectorServer(port: number): void
|
|
493
|
+
|
|
494
|
+
// Configuration
|
|
495
|
+
configureInspector(options: InspectorOptions): void
|
|
207
496
|
```
|
|
208
497
|
|
|
209
|
-
|
|
498
|
+
### Connection Options
|
|
499
|
+
|
|
500
|
+
```typescript
|
|
501
|
+
interface InspectorOptions {
|
|
502
|
+
autoConnect?: boolean // Auto-connect to local server
|
|
503
|
+
theme?: 'light' | 'dark' | 'auto'
|
|
504
|
+
persistence?: boolean // Save sessions
|
|
505
|
+
maxConnections?: number
|
|
506
|
+
connectionTimeout?: number
|
|
507
|
+
}
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
---
|
|
511
|
+
|
|
512
|
+
## 🤝 Contributing
|
|
513
|
+
|
|
514
|
+
We welcome contributions! Areas for improvement:
|
|
515
|
+
- Additional UI themes
|
|
516
|
+
- More keyboard shortcuts
|
|
517
|
+
- Enhanced tool testing features
|
|
518
|
+
- Performance optimizations
|
|
519
|
+
- Localization support
|
|
520
|
+
|
|
521
|
+
See our [contributing guide](https://github.com/mcp-use/mcp-use-ts/blob/main/CONTRIBUTING.md) for details.
|
|
522
|
+
|
|
523
|
+
---
|
|
524
|
+
|
|
525
|
+
## 📚 Learn More
|
|
526
|
+
|
|
527
|
+
- [MCP-Use Documentation](https://github.com/mcp-use/mcp-use-ts)
|
|
528
|
+
- [Model Context Protocol](https://modelcontextprotocol.io)
|
|
529
|
+
- [Creating MCP Servers](https://github.com/mcp-use/mcp-use-ts/tree/main/packages/mcp-use#-mcp-server-framework)
|
|
530
|
+
- [Building with React](https://react.dev)
|
|
531
|
+
- [Tailwind CSS](https://tailwindcss.com)
|
|
532
|
+
|
|
533
|
+
---
|
|
534
|
+
|
|
535
|
+
## 📜 License
|
|
536
|
+
|
|
537
|
+
MIT © [MCP-Use](https://github.com/mcp-use)
|