|
1 | 1 | # MCP Inspector |
2 | 2 |
|
3 | | -A web-based interface for connecting to and managing MCP (Model Context Protocol) servers. |
| 3 | +A web-based interface for connecting to and managing MCP (Model Context Protocol) servers using the `useMcp` React hook. |
4 | 4 |
|
5 | 5 | ## Features |
6 | 6 |
|
7 | | -- **Server Management**: Add, connect to, and manage MCP servers |
8 | | -- **Real-time Connection**: Test connections before adding servers |
9 | | -- **Browser-Compatible**: Works entirely in the browser using the MCP client |
| 7 | +- **Server Management**: Add, connect to, and manage multiple MCP servers simultaneously |
| 8 | +- **Real-time Connection Status**: See live connection states and errors |
| 9 | +- **OAuth Authentication**: Automatic OAuth flow handling with popup support |
| 10 | +- **Tool Execution**: Inspect and execute MCP tools directly from the UI |
| 11 | +- **Resource & Prompt Browsing**: View available resources and prompts from connected servers |
| 12 | +- **Browser-Compatible**: Works entirely in the browser using the `useMcp` React hook |
10 | 13 | - **Multiple Connection Types**: Support for HTTP/SSE and WebSocket connections |
| 14 | +- **Persistent Storage**: Connections are saved to localStorage and automatically reconnect |
11 | 15 |
|
12 | 16 | ## Usage |
13 | 17 |
|
14 | 18 | ### Adding a New Server |
15 | 19 |
|
16 | | -1. Click the server selection dropdown in the top-left corner |
17 | | -2. Click "Add Server" button |
18 | | -3. Fill in the server details: |
19 | | - - **Server Name**: A friendly name for your server |
20 | | - - **Connection Type**: Choose between HTTP/SSE or WebSocket |
21 | | - - **Server URL**: The URL to connect to (e.g., `http://localhost:3000` or `ws://localhost:3000`) |
22 | | - - **Description** (optional): Brief description of the server |
23 | | -4. Click "Add Server" to test the connection and add the server |
| 20 | +1. Go to the main dashboard |
| 21 | +2. In the "Add New MCP Server" section: |
| 22 | + - **Server Name** (optional): A friendly name for your server |
| 23 | + - **Server URL**: The URL to connect to (e.g., `https://mcp.linear.app/sse`) |
| 24 | +3. Click "Connect" to add the server |
| 25 | +4. The server will automatically attempt to connect |
24 | 26 |
|
25 | | -### Connecting to Servers |
| 27 | +### Server States |
26 | 28 |
|
27 | | -1. Select a server from the dropdown |
28 | | -2. The system will automatically attempt to connect |
29 | | -3. Once connected, you'll see a "Connected" badge |
| 29 | +The inspector displays various connection states: |
| 30 | + |
| 31 | +- **discovering**: Finding the server |
| 32 | +- **connecting**: Establishing connection |
| 33 | +- **authenticating**: Going through OAuth flow (if required) |
| 34 | +- **loading**: Loading tools, resources, and prompts |
| 35 | +- **ready**: Connected and ready to use |
| 36 | +- **failed**: Connection failed (with retry option) |
| 37 | +- **pending_auth**: Waiting for OAuth authentication |
| 38 | + |
| 39 | +### Authentication |
| 40 | + |
| 41 | +For servers requiring OAuth (like Linear): |
| 42 | + |
| 43 | +1. Click the "Authenticate" button when prompted |
| 44 | +2. Complete the OAuth flow in the popup window |
| 45 | +3. If the popup is blocked, click the "open auth page" link to authenticate manually |
| 46 | +4. Once authenticated, the connection will automatically complete |
| 47 | + |
| 48 | +### Inspecting a Server |
| 49 | + |
| 50 | +1. Click the "Inspect" button on any connected server |
| 51 | +2. View all available tools, resources, and prompts |
| 52 | +3. Execute tools by clicking "Execute" and providing JSON input |
| 53 | +4. Copy resource URIs to clipboard |
| 54 | +5. View detailed schema information for each tool |
30 | 55 |
|
31 | 56 | ## Example Server Configurations |
32 | 57 |
|
33 | | -### Linear Server |
| 58 | +### Linear MCP Server |
34 | 59 |
|
35 | | -For connecting to a Linear MCP server: |
| 60 | +For connecting to Linear's official MCP server: |
36 | 61 |
|
37 | 62 | - **Server Name**: Linear |
38 | | -- **Connection Type**: HTTP/SSE |
39 | | -- **Server URL**: `https://your-linear-mcp-server.com` |
40 | | -- **Description**: Linear project management integration |
| 63 | +- **Server URL**: `https://mcp.linear.app/sse` |
| 64 | + |
| 65 | +This server requires OAuth authentication and provides tools for managing Linear issues, projects, teams, and more. |
41 | 66 |
|
42 | 67 | ### Local Development Server |
43 | 68 |
|
44 | | -For local development: |
| 69 | +For local development using HTTP/SSE: |
45 | 70 |
|
46 | 71 | - **Server Name**: Local Dev |
47 | | -- **Connection Type**: HTTP/SSE |
48 | | -- **Server URL**: `http://localhost:3000` |
49 | | -- **Description**: Local development server |
| 72 | +- **Server URL**: `http://localhost:3000/sse` |
50 | 73 |
|
51 | 74 | ### WebSocket Server |
52 | 75 |
|
53 | 76 | For WebSocket-based servers: |
54 | 77 |
|
55 | 78 | - **Server Name**: WebSocket Server |
56 | | -- **Connection Type**: WebSocket |
57 | 79 | - **Server URL**: `ws://localhost:8080` |
58 | | -- **Description**: WebSocket-based MCP server |
59 | 80 |
|
60 | 81 | ## Technical Details |
61 | 82 |
|
62 | | -The inspector uses the browser-compatible MCP client from `mcp-use/browser`, which supports: |
| 83 | +The inspector is built using: |
| 84 | + |
| 85 | +- **React**: UI framework |
| 86 | +- **useMcp Hook**: From `mcp-use/react` for managing MCP connections |
| 87 | +- **React Router**: For navigation between dashboard and server detail views |
| 88 | +- **Tailwind CSS**: For styling |
| 89 | +- **shadcn/ui**: UI component library |
63 | 90 |
|
64 | | -- HTTP/SSE connections |
65 | | -- WebSocket connections |
66 | | -- OAuth authentication (when configured) |
| 91 | +### Architecture |
67 | 92 |
|
68 | | -The client automatically handles: |
| 93 | +- **McpContext**: Context provider that manages multiple MCP connections using `useMcp` hooks |
| 94 | +- **InspectorDashboard**: Main dashboard showing all connections and stats |
| 95 | +- **ServerList**: List view of all servers with detailed information |
| 96 | +- **ServerDetail**: Detailed view of a single server with tool execution capabilities |
69 | 97 |
|
70 | | -- Connection testing before adding servers |
71 | | -- Session management |
72 | | -- Error handling and reporting |
| 98 | +The `useMcp` hook automatically handles: |
| 99 | + |
| 100 | +- Connection lifecycle management |
| 101 | +- OAuth authentication flows |
| 102 | +- Tool, resource, and prompt discovery |
| 103 | +- Error handling and retry logic |
| 104 | +- Session persistence via localStorage |
73 | 105 |
|
74 | 106 | ## Development |
75 | 107 |
|
76 | 108 | To run the inspector in development mode: |
77 | 109 |
|
78 | 110 | ```bash |
79 | | -cd inspector |
| 111 | +cd packages/inspector |
80 | 112 | yarn install |
81 | 113 | yarn dev |
82 | 114 | ``` |
83 | 115 |
|
84 | 116 | The inspector will be available at `http://localhost:5173`. |
| 117 | + |
| 118 | +### Project Structure |
| 119 | + |
| 120 | +``` |
| 121 | +src/ |
| 122 | +├── client/ |
| 123 | +│ ├── components/ |
| 124 | +│ │ ├── InspectorDashboard.tsx # Main dashboard |
| 125 | +│ │ ├── ServerList.tsx # Server list view |
| 126 | +│ │ ├── ServerDetail.tsx # Server detail view |
| 127 | +│ │ └── Layout.tsx # App layout |
| 128 | +│ ├── context/ |
| 129 | +│ │ └── McpContext.tsx # MCP connection context |
| 130 | +│ ├── App.tsx # Root app component |
| 131 | +│ └── main.tsx # Entry point |
| 132 | +└── components/ |
| 133 | + └── ui/ # shadcn/ui components |
| 134 | +``` |
| 135 | + |
| 136 | +## Building |
| 137 | + |
| 138 | +To build the inspector for production: |
| 139 | + |
| 140 | +```bash |
| 141 | +yarn build |
| 142 | +``` |
| 143 | + |
| 144 | +The built files will be in the `dist/` directory. |
0 commit comments